forked from github/plane
fix: project pages loader (#3461)
This commit is contained in:
parent
f007dcff26
commit
7fd625e0e3
@ -4,13 +4,20 @@ import { observer } from "mobx-react-lite";
|
|||||||
import { PagesListView } from "components/pages/pages-list";
|
import { PagesListView } from "components/pages/pages-list";
|
||||||
// hooks
|
// hooks
|
||||||
// ui
|
// ui
|
||||||
import { Loader } from "@plane/ui";
|
import { Loader, Spinner } from "@plane/ui";
|
||||||
import { useProjectPages } from "hooks/store/use-project-specific-pages";
|
import { useProjectPages } from "hooks/store/use-project-specific-pages";
|
||||||
|
|
||||||
export const ArchivedPagesList: FC = observer(() => {
|
export const ArchivedPagesList: FC = observer(() => {
|
||||||
const projectPageStore = useProjectPages();
|
const projectPageStore = useProjectPages();
|
||||||
const { archivedPageIds } = projectPageStore;
|
const { archivedPageIds, archivedProjectLoader } = projectPageStore;
|
||||||
|
|
||||||
|
if (archivedProjectLoader) {
|
||||||
|
return (
|
||||||
|
<div className="flex items-center justify-center h-full w-full">
|
||||||
|
<Spinner />
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
if (!archivedPageIds)
|
if (!archivedPageIds)
|
||||||
return (
|
return (
|
||||||
<Loader className="space-y-4">
|
<Loader className="space-y-4">
|
||||||
|
@ -11,6 +11,7 @@ import { isThisWeek, isToday, isYesterday } from "date-fns";
|
|||||||
|
|
||||||
export interface IProjectPageStore {
|
export interface IProjectPageStore {
|
||||||
loader: boolean;
|
loader: boolean;
|
||||||
|
archivedProjectLoader: boolean;
|
||||||
projectPageMap: Record<string, Record<string, IPageStore>>;
|
projectPageMap: Record<string, Record<string, IPageStore>>;
|
||||||
projectArchivedPageMap: Record<string, Record<string, IPageStore>>;
|
projectArchivedPageMap: Record<string, Record<string, IPageStore>>;
|
||||||
|
|
||||||
@ -32,6 +33,7 @@ export interface IProjectPageStore {
|
|||||||
|
|
||||||
export class ProjectPageStore implements IProjectPageStore {
|
export class ProjectPageStore implements IProjectPageStore {
|
||||||
loader: boolean = false;
|
loader: boolean = false;
|
||||||
|
archivedProjectLoader: boolean = false;
|
||||||
projectPageMap: Record<string, Record<string, IPageStore>> = {}; // { projectId: [page1, page2] }
|
projectPageMap: Record<string, Record<string, IPageStore>> = {}; // { projectId: [page1, page2] }
|
||||||
projectArchivedPageMap: Record<string, Record<string, IPageStore>> = {}; // { projectId: [page1, page2] }
|
projectArchivedPageMap: Record<string, Record<string, IPageStore>> = {}; // { projectId: [page1, page2] }
|
||||||
|
|
||||||
@ -42,6 +44,7 @@ export class ProjectPageStore implements IProjectPageStore {
|
|||||||
constructor(_rootStore: RootStore) {
|
constructor(_rootStore: RootStore) {
|
||||||
makeObservable(this, {
|
makeObservable(this, {
|
||||||
loader: observable.ref,
|
loader: observable.ref,
|
||||||
|
archivedProjectLoader: observable.ref,
|
||||||
projectPageMap: observable,
|
projectPageMap: observable,
|
||||||
projectArchivedPageMap: observable,
|
projectArchivedPageMap: observable,
|
||||||
|
|
||||||
@ -180,18 +183,18 @@ export class ProjectPageStore implements IProjectPageStore {
|
|||||||
*/
|
*/
|
||||||
fetchArchivedProjectPages = async (workspaceSlug: string, projectId: string) => {
|
fetchArchivedProjectPages = async (workspaceSlug: string, projectId: string) => {
|
||||||
try {
|
try {
|
||||||
this.loader = true;
|
this.archivedProjectLoader = true;
|
||||||
await this.pageService.getArchivedPages(workspaceSlug, projectId).then((response) => {
|
await this.pageService.getArchivedPages(workspaceSlug, projectId).then((response) => {
|
||||||
runInAction(() => {
|
runInAction(() => {
|
||||||
for (const page of response) {
|
for (const page of response) {
|
||||||
set(this.projectArchivedPageMap, [projectId, page.id], new PageStore(page, this.rootStore));
|
set(this.projectArchivedPageMap, [projectId, page.id], new PageStore(page, this.rootStore));
|
||||||
}
|
}
|
||||||
this.loader = false;
|
this.archivedProjectLoader = false;
|
||||||
});
|
});
|
||||||
return response;
|
return response;
|
||||||
});
|
});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
this.loader = false;
|
this.archivedProjectLoader = false;
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user