Merge pull request #1351 from ONLYOFFICE/feature/redirect-after-access-denied

Feature/redirect after access denied
This commit is contained in:
Alexey Safronov 2023-06-01 15:51:46 +04:00 committed by GitHub
commit 73ad86c06c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 246 additions and 195 deletions

View File

@ -37,24 +37,25 @@ import AccountsDialogs from "./Section/AccountsBody/Dialogs";
import MediaViewer from "./MediaViewer";
import SelectionArea from "./SelectionArea";
import { InfoPanelBodyContent, InfoPanelHeaderContent } from "./InfoPanel";
import { RoomSearchArea } from "@docspace/common/constants";
const PureHome = (props) => {
const {
fetchFiles,
fetchRooms,
alreadyFetchingRooms,
setAlreadyFetchingRooms,
//homepage,
setIsLoading,
setFirstLoad,
setToPreviewFile,
playlist,
const {
fetchFiles,
fetchRooms,
alreadyFetchingRooms,
setAlreadyFetchingRooms,
//homepage,
setIsLoading,
setFirstLoad,
setToPreviewFile,
playlist,
getFileInfo,
gallerySelected,
setIsUpdatingRowItem,
setIsPreview,
selectedFolderStore,
getFileInfo,
gallerySelected,
setIsUpdatingRowItem,
setIsPreview,
selectedFolderStore,
t,
startUpload,
setDragging,
@ -178,6 +179,12 @@ const PureHome = (props) => {
if (!filterObj) {
setIsLoading(true);
if (window.location.pathname.indexOf("/rooms/archived") !== -1) {
fetchArchiveDefaultRooms();
return;
}
fetchDefaultRooms();
return;
@ -337,7 +344,27 @@ const PureHome = (props) => {
});
};
const fetchArchiveDefaultRooms = () => {
const { fetchRooms, setIsLoading, setFirstLoad } = this.props;
const filter = RoomsFilter.getDefault();
filter.searchArea = RoomSearchArea.Archive;
fetchRooms(null, filter).finally(() => {
setIsLoading(false);
setFirstLoad(false);
});
};
const onDrop = (files, uploadToFolder) => {
const {
t,
startUpload,
setDragging,
dragging,
uploadEmptyFolders,
disableDrag,
} = this.props;
dragging && setDragging(false);
if (disableDrag) return;
@ -360,18 +387,18 @@ const PureHome = (props) => {
if (qty > 1) {
return (
toastr.success(
<Trans t={t} i18nKey="MoveItems" ns="Files">
{{ qty }} elements has been moved
</Trans>
<Trans t={t} i18nKey="MoveItems" ns="Files">
{{ qty }} elements has been moved
</Trans>
),
refreshFiles()
);
}
return (
toastr.success(
<Trans t={t} i18nKey="MoveItem" ns="Files">
{{ title }} moved
</Trans>
<Trans t={t} i18nKey="MoveItem" ns="Files">
{{ title }} moved
</Trans>
),
refreshFiles()
);
@ -380,18 +407,18 @@ const PureHome = (props) => {
if (qty > 1) {
return (
toastr.success(
<Trans t={t} i18nKey="CopyItems" ns="Files">
{{ qty }} elements copied
</Trans>
<Trans t={t} i18nKey="CopyItems" ns="Files">
{{ qty }} elements copied
</Trans>
),
refreshFiles()
);
}
return (
toastr.success(
<Trans t={t} i18nKey="CopyItem" ns="Files">
{{ title }} copied
</Trans>
<Trans t={t} i18nKey="CopyItem" ns="Files">
{{ title }} copied
</Trans>
),
refreshFiles()
);
@ -607,29 +634,29 @@ const PureHome = (props) => {
sectionProps.secondaryProgressBarIcon = secondaryProgressDataStoreIcon;
sectionProps.showSecondaryButtonAlert = secondaryProgressDataStoreAlert;
return (
<>
return (
<>
{isSettingsPage ? (
<></>
) : isAccountsPage ? (
<AccountsDialogs />
) : (
<>
<DragTooltip />
<SelectionArea />
<DragTooltip />
<SelectionArea />
</>
)}
<MediaViewer />
<Section {...sectionProps}>
{(!isErrorRoomNotAvailable || isAccountsPage || isSettingsPage) && (
<Section.SectionHeader>
{isFrame ? (
showTitle && <SectionHeaderContent />
) : (
<SectionHeaderContent />
)}
</Section.SectionHeader>
)}
<Section.SectionHeader>
{isFrame ? (
showTitle && <SectionHeaderContent />
) : (
<SectionHeaderContent />
)}
</Section.SectionHeader>
)}
{((!isEmptyPage && !isErrorRoomNotAvailable) || isAccountsPage) &&
!isSettingsPage && (
@ -642,25 +669,25 @@ const PureHome = (props) => {
</Section.SectionFilter>
)}
<Section.SectionBody>
<Section.SectionBody>
<Outlet />
</Section.SectionBody>
</Section.SectionBody>
<Section.InfoPanelHeader>
<InfoPanelHeaderContent />
</Section.InfoPanelHeader>
<Section.InfoPanelBody>
<InfoPanelBodyContent />
</Section.InfoPanelBody>
<Section.InfoPanelHeader>
<InfoPanelHeaderContent />
</Section.InfoPanelHeader>
<Section.InfoPanelBody>
<InfoPanelBodyContent />
</Section.InfoPanelBody>
{withPaging && !isSettingsPage && (
<Section.SectionPaging>
<SectionPagingContent tReady={tReady} />
</Section.SectionPaging>
)}
</Section>
</>
);
<Section.SectionPaging>
<SectionPagingContent tReady={tReady} />
</Section.SectionPaging>
)}
</Section>
</>
);
};
const Home = withTranslation(["Files", "People"])(PureHome);

View File

@ -43,165 +43,173 @@ const ClientRoutes = [
element: <Home />,
children: [
{
index: true,
element: (
<PrivateRoute>
<Navigate to="/rooms/shared" replace />
</PrivateRoute>
),
},
{
path: "rooms",
element: (
<PrivateRoute>
<Navigate to="/rooms/shared" replace />
</PrivateRoute>
),
},
{
path: "rooms/personal",
element: (
<PrivateRoute restricted withManager withCollaborator>
index: true,
element: (
<PrivateRoute>
<Navigate to="/rooms/shared" replace />
</PrivateRoute>
),
},
{
path: "rooms",
element: (
<PrivateRoute>
<Navigate to="/rooms/shared" replace />
</PrivateRoute>
),
},
{
path: "archived",
element: (
<PrivateRoute>
<Navigate to="/rooms/archived" replace />
</PrivateRoute>
),
},
{
path: "rooms/personal",
element: (
<PrivateRoute restricted withManager withCollaborator>
<FilesView />
</PrivateRoute>
),
},
{
path: "rooms/personal/filter",
element: (
<PrivateRoute restricted withManager withCollaborator>
</PrivateRoute>
),
},
{
path: "rooms/personal/filter",
element: (
<PrivateRoute restricted withManager withCollaborator>
<FilesView />
</PrivateRoute>
),
},
{
path: "files/trash",
element: (
<PrivateRoute restricted withManager withCollaborator>
</PrivateRoute>
),
},
{
path: "files/trash",
element: (
<PrivateRoute restricted withManager withCollaborator>
<FilesView />
</PrivateRoute>
),
},
{
path: "files/trash/filter",
element: (
<PrivateRoute restricted withManager withCollaborator>
</PrivateRoute>
),
},
{
path: "files/trash/filter",
element: (
<PrivateRoute restricted withManager withCollaborator>
<FilesView />
</PrivateRoute>
),
},
{
path: "rooms/shared",
element: (
<PrivateRoute>
</PrivateRoute>
),
},
{
path: "rooms/shared",
element: (
<PrivateRoute>
<FilesView />
</PrivateRoute>
),
},
{
path: "rooms/shared/filter",
element: (
<PrivateRoute>
</PrivateRoute>
),
},
{
path: "rooms/shared/filter",
element: (
<PrivateRoute>
<FilesView />
</PrivateRoute>
),
},
{
path: "rooms/shared/:room",
element: (
<PrivateRoute>
</PrivateRoute>
),
},
{
path: "rooms/shared/:room",
element: (
<PrivateRoute>
<FilesView />
</PrivateRoute>
),
},
{
path: "rooms/shared/:room/filter",
element: (
<PrivateRoute>
</PrivateRoute>
),
},
{
path: "rooms/shared/:room/filter",
element: (
<PrivateRoute>
<FilesView />
</PrivateRoute>
),
},
{
path: "rooms/archived",
element: (
<PrivateRoute>
</PrivateRoute>
),
},
{
path: "rooms/archived",
element: (
<PrivateRoute>
<FilesView />
</PrivateRoute>
),
},
{
path: "rooms/archived/filter",
element: (
<PrivateRoute>
</PrivateRoute>
),
},
{
path: "rooms/archived/filter",
element: (
<PrivateRoute>
<FilesView />
</PrivateRoute>
),
},
{
path: "rooms/archived/:room",
element: (
<PrivateRoute>
</PrivateRoute>
),
},
{
path: "rooms/archived/:room",
element: (
<PrivateRoute>
<FilesView />
</PrivateRoute>
),
},
{
path: "rooms/archived/:room/filter",
element: (
<PrivateRoute>
</PrivateRoute>
),
},
{
path: "rooms/archived/:room/filter",
element: (
<PrivateRoute>
<FilesView />
</PrivateRoute>
),
},
{
path: "products/files",
element: (
<PrivateRoute>
</PrivateRoute>
),
},
{
path: "products/files",
element: (
<PrivateRoute>
<FilesView />
</PrivateRoute>
),
},
{
path: "accounts",
element: (
<PrivateRoute restricted withManager>
<Navigate to="/accounts/filter" replace />
</PrivateRoute>
),
},
{
path: "accounts/filter",
element: (
<PrivateRoute restricted withManager>
</PrivateRoute>
),
},
{
path: "accounts",
element: (
<PrivateRoute restricted withManager>
<Navigate to="/accounts/filter" replace />
</PrivateRoute>
),
},
{
path: "accounts/filter",
element: (
<PrivateRoute restricted withManager>
<AccountsView />
</PrivateRoute>
),
},
{
</PrivateRoute>
),
},
{
path: "settings",
element: (
element: (
<PrivateRoute withCollaborator restricted>
<Navigate to="/settings/common" replace />
</PrivateRoute>
),
},
{
</PrivateRoute>
),
},
{
path: "settings/common",
element: (
element: (
<PrivateRoute withCollaborator restricted>
<SettingsView />
</PrivateRoute>
),
},
{
</PrivateRoute>
),
},
{
path: "settings/admin",
element: (
<PrivateRoute withCollaborator restricted>
element: (
<PrivateRoute withCollaborator restricted>
<SettingsView />
</PrivateRoute>
),
},
</PrivateRoute>
),
},
],
},

View File

@ -220,9 +220,9 @@ class ContextOptionsStore {
};
finalizeVersion = (id) => {
this.filesActionsStore
.finalizeVersionAction(id)
.catch((err) => toastr.error(err));
this.filesActionsStore.finalizeVersionAction(id).catch((err) => {
toastr.error(err);
});
};
onClickFavorite = (e, id, t) => {
@ -253,7 +253,9 @@ class ContextOptionsStore {
: toastr.success(t("Translations:FileLocked"))
)
.then(() => setInfoPanelSelection({ ...item, locked: !locked }))
.catch((err) => toastr.error(err));
.catch((err) => {
toastr.error(err);
});
};
onClickLinkForPortal = (item, t) => {

View File

@ -150,6 +150,20 @@ class AxiosClient {
if (!window.location.pathname.includes("payments")) {
// window.location.href = this.paymentsURL;
}
break;
case 403:
const pathname = window.location.pathname;
const isArchived = pathname.indexOf("/rooms/archived") !== -1;
const isRooms =
pathname.indexOf("/rooms/shared") !== -1 || isArchived;
if (!isRooms) return;
setTimeout(() => {
window.DocSpace.navigate(isArchived ? "/archived" : "/");
}, 1000);
break;
default:
break;