fixed bad merge

This commit is contained in:
DmitrySychugov 2023-10-04 20:41:41 +05:00
parent 2fc16bc9ec
commit 887ed64df0
3 changed files with 1467 additions and 113 deletions

View File

@ -0,0 +1,102 @@
import axios from "axios";
import config from "PACKAGE_FILE";
import { combineUrl } from "@docspace/common/utils";
export const generateLogo = (
width,
height,
text,
fontSize = 18,
fontColor = "#000",
alignCenter
) => {
const canvas = document.createElement("canvas");
canvas.width = width;
canvas.height = height;
const ctx = canvas.getContext("2d");
const x = alignCenter ? width / 2 : 0;
ctx.fillStyle = "transparent";
ctx.clearRect(0, 0, width, height);
ctx.fillStyle = fontColor;
ctx.textAlign = alignCenter ? "center" : "start";
ctx.textBaseline = "middle";
ctx.font = `${fontSize}px Arial`;
ctx.fillText(text, x, height - fontSize / 2);
return canvas.toDataURL();
};
export const getLogoOptions = (index, text) => {
switch (index) {
case 0:
return { fontSize: 18, text: text, width: 211, height: 24 };
case 1:
return { fontSize: 32, text: text, width: 384, height: 42 };
case 2:
return {
fontSize: 26,
text: text.trim().charAt(0),
width: 30,
height: 30,
alignCenter: true,
};
case 3:
return { fontSize: 22, text: text, width: 154, height: 27 };
case 4:
return { fontSize: 22, text: text, width: 154, height: 27 };
case 5:
return {
fontSize: 24,
text: text.trim().charAt(0),
width: 28,
height: 28,
alignCenter: true,
};
case 6:
return { fontSize: 18, text: text, width: 211, height: 24 };
default:
return { fontSize: 18, text: text, width: 211, height: 24 };
}
};
export const uploadLogo = async (file) => {
try {
const { width, height } = await getUploadedFileDimensions(file);
let data = new FormData();
data.append("file", file);
data.append("width", width);
data.append("height", height);
return await axios.post(
`${combineUrl(
window.DocSpaceConfig?.proxy?.url,
config.homepage
)}/logoUploader.ashx`,
data
);
} catch (error) {
console.error(error);
}
};
const getUploadedFileDimensions = (file) =>
new Promise((resolve, reject) => {
try {
let img = new Image();
img.onload = () => {
const width = img.naturalWidth,
height = img.naturalHeight;
window.URL.revokeObjectURL(img.src);
return resolve({ width, height });
};
img.src = window.URL.createObjectURL(file);
} catch (exception) {
return reject(exception);
}
});

View File

@ -10,17 +10,11 @@ import BookTrainingReactSvgUrl from "PUBLIC_DIR/images/book.training.react.svg?u
import InfoOutlineReactSvgUrl from "PUBLIC_DIR/images/info.outline.react.svg?url";
import LogoutReactSvgUrl from "PUBLIC_DIR/images/logout.react.svg?url";
import SpacesReactSvgUrl from "PUBLIC_DIR/images/spaces.react.svg?url";
import { makeAutoObservable } from "mobx";
import { combineUrl } from "@docspace/common/utils";
import {
isDesktop,
isTablet,
isMobile,
isMobileOnly,
} from "react-device-detect";
import { getProfileMenuItems } from "SRC_DIR/helpers/plugins";
import { isDesktop, isTablet, isMobile } from "react-device-detect";
import { ZendeskAPI } from "@docspace/common/components/Zendesk";
import { LIVE_CHAT_LOCAL_STORAGE_KEY } from "@docspace/common/constants";
import toastr from "@docspace/components/toast/toastr";
@ -37,13 +31,13 @@ const PAYMENTS_URL = combineUrl(
//const VIDEO_GUIDES_URL = "https://onlyoffice.com/";
const SPACES_URL = combineUrl(PROXY_HOMEPAGE_URL, "/management");
class ProfileActionsStore {
authStore = null;
filesStore = null;
peopleStore = null;
treeFoldersStore = null;
selectedFolderStore = null;
pluginStore = null;
isAboutDialogVisible = false;
isDebugDialogVisible = false;
isShowLiveChat = false;
@ -54,13 +48,15 @@ class ProfileActionsStore {
filesStore,
peopleStore,
treeFoldersStore,
selectedFolderStore
selectedFolderStore,
pluginStore
) {
this.authStore = authStore;
this.filesStore = filesStore;
this.peopleStore = peopleStore;
this.treeFoldersStore = treeFoldersStore;
this.selectedFolderStore = selectedFolderStore;
this.pluginStore = pluginStore;
this.isShowLiveChat = this.getStateLiveChat();
@ -224,7 +220,7 @@ class ProfileActionsStore {
? {
key: "user-menu-settings",
icon: CatalogSettingsReactSvgUrl,
label: t("Common:SettingsDocSpace"),
label: t("Common:Settings"),
onClick: () => this.onSettingsClick(settingsUrl),
}
: null;
@ -341,7 +337,7 @@ class ProfileActionsStore {
// onClick: this.onVideoGuidesClick,
// },
hotkeys,
{
!isMobile && {
isSeparator: true,
key: "separator2",
},
@ -359,18 +355,20 @@ class ProfileActionsStore {
label: t("Common:AboutCompanyTitle"),
onClick: this.onAboutClick,
},
{
isSeparator: true,
key: "separator3",
},
{
];
if (
!window.navigator.userAgent.includes("ZoomWebKit") &&
!window.navigator.userAgent.includes("ZoomApps")
) {
actions.push({
key: "user-menu-logout",
icon: LogoutReactSvgUrl,
label: t("Common:LogoutButton"),
onClick: this.onLogoutClick,
isButton: true,
},
];
});
}
if (debugInfo) {
actions.splice(4, 0, {
@ -381,18 +379,14 @@ class ProfileActionsStore {
});
}
if (enablePlugins) {
const pluginActions = getProfileMenuItems();
if (pluginActions) {
pluginActions.forEach((option) => {
if (this.pluginStore.profileMenuItemsList && enablePlugins) {
this.pluginStore.profileMenuItemsList.forEach((option) => {
actions.splice(option.value.position, 0, {
key: option.key,
...option.value,
});
});
}
}
return this.checkEnabledActions(actions);
};

1426
yarn.lock

File diff suppressed because it is too large Load Diff