diff --git a/package.json b/package.json index 48b963b88a..46822adf48 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "docspace", - "version": "2.6.0", + "version": "2.6.1", "private": true, "workspaces": { "packages": [ diff --git a/packages/client/package.json b/packages/client/package.json index dfd93519cb..e68d87aa19 100644 --- a/packages/client/package.json +++ b/packages/client/package.json @@ -1,6 +1,6 @@ { "name": "@docspace/client", - "version": "2.6.0", + "version": "2.6.1", "private": true, "homepage": "", "scripts": { diff --git a/packages/client/src/components/panels/InvitePanel/index.js b/packages/client/src/components/panels/InvitePanel/index.js index 8799b4de81..7633df58a1 100644 --- a/packages/client/src/components/panels/InvitePanel/index.js +++ b/packages/client/src/components/panels/InvitePanel/index.js @@ -34,7 +34,7 @@ import React, { import { observer, inject } from "mobx-react"; import { withTranslation } from "react-i18next"; -import { DeviceType } from "@docspace/shared/enums"; +import { DeviceType, EmployeeType } from "@docspace/shared/enums"; import { LOADER_TIMEOUT } from "@docspace/shared/constants"; import { Backdrop } from "@docspace/shared/components/backdrop"; @@ -72,11 +72,6 @@ const InvitePanel = ({ visible, setRoomSecurity, getRoomSecurityInfo, - getPortalInviteLinks, - userLink, - guestLink, - adminLink, - collaboratorLink, defaultAccess, inviteUsers, setInfoPanelIsMobileHidden, @@ -88,9 +83,7 @@ const InvitePanel = ({ currentDeviceType, }) => { const [invitePanelIsLoding, setInvitePanelIsLoading] = useState( - () => - ((!userLink || !guestLink || !collaboratorLink) && !adminLink) || - roomId !== -1, + roomId !== -1, ); const [selectedRoom, setSelectedRoom] = useState(null); const [hasErrors, setHasErrors] = useState(false); @@ -117,6 +110,33 @@ const InvitePanel = ({ setExternalLinksVisible(visible); }; + const accessModel = [ + { + id: "user", + title: "User", + shareLink: "", + access: EmployeeType.User, + }, + { + id: "guest", + title: "Guest", + shareLink: "", + access: EmployeeType.Guest, + }, + { + id: "admin", + title: "Admin", + shareLink: "", + access: EmployeeType.Admin, + }, + { + id: "collaborator", + title: "Collaborator", + shareLink: "", + access: EmployeeType.Collaborator, + }, + ]; + const selectRoom = () => { const room = folders.find((folder) => folder.id === roomId); @@ -167,40 +187,7 @@ const InvitePanel = ({ useEffect(() => { if (roomId === -1) { - if ((!userLink || !guestLink || !collaboratorLink) && !adminLink) { - setInvitePanelIsLoading(true); - getPortalInviteLinks().finally(() => { - disableInvitePanelLoader(); - }); - } - - setShareLinks([ - { - id: "user", - title: "User", - shareLink: userLink, - access: 1, - }, - { - id: "guest", - title: "Guest", - shareLink: guestLink, - access: 2, - }, - { - id: "admin", - title: "Admin", - shareLink: adminLink, - access: 3, - }, - { - id: "collaborator", - title: "Collaborator", - shareLink: collaboratorLink, - access: 4, - }, - ]); - + setShareLinks(accessModel); return; } @@ -208,7 +195,7 @@ const InvitePanel = ({ Promise.all([selectRoom(), getInfo()]).finally(() => { disableInvitePanelLoader(false); }); - }, [roomId, userLink, guestLink, adminLink, collaboratorLink]); + }, [roomId]); useEffect(() => { const hasErrors = inviteItems.some((item) => !!item.errors?.length); @@ -487,14 +474,6 @@ export default inject( isRoomMembersPanelOpen, } = infoPanelStore; - const { - getPortalInviteLinks, - userLink, - guestLink, - adminLink, - collaboratorLink, - } = peopleStore.inviteLinksStore; - const { inviteItems, invitePanelOptions, @@ -520,11 +499,6 @@ export default inject( visible: invitePanelOptions.visible, defaultAccess: invitePanelOptions.defaultAccess, getFolderInfo, - getPortalInviteLinks, - userLink, - guestLink, - adminLink, - collaboratorLink, inviteUsers, setInfoPanelIsMobileHidden, updateInfoPanelMembers, diff --git a/packages/client/src/components/panels/InvitePanel/sub-components/ExternalLinks.js b/packages/client/src/components/panels/InvitePanel/sub-components/ExternalLinks.js index ddeb656146..3157df9554 100644 --- a/packages/client/src/components/panels/InvitePanel/sub-components/ExternalLinks.js +++ b/packages/client/src/components/panels/InvitePanel/sub-components/ExternalLinks.js @@ -64,20 +64,26 @@ const ExternalLinks = ({ setActiveLink, activeLink, isMobileView, + getPortalInviteLink, }) => { const [actionLinksVisible, setActionLinksVisible] = useState(false); const inputsRef = useRef(); - const toggleLinks = () => { + const toggleLinks = async (e) => { if (roomId === -1) { - const link = shareLinks.find((l) => l.access === +defaultAccess); + if (e?.target?.checked) { + const link = shareLinks.find((l) => l.access === defaultAccess); - setActiveLink(link); - copyLink(link.shareLink); + link.shareLink = await getPortalInviteLink(defaultAccess); + + setActiveLink(link); + copyLink(link.shareLink); + } } else { !externalLinksVisible ? editLink() : disableLink(); } + onChangeExternalLinksVisible(!externalLinksVisible); }; @@ -106,11 +112,13 @@ const ExternalLinks = ({ setActiveLink(activeLink); }; - const onSelectAccess = (access) => { + const onSelectAccess = async (access) => { let link = null; if (roomId === -1) { link = shareLinks.find((l) => l.access === access.access); + link.shareLink = await getPortalInviteLink(access.access); + setActiveLink(link); } else { setInvitationLinks(roomId, "Invite", +access.access, shareLinks[0].id); @@ -254,17 +262,21 @@ const ExternalLinks = ({ ); }; -export default inject(({ userStore, dialogsStore, filesStore }) => { - const { isOwner } = userStore.user; - const { invitePanelOptions } = dialogsStore; - const { setInvitationLinks } = filesStore; - const { roomId, hideSelector, defaultAccess } = invitePanelOptions; +export default inject( + ({ userStore, dialogsStore, filesStore, peopleStore }) => { + const { isOwner } = userStore.user; + const { invitePanelOptions } = dialogsStore; + const { setInvitationLinks } = filesStore; + const { roomId, hideSelector, defaultAccess } = invitePanelOptions; + const { getPortalInviteLink } = peopleStore.inviteLinksStore; - return { - setInvitationLinks, - roomId, - hideSelector, - defaultAccess, - isOwner, - }; -})(observer(ExternalLinks)); + return { + setInvitationLinks, + roomId, + hideSelector, + defaultAccess, + isOwner, + getPortalInviteLink, + }; + }, +)(observer(ExternalLinks)); diff --git a/packages/client/src/components/panels/UploadPanel/index.js b/packages/client/src/components/panels/UploadPanel/index.js index c1544e6c7f..dc0ee3c326 100644 --- a/packages/client/src/components/panels/UploadPanel/index.js +++ b/packages/client/src/components/panels/UploadPanel/index.js @@ -24,7 +24,7 @@ // content are licensed under the terms of the Creative Commons Attribution-ShareAlike 4.0 // International. See the License terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode -import ClearActiveReactSvgUrl from "PUBLIC_DIR/images/clear.active.react.svg?url"; +import ClearReactSvgUrl from "PUBLIC_DIR/images/clear.react.svg?url"; import ButtonCancelReactSvgUrl from "PUBLIC_DIR/images/button.cancel.react.svg?url"; import React from "react"; @@ -136,8 +136,8 @@ class UploadPanelComponent extends React.Component {
{uploaded && converted ? ( diff --git a/packages/client/src/pages/Home/Section/Header/index.js b/packages/client/src/pages/Home/Section/Header/index.js index 43bb16753b..8ec84ec116 100644 --- a/packages/client/src/pages/Home/Section/Header/index.js +++ b/packages/client/src/pages/Home/Section/Header/index.js @@ -259,6 +259,8 @@ const SectionHeaderContent = (props) => { }; const onContextOptionsClick = () => { + if (isInsideGroup) return; + setBufferSelection(selectedFolder); }; diff --git a/packages/client/src/store/InviteLinksStore.js b/packages/client/src/store/InviteLinksStore.js index 550ffbc6fa..ad26f54fe0 100644 --- a/packages/client/src/store/InviteLinksStore.js +++ b/packages/client/src/store/InviteLinksStore.js @@ -27,9 +27,12 @@ import { makeAutoObservable, runInAction } from "mobx"; import { getInvitationLinks, + getInvitationLink, getShortenedLink, } from "@docspace/shared/api/portal"; +import { EmployeeType } from "@docspace/shared/enums"; + class InviteLinksStore { peopleStore = null; userLink = null; @@ -59,9 +62,7 @@ class InviteLinksStore { }; getPortalInviteLinks = async () => { - const isViewerAdmin = !this.peopleStore.authStore.isVisitor; - - if (!isViewerAdmin) return Promise.resolve(); + if (this.peopleStore.authStore.isVisitor) return Promise.resolve(); const links = await getInvitationLinks(); @@ -73,6 +74,31 @@ class InviteLinksStore { }); }; + getPortalInviteLink = async (type) => { + if (this.peopleStore.authStore.isVisitor) return Promise.resolve(); + + const link = await getInvitationLink(type); + + runInAction(() => { + switch (type) { + case EmployeeType.User: + this.setUserLink(link); + break; + case EmployeeType.Guest: + this.setGuestLink(link); + break; + case EmployeeType.Admin: + this.setAdminLink(link); + break; + case EmployeeType.Collaborator: + this.setCollaboratorLink(link); + break; + } + }); + + return link; + }; + getShortenedLink = async (link, forUser = false) => { if (forUser) { const userLink = await getShortenedLink(link); diff --git a/packages/doceditor/package.json b/packages/doceditor/package.json index 6f3ab93da3..42872f3c59 100644 --- a/packages/doceditor/package.json +++ b/packages/doceditor/package.json @@ -1,6 +1,6 @@ { "name": "@docspace/doceditor", - "version": "2.6.0", + "version": "2.6.1", "private": true, "scripts": { "build": "node ./scripts/buildTranslations.js && next build", diff --git a/packages/doceditor/src/utils/actions.ts b/packages/doceditor/src/utils/actions.ts index 5d988668b7..7537bbe23d 100644 --- a/packages/doceditor/src/utils/actions.ts +++ b/packages/doceditor/src/utils/actions.ts @@ -393,28 +393,28 @@ export const checkIsAuthenticated = async () => { return isAuth.response as boolean; }; -export async function checkFillFromDraft( - templateFileId: number, - share?: string, -) { - const [checkFillFormDraft] = createRequest( - [`/files/masterform/${templateFileId}/checkfillformdraft`], - [ - share ? ["Request-Token", share] : ["", ""], - ["Content-Type", "application/json;charset=utf-8"], - ], - "POST", - JSON.stringify({ fileId: templateFileId }), - ); +// export async function checkFillFromDraft( +// templateFileId: number, +// share?: string, +// ) { +// const [checkFillFormDraft] = createRequest( +// [`/files/masterform/${templateFileId}/checkfillformdraft`], +// [ +// share ? ["Request-Token", share] : ["", ""], +// ["Content-Type", "application/json;charset=utf-8"], +// ], +// "POST", +// JSON.stringify({ fileId: templateFileId }), +// ); - const response = await fetch(checkFillFormDraft); +// const response = await fetch(checkFillFormDraft); - if (!response.ok) return null; +// if (!response.ok) return null; - const { response: formUrl } = await response.json(); +// const { response: formUrl } = await response.json(); - return formUrl as string; -} +// return formUrl as string; +// } export async function openEdit( fileId: number | string, diff --git a/packages/login/package.json b/packages/login/package.json index 25b790b2df..7bc328fdd9 100644 --- a/packages/login/package.json +++ b/packages/login/package.json @@ -1,6 +1,6 @@ { "name": "@docspace/login", - "version": "2.6.0", + "version": "2.6.1", "private": true, "scripts": { "build": "node ./scripts/buildTranslations.js && next build", diff --git a/packages/management/package.json b/packages/management/package.json index 125450cc67..9bad9a5743 100644 --- a/packages/management/package.json +++ b/packages/management/package.json @@ -1,6 +1,6 @@ { "name": "@docspace/management", - "version": "2.6.0", + "version": "2.6.1", "private": true, "homepage": "/management", "scripts": { diff --git a/packages/shared/api/files/index.ts b/packages/shared/api/files/index.ts index 15008c9041..3bbcd93102 100644 --- a/packages/shared/api/files/index.ts +++ b/packages/shared/api/files/index.ts @@ -1180,15 +1180,15 @@ export async function getPresignedUri(fileId: number | string) { return res; } -export async function checkFillFormDraft(fileId: number | string) { - const res = (await request({ - method: "post", - url: `files/masterform/${fileId}/checkfillformdraft`, - data: { fileId }, - })) as string; +// export async function checkFillFormDraft(fileId: number | string) { +// const res = (await request({ +// method: "post", +// url: `files/masterform/${fileId}/checkfillformdraft`, +// data: { fileId }, +// })) as string; - return res; -} +// return res; +// } export async function fileCopyAs( fileId: number, diff --git a/packages/shared/api/portal/index.ts b/packages/shared/api/portal/index.ts index 24857846c9..9e950568ef 100644 --- a/packages/shared/api/portal/index.ts +++ b/packages/shared/api/portal/index.ts @@ -35,7 +35,7 @@ import { TTenantExtra, } from "./types"; -export function getShortenedLink(link) { +export function getShortenedLink(link: string) { return request({ method: "put", url: "/portal/getshortenlink", @@ -43,13 +43,13 @@ export function getShortenedLink(link) { }); } -export function getInvitationLink(type) { - return request({ +export async function getInvitationLink(type: EmployeeType) { + const res = await request({ method: "get", url: `/portal/users/invite/${type}`, - }).then((link) => { - return Promise.resolve(link); }); + + return res; } export function getInvitationLinks() { diff --git a/packages/shared/package.json b/packages/shared/package.json index a4ac43980b..f517c9112f 100644 --- a/packages/shared/package.json +++ b/packages/shared/package.json @@ -1,6 +1,6 @@ { "name": "@docspace/shared", - "version": "2.6.0", + "version": "2.6.1", "private": true, "scripts": { "build": "echo 'skip it'", diff --git a/public/scripts/browserDetector.js b/public/scripts/browserDetector.js index 8d38b36613..13d9d84a0a 100644 --- a/public/scripts/browserDetector.js +++ b/public/scripts/browserDetector.js @@ -34,7 +34,7 @@ IE: 11, Edge: 109, Opera: 90, - Safari: 16, + Safari: 15, SafariMobile: 16, AscDesktopEditor: 6, SamsungBrowser: 4, @@ -50,7 +50,7 @@ let temp = []; let match = agent.match( - /(opera|chrome|safari|firefox|msie|trident(?=\/))\/?\s*(\d+)/i, + /(opera|chrome|safari|firefox|msie|trident(?=\/))\/?\s*(\d+)/i ) || []; if (/trident/i.test(match[1])) { @@ -60,7 +60,7 @@ if (match[1] === "Chrome") { temp = agent.match( - /\b(OPR|Edge|AscDesktopEditor|SamsungBrowser|UCBrowser)\/(\d+.\d)/, + /\b(OPR|Edge|AscDesktopEditor|SamsungBrowser|UCBrowser)\/(\d+.\d)/ ); const userOS =