Web: Optimization of store

This commit is contained in:
Alexey Safronov 2022-08-04 17:34:53 +03:00
parent de61cedfd1
commit 7741d235f7
27 changed files with 211 additions and 344 deletions

View File

@ -15,8 +15,7 @@ import { combineUrl, updateTempContent } from "@docspace/common/utils";
import { Provider as MobxProvider } from "mobx-react"; import { Provider as MobxProvider } from "mobx-react";
import ThemeProvider from "@docspace/components/theme-provider"; import ThemeProvider from "@docspace/components/theme-provider";
import store from "client/store"; import store from "SRC_DIR/store";
import filesStores from "./store/index.Files";
import config from "PACKAGE_FILE"; import config from "PACKAGE_FILE";
import { I18nextProvider, useTranslation } from "react-i18next"; import { I18nextProvider, useTranslation } from "react-i18next";
@ -600,7 +599,7 @@ const ThemeProviderWrapper = inject(({ auth }) => {
})(observer(ThemeProvider)); })(observer(ThemeProvider));
export default () => ( export default () => (
<MobxProvider {...store} {...filesStores}> <MobxProvider {...store}>
<I18nextProvider i18n={i18n}> <I18nextProvider i18n={i18n}>
<ThemeProviderWrapper> <ThemeProviderWrapper>
<ShellWrapper /> <ShellWrapper />

View File

@ -2,8 +2,7 @@ import React from "react";
import { Provider as MobxProvider, inject, observer } from "mobx-react"; import { Provider as MobxProvider, inject, observer } from "mobx-react";
import { I18nextProvider } from "react-i18next"; import { I18nextProvider } from "react-i18next";
import SelectFileDialog from "./index"; import SelectFileDialog from "./index";
import stores from "../../../store/index.Files"; import store from "SRC_DIR/store";
import store from "client/store";
import i18n from "./i18n"; import i18n from "./i18n";
const { auth: authStore } = store; const { auth: authStore } = store;
@ -32,7 +31,7 @@ class SelectFileDialogWrapper extends React.Component {
render() { render() {
return ( return (
<MobxProvider auth={authStore} {...stores}> <MobxProvider {...store}>
<I18nextProvider i18n={i18n}> <I18nextProvider i18n={i18n}>
<SelectFileWrapper {...this.props} /> <SelectFileWrapper {...this.props} />
</I18nextProvider> </I18nextProvider>

View File

@ -1,8 +1,7 @@
import React from "react"; import React from "react";
import { Provider as MobxProvider } from "mobx-react"; import { Provider as MobxProvider } from "mobx-react";
import { I18nextProvider } from "react-i18next"; import { I18nextProvider } from "react-i18next";
import stores from "../../../store/index.Files"; import store from "SRC_DIR/store";
import store from "client/store";
import SelectFileInput from "./index"; import SelectFileInput from "./index";
import i18n from "./i18n"; import i18n from "./i18n";
const { auth: authStore } = store; const { auth: authStore } = store;
@ -16,7 +15,7 @@ class SelectFileInputWrapper extends React.Component {
render() { render() {
return ( return (
<MobxProvider auth={authStore} {...stores}> <MobxProvider {...store}>
<I18nextProvider i18n={i18n}> <I18nextProvider i18n={i18n}>
<SelectFileModalWrapper {...this.props} /> <SelectFileModalWrapper {...this.props} />
</I18nextProvider> </I18nextProvider>

View File

@ -1,10 +1,10 @@
import React from "react"; import React from "react";
import { Provider as MobxProvider, inject, observer } from "mobx-react"; import { Provider as MobxProvider, inject, observer } from "mobx-react";
import PropTypes from "prop-types"; import PropTypes from "prop-types";
import stores from "../../../store/index.Files";
import SelectFileDialog from "../SelectFileDialog"; import SelectFileDialog from "../SelectFileDialog";
import StyledComponent from "./StyledSelectFileInput"; import StyledComponent from "./StyledSelectFileInput";
import SimpleFileInput from "../../SimpleFileInput"; import SimpleFileInput from "../../SimpleFileInput";
import store from "SRC_DIR/store";
class SelectFileInputBody extends React.PureComponent { class SelectFileInputBody extends React.PureComponent {
constructor(props) { constructor(props) {
@ -88,7 +88,7 @@ const SelectFileInputBodyWrapper = inject(({ filesStore }) => {
class SelectFileInput extends React.Component { class SelectFileInput extends React.Component {
render() { render() {
return ( return (
<MobxProvider {...stores}> <MobxProvider {...store}>
<SelectFileInputBodyWrapper {...this.props} /> <SelectFileInputBodyWrapper {...this.props} />
</MobxProvider> </MobxProvider>
); );

View File

@ -1,8 +1,7 @@
import React from "react"; import React from "react";
import { Provider as MobxProvider, inject, observer } from "mobx-react"; import { Provider as MobxProvider, inject, observer } from "mobx-react";
import { I18nextProvider } from "react-i18next"; import { I18nextProvider } from "react-i18next";
import stores from "../../../store/index.Files"; import store from "SRC_DIR/store";
import store from "client/store";
import SelectFolderDialog from "./index"; import SelectFolderDialog from "./index";
import i18n from "./i18n"; import i18n from "./i18n";
import { getFolder } from "@docspace/common/api/files"; import { getFolder } from "@docspace/common/api/files";
@ -76,7 +75,7 @@ class SelectFolderModal extends React.Component {
render() { render() {
return ( return (
<MobxProvider auth={authStore} {...stores}> <MobxProvider {...store}>
<I18nextProvider i18n={i18n}> <I18nextProvider i18n={i18n}>
<SelectFolderModalWrapper {...this.props} /> <SelectFolderModalWrapper {...this.props} />
</I18nextProvider> </I18nextProvider>

View File

@ -1,10 +1,9 @@
import React from "react"; import React from "react";
import { Provider as MobxProvider } from "mobx-react"; import { Provider as MobxProvider } from "mobx-react";
import { I18nextProvider } from "react-i18next"; import { I18nextProvider } from "react-i18next";
import stores from "../../../store/index.Files";
import store from "client/store";
import SelectFolderInput from "./index"; import SelectFolderInput from "./index";
import i18n from "./i18n"; import i18n from "./i18n";
import store from "SRC_DIR/store";
const { auth: authStore } = store; const { auth: authStore } = store;
const SelectFolderModalWrapper = (props) => <SelectFolderInput {...props} />; const SelectFolderModalWrapper = (props) => <SelectFolderInput {...props} />;
@ -16,7 +15,7 @@ class SelectFolderInputWrapper extends React.Component {
render() { render() {
return ( return (
<MobxProvider auth={authStore} {...stores}> <MobxProvider {...store}>
<I18nextProvider i18n={i18n}> <I18nextProvider i18n={i18n}>
<SelectFolderModalWrapper {...this.props} /> <SelectFolderModalWrapper {...this.props} />
</I18nextProvider> </I18nextProvider>

View File

@ -2,10 +2,7 @@ import React, { useEffect } from "react";
import { Provider as MobxProvider, inject, observer } from "mobx-react"; import { Provider as MobxProvider, inject, observer } from "mobx-react";
import { getShareFiles } from "@docspace/common/api/files"; import { getShareFiles } from "@docspace/common/api/files";
import SharingPanel from "../SharingPanel"; import SharingPanel from "../SharingPanel";
import store from "SRC_DIR/store";
import stores from "../../../store/index.Files";
import store from "client/store";
const { auth: authStore } = store; const { auth: authStore } = store;
const SharingDialog = ({ const SharingDialog = ({
@ -69,7 +66,7 @@ class SharingModal extends React.Component {
render() { render() {
return ( return (
<MobxProvider auth={authStore} {...stores}> <MobxProvider {...store}>
<SharingDialogWrapper {...this.props} /> <SharingDialogWrapper {...this.props} />
</MobxProvider> </MobxProvider>
); );

View File

@ -1,9 +1,8 @@
import filesStore from "../store"; import store from "SRC_DIR/store";
import store from "client/store";
import { desktopConstants } from "@docspace/common/desktop"; import { desktopConstants } from "@docspace/common/desktop";
export function encryptionUploadDialog(callback) { export function encryptionUploadDialog(callback) {
const filter = filesStore.settingsStore.extsWebEncrypt const filter = store.filesStore.settingsStore.extsWebEncrypt
.map((f) => "*" + f) .map((f) => "*" + f)
.join(" "); .join(" ");

View File

@ -1,4 +1,4 @@
import authStore from "@docspace/common/store/AuthStore"; import authStore from "SRC_DIR/store/AuthStore";
import { AppServerConfig, RoomsType } from "@docspace/common/constants"; import { AppServerConfig, RoomsType } from "@docspace/common/constants";
import config from "PACKAGE_FILE"; import config from "PACKAGE_FILE";
import { combineUrl, toUrlParams } from "@docspace/common/utils"; import { combineUrl, toUrlParams } from "@docspace/common/utils";

View File

@ -1,4 +1,4 @@
import authStore from "@docspace/common/store/AuthStore"; import authStore from "SRC_DIR/store/AuthStore";
import { toCommunityHostname } from "@docspace/common/utils"; import { toCommunityHostname } from "@docspace/common/utils";
import history from "@docspace/common/history"; import history from "@docspace/common/history";
import { useEffect, useState } from "react"; import { useEffect, useState } from "react";

View File

@ -1,16 +1,22 @@
import { makeAutoObservable } from "mobx"; import { makeAutoObservable } from "mobx";
import api from "../api"; import api from "@docspace/common/api";
import { setWithCredentialsStatus } from "../api/client"; import { setWithCredentialsStatus } from "@docspace/common/api/client";
import history from "../history"; //import history from "../history";
import SettingsStore from "./SettingsStore"; import SettingsStore from "./PortalSettingsStore";
import UserStore from "./UserStore"; import UserStore from "./UserStore";
import TfaStore from "./TfaStore"; import TfaStore from "./TfaStore";
import InfoPanelStore from "./InfoPanelStore"; import InfoPanelStore from "./InfoPanelStore";
import { logout as logoutDesktop, desktopConstants } from "../desktop"; import {
import { combineUrl, isAdmin } from "../utils"; logout as logoutDesktop,
import { AppServerConfig, LANGUAGE, TenantStatus } from "../constants"; desktopConstants,
const { proxyURL } = AppServerConfig; } from "@docspace/common/desktop";
import { /*combineUrl,*/ isAdmin } from "@docspace/common/utils";
import {
/*AppServerConfig,*/ LANGUAGE,
TenantStatus,
} from "@docspace/common/constants";
//const { proxyURL } = AppServerConfig;
class AuthStore { class AuthStore {
userStore = null; userStore = null;
@ -173,14 +179,14 @@ class AuthStore {
if (redirectPath) { if (redirectPath) {
return window.location.replace(redirectPath); return window.location.replace(redirectPath);
} }
if (personal) { //if (personal) {
return window.location.replace("/"); return window.location.replace("/");
} else { // } else {
this.reset(true); // this.reset(true);
this.userStore.setUser(null); // this.userStore.setUser(null);
this.init(); // this.init();
return history.push(combineUrl(proxyURL, "/login")); // return history.push(combineUrl(proxyURL, "/login"));
} // }
} else { } else {
this.reset(); this.reset();
this.init(); this.init();

View File

@ -1,5 +1,5 @@
import { makeAutoObservable, runInAction } from "mobx"; import { makeAutoObservable, runInAction } from "mobx";
import authStore from "@docspace/common/store/AuthStore"; import authStore from "SRC_DIR/store/AuthStore";
import api from "@docspace/common/api"; import api from "@docspace/common/api";
class CommonStore { class CommonStore {

View File

@ -3,14 +3,14 @@ import {
getInvitationLinks, getInvitationLinks,
getShortenedLink, getShortenedLink,
} from "@docspace/common/api/portal"; } from "@docspace/common/api/portal";
import store from "client/store";
const { auth: authStore } = store;
class InviteLinksStore { class InviteLinksStore {
userLink = null; userLink = null;
guestLink = null; guestLink = null;
authStore = null;
constructor() { constructor(authStore) {
this.authStore = authStore;
makeAutoObservable(this); makeAutoObservable(this);
} }
@ -22,7 +22,7 @@ class InviteLinksStore {
}; };
getPortalInviteLinks = async () => { getPortalInviteLinks = async () => {
const isViewerAdmin = authStore.isAdmin; const isViewerAdmin = this.authStore.isAdmin;
if (!isViewerAdmin) return Promise.resolve(); if (!isViewerAdmin) return Promise.resolve();

View File

@ -9,13 +9,12 @@ import SelectionStore from "./SelectionPeopleStore";
import HeaderMenuStore from "./HeaderMenuStore"; import HeaderMenuStore from "./HeaderMenuStore";
import AvatarEditorStore from "./AvatarEditorStore"; import AvatarEditorStore from "./AvatarEditorStore";
import InviteLinksStore from "./InviteLinksStore"; import InviteLinksStore from "./InviteLinksStore";
import store from "client/store";
import DialogStore from "./DialogStore"; import DialogStore from "./DialogStore";
import LoadingStore from "./LoadingStore"; import LoadingStore from "./LoadingStore";
import { isMobile } from "react-device-detect"; import { isMobile } from "react-device-detect";
const { auth: authStore } = store;
class PeopleStore { class PeopleStore {
authStore = null;
groupsStore = null; groupsStore = null;
usersStore = null; usersStore = null;
targetUserStore = null; targetUserStore = null;
@ -31,7 +30,8 @@ class PeopleStore {
isInit = false; isInit = false;
viewAs = isMobile ? "row" : "table"; viewAs = isMobile ? "row" : "table";
constructor() { constructor(authStore) {
this.authStore = authStore;
this.groupsStore = new GroupsStore(this); this.groupsStore = new GroupsStore(this);
this.usersStore = new UsersStore(this); this.usersStore = new UsersStore(this);
this.targetUserStore = new TargetUserStore(this); this.targetUserStore = new TargetUserStore(this);
@ -41,7 +41,7 @@ class PeopleStore {
this.selectionStore = new SelectionStore(this); this.selectionStore = new SelectionStore(this);
this.headerMenuStore = new HeaderMenuStore(this); this.headerMenuStore = new HeaderMenuStore(this);
this.avatarEditorStore = new AvatarEditorStore(this); this.avatarEditorStore = new AvatarEditorStore(this);
this.inviteLinksStore = new InviteLinksStore(this); this.inviteLinksStore = new InviteLinksStore(authStore);
this.dialogStore = new DialogStore(); this.dialogStore = new DialogStore();
this.loadingStore = new LoadingStore(); this.loadingStore = new LoadingStore();
@ -49,16 +49,16 @@ class PeopleStore {
} }
get isPeoplesAdmin() { get isPeoplesAdmin() {
return authStore.isAdmin; return this.authStore.isAdmin;
} }
init = async () => { init = async () => {
if (this.isInit) return; if (this.isInit) return;
this.isInit = true; this.isInit = true;
//authStore.settingsStore.setModuleInfo(config.homepage, config.id); //this.authStore.settingsStore.setModuleInfo(config.homepage, config.id);
await authStore.settingsStore.getPortalPasswordSettings(); await this.authStore.settingsStore.getPortalPasswordSettings();
this.loadingStore.setIsLoaded(true); this.loadingStore.setIsLoaded(true);
}; };
@ -79,7 +79,10 @@ class PeopleStore {
}; };
getHeaderMenu = (t) => { getHeaderMenu = (t) => {
const { userCaption, guestCaption } = authStore.settingsStore.customNames; const {
userCaption,
guestCaption,
} = this.authStore.settingsStore.customNames;
const { const {
hasUsersToMakeEmployees, hasUsersToMakeEmployees,
hasUsersToMakeGuests, hasUsersToMakeGuests,

View File

@ -1,11 +1,11 @@
import { makeAutoObservable } from "mobx"; import { makeAutoObservable } from "mobx";
import api from "../api"; import api from "@docspace/common/api";
import { LANGUAGE, TenantStatus } from "../constants"; import { LANGUAGE, TenantStatus } from "@docspace/common/constants";
import { combineUrl } from "../utils"; import { combineUrl } from "@docspace/common/utils";
import FirebaseHelper from "../utils/firebase"; import FirebaseHelper from "@docspace/common/utils/firebase";
import { AppServerConfig, ThemeKeys } from "../constants"; import { AppServerConfig, ThemeKeys } from "@docspace/common/constants";
import { version } from "../package.json"; import { version } from "PACKAGE_FILE";
import SocketIOHelper from "../utils/socket"; import SocketIOHelper from "@docspace/common/utils/socket";
import { Dark, Base } from "@docspace/components/themes"; import { Dark, Base } from "@docspace/components/themes";

View File

@ -2,14 +2,13 @@ import { makeAutoObservable } from "mobx";
import { combineUrl } from "@docspace/common/utils"; import { combineUrl } from "@docspace/common/utils";
import { AppServerConfig } from "@docspace/common/constants"; import { AppServerConfig } from "@docspace/common/constants";
import history from "@docspace/common/history"; import history from "@docspace/common/history";
import authStore from "@docspace/common/store/AuthStore";
import { isDesktop, isTablet, isMobile } from "react-device-detect"; import { isDesktop, isTablet, isMobile } from "react-device-detect";
const { proxyURL } = AppServerConfig; const { proxyURL } = AppServerConfig;
const PROXY_HOMEPAGE_URL = combineUrl(proxyURL, "/"); const PROXY_HOMEPAGE_URL = combineUrl(proxyURL, "/");
const PROFILE_SELF_URL = combineUrl(PROXY_HOMEPAGE_URL, "/accounts/view/@self"); const PROFILE_SELF_URL = combineUrl(PROXY_HOMEPAGE_URL, "/accounts/view/@self");
const PROFILE_MY_URL = combineUrl(PROXY_HOMEPAGE_URL, "/my"); //const PROFILE_MY_URL = combineUrl(PROXY_HOMEPAGE_URL, "/my");
const ABOUT_URL = combineUrl(PROXY_HOMEPAGE_URL, "/about"); const ABOUT_URL = combineUrl(PROXY_HOMEPAGE_URL, "/about");
const PAYMENTS_URL = combineUrl(PROXY_HOMEPAGE_URL, "/payments"); const PAYMENTS_URL = combineUrl(PROXY_HOMEPAGE_URL, "/payments");
const HELP_URL = "https://onlyoffice.com/"; const HELP_URL = "https://onlyoffice.com/";
@ -21,7 +20,7 @@ class ProfileActionsStore {
isAboutDialogVisible = false; isAboutDialogVisible = false;
isDebugDialogVisible = false; isDebugDialogVisible = false;
constructor() { constructor(authStore) {
this.authStore = authStore; this.authStore = authStore;
makeAutoObservable(this); makeAutoObservable(this);
} }

View File

@ -4,8 +4,6 @@ import {
EmployeeActivationStatus, EmployeeActivationStatus,
} from "@docspace/common/constants"; } from "@docspace/common/constants";
import { getUserStatus } from "../helpers/people-helpers"; import { getUserStatus } from "../helpers/people-helpers";
import store from "client/store";
const { auth: authStore } = store;
class SelectionStore { class SelectionStore {
selection = []; selection = [];
@ -115,7 +113,7 @@ class SelectionStore {
!x.isOwner && !x.isOwner &&
x.isVisitor && x.isVisitor &&
x.status !== EmployeeStatus.Disabled && x.status !== EmployeeStatus.Disabled &&
x.id !== authStore.userStore.user.id x.id !== this.peopleStore.authStore.userStore.user.id
); );
}); });
return !!users.length; return !!users.length;
@ -128,7 +126,7 @@ class SelectionStore {
!x.isOwner && !x.isOwner &&
x.isVisitor && x.isVisitor &&
x.status !== EmployeeStatus.Disabled && x.status !== EmployeeStatus.Disabled &&
x.id !== authStore.userStore.user.id x.id !== this.peopleStore.authStore.userStore.user.id
); );
}); });
return users.map((u) => u.id); return users.map((u) => u.id);
@ -141,7 +139,7 @@ class SelectionStore {
!x.isOwner && !x.isOwner &&
!x.isVisitor && !x.isVisitor &&
x.status !== EmployeeStatus.Disabled && x.status !== EmployeeStatus.Disabled &&
x.id !== authStore.userStore.user.id x.id !== this.peopleStore.authStore.userStore.user.id
); );
}); });
return !!users.length; return !!users.length;
@ -154,7 +152,7 @@ class SelectionStore {
!x.isOwner && !x.isOwner &&
!x.isVisitor && !x.isVisitor &&
x.status !== EmployeeStatus.Disabled && x.status !== EmployeeStatus.Disabled &&
x.id !== authStore.userStore.user.id x.id !== this.peopleStore.authStore.userStore.user.id
); );
}); });
return users.map((u) => u.id); return users.map((u) => u.id);
@ -165,7 +163,7 @@ class SelectionStore {
(x) => (x) =>
!x.isOwner && !x.isOwner &&
x.status !== EmployeeStatus.Active && x.status !== EmployeeStatus.Active &&
x.id !== authStore.userStore.user.id x.id !== this.peopleStore.authStore.userStore.user.id
); );
return !!users.length; return !!users.length;
} }
@ -175,7 +173,7 @@ class SelectionStore {
(x) => (x) =>
!x.isOwner && !x.isOwner &&
x.status !== EmployeeStatus.Active && x.status !== EmployeeStatus.Active &&
x.id !== authStore.userStore.user.id x.id !== this.peopleStore.authStore.userStore.user.id
); );
return users.map((u) => u.id); return users.map((u) => u.id);
} }
@ -185,7 +183,7 @@ class SelectionStore {
(x) => (x) =>
!x.isOwner && !x.isOwner &&
x.status !== EmployeeStatus.Disabled && x.status !== EmployeeStatus.Disabled &&
x.id !== authStore.userStore.user.id x.id !== this.peopleStore.authStore.userStore.user.id
); );
return !!users.length; return !!users.length;
} }
@ -195,7 +193,7 @@ class SelectionStore {
(x) => (x) =>
!x.isOwner && !x.isOwner &&
x.status !== EmployeeStatus.Disabled && x.status !== EmployeeStatus.Disabled &&
x.id !== authStore.userStore.user.id x.id !== this.peopleStore.authStore.userStore.user.id
); );
return users.map((u) => u.id); return users.map((u) => u.id);
} }

View File

@ -2,8 +2,6 @@ import api from "@docspace/common/api";
import { makeAutoObservable } from "mobx"; import { makeAutoObservable } from "mobx";
const { Filter } = api; const { Filter } = api;
import SelectionStore from "./SelectionStore"; import SelectionStore from "./SelectionStore";
//import CommonStore from "./CommonStore";
import authStore from "@docspace/common/store/AuthStore";
import { combineUrl } from "@docspace/common/utils"; import { combineUrl } from "@docspace/common/utils";
import { AppServerConfig } from "@docspace/common/constants"; import { AppServerConfig } from "@docspace/common/constants";
import config from "PACKAGE_FILE"; import config from "PACKAGE_FILE";
@ -40,7 +38,7 @@ class SettingsSetupStore {
commonThirdPartyList: [], commonThirdPartyList: [],
}; };
constructor() { constructor(authStore) {
this.selectionStore = new SelectionStore(this); this.selectionStore = new SelectionStore(this);
this.authStore = authStore; this.authStore = authStore;
makeAutoObservable(this); makeAutoObservable(this);
@ -50,12 +48,12 @@ class SettingsSetupStore {
if (this.isInit) return; if (this.isInit) return;
this.isInit = true; this.isInit = true;
if (authStore.isAuthenticated) { if (this.authStore.isAuthenticated) {
await authStore.settingsStore.getPortalPasswordSettings(); await this.authStore.settingsStore.getPortalPasswordSettings();
await authStore.tfaStore.getTfaType(); await this.authStore.tfaStore.getTfaType();
await authStore.settingsStore.getIpRestrictionsEnable(); await this.authStore.settingsStore.getIpRestrictionsEnable();
await authStore.settingsStore.getIpRestrictions(); await this.authStore.settingsStore.getIpRestrictions();
await authStore.settingsStore.getSessionLifetime(); await this.authStore.settingsStore.getSessionLifetime();
} }
}; };

View File

@ -1,9 +1,6 @@
import api from "@docspace/common/api"; import api from "@docspace/common/api";
import { LANGUAGE } from "@docspace/common/constants"; import { LANGUAGE } from "@docspace/common/constants";
import { makeAutoObservable } from "mobx"; import { makeAutoObservable } from "mobx";
import store from "client/store";
const { auth: authStore } = store;
class TargetUserStore { class TargetUserStore {
targetUser = null; targetUser = null;
@ -17,8 +14,8 @@ class TargetUserStore {
get getDisableProfileType() { get getDisableProfileType() {
const res = const res =
authStore.userStore.user.id === this.targetUser.id || this.peopleStore.authStore.userStore.user.id === this.targetUser.id ||
!authStore.isAdmin || !this.peopleStore.authStore.isAdmin ||
this.peopleStore.isPeoplesAdmin this.peopleStore.isPeoplesAdmin
? false ? false
: true; : true;
@ -29,22 +26,19 @@ class TargetUserStore {
get isMe() { get isMe() {
return ( return (
this.targetUser && this.targetUser &&
this.targetUser.userName === authStore.userStore.user.userName this.targetUser.userName ===
this.peopleStore.authStore.userStore.user.userName
); );
} }
getTargetUser = async (userName) => { getTargetUser = async (userName) => {
/*if (authStore.userStore.user.userName === userName) {
return this.setTargetUser(authStore.userStore.user);
} else {*/
const user = await api.people.getUser(userName); const user = await api.people.getUser(userName);
if (user?.userName === authStore.userStore.user.userName) { if (user?.userName === this.peopleStore.authStore.userStore.user.userName) {
const tipsSubscription = await api.settings.getTipsSubscription(); const tipsSubscription = await api.settings.getTipsSubscription();
this.tipsSubscription = tipsSubscription; this.tipsSubscription = tipsSubscription;
} }
this.setTargetUser(user); this.setTargetUser(user);
return user; return user;
//}
}; };
setTargetUser = (user) => { setTargetUser = (user) => {
@ -63,7 +57,7 @@ class TargetUserStore {
); );
const res = await api.people.updateUser(member); const res = await api.people.updateUser(member);
if (!res.theme) res.theme = authStore.userStore.user.theme; if (!res.theme) res.theme = this.peopleStore.authStore.userStore.user.theme;
this.setTargetUser(res); this.setTargetUser(res);
return Promise.resolve(res); return Promise.resolve(res);
@ -80,11 +74,10 @@ class TargetUserStore {
updateProfileCulture = async (id, culture) => { updateProfileCulture = async (id, culture) => {
const res = await api.people.updateUserCulture(id, culture); const res = await api.people.updateUserCulture(id, culture);
authStore.userStore.setUser(res); this.peopleStore.authStore.userStore.setUser(res);
this.setTargetUser(res); this.setTargetUser(res);
//caches.delete("api-cache");
//await authStore.settingsStore.init();
localStorage.setItem(LANGUAGE, culture); localStorage.setItem(LANGUAGE, culture);
}; };

View File

@ -1,6 +1,6 @@
import { makeAutoObservable } from "mobx"; import { makeAutoObservable } from "mobx";
import api from "../api"; import api from "@docspace/common/api";
import history from "../history"; //import history from "../history";
class TfaStore { class TfaStore {
tfaSettings = null; tfaSettings = null;

View File

@ -1,5 +1,5 @@
import { makeAutoObservable } from "mobx"; import { makeAutoObservable } from "mobx";
import api from "../api"; import api from "@docspace/common/api";
class UserStore { class UserStore {
user = null; user = null;

View File

@ -6,8 +6,7 @@ import {
} from "@docspace/common/constants"; } from "@docspace/common/constants";
import { isMobileOnly } from "react-device-detect"; import { isMobileOnly } from "react-device-detect";
const { Filter } = api; const { Filter } = api;
import store from "client/store";
const { auth: authStore } = store;
class UsersStore { class UsersStore {
users = []; users = [];
providers = []; providers = [];
@ -237,9 +236,9 @@ class UsersStore {
const statusType = this.getStatusType(user); const statusType = this.getStatusType(user);
const role = this.getUserRole(user); const role = this.getUserRole(user);
const isMySelf = const isMySelf =
authStore.userStore.user && this.peopleStore.authStore.userStore.user &&
user.userName === authStore.userStore.user.userName; user.userName === this.peopleStore.authStore.userStore.user.userName;
const isViewerAdmin = authStore.isAdmin; const isViewerAdmin = this.peopleStore.authStore.isAdmin;
const options = this.getUserContextOptions( const options = this.getUserContextOptions(
isMySelf, isMySelf,

View File

@ -1,113 +0,0 @@
import FilesStore from "./FilesStore";
import SelectedFolderStore from "./SelectedFolderStore";
import TreeFoldersStore from "./TreeFoldersStore";
import thirdPartyStore from "./ThirdPartyStore";
import SettingsStore from "./SettingsStore";
import FilesActionsStore from "./FilesActionsStore";
import MediaViewerDataStore from "./MediaViewerDataStore";
import UploadDataStore from "./UploadDataStore";
import SecondaryProgressDataStore from "./SecondaryProgressDataStore";
import PrimaryProgressDataStore from "./PrimaryProgressDataStore";
import VersionHistoryStore from "./VersionHistoryStore";
import DialogsStore from "./DialogsStore";
import selectFolderDialogStore from "./SelectFolderDialogStore";
import ContextOptionsStore from "./ContextOptionsStore";
import HotkeyStore from "./HotkeyStore";
import store from "client/store";
import selectFileDialogStore from "./SelectFileDialogStore";
import TagsStore from "./TagsStore";
const tagsStore = new TagsStore();
const selectedFolderStore = new SelectedFolderStore(store.auth.settingsStore);
const treeFoldersStore = new TreeFoldersStore(selectedFolderStore);
const settingsStore = new SettingsStore(thirdPartyStore, treeFoldersStore);
const filesStore = new FilesStore(
store.auth,
store.auth.settingsStore,
store.auth.userStore,
selectedFolderStore,
treeFoldersStore,
settingsStore,
selectFolderDialogStore,
selectFileDialogStore
);
const mediaViewerDataStore = new MediaViewerDataStore(
filesStore,
settingsStore
);
const secondaryProgressDataStore = new SecondaryProgressDataStore();
const primaryProgressDataStore = new PrimaryProgressDataStore();
const versionHistoryStore = new VersionHistoryStore(filesStore);
const dialogsStore = new DialogsStore(
store.auth,
treeFoldersStore,
filesStore,
selectedFolderStore,
versionHistoryStore
);
const uploadDataStore = new UploadDataStore(
treeFoldersStore,
selectedFolderStore,
filesStore,
secondaryProgressDataStore,
primaryProgressDataStore,
dialogsStore,
settingsStore
);
const filesActionsStore = new FilesActionsStore(
store.auth,
uploadDataStore,
treeFoldersStore,
filesStore,
selectedFolderStore,
settingsStore,
dialogsStore,
mediaViewerDataStore
);
const contextOptionsStore = new ContextOptionsStore(
store.auth,
dialogsStore,
filesActionsStore,
filesStore,
mediaViewerDataStore,
treeFoldersStore,
uploadDataStore,
versionHistoryStore,
settingsStore
);
const hotkeyStore = new HotkeyStore(
filesStore,
dialogsStore,
settingsStore,
filesActionsStore,
treeFoldersStore,
uploadDataStore
);
const stores = {
filesStore,
settingsStore,
mediaViewerDataStore,
versionHistoryStore,
uploadDataStore,
dialogsStore,
treeFoldersStore,
selectedFolderStore,
filesActionsStore,
selectFolderDialogStore,
contextOptionsStore,
hotkeyStore,
selectFileDialogStore,
tagsStore,
};
export default stores;

View File

@ -1,118 +0,0 @@
import FilesStore from "./FilesStore";
import SelectedFolderStore from "./SelectedFolderStore";
import TreeFoldersStore from "./TreeFoldersStore";
import thirdPartyStore from "./ThirdPartyStore";
import SettingsStore from "./SettingsStore";
import FilesActionsStore from "./FilesActionsStore";
import MediaViewerDataStore from "./MediaViewerDataStore";
import UploadDataStore from "./UploadDataStore";
import SecondaryProgressDataStore from "./SecondaryProgressDataStore";
import PrimaryProgressDataStore from "./PrimaryProgressDataStore";
import VersionHistoryStore from "./VersionHistoryStore";
import DialogsStore from "./DialogsStore";
import selectFolderDialogStore from "./SelectFolderDialogStore";
import ContextOptionsStore from "./ContextOptionsStore";
import HotkeyStore from "./HotkeyStore";
import store from "client/store";
import selectFileDialogStore from "./SelectFileDialogStore";
import TagsStore from "./TagsStore";
import PeopleStore from "./PeopleStore";
const peopleStore = new PeopleStore();
const tagsStore = new TagsStore();
const selectedFolderStore = new SelectedFolderStore(store.auth.settingsStore);
const treeFoldersStore = new TreeFoldersStore(selectedFolderStore);
const settingsStore = new SettingsStore(thirdPartyStore, treeFoldersStore);
const filesStore = new FilesStore(
store.auth,
store.auth.settingsStore,
store.auth.userStore,
selectedFolderStore,
treeFoldersStore,
settingsStore,
selectFolderDialogStore,
selectFileDialogStore
);
const mediaViewerDataStore = new MediaViewerDataStore(
filesStore,
settingsStore
);
const secondaryProgressDataStore = new SecondaryProgressDataStore();
const primaryProgressDataStore = new PrimaryProgressDataStore();
const versionHistoryStore = new VersionHistoryStore(filesStore);
const dialogsStore = new DialogsStore(
store.auth,
treeFoldersStore,
filesStore,
selectedFolderStore,
versionHistoryStore
);
const uploadDataStore = new UploadDataStore(
treeFoldersStore,
selectedFolderStore,
filesStore,
secondaryProgressDataStore,
primaryProgressDataStore,
dialogsStore,
settingsStore
);
const filesActionsStore = new FilesActionsStore(
store.auth,
uploadDataStore,
treeFoldersStore,
filesStore,
selectedFolderStore,
settingsStore,
dialogsStore,
mediaViewerDataStore
);
const contextOptionsStore = new ContextOptionsStore(
store.auth,
dialogsStore,
filesActionsStore,
filesStore,
mediaViewerDataStore,
treeFoldersStore,
uploadDataStore,
versionHistoryStore,
settingsStore
);
const hotkeyStore = new HotkeyStore(
filesStore,
dialogsStore,
settingsStore,
filesActionsStore,
treeFoldersStore,
uploadDataStore
);
const stores = {
filesStore,
settingsStore,
mediaViewerDataStore,
versionHistoryStore,
uploadDataStore,
dialogsStore,
treeFoldersStore,
selectedFolderStore,
filesActionsStore,
selectFolderDialogStore,
contextOptionsStore,
hotkeyStore,
selectFileDialogStore,
tagsStore,
peopleStore,
};
export default stores;

View File

@ -1,4 +1,4 @@
import authStore from "@docspace/common/store/AuthStore"; import authStore from "./AuthStore";
import PaymentStore from "./PaymentStore"; import PaymentStore from "./PaymentStore";
import WizardStore from "./WizardStore"; import WizardStore from "./WizardStore";
import SettingsSetupStore from "./SettingsSetupStore"; import SettingsSetupStore from "./SettingsSetupStore";
@ -7,15 +7,109 @@ import BackupStore from "./BackupStore";
import CommonStore from "./CommonStore"; import CommonStore from "./CommonStore";
import BannerStore from "./BannerStore"; import BannerStore from "./BannerStore";
import ProfileActionsStore from "./ProfileActionsStore"; import ProfileActionsStore from "./ProfileActionsStore";
import FilesStore from "./FilesStore";
import SelectedFolderStore from "./SelectedFolderStore";
import TreeFoldersStore from "./TreeFoldersStore";
import thirdPartyStore from "./ThirdPartyStore";
import SettingsStore from "./SettingsStore";
import FilesActionsStore from "./FilesActionsStore";
import MediaViewerDataStore from "./MediaViewerDataStore";
import UploadDataStore from "./UploadDataStore";
import SecondaryProgressDataStore from "./SecondaryProgressDataStore";
import PrimaryProgressDataStore from "./PrimaryProgressDataStore";
import VersionHistoryStore from "./VersionHistoryStore";
import DialogsStore from "./DialogsStore";
import selectFolderDialogStore from "./SelectFolderDialogStore";
import ContextOptionsStore from "./ContextOptionsStore";
import HotkeyStore from "./HotkeyStore";
import selectFileDialogStore from "./SelectFileDialogStore";
import TagsStore from "./TagsStore";
import PeopleStore from "./PeopleStore";
const paymentStore = new PaymentStore(); const paymentStore = new PaymentStore();
const wizardStore = new WizardStore(); const wizardStore = new WizardStore();
const setupStore = new SettingsSetupStore(); const setupStore = new SettingsSetupStore(authStore);
const confirmStore = new ConfirmStore(); const confirmStore = new ConfirmStore();
const backupStore = new BackupStore(); const backupStore = new BackupStore();
const commonStore = new CommonStore(); const commonStore = new CommonStore();
const bannerStore = new BannerStore(); const bannerStore = new BannerStore();
const profileActionsStore = new ProfileActionsStore(); const profileActionsStore = new ProfileActionsStore(authStore);
const peopleStore = new PeopleStore(authStore);
const tagsStore = new TagsStore();
const selectedFolderStore = new SelectedFolderStore(authStore.settingsStore);
const treeFoldersStore = new TreeFoldersStore(selectedFolderStore);
const settingsStore = new SettingsStore(thirdPartyStore, treeFoldersStore);
const filesStore = new FilesStore(
authStore,
authStore.settingsStore,
authStore.userStore,
selectedFolderStore,
treeFoldersStore,
settingsStore,
selectFolderDialogStore,
selectFileDialogStore
);
const mediaViewerDataStore = new MediaViewerDataStore(
filesStore,
settingsStore
);
const secondaryProgressDataStore = new SecondaryProgressDataStore();
const primaryProgressDataStore = new PrimaryProgressDataStore();
const versionHistoryStore = new VersionHistoryStore(filesStore);
const dialogsStore = new DialogsStore(
authStore,
treeFoldersStore,
filesStore,
selectedFolderStore,
versionHistoryStore
);
const uploadDataStore = new UploadDataStore(
treeFoldersStore,
selectedFolderStore,
filesStore,
secondaryProgressDataStore,
primaryProgressDataStore,
dialogsStore,
settingsStore
);
const filesActionsStore = new FilesActionsStore(
authStore,
uploadDataStore,
treeFoldersStore,
filesStore,
selectedFolderStore,
settingsStore,
dialogsStore,
mediaViewerDataStore
);
const contextOptionsStore = new ContextOptionsStore(
authStore,
dialogsStore,
filesActionsStore,
filesStore,
mediaViewerDataStore,
treeFoldersStore,
uploadDataStore,
versionHistoryStore,
settingsStore
);
const hotkeyStore = new HotkeyStore(
filesStore,
dialogsStore,
settingsStore,
filesActionsStore,
treeFoldersStore,
uploadDataStore
);
const store = { const store = {
auth: authStore, auth: authStore,
@ -27,6 +121,25 @@ const store = {
common: commonStore, common: commonStore,
bannerStore: bannerStore, bannerStore: bannerStore,
profileActionsStore: profileActionsStore, profileActionsStore: profileActionsStore,
filesStore,
settingsStore,
mediaViewerDataStore,
versionHistoryStore,
uploadDataStore,
dialogsStore,
treeFoldersStore,
selectedFolderStore,
filesActionsStore,
selectFolderDialogStore,
contextOptionsStore,
hotkeyStore,
selectFileDialogStore,
tagsStore,
peopleStore,
}; };
export default store; export default store;

View File

@ -1,2 +0,0 @@
import authStore from "./AuthStore";
export default { authStore };