Merge pull request #576 from ONLYOFFICE/feature/api-separation
Feature/api separation
This commit is contained in:
commit
6102224d65
@ -421,9 +421,11 @@ export default inject(
|
||||
clientLoadingStore,
|
||||
userStore,
|
||||
settingsStore,
|
||||
currentTariffStatusStore,
|
||||
}) => {
|
||||
const { isCommunity, isPaymentPageAvailable, currentDeviceType } =
|
||||
authStore;
|
||||
const { isPaymentPageAvailable, currentDeviceType } = authStore;
|
||||
const { isCommunity } = currentTariffStatusStore;
|
||||
|
||||
const { showText, currentColorScheme } = settingsStore;
|
||||
|
||||
const {
|
||||
|
@ -48,7 +48,6 @@ export default inject<TStore>(
|
||||
isLiveChatAvailable,
|
||||
|
||||
isPaymentPageAvailable,
|
||||
isEnterprise,
|
||||
} = authStore;
|
||||
|
||||
const { getActions, getUserRole, onProfileClick, isShowLiveChat } =
|
||||
@ -114,7 +113,7 @@ export default inject<TStore>(
|
||||
showProgress,
|
||||
|
||||
isBurgerLoading,
|
||||
isEnterprise,
|
||||
|
||||
isTrial,
|
||||
isLicenseDateExpired,
|
||||
trialDaysLeft,
|
||||
|
@ -74,16 +74,11 @@ const PrivateRouteWrapper = ({
|
||||
|
||||
export default inject<TStore>(
|
||||
({ authStore, settingsStore, userStore, currentTariffStatusStore }) => {
|
||||
const {
|
||||
isAuthenticated,
|
||||
isLoaded,
|
||||
isAdmin,
|
||||
const { isAuthenticated, isLoaded, isAdmin, isLogout } = authStore;
|
||||
|
||||
const { isNotPaidPeriod, isCommunity, isEnterprise } =
|
||||
currentTariffStatusStore;
|
||||
|
||||
isLogout,
|
||||
isCommunity,
|
||||
isEnterprise,
|
||||
} = authStore;
|
||||
const { isNotPaidPeriod } = currentTariffStatusStore;
|
||||
const { user } = userStore;
|
||||
|
||||
const {
|
||||
|
@ -109,10 +109,9 @@ const BenefitsContainer = ({ isTrial, isEnterprise }) => {
|
||||
};
|
||||
|
||||
export default inject(
|
||||
({ authStore, currentQuotaStore, paymentQuotasStore }) => {
|
||||
const { isEnterprise } = authStore;
|
||||
|
||||
({ currentTariffStatusStore, currentQuotaStore, paymentQuotasStore }) => {
|
||||
const { portalPaymentQuotasFeatures } = paymentQuotasStore;
|
||||
const { isEnterprise } = currentTariffStatusStore;
|
||||
|
||||
const { isTrial } = currentQuotaStore;
|
||||
return {
|
||||
|
@ -149,9 +149,11 @@ const ContactContainer = (props) => {
|
||||
);
|
||||
};
|
||||
|
||||
export default inject(({ authStore, settingsStore, paymentStore }) => {
|
||||
const { isCommunity } = authStore;
|
||||
const { helpUrl, salesEmail } = paymentStore;
|
||||
const { theme } = settingsStore;
|
||||
return { helpUrl, salesEmail, theme, isCommunity };
|
||||
})(observer(ContactContainer));
|
||||
export default inject(
|
||||
({ currentTariffStatusStore, settingsStore, paymentStore }) => {
|
||||
const { isCommunity } = currentTariffStatusStore;
|
||||
const { helpUrl, salesEmail } = paymentStore;
|
||||
const { theme } = settingsStore;
|
||||
return { helpUrl, salesEmail, theme, isCommunity };
|
||||
},
|
||||
)(observer(ContactContainer));
|
||||
|
@ -134,11 +134,7 @@ export default inject(
|
||||
currentQuotaStore,
|
||||
currentTariffStatusStore,
|
||||
}) => {
|
||||
const {
|
||||
isPaymentPageAvailable,
|
||||
|
||||
isEnterprise,
|
||||
} = authStore;
|
||||
const { isPaymentPageAvailable } = authStore;
|
||||
const { isFreeTariff, isNonProfit, isTrial } = currentQuotaStore;
|
||||
const {
|
||||
isGracePeriod,
|
||||
@ -146,6 +142,7 @@ export default inject(
|
||||
isLicenseDateExpired,
|
||||
paymentDate,
|
||||
trialDaysLeft,
|
||||
isEnterprise,
|
||||
} = currentTariffStatusStore;
|
||||
const { standalone } = settingsStore;
|
||||
|
||||
|
@ -59,7 +59,6 @@ const ArticleBodyContent = (props) => {
|
||||
isOwner,
|
||||
isLoadedArticleBody,
|
||||
standalone,
|
||||
isEnterprise,
|
||||
isCommunity,
|
||||
currentDeviceType,
|
||||
isProfileLoading,
|
||||
@ -347,8 +346,8 @@ export default inject(
|
||||
currentTariffStatusStore,
|
||||
}) => {
|
||||
const { isLoadedArticleBody, setIsLoadedArticleBody } = common;
|
||||
const { isEnterprise, isCommunity } = authStore;
|
||||
const { isNotPaidPeriod } = currentTariffStatusStore;
|
||||
|
||||
const { isNotPaidPeriod, isCommunity } = currentTariffStatusStore;
|
||||
const { user } = userStore;
|
||||
const { isOwner } = user;
|
||||
const {
|
||||
@ -368,7 +367,7 @@ export default inject(
|
||||
|
||||
return {
|
||||
standalone,
|
||||
isEnterprise,
|
||||
|
||||
showText,
|
||||
toggleArticleOpen,
|
||||
isLoadedArticleBody,
|
||||
|
@ -45,9 +45,7 @@ const StyledBodyContent = styled.div`
|
||||
}
|
||||
`;
|
||||
const StyledBody = styled.div`
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
margin: 0 auto;
|
||||
width: 100%;
|
||||
|
||||
.portal-unavailable_container {
|
||||
.portal-unavailable_contact-text {
|
||||
|
@ -45,18 +45,16 @@ import { StyledWrapper } from "./styled-social-networks";
|
||||
|
||||
const SocialNetworks = (props) => {
|
||||
const { t } = useTranslation(["Profile", "Common"]);
|
||||
const {
|
||||
providers,
|
||||
setProviders,
|
||||
isOAuthAvailable,
|
||||
//setPortalQuota
|
||||
} = props;
|
||||
const { providers, setProviders, getCapabilities, capabilities } = props;
|
||||
|
||||
const fetchData = async () => {
|
||||
try {
|
||||
const data = await getAuthProviders();
|
||||
//if (typeof isOAuthAvailable === "undefined") await setPortalQuota();
|
||||
setProviders(data);
|
||||
const [providers] = await Promise.all([
|
||||
getAuthProviders(),
|
||||
getCapabilities(),
|
||||
]);
|
||||
|
||||
setProviders(providers);
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
@ -155,7 +153,8 @@ const SocialNetworks = (props) => {
|
||||
);
|
||||
});
|
||||
|
||||
if (!isOAuthAvailable) return <></>;
|
||||
if (!capabilities?.oauthEnabled) return <></>;
|
||||
|
||||
if (providers.length === 0) return <></>;
|
||||
|
||||
return (
|
||||
@ -168,19 +167,15 @@ const SocialNetworks = (props) => {
|
||||
);
|
||||
};
|
||||
|
||||
export default inject(({ currentQuotaStore, peopleStore }) => {
|
||||
export default inject(({ authStore, peopleStore }) => {
|
||||
const { usersStore } = peopleStore;
|
||||
const { providers, setProviders } = usersStore;
|
||||
|
||||
const {
|
||||
isOAuthAvailable,
|
||||
//setPortalQuota
|
||||
} = currentQuotaStore;
|
||||
const { getCapabilities, capabilities } = authStore;
|
||||
|
||||
return {
|
||||
providers,
|
||||
setProviders,
|
||||
isOAuthAvailable,
|
||||
// setPortalQuota,
|
||||
getCapabilities,
|
||||
capabilities,
|
||||
};
|
||||
})(observer(SocialNetworks));
|
||||
|
@ -127,12 +127,12 @@ class PaymentStore {
|
||||
basicSettings = async () => {
|
||||
if (!this.currentTariffStatusStore || !this.currentQuotaStore) return;
|
||||
|
||||
const { setPortalTariff, setPayerInfo } = this.currentTariffStatusStore;
|
||||
const { fetchPortalTariff, setPayerInfo } = this.currentTariffStatusStore;
|
||||
const { addedManagersCount } = this.currentQuotaStore;
|
||||
|
||||
this.setIsUpdatingBasicSettings(true);
|
||||
|
||||
const requests = [setPortalTariff()];
|
||||
const requests = [fetchPortalTariff()];
|
||||
|
||||
if (this.isAlreadyPaid) requests.push(this.setPaymentAccount());
|
||||
else requests.push(this.getBasicPaymentLink(addedManagersCount));
|
||||
@ -231,12 +231,12 @@ class PaymentStore {
|
||||
};
|
||||
|
||||
standaloneBasicSettings = async (t: TTranslation) => {
|
||||
const { getTenantExtra } = authStore;
|
||||
const { getPaymentInfo } = authStore;
|
||||
|
||||
this.setIsUpdatingBasicSettings(true);
|
||||
|
||||
try {
|
||||
await getTenantExtra();
|
||||
await getPaymentInfo();
|
||||
} catch (e) {
|
||||
toastr.error(t("Common:UnexpectedError"));
|
||||
|
||||
@ -247,7 +247,7 @@ class PaymentStore {
|
||||
};
|
||||
|
||||
standaloneInit = async (t: TTranslation) => {
|
||||
const { getTenantExtra } = authStore;
|
||||
const { getPaymentInfo } = authStore;
|
||||
|
||||
if (this.isInitPaymentPage) {
|
||||
this.standaloneBasicSettings(t);
|
||||
@ -256,7 +256,7 @@ class PaymentStore {
|
||||
}
|
||||
|
||||
try {
|
||||
await Promise.all([this.getSettingsPayment(), getTenantExtra()]);
|
||||
await Promise.all([this.getSettingsPayment(), getPaymentInfo()]);
|
||||
} catch (error) {
|
||||
toastr.error(t("Common:UnexpectedError"));
|
||||
console.error(error);
|
||||
@ -317,14 +317,14 @@ class PaymentStore {
|
||||
|
||||
acceptPaymentsLicense = async (t: TTranslation) => {
|
||||
try {
|
||||
const { getTenantExtra } = authStore;
|
||||
const { getPaymentInfo } = authStore;
|
||||
|
||||
await acceptLicense();
|
||||
|
||||
toastr.success(t("ActivateLicenseActivated"));
|
||||
localStorage.removeItem("enterpriseAlertClose");
|
||||
|
||||
await getTenantExtra();
|
||||
await getPaymentInfo();
|
||||
} catch (e) {
|
||||
toastr.error(e as TData);
|
||||
}
|
||||
|
@ -83,6 +83,7 @@ class ProfileActionsStore {
|
||||
pluginStore,
|
||||
userStore,
|
||||
settingsStore,
|
||||
currentTariffStatusStore,
|
||||
) {
|
||||
this.authStore = authStore;
|
||||
this.filesStore = filesStore;
|
||||
@ -92,6 +93,7 @@ class ProfileActionsStore {
|
||||
this.pluginStore = pluginStore;
|
||||
this.userStore = userStore;
|
||||
this.settingsStore = settingsStore;
|
||||
this.currentTariffStatusStore = currentTariffStatusStore;
|
||||
|
||||
this.isShowLiveChat = this.getStateLiveChat();
|
||||
|
||||
@ -248,7 +250,7 @@ class ProfileActionsStore {
|
||||
limitedAccessSpace,
|
||||
} = this.settingsStore;
|
||||
const isAdmin = this.authStore.isAdmin;
|
||||
const isCommunity = this.authStore.isCommunity;
|
||||
const isCommunity = this.currentTariffStatusStore.isCommunity;
|
||||
// const { isOwner } = this.userStore.user;
|
||||
|
||||
// const settingsModule = modules.find((module) => module.id === "settings");
|
||||
|
@ -164,7 +164,7 @@ class StorageManagement {
|
||||
};
|
||||
|
||||
updateQuotaInfo = async (type) => {
|
||||
const { getTenantExtra } = this.authStore;
|
||||
const { fetchPortalQuota } = this.currentQuotaStore;
|
||||
const { getFilesListItems } = this.filesStore;
|
||||
const { usersStore } = this.peopleStore;
|
||||
const { getPeopleListItem } = usersStore;
|
||||
@ -175,7 +175,7 @@ class StorageManagement {
|
||||
const roomFilterData = RoomsFilter.getDefault();
|
||||
roomFilterData.pageCount = FILTER_COUNT;
|
||||
|
||||
const requests = [getTenantExtra()];
|
||||
const requests = [fetchPortalQuota()];
|
||||
|
||||
type === "user"
|
||||
? requests.push(getUserList(userFilterData))
|
||||
|
@ -257,6 +257,7 @@ const profileActionsStore = new ProfileActionsStore(
|
||||
pluginStore,
|
||||
userStore,
|
||||
settingsStore,
|
||||
currentTariffStatusStore,
|
||||
);
|
||||
|
||||
peopleStore.profileActionsStore = profileActionsStore;
|
||||
|
@ -57,10 +57,12 @@ let isPaymentPageUnavailable = true;
|
||||
let isBonusPageUnavailable = true;
|
||||
|
||||
const App = observer(() => {
|
||||
const { authStore, userStore, settingsStore } = useStore();
|
||||
const { authStore, userStore, settingsStore, currentTariffStatusStore } =
|
||||
useStore();
|
||||
const location = useLocation();
|
||||
|
||||
const { init, isCommunity, isLoaded } = authStore;
|
||||
const { init, isLoaded } = authStore;
|
||||
const { isCommunity } = currentTariffStatusStore;
|
||||
const { setTheme, limitedAccessSpace, timezone } = settingsStore;
|
||||
|
||||
window.timezone = timezone;
|
||||
|
@ -52,9 +52,9 @@ const ArticleBodyContent = () => {
|
||||
|
||||
const { t } = useTranslation(["Settings", "Common"]);
|
||||
|
||||
const { settingsStore, authStore } = useStore();
|
||||
const { settingsStore, currentTariffStatusStore } = useStore();
|
||||
|
||||
const { isCommunity } = authStore;
|
||||
const { isCommunity } = currentTariffStatusStore;
|
||||
const { toggleArticleOpen, setIsBurgerLoading, currentColorScheme } =
|
||||
settingsStore;
|
||||
|
||||
|
@ -37,10 +37,12 @@ const {
|
||||
userStore,
|
||||
bannerStore,
|
||||
settingsStore,
|
||||
currentTariffStatusStore,
|
||||
}: {
|
||||
userStore: UserStore;
|
||||
bannerStore: BannerStore;
|
||||
authStore: any;
|
||||
currentTariffStatusStore: any;
|
||||
settingsStore: SettingsStore;
|
||||
} = store;
|
||||
|
||||
@ -49,6 +51,7 @@ export class RootStore {
|
||||
userStore = userStore;
|
||||
bannerStore = bannerStore;
|
||||
settingsStore = settingsStore;
|
||||
currentTariffStatusStore = currentTariffStatusStore;
|
||||
spacesStore = new SpacesStore(this.settingsStore);
|
||||
}
|
||||
|
||||
|
@ -32,7 +32,6 @@ import {
|
||||
TPortal,
|
||||
TPortalTariff,
|
||||
TRestoreProgress,
|
||||
TTenantExtra,
|
||||
} from "./types";
|
||||
|
||||
export function getShortenedLink(link: string) {
|
||||
@ -256,16 +255,6 @@ export async function getPortalPaymentQuotas() {
|
||||
return res;
|
||||
}
|
||||
|
||||
export async function getPortalTenantExtra(refresh: boolean) {
|
||||
const params = refresh ? { refresh: true } : {};
|
||||
const res = (await request({
|
||||
method: "get",
|
||||
url: "/portal/tenantextra",
|
||||
params,
|
||||
})) as TTenantExtra;
|
||||
|
||||
return res;
|
||||
}
|
||||
export async function getPortalQuota(refresh = false) {
|
||||
const params = refresh ? { refresh: true } : {};
|
||||
// console.log("getPortalQuota", { params });
|
||||
|
@ -38,6 +38,8 @@ export type TPortalTariff = {
|
||||
customerId: string;
|
||||
portalStatus?: number;
|
||||
quotas: TQuotas[];
|
||||
enterprise: boolean;
|
||||
openSource: boolean;
|
||||
};
|
||||
|
||||
export type TPaymentFeature = {
|
||||
@ -117,17 +119,6 @@ export type TTenantExtraRes = {
|
||||
enableTariffPage: boolean;
|
||||
};
|
||||
|
||||
export type TTenantExtra = {
|
||||
customMode: boolean;
|
||||
opensource: boolean;
|
||||
enterprise: boolean;
|
||||
tariff: TTariff;
|
||||
quota: TPaymentQuota;
|
||||
notPaid: boolean;
|
||||
licenseAccept: Date;
|
||||
enableTariffPage: boolean;
|
||||
};
|
||||
|
||||
export type TRestoreProgress = {
|
||||
progress: number;
|
||||
error?: TError;
|
||||
|
@ -883,13 +883,6 @@ export function getStorageRegions() {
|
||||
return request(options);
|
||||
}
|
||||
|
||||
export function getPortalQuota() {
|
||||
return request({
|
||||
method: "get",
|
||||
url: `/settings/quota`,
|
||||
});
|
||||
}
|
||||
|
||||
export function getAllActiveSessions() {
|
||||
return request({
|
||||
method: "get",
|
||||
|
@ -139,7 +139,6 @@ export interface ArticleProps {
|
||||
isPaymentPageAvailable?: boolean;
|
||||
isLicenseExpiring?: boolean;
|
||||
isLicenseDateExpired?: boolean;
|
||||
isEnterprise?: boolean;
|
||||
isTrial?: boolean;
|
||||
standalone?: boolean;
|
||||
currentTariffPlanTitle?: string;
|
||||
|
@ -92,7 +92,6 @@ const Article = ({
|
||||
isBurgerLoading,
|
||||
|
||||
isNonProfit,
|
||||
isEnterprise,
|
||||
isFreeTariff,
|
||||
isGracePeriod,
|
||||
isLicenseDateExpired,
|
||||
|
@ -30,7 +30,6 @@ import { makeAutoObservable, runInAction } from "mobx";
|
||||
import api from "../api";
|
||||
import { setWithCredentialsStatus } from "../api/client";
|
||||
import { loginWithTfaCode } from "../api/user";
|
||||
import { getPortalTenantExtra } from "../api/portal";
|
||||
import { TUser } from "../api/people/types";
|
||||
import { TCapabilities, TThirdPartyProvider } from "../api/settings/types";
|
||||
import { logout as logoutDesktop } from "../utils/desktop";
|
||||
@ -158,7 +157,7 @@ class AuthStore {
|
||||
updateTariff = async () => {
|
||||
this.setIsUpdatingTariff(true);
|
||||
|
||||
await this.getTenantExtra();
|
||||
await this.getPaymentInfo();
|
||||
await this.currentTariffStatusStore?.setPayerInfo();
|
||||
|
||||
this.setIsUpdatingTariff(false);
|
||||
@ -189,7 +188,7 @@ class AuthStore {
|
||||
requests.push(
|
||||
this.userStore?.init(i18n, this.settingsStore.culture).then(() => {
|
||||
if (!isPortalRestore) {
|
||||
this.getTenantExtra();
|
||||
this.getPaymentInfo();
|
||||
}
|
||||
}),
|
||||
);
|
||||
@ -227,36 +226,24 @@ class AuthStore {
|
||||
});
|
||||
};
|
||||
|
||||
get isEnterprise() {
|
||||
this.currentTariffStatusStore?.setIsEnterprise(
|
||||
this.tenantExtra?.enterprise || false,
|
||||
);
|
||||
return this.tenantExtra?.enterprise;
|
||||
}
|
||||
|
||||
get isCommunity() {
|
||||
return this.tenantExtra?.opensource;
|
||||
}
|
||||
|
||||
getTenantExtra = async () => {
|
||||
getPaymentInfo = async () => {
|
||||
let refresh = false;
|
||||
|
||||
if (window.location.search === "?complete=true") {
|
||||
window.history.replaceState({}, document.title, window.location.pathname);
|
||||
refresh = true;
|
||||
}
|
||||
const user = this.userStore?.user?.isVisitor;
|
||||
|
||||
const result = await getPortalTenantExtra(refresh);
|
||||
const request = [];
|
||||
|
||||
if (!result) return;
|
||||
request.push(this.currentTariffStatusStore?.fetchPortalTariff(refresh));
|
||||
|
||||
const { tariff, quota, ...tenantExtra } = result;
|
||||
if (!user) {
|
||||
request.push(this.currentQuotaStore?.fetchPortalQuota(refresh));
|
||||
}
|
||||
|
||||
runInAction(() => {
|
||||
this.tenantExtra = { ...tenantExtra };
|
||||
});
|
||||
|
||||
this.currentQuotaStore?.setPortalQuotaValue(quota);
|
||||
this.currentTariffStatusStore?.setPortalTariffValue(tariff);
|
||||
await Promise.all(request);
|
||||
|
||||
this.isPortalInfoLoaded = true;
|
||||
};
|
||||
|
@ -346,18 +346,12 @@ class CurrentQuotasStore {
|
||||
});
|
||||
};
|
||||
|
||||
setPortalQuota = async () => {
|
||||
try {
|
||||
const res = await api.portal.getPortalQuota();
|
||||
|
||||
if (!res) return;
|
||||
|
||||
fetchPortalQuota = async (refresh?: boolean) => {
|
||||
return api.portal.getPortalQuota(refresh).then((res) => {
|
||||
this.setPortalQuotaValue(res);
|
||||
|
||||
this.setIsLoaded(true);
|
||||
} catch (e) {
|
||||
toastr.error(e as TData);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
setUserQuota = async (quota: string | number, t: (key: string) => string) => {
|
||||
|
@ -46,8 +46,6 @@ class CurrentTariffStatusStore {
|
||||
|
||||
language: string = "en";
|
||||
|
||||
isEnterprise: boolean = false;
|
||||
|
||||
constructor() {
|
||||
makeAutoObservable(this);
|
||||
}
|
||||
@ -56,14 +54,18 @@ class CurrentTariffStatusStore {
|
||||
this.language = language;
|
||||
};
|
||||
|
||||
setIsEnterprise = (isEnterprise: boolean) => {
|
||||
this.isEnterprise = isEnterprise;
|
||||
};
|
||||
|
||||
setIsLoaded = (isLoaded: boolean) => {
|
||||
this.isLoaded = isLoaded;
|
||||
};
|
||||
|
||||
get isEnterprise() {
|
||||
return this.portalTariffStatus?.enterprise;
|
||||
}
|
||||
|
||||
get isCommunity() {
|
||||
return this.portalTariffStatus?.openSource;
|
||||
}
|
||||
|
||||
get isGracePeriod() {
|
||||
return this.portalTariffStatus?.state === TariffState.Delay;
|
||||
}
|
||||
@ -164,19 +166,12 @@ class CurrentTariffStatusStore {
|
||||
return getDaysLeft(this.dueDate);
|
||||
}
|
||||
|
||||
setPortalTariffValue = async (res: TPortalTariff) => {
|
||||
this.portalTariffStatus = res;
|
||||
fetchPortalTariff = async (refresh?: boolean) => {
|
||||
return api.portal.getPortalTariff(refresh).then((res) => {
|
||||
if (!res) return;
|
||||
|
||||
this.setIsLoaded(true);
|
||||
};
|
||||
|
||||
setPortalTariff = async () => {
|
||||
const res = await api.portal.getPortalTariff();
|
||||
|
||||
if (!res) return;
|
||||
|
||||
runInAction(() => {
|
||||
this.portalTariffStatus = res;
|
||||
this.setIsLoaded(true);
|
||||
});
|
||||
};
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user