Web: Hiding elements by conditions, refactoring.

This commit is contained in:
Tatiana Lopaeva 2023-05-22 16:12:36 +03:00
parent 4930238bce
commit 41e3321e75
7 changed files with 36 additions and 40 deletions

View File

@ -174,8 +174,7 @@ const Items = ({
deleteAction,
startDrag,
emptyTrashInProgress,
standalone,
isEnterprise,
isCommunity,
}) => {
useEffect(() => {
data.forEach((elem) => {
@ -385,8 +384,7 @@ const Items = ({
if (!isVisitor) items.splice(3, 0, <CatalogDivider key="other-header" />);
else items.splice(2, 0, <CatalogDivider key="other-header" />);
if (standalone && !isEnterprise)
items.push(<BonusItem key="bonus-item" />);
if (isCommunity) items.push(<BonusItem key="bonus-item" />);
return items;
},
@ -434,8 +432,8 @@ export default inject(
uploadDataStore,
dialogsStore,
}) => {
const { isEnterprise, settingsStore } = auth;
const { showText, docSpace, standalone } = settingsStore;
const { settingsStore, isCommunity } = auth;
const { showText, docSpace } = settingsStore;
const {
selection,
@ -467,7 +465,6 @@ export default inject(
const { setEmptyTrashDialogVisible } = dialogsStore;
return {
isEnterprise,
isAdmin: auth.isAdmin,
isVisitor: auth.userStore.user.isVisitor,
isCollaborator: auth.userStore.user.isCollaborator,
@ -477,7 +474,6 @@ export default inject(
currentId: id,
showText,
docSpace,
standalone,
pathParts,
data: treeFolders,
selectedTreeNode,
@ -498,6 +494,7 @@ export default inject(
firstLoad,
startDrag,
emptyTrashInProgress,
isCommunity,
};
}
)(withTranslation(["Files", "Common", "Translations"])(observer(Items)));

View File

@ -262,6 +262,7 @@ class ArticleBodyContent extends React.Component {
isOwner,
isEnterprise,
standalone,
isCommunity,
} = this.props;
const items = [];
@ -277,17 +278,17 @@ class ArticleBodyContent extends React.Component {
});
}
if (!standalone) {
const index = resultTree.findIndex((el) => el.tKey === "Common:Bonus");
if (standalone) {
const deletionTKey = isCommunity
? "Common:PaymentsTitle"
: "Common:Bonus";
const index = resultTree.findIndex((el) => el.tKey === deletionTKey);
if (index !== -1) {
resultTree.splice(index, 1);
}
}
if (standalone && !isEnterprise) {
resultTree = [...settingsTree].filter((e) => {
return e.tKey !== "Common:PaymentsTitle";
});
}
if (!isOwner || standalone) {
const index = resultTree.findIndex((n) => n.tKey === "PortalDeletion");
@ -335,6 +336,7 @@ export default inject(({ auth, common }) => {
userStore,
isEnterprise,
settingsStore,
isCommunity,
} = auth;
const { isNotPaidPeriod } = currentTariffStatusStore;
const { user } = userStore;
@ -350,6 +352,7 @@ export default inject(({ auth, common }) => {
setIsLoadedArticleBody,
isNotPaidPeriod,
isOwner,
isCommunity,
};
})(
withLoading(

View File

@ -4,8 +4,6 @@ import { inject, observer } from "mobx-react";
import { useTranslation } from "react-i18next";
import { setDocumentTitle } from "@docspace/client/src/helpers/filesUtils";
import { combineUrl } from "@docspace/common/utils";
import history from "@docspace/common/history";
import LicenseContainer from "./LicenseContainer";
import { StyledComponent } from "./StyledComponent";
@ -19,15 +17,10 @@ const StandalonePage = (props) => {
isInitPaymentPage,
isLoadedTariffStatus,
isLoadedCurrentQuota,
isEnterprise,
isTrial,
} = props;
const { t, ready } = useTranslation(["PaymentsEnterprise", "Common"]);
useEffect(() => {
enterpriseInit();
}, []);
useEffect(() => {
setDocumentTitle(t("Common:PaymentsTitle"));
}, [ready]);
@ -35,19 +28,14 @@ const StandalonePage = (props) => {
useEffect(() => {
if (!isLoadedTariffStatus || !isLoadedCurrentQuota) return;
if (!isEnterprise) {
history.push(
combineUrl(window.DocSpaceConfig?.proxy?.url, "/portal-settings/")
);
}
enterpriseInit();
}, [isLoadedTariffStatus, isLoadedCurrentQuota]);
if (
!isInitPaymentPage ||
!isLoadedTariffStatus ||
!isLoadedCurrentQuota ||
!ready ||
!isEnterprise
!ready
)
return <></>;
@ -61,7 +49,7 @@ const StandalonePage = (props) => {
};
export default inject(({ auth, payments }) => {
const { currentQuotaStore, currentTariffStatusStore, isEnterprise } = auth;
const { currentQuotaStore, currentTariffStatusStore } = auth;
const { enterpriseInit, isInitPaymentPage } = payments;
const { isLoaded: isLoadedCurrentQuota, isTrial } = currentQuotaStore;
@ -73,6 +61,5 @@ export default inject(({ auth, payments }) => {
isInitPaymentPage,
isLoadedTariffStatus,
isLoadedCurrentQuota,
isEnterprise,
};
})(withRouter(observer(StandalonePage)));

View File

@ -360,7 +360,7 @@ export const settingsTree = [
id: "portal-settings_catalog-portal-bonus",
key: "8-0",
icon: "",
link: "bonus",
link: "",
tKey: "Common:FreeProFeatures",
isCategory: true,
},

View File

@ -174,8 +174,9 @@ class ProfileActionsStore {
};
getActions = (t) => {
const { enablePlugins } = this.authStore.settingsStore;
const { enablePlugins, standalone } = this.authStore.settingsStore;
const isAdmin = this.authStore.isAdmin;
const isCommunity = this.authStore.isCommunity;
// const settingsModule = modules.find((module) => module.id === "settings");
// const peopleAvailable = modules.some((m) => m.appName === "people");
@ -247,7 +248,8 @@ class ProfileActionsStore {
onClick: this.onProfileClick,
},
settings,
isAdmin && {
isAdmin &&
!isCommunity && {
key: "user-menu-payments",
icon: PaymentsReactSvgUrl,
label: t("Common:PaymentsTitle"),

View File

@ -32,6 +32,7 @@ const PrivateRoute = ({ component: Component, ...rest }) => {
withCollaborator,
isLogout,
standalone,
isCommunity,
} = rest;
const { params, path } = computedMatch;
@ -83,7 +84,8 @@ const PrivateRoute = ({ component: Component, ...rest }) => {
isLoaded &&
((!isNotPaidPeriod && isPortalUnavailableUrl) ||
(!user.isOwner && isPortalDeletionUrl) ||
(standalone && isPortalDeletionUrl))
(standalone && isPortalDeletionUrl) ||
(isCommunity && isPaymentsUrl))
) {
return window.location.replace("/");
}
@ -244,6 +246,7 @@ export default inject(({ auth }) => {
settingsStore,
currentTariffStatusStore,
isLogout,
isCommunity,
} = auth;
const { isNotPaidPeriod } = currentTariffStatusStore;
const { user } = userStore;
@ -257,6 +260,7 @@ export default inject(({ auth }) => {
} = settingsStore;
return {
isCommunity,
isNotPaidPeriod,
user,
isAuthenticated,

View File

@ -128,6 +128,9 @@ class AuthStore {
get isEnterprise() {
return this.tenantExtra.enterprise;
}
get isCommunity() {
return this.tenantExtra.opensource;
}
getTenantExtra = async () => {
let refresh = false;