Management: delete useless
This commit is contained in:
parent
24317a1980
commit
e6b02aea48
@ -1,84 +0,0 @@
|
||||
import axios from "axios";
|
||||
import { makeAutoObservable, runInAction } from "mobx";
|
||||
import isEqual from "lodash/isEqual";
|
||||
|
||||
import api from "@docspace/common/api";
|
||||
|
||||
import { TLogoUrl } from "SRC_DIR/types/branding";
|
||||
|
||||
type BrandingData = {
|
||||
logoText: string | null;
|
||||
logo: TLogoUrl[];
|
||||
};
|
||||
|
||||
class BrandingStore {
|
||||
isInit = false;
|
||||
|
||||
defaultWhiteLabelLogos: TLogoUrl[] | null = null;
|
||||
whiteLabelLogos: TLogoUrl[] | null = null;
|
||||
whiteLabelLogoText: string | null = null;
|
||||
defaultWhiteLabelLogoText: string | null = null;
|
||||
|
||||
constructor() {
|
||||
makeAutoObservable(this);
|
||||
}
|
||||
|
||||
initStore = async () => {
|
||||
if (this.isInit) return;
|
||||
this.isInit = true;
|
||||
|
||||
const requests = [];
|
||||
requests.push(this.getWhiteLabelLogoUrls(), this.getWhiteLabelLogoText());
|
||||
|
||||
return Promise.all(requests);
|
||||
};
|
||||
|
||||
getWhiteLabelLogoUrls = async () => {
|
||||
const res = await api.settings.getLogoUrls();
|
||||
this.setWhiteLabelLogos(Object.values(res));
|
||||
this.setDefaultWhiteLabelLogos(Object.values(res));
|
||||
};
|
||||
|
||||
getWhiteLabelLogoText = async () => {
|
||||
const res = await api.settings.getLogoText();
|
||||
this.setWhiteLabelLogoText(res);
|
||||
this.setDefaultWhiteLabelLogoText(res);
|
||||
};
|
||||
|
||||
setWhiteLabelLogos = (whiteLabelLogos: TLogoUrl[]) => {
|
||||
this.whiteLabelLogos = whiteLabelLogos;
|
||||
};
|
||||
|
||||
setDefaultWhiteLabelLogos = (defaultWhiteLabelLogos: TLogoUrl[]) => {
|
||||
this.defaultWhiteLabelLogos = defaultWhiteLabelLogos;
|
||||
};
|
||||
|
||||
setWhiteLabelLogoText = (whiteLabelLogoText: string) => {
|
||||
this.whiteLabelLogoText = whiteLabelLogoText;
|
||||
};
|
||||
|
||||
setDefaultWhiteLabelLogoText = (defaultWhiteLabelLogoText: string) => {
|
||||
this.defaultWhiteLabelLogoText = defaultWhiteLabelLogoText;
|
||||
};
|
||||
|
||||
saveWhiteLabelSettings = async (data: BrandingData) => {
|
||||
const response = await api.settings.setWhiteLabelSettings(data);
|
||||
return Promise.resolve(response);
|
||||
};
|
||||
|
||||
restoreDefault = async (isDefault: boolean) => {
|
||||
const res = await api.settings.restoreWhiteLabelSettings(isDefault);
|
||||
this.getWhiteLabelLogoUrls();
|
||||
this.getWhiteLabelLogoText();
|
||||
};
|
||||
|
||||
get isEqualLogo() {
|
||||
return isEqual(this.whiteLabelLogos, this.defaultWhiteLabelLogos);
|
||||
}
|
||||
|
||||
get isEqualText() {
|
||||
return this.whiteLabelLogoText === this.defaultWhiteLabelLogoText;
|
||||
}
|
||||
}
|
||||
|
||||
export default BrandingStore;
|
@ -1,3 +1,4 @@
|
||||
import { settingsTree } from 'SRC_DIR/utils/settingsTree';
|
||||
import { makeAutoObservable } from "mobx";
|
||||
import { getLogoFromPath } from "@docspace/common/utils";
|
||||
import {
|
||||
@ -13,7 +14,7 @@ import { TNewPortalData, TPortals } from "SRC_DIR/types/spaces";
|
||||
|
||||
class SpacesStore {
|
||||
isInit = false;
|
||||
brandingStore = null;
|
||||
authStore = null;
|
||||
|
||||
portals: TPortals[] = [];
|
||||
domain: string | null = null;
|
||||
@ -21,15 +22,14 @@ class SpacesStore {
|
||||
createPortalDialogVisible = false;
|
||||
domainDialogVisible = false;
|
||||
|
||||
constructor(brandingStore) {
|
||||
this.brandingStore = brandingStore;
|
||||
constructor(authStore) {
|
||||
this.authStore = authStore;
|
||||
makeAutoObservable(this);
|
||||
}
|
||||
|
||||
initStore = async () => {
|
||||
if (this.isInit) return;
|
||||
this.isInit = true;
|
||||
this.brandingStore.initStore();
|
||||
|
||||
const requests = [];
|
||||
requests.push(this.getPortalDomain(), this.getAllPortals());
|
||||
@ -63,7 +63,7 @@ class SpacesStore {
|
||||
}
|
||||
|
||||
get faviconLogo() {
|
||||
const logos = this.brandingStore.whiteLabelLogos;
|
||||
const logos = this.authStore.settingsStore.whiteLabelLogoUrls;
|
||||
if (!logos) return;
|
||||
return getLogoFromPath(logos[2]?.path?.light);
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
import { createContext, useContext } from "react";
|
||||
|
||||
import BrandingStore from "./BrandingStore";
|
||||
import SpacesStore from "./SpacesStore";
|
||||
|
||||
import store from "client/store";
|
||||
@ -8,8 +7,7 @@ const { auth: authStore } = store;
|
||||
|
||||
export class RootStore {
|
||||
authStore = authStore;
|
||||
brandingStore = new BrandingStore();
|
||||
spacesStore = new SpacesStore(this.brandingStore);
|
||||
spacesStore = new SpacesStore(this.authStore);
|
||||
}
|
||||
|
||||
export const RootStoreContext = createContext<RootStore | null>(null);
|
||||
|
@ -1,16 +0,0 @@
|
||||
type TLogoPath = {
|
||||
light: string;
|
||||
dark?: string;
|
||||
}
|
||||
|
||||
type TLogoSize = {
|
||||
width: number;
|
||||
height: number;
|
||||
isEmpty: boolean;
|
||||
}
|
||||
|
||||
export type TLogoUrl = {
|
||||
name: string;
|
||||
path: TLogoPath;
|
||||
size: TLogoSize;
|
||||
}
|
Loading…
Reference in New Issue
Block a user