chore: empty state action button validation (#3094)

This commit is contained in:
Anmol Singh Bhatia 2023-12-13 23:05:23 +05:30 committed by GitHub
parent b4f51cb5af
commit 2605b938f0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 63 additions and 16 deletions

View file

@ -15,6 +15,7 @@ import { Plus } from "lucide-react";
import emptyAnalytics from "public/empty-state/empty_analytics.webp";
// constants
import { ANALYTICS_TABS } from "constants/analytics";
import { EUserWorkspaceRoles } from "constants/workspace";
// type
import { NextPageWithLayout } from "types/app";
@ -24,8 +25,11 @@ const AnalyticsPage: NextPageWithLayout = observer(() => {
project: { workspaceProjects },
commandPalette: { toggleCreateProjectModal },
trackEvent: { setTrackElement },
user: { currentProjectRole },
} = useMobxStore();
const isEditingAllowed = !!currentProjectRole && currentProjectRole >= EUserWorkspaceRoles.MEMBER;
return (
<>
{workspaceProjects && workspaceProjects.length > 0 ? (
@ -77,6 +81,7 @@ const AnalyticsPage: NextPageWithLayout = observer(() => {
toggleCreateProjectModal(true);
},
}}
disabled={!isEditingAllowed}
/>
</>
)}

View file

@ -19,6 +19,7 @@ import { TCycleView, TCycleLayout } from "types";
import { NextPageWithLayout } from "types/app";
// constants
import { CYCLE_TAB_LIST, CYCLE_VIEW_LAYOUTS } from "constants/cycle";
import { EUserWorkspaceRoles } from "constants/workspace";
// lib cookie
import { setLocalStorage, getLocalStorage } from "lib/local-storage";
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 [createModal, setCreateModal] = useState(false);
// store
const { cycle: cycleStore } = useMobxStore();
const {
cycle: cycleStore,
user: { currentProjectRole },
} = useMobxStore();
const { projectCycles } = cycleStore;
// router
const router = useRouter();
@ -75,6 +79,8 @@ const ProjectCyclesPage: NextPageWithLayout = observer(() => {
const cycleLayout = cycleStore?.cycleLayout;
const totalCycles = projectCycles?.length ?? 0;
const isEditingAllowed = !!currentProjectRole && currentProjectRole >= EUserWorkspaceRoles.MEMBER;
if (!workspaceSlug || !projectId) return null;
return (
@ -104,6 +110,7 @@ const ProjectCyclesPage: NextPageWithLayout = observer(() => {
setCreateModal(true);
},
}}
disabled={!isEditingAllowed}
/>
</div>
) : (