Merge pull request #206 from ONLYOFFICE/bugfix/sdk-fixes

Bugfix/sdk fixes
This commit is contained in:
Alexey Safronov 2024-01-26 19:23:01 +04:00 committed by GitHub
commit 0d4d067bb9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with 36 additions and 7 deletions

View File

@ -424,6 +424,8 @@ const ShellWrapper = inject(({ auth, backup, clientLoadingStore }) => {
whiteLabelLogoUrls,
standalone,
currentDeviceType,
isFrame,
frameConfig,
} = settingsStore;
const isBase = settingsStore.theme.isBase;
@ -462,7 +464,7 @@ const ShellWrapper = inject(({ auth, backup, clientLoadingStore }) => {
setTheme,
roomsMode,
setSnackbarExist,
userTheme: userTheme,
userTheme: isFrame ? frameConfig?.theme : userTheme,
userId: auth?.userStore?.user?.id,
whiteLabelLogoUrls,
standalone,

View File

@ -36,6 +36,7 @@ export type BreadCrumb = {
label: string;
id: number | string;
isRoom: boolean;
shared: boolean;
};
type setItems = (value: Item[] | null) => Item[];
@ -198,6 +199,8 @@ export type FilesSelectorProps = {
id: string | number;
title: string;
path?: string[];
fileExst?: string;
inPublic?: boolean;
},
breadCrumbs: BreadCrumb[]
) => void;

View File

@ -127,6 +127,7 @@ const FilesSelector = ({
title: string;
path?: string[];
fileExst?: string;
inPublic?: boolean;
} | null>(null);
const [total, setTotal] = React.useState<number>(0);
@ -214,6 +215,9 @@ const FilesSelector = ({
});
const onSelectAction = (item: Item) => {
const inPublic =
breadCrumbs.findIndex((f: any) => f.roomType === RoomsType.PublicRoom) >
-1;
if (item.isFolder) {
setIsFirstLoad(true);
setItems(null);
@ -243,6 +247,7 @@ const FilesSelector = ({
id: item.id,
title: item.title,
fileExst: item.fileExst,
inPublic: inPublic,
});
}
};

View File

@ -28,6 +28,7 @@ const Sdk = ({
updateProfileCulture,
getRoomsIcon,
fetchExternalLinks,
getFilePrimaryLink,
}) => {
useEffect(() => {
window.addEventListener("message", handleMessage, false);
@ -135,10 +136,11 @@ const Sdk = ({
const links = await fetchExternalLinks(data[0].id);
const requestTokens = links.map((link) => {
const { id, title, requestToken } = link.sharedTo;
const { id, title, requestToken, primary } = link.sharedTo;
return {
id,
primary,
title,
requestToken,
};
@ -153,9 +155,17 @@ const Sdk = ({
);
const onSelectFile = useCallback(
(data) => {
async (data) => {
data.icon = getIcon(64, data.fileExst);
if (data.inPublic) {
const link = await getFilePrimaryLink(data.id);
const { id, title, requestToken, primary } = link.sharedTo;
data.requestTokens = [{ id, primary, title, requestToken }];
}
frameCallEvent({ event: "onSelectCallback", data });
},
[frameCallEvent]
@ -208,7 +218,7 @@ const Sdk = ({
};
export default inject(
({ auth, settingsStore, peopleStore, publicRoomStore }) => {
({ auth, settingsStore, peopleStore, publicRoomStore, filesStore }) => {
const { login, logout, userStore } = auth;
const { theme, setFrameConfig, frameConfig, getSettings, isLoaded } =
auth.settingsStore;
@ -216,6 +226,7 @@ export default inject(
const { updateProfileCulture } = peopleStore.targetUserStore;
const { getIcon, getRoomsIcon } = settingsStore;
const { fetchExternalLinks } = publicRoomStore;
const { getFilePrimaryLink } = filesStore;
return {
theme,
@ -231,6 +242,7 @@ export default inject(
updateProfileCulture,
user,
fetchExternalLinks,
getFilePrimaryLink,
};
}
)(observer(Sdk));

View File

@ -3965,6 +3965,10 @@ class FilesStore {
return link;
};
getFilePrimaryLink = async (fileId) => {
return await api.files.getFileLink(fileId);
};
setRoomShared = (roomId, shared) => {
const roomIndex = this.folders.findIndex((r) => r.id === roomId);

View File

@ -8,7 +8,7 @@ import UserStore from "./UserStore";
import TfaStore from "./TfaStore";
import InfoPanelStore from "./InfoPanelStore";
import { logout as logoutDesktop, desktopConstants } from "../desktop";
import { isAdmin, setCookie } from "../utils";
import { isAdmin, setCookie, frameCallEvent } from "../utils";
import { getCookie } from "@docspace/components/utils/cookie";
import CurrentQuotasStore from "./CurrentQuotaStore";
import CurrentTariffStatusStore from "./CurrentTariffStatusStore";
@ -332,10 +332,12 @@ class AuthStore {
this.isLogout = true;
const { isDesktopClient: isDesktop } = this.settingsStore;
const { isDesktopClient: isDesktop, isFrame } = this.settingsStore;
isDesktop && logoutDesktop();
isFrame && frameCallEvent({ event: "onSignOut" });
if (ssoLogoutUrl) return ssoLogoutUrl;
if (!reset) return;

View File

@ -933,7 +933,6 @@ class SettingsStore {
});
if (!!frameConfig) {
this.setTheme(frameConfig?.theme);
frameCallEvent({
event: "onAppReady",
data: { frameId: frameConfig.frameId },

View File

@ -129,6 +129,7 @@ const Selector = ({
avatar: item.avatar,
icon: item.icon,
label: item.label,
shared: item.shared,
});
if (isMultiSelect) {

View File

@ -52,6 +52,7 @@
onAppError: (e) => console.log("onAppError", e),
onEditorCloseCallback: null,
onAuthSuccess: null,
onSignOut: null,
},
};