Web: Added redirect with navigate. Added redirect to archives.

This commit is contained in:
Tatiana Lopaeva 2023-04-20 17:59:15 +03:00
parent d53d615c5b
commit c100b87933
3 changed files with 33 additions and 3 deletions

View File

@ -94,6 +94,15 @@ const FilesSection = React.memo(({ withMainButton }) => {
}
/>
<Route
path="/archived"
element={
<PrivateRoute location={location}>
<Navigate to="/rooms/archived" replace />
</PrivateRoute>
}
/>
<Route
path="/rooms"
element={

View File

@ -33,6 +33,7 @@ import RoomsFilter from "@docspace/common/api/rooms/filter";
import { getCategoryType } from "SRC_DIR/helpers/utils";
import { CategoryType } from "SRC_DIR/helpers/constants";
import { InfoPanelBodyContent, InfoPanelHeaderContent } from "./InfoPanel";
import { RoomSearchArea } from "@docspace/common/constants";
class PureHome extends React.Component {
componentDidMount() {
@ -100,6 +101,12 @@ class PureHome extends React.Component {
if (!filterObj) {
setIsLoading(true);
if (window.location.pathname.indexOf("/rooms/archived") !== -1) {
this.fetchArchiveDefaultRooms();
return;
}
this.fetchDefaultRooms();
return;
@ -258,6 +265,18 @@ class PureHome extends React.Component {
});
};
fetchArchiveDefaultRooms = () => {
const { fetchRooms, setIsLoading, setFirstLoad } = this.props;
const filter = RoomsFilter.getDefault();
filter.searchArea = RoomSearchArea.Archive;
fetchRooms(null, filter).finally(() => {
setIsLoading(false);
setFirstLoad(false);
});
};
onDrop = (files, uploadToFolder) => {
const {
t,

View File

@ -1,6 +1,7 @@
import axios from "axios";
import combineUrl from "./combineUrl";
import defaultConfig from "PUBLIC_DIR/scripts/config.json";
import history from "@docspace/common/history";
let { api: apiConf, proxy: proxyConf } = defaultConfig;
let { orign: apiOrigin, prefix: apiPrefix, timeout: apiTimeout } = apiConf;
@ -152,14 +153,15 @@ class AxiosClient {
break;
case 403:
const pathname = window.location.pathname;
const isArchived = pathname.indexOf("/rooms/archived") !== -1;
const isRooms =
pathname.indexOf("/rooms/shared") !== -1 ||
pathname.indexOf("/rooms/archived") !== -1;
pathname.indexOf("/rooms/shared") !== -1 || isArchived;
if (!isRooms) return;
setTimeout(() => {
window.location.replace("/");
history.navigate(isArchived ? "/archived" : "/");
}, 1000);
break;