mirror of
https://github.com/makeplane/plane
synced 2024-06-14 14:31:34 +00:00
chore: empty state action button validation (#3094)
This commit is contained in:
parent
b4f51cb5af
commit
2605b938f0
@ -4,6 +4,8 @@ import { PlusIcon } from "lucide-react";
|
|||||||
import { useMobxStore } from "lib/mobx/store-provider";
|
import { useMobxStore } from "lib/mobx/store-provider";
|
||||||
// components
|
// components
|
||||||
import { NewEmptyState } from "components/common/new-empty-state";
|
import { NewEmptyState } from "components/common/new-empty-state";
|
||||||
|
// constants
|
||||||
|
import { EUserWorkspaceRoles } from "constants/workspace";
|
||||||
// assets
|
// assets
|
||||||
import emptyIssue from "public/empty-state/empty_issues.webp";
|
import emptyIssue from "public/empty-state/empty_issues.webp";
|
||||||
import { EProjectStore } from "store/command-palette.store";
|
import { EProjectStore } from "store/command-palette.store";
|
||||||
@ -12,8 +14,11 @@ export const ProjectEmptyState: React.FC = observer(() => {
|
|||||||
const {
|
const {
|
||||||
commandPalette: commandPaletteStore,
|
commandPalette: commandPaletteStore,
|
||||||
trackEvent: { setTrackElement },
|
trackEvent: { setTrackElement },
|
||||||
|
user: { currentProjectRole },
|
||||||
} = useMobxStore();
|
} = useMobxStore();
|
||||||
|
|
||||||
|
const isEditingAllowed = !!currentProjectRole && currentProjectRole >= EUserWorkspaceRoles.MEMBER;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="grid h-full w-full place-items-center">
|
<div className="grid h-full w-full place-items-center">
|
||||||
<NewEmptyState
|
<NewEmptyState
|
||||||
@ -34,6 +39,7 @@ export const ProjectEmptyState: React.FC = observer(() => {
|
|||||||
commandPaletteStore.toggleCreateIssueModal(true, EProjectStore.PROJECT);
|
commandPaletteStore.toggleCreateIssueModal(true, EProjectStore.PROJECT);
|
||||||
},
|
},
|
||||||
}}
|
}}
|
||||||
|
disabled={!isEditingAllowed}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
@ -9,6 +9,8 @@ import useLocalStorage from "hooks/use-local-storage";
|
|||||||
import { ModuleCardItem, ModuleListItem, ModulePeekOverview, ModulesListGanttChartView } from "components/modules";
|
import { ModuleCardItem, ModuleListItem, ModulePeekOverview, ModulesListGanttChartView } from "components/modules";
|
||||||
// ui
|
// ui
|
||||||
import { Loader } from "@plane/ui";
|
import { Loader } from "@plane/ui";
|
||||||
|
// constants
|
||||||
|
import { EUserWorkspaceRoles } from "constants/workspace";
|
||||||
// assets
|
// assets
|
||||||
import emptyModule from "public/empty-state/empty_modules.webp";
|
import emptyModule from "public/empty-state/empty_modules.webp";
|
||||||
import { NewEmptyState } from "components/common/new-empty-state";
|
import { NewEmptyState } from "components/common/new-empty-state";
|
||||||
@ -17,12 +19,18 @@ export const ModulesListView: React.FC = observer(() => {
|
|||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const { workspaceSlug, projectId, peekModule } = router.query;
|
const { workspaceSlug, projectId, peekModule } = router.query;
|
||||||
|
|
||||||
const { module: moduleStore, commandPalette: commandPaletteStore } = useMobxStore();
|
const {
|
||||||
|
module: moduleStore,
|
||||||
|
commandPalette: commandPaletteStore,
|
||||||
|
user: { currentProjectRole },
|
||||||
|
} = useMobxStore();
|
||||||
|
|
||||||
const { storedValue: modulesView } = useLocalStorage("modules_view", "grid");
|
const { storedValue: modulesView } = useLocalStorage("modules_view", "grid");
|
||||||
|
|
||||||
const modulesList = moduleStore.projectModules;
|
const modulesList = moduleStore.projectModules;
|
||||||
|
|
||||||
|
const isEditingAllowed = !!currentProjectRole && currentProjectRole >= EUserWorkspaceRoles.MEMBER;
|
||||||
|
|
||||||
if (!modulesList)
|
if (!modulesList)
|
||||||
return (
|
return (
|
||||||
<Loader className="grid grid-cols-3 gap-4 p-8">
|
<Loader className="grid grid-cols-3 gap-4 p-8">
|
||||||
@ -93,6 +101,7 @@ export const ModulesListView: React.FC = observer(() => {
|
|||||||
text: "Build your first module",
|
text: "Build your first module",
|
||||||
onClick: () => commandPaletteStore.toggleCreateModuleModal(true),
|
onClick: () => commandPaletteStore.toggleCreateModuleModal(true),
|
||||||
}}
|
}}
|
||||||
|
disabled={!isEditingAllowed}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</>
|
</>
|
||||||
|
@ -8,6 +8,8 @@ import { useMobxStore } from "lib/mobx/store-provider";
|
|||||||
import { TourRoot } from "components/onboarding";
|
import { TourRoot } from "components/onboarding";
|
||||||
import { UserGreetingsView } from "components/user";
|
import { UserGreetingsView } from "components/user";
|
||||||
import { CompletedIssuesGraph, IssuesList, IssuesPieChart, IssuesStats } from "components/workspace";
|
import { CompletedIssuesGraph, IssuesList, IssuesPieChart, IssuesStats } from "components/workspace";
|
||||||
|
// constants
|
||||||
|
import { EUserWorkspaceRoles } from "constants/workspace";
|
||||||
// images
|
// images
|
||||||
import { NewEmptyState } from "components/common/new-empty-state";
|
import { NewEmptyState } from "components/common/new-empty-state";
|
||||||
import emptyProject from "public/empty-state/dashboard_empty_project.webp";
|
import emptyProject from "public/empty-state/dashboard_empty_project.webp";
|
||||||
@ -36,6 +38,8 @@ export const WorkspaceDashboardView = observer(() => {
|
|||||||
workspaceSlug ? () => userStore.fetchUserDashboardInfo(workspaceSlug.toString(), month) : null
|
workspaceSlug ? () => userStore.fetchUserDashboardInfo(workspaceSlug.toString(), month) : null
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const isEditingAllowed = !!userStore.currentProjectRole && userStore.currentProjectRole >= EUserWorkspaceRoles.MEMBER;
|
||||||
|
|
||||||
const handleTourCompleted = () => {
|
const handleTourCompleted = () => {
|
||||||
userStore
|
userStore
|
||||||
.updateTourCompleted()
|
.updateTourCompleted()
|
||||||
@ -96,6 +100,7 @@ export const WorkspaceDashboardView = observer(() => {
|
|||||||
commandPaletteStore.toggleCreateProjectModal(true);
|
commandPaletteStore.toggleCreateProjectModal(true);
|
||||||
},
|
},
|
||||||
}}
|
}}
|
||||||
|
disabled={!isEditingAllowed}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
) : null}
|
) : null}
|
||||||
|
@ -30,18 +30,7 @@ export const PagesListView: FC<IPagesListView> = observer(({ pages }) => {
|
|||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const { workspaceSlug, projectId } = router.query;
|
const { workspaceSlug, projectId } = router.query;
|
||||||
|
|
||||||
const canUserCreatePage =
|
const isEditingAllowed = !!currentProjectRole && currentProjectRole >= EUserWorkspaceRoles.MEMBER;
|
||||||
currentProjectRole && [EUserWorkspaceRoles.ADMIN, EUserWorkspaceRoles.MEMBER].includes(currentProjectRole);
|
|
||||||
|
|
||||||
const emptyStatePrimaryButton = canUserCreatePage
|
|
||||||
? {
|
|
||||||
primaryButton: {
|
|
||||||
icon: <Plus className="h-4 w-4" />,
|
|
||||||
text: "Create your first page",
|
|
||||||
onClick: () => toggleCreatePageModal(true),
|
|
||||||
},
|
|
||||||
}
|
|
||||||
: {};
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
@ -69,7 +58,12 @@ export const PagesListView: FC<IPagesListView> = observer(({ pages }) => {
|
|||||||
"We wrote Parth and Meera’s love story. You could write your project’s mission, goals, and eventual vision.",
|
"We wrote Parth and Meera’s love story. You could write your project’s mission, goals, and eventual vision.",
|
||||||
direction: "right",
|
direction: "right",
|
||||||
}}
|
}}
|
||||||
{...emptyStatePrimaryButton}
|
primaryButton={{
|
||||||
|
icon: <Plus className="h-4 w-4" />,
|
||||||
|
text: "Create your first page",
|
||||||
|
onClick: () => toggleCreatePageModal(true),
|
||||||
|
}}
|
||||||
|
disabled={!isEditingAllowed}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
@ -12,16 +12,21 @@ import { Loader } from "@plane/ui";
|
|||||||
import emptyPage from "public/empty-state/empty_page.png";
|
import emptyPage from "public/empty-state/empty_page.png";
|
||||||
// helpers
|
// helpers
|
||||||
import { replaceUnderscoreIfSnakeCase } from "helpers/string.helper";
|
import { replaceUnderscoreIfSnakeCase } from "helpers/string.helper";
|
||||||
|
// constants
|
||||||
|
import { EUserWorkspaceRoles } from "constants/workspace";
|
||||||
|
|
||||||
export const RecentPagesList: FC = observer(() => {
|
export const RecentPagesList: FC = observer(() => {
|
||||||
// store
|
// store
|
||||||
const {
|
const {
|
||||||
commandPalette: commandPaletteStore,
|
commandPalette: commandPaletteStore,
|
||||||
page: { recentProjectPages },
|
page: { recentProjectPages },
|
||||||
|
user: { currentProjectRole },
|
||||||
} = useMobxStore();
|
} = useMobxStore();
|
||||||
|
|
||||||
const isEmpty = recentProjectPages && Object.values(recentProjectPages).every((value) => value.length === 0);
|
const isEmpty = recentProjectPages && Object.values(recentProjectPages).every((value) => value.length === 0);
|
||||||
|
|
||||||
|
const isEditingAllowed = !!currentProjectRole && currentProjectRole >= EUserWorkspaceRoles.MEMBER;
|
||||||
|
|
||||||
if (!recentProjectPages) {
|
if (!recentProjectPages) {
|
||||||
return (
|
return (
|
||||||
<Loader className="space-y-4">
|
<Loader className="space-y-4">
|
||||||
@ -66,6 +71,7 @@ export const RecentPagesList: FC = observer(() => {
|
|||||||
text: "Create your first page",
|
text: "Create your first page",
|
||||||
onClick: () => commandPaletteStore.toggleCreatePageModal(true),
|
onClick: () => commandPaletteStore.toggleCreatePageModal(true),
|
||||||
}}
|
}}
|
||||||
|
disabled={!isEditingAllowed}
|
||||||
/>
|
/>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
|
@ -9,6 +9,8 @@ import { Loader } from "@plane/ui";
|
|||||||
import emptyProject from "public/empty-state/empty_project.webp";
|
import emptyProject from "public/empty-state/empty_project.webp";
|
||||||
// icons
|
// icons
|
||||||
import { NewEmptyState } from "components/common/new-empty-state";
|
import { NewEmptyState } from "components/common/new-empty-state";
|
||||||
|
// constants
|
||||||
|
import { EUserWorkspaceRoles } from "constants/workspace";
|
||||||
|
|
||||||
export interface IProjectCardList {
|
export interface IProjectCardList {
|
||||||
workspaceSlug: string;
|
workspaceSlug: string;
|
||||||
@ -21,10 +23,13 @@ export const ProjectCardList: FC<IProjectCardList> = observer((props) => {
|
|||||||
project: projectStore,
|
project: projectStore,
|
||||||
commandPalette: commandPaletteStore,
|
commandPalette: commandPaletteStore,
|
||||||
trackEvent: { setTrackElement },
|
trackEvent: { setTrackElement },
|
||||||
|
user: { currentProjectRole },
|
||||||
} = useMobxStore();
|
} = useMobxStore();
|
||||||
|
|
||||||
const projects = workspaceSlug ? projectStore.projects[workspaceSlug.toString()] : null;
|
const projects = workspaceSlug ? projectStore.projects[workspaceSlug.toString()] : null;
|
||||||
|
|
||||||
|
const isEditingAllowed = !!currentProjectRole && currentProjectRole >= EUserWorkspaceRoles.MEMBER;
|
||||||
|
|
||||||
if (!projects) {
|
if (!projects) {
|
||||||
return (
|
return (
|
||||||
<Loader className="grid grid-cols-3 gap-4">
|
<Loader className="grid grid-cols-3 gap-4">
|
||||||
@ -69,6 +74,7 @@ export const ProjectCardList: FC<IProjectCardList> = observer((props) => {
|
|||||||
commandPaletteStore.toggleCreateProjectModal(true);
|
commandPaletteStore.toggleCreateProjectModal(true);
|
||||||
},
|
},
|
||||||
}}
|
}}
|
||||||
|
disabled={!isEditingAllowed}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</>
|
</>
|
||||||
|
@ -13,6 +13,8 @@ import { Input, Loader } from "@plane/ui";
|
|||||||
import emptyView from "public/empty-state/empty_view.webp";
|
import emptyView from "public/empty-state/empty_view.webp";
|
||||||
// icons
|
// icons
|
||||||
import { Plus, Search } from "lucide-react";
|
import { Plus, Search } from "lucide-react";
|
||||||
|
// constants
|
||||||
|
import { EUserWorkspaceRoles } from "constants/workspace";
|
||||||
|
|
||||||
export const ProjectViewsList = observer(() => {
|
export const ProjectViewsList = observer(() => {
|
||||||
const [query, setQuery] = useState("");
|
const [query, setQuery] = useState("");
|
||||||
@ -20,10 +22,16 @@ export const ProjectViewsList = observer(() => {
|
|||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const { projectId } = router.query;
|
const { projectId } = router.query;
|
||||||
|
|
||||||
const { projectViews: projectViewsStore, commandPalette: commandPaletteStore } = useMobxStore();
|
const {
|
||||||
|
projectViews: projectViewsStore,
|
||||||
|
commandPalette: commandPaletteStore,
|
||||||
|
user: { currentProjectRole },
|
||||||
|
} = useMobxStore();
|
||||||
|
|
||||||
const viewsList = projectId ? projectViewsStore.viewsList[projectId.toString()] : undefined;
|
const viewsList = projectId ? projectViewsStore.viewsList[projectId.toString()] : undefined;
|
||||||
|
|
||||||
|
const isEditingAllowed = !!currentProjectRole && currentProjectRole >= EUserWorkspaceRoles.MEMBER;
|
||||||
|
|
||||||
if (!viewsList)
|
if (!viewsList)
|
||||||
return (
|
return (
|
||||||
<Loader className="space-y-4 p-4">
|
<Loader className="space-y-4 p-4">
|
||||||
@ -73,6 +81,7 @@ export const ProjectViewsList = observer(() => {
|
|||||||
text: "Build your first view",
|
text: "Build your first view",
|
||||||
onClick: () => commandPaletteStore.toggleCreateViewModal(true),
|
onClick: () => commandPaletteStore.toggleCreateViewModal(true),
|
||||||
}}
|
}}
|
||||||
|
disabled={!isEditingAllowed}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</>
|
</>
|
||||||
|
@ -15,6 +15,7 @@ import { Plus } from "lucide-react";
|
|||||||
import emptyAnalytics from "public/empty-state/empty_analytics.webp";
|
import emptyAnalytics from "public/empty-state/empty_analytics.webp";
|
||||||
// constants
|
// constants
|
||||||
import { ANALYTICS_TABS } from "constants/analytics";
|
import { ANALYTICS_TABS } from "constants/analytics";
|
||||||
|
import { EUserWorkspaceRoles } from "constants/workspace";
|
||||||
// type
|
// type
|
||||||
import { NextPageWithLayout } from "types/app";
|
import { NextPageWithLayout } from "types/app";
|
||||||
|
|
||||||
@ -24,8 +25,11 @@ const AnalyticsPage: NextPageWithLayout = observer(() => {
|
|||||||
project: { workspaceProjects },
|
project: { workspaceProjects },
|
||||||
commandPalette: { toggleCreateProjectModal },
|
commandPalette: { toggleCreateProjectModal },
|
||||||
trackEvent: { setTrackElement },
|
trackEvent: { setTrackElement },
|
||||||
|
user: { currentProjectRole },
|
||||||
} = useMobxStore();
|
} = useMobxStore();
|
||||||
|
|
||||||
|
const isEditingAllowed = !!currentProjectRole && currentProjectRole >= EUserWorkspaceRoles.MEMBER;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{workspaceProjects && workspaceProjects.length > 0 ? (
|
{workspaceProjects && workspaceProjects.length > 0 ? (
|
||||||
@ -77,6 +81,7 @@ const AnalyticsPage: NextPageWithLayout = observer(() => {
|
|||||||
toggleCreateProjectModal(true);
|
toggleCreateProjectModal(true);
|
||||||
},
|
},
|
||||||
}}
|
}}
|
||||||
|
disabled={!isEditingAllowed}
|
||||||
/>
|
/>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
|
@ -19,6 +19,7 @@ import { TCycleView, TCycleLayout } from "types";
|
|||||||
import { NextPageWithLayout } from "types/app";
|
import { NextPageWithLayout } from "types/app";
|
||||||
// constants
|
// constants
|
||||||
import { CYCLE_TAB_LIST, CYCLE_VIEW_LAYOUTS } from "constants/cycle";
|
import { CYCLE_TAB_LIST, CYCLE_VIEW_LAYOUTS } from "constants/cycle";
|
||||||
|
import { EUserWorkspaceRoles } from "constants/workspace";
|
||||||
// lib cookie
|
// lib cookie
|
||||||
import { setLocalStorage, getLocalStorage } from "lib/local-storage";
|
import { setLocalStorage, getLocalStorage } from "lib/local-storage";
|
||||||
import { NewEmptyState } from "components/common/new-empty-state";
|
import { NewEmptyState } from "components/common/new-empty-state";
|
||||||
@ -27,7 +28,10 @@ import { NewEmptyState } from "components/common/new-empty-state";
|
|||||||
const ProjectCyclesPage: NextPageWithLayout = observer(() => {
|
const ProjectCyclesPage: NextPageWithLayout = observer(() => {
|
||||||
const [createModal, setCreateModal] = useState(false);
|
const [createModal, setCreateModal] = useState(false);
|
||||||
// store
|
// store
|
||||||
const { cycle: cycleStore } = useMobxStore();
|
const {
|
||||||
|
cycle: cycleStore,
|
||||||
|
user: { currentProjectRole },
|
||||||
|
} = useMobxStore();
|
||||||
const { projectCycles } = cycleStore;
|
const { projectCycles } = cycleStore;
|
||||||
// router
|
// router
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
@ -75,6 +79,8 @@ const ProjectCyclesPage: NextPageWithLayout = observer(() => {
|
|||||||
const cycleLayout = cycleStore?.cycleLayout;
|
const cycleLayout = cycleStore?.cycleLayout;
|
||||||
const totalCycles = projectCycles?.length ?? 0;
|
const totalCycles = projectCycles?.length ?? 0;
|
||||||
|
|
||||||
|
const isEditingAllowed = !!currentProjectRole && currentProjectRole >= EUserWorkspaceRoles.MEMBER;
|
||||||
|
|
||||||
if (!workspaceSlug || !projectId) return null;
|
if (!workspaceSlug || !projectId) return null;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@ -104,6 +110,7 @@ const ProjectCyclesPage: NextPageWithLayout = observer(() => {
|
|||||||
setCreateModal(true);
|
setCreateModal(true);
|
||||||
},
|
},
|
||||||
}}
|
}}
|
||||||
|
disabled={!isEditingAllowed}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
|
Loading…
Reference in New Issue
Block a user