mirror of
https://github.com/makeplane/plane.git
synced 2026-02-24 04:00:14 +01:00
chore: merge helpers and layouts (#8624)
* fix: remove constants and services * fix: formatting * chore: merge helpers and layouts * fix: workspace disbale flag handling
This commit is contained in:
committed by
GitHub
parent
7793febcf8
commit
2b6e24d526
@@ -24,9 +24,10 @@ import { useAppTheme } from "@/hooks/store/use-app-theme";
|
||||
import { useIssueDetail } from "@/hooks/store/use-issue-detail";
|
||||
import { useProject } from "@/hooks/store/use-project";
|
||||
import { useAppRouter } from "@/hooks/use-app-router";
|
||||
// layouts
|
||||
import { ProjectAuthWrapper } from "@/layouts/auth-layout/project-wrapper";
|
||||
// plane web imports
|
||||
import { useWorkItemProperties } from "@/plane-web/hooks/use-issue-properties";
|
||||
import { ProjectAuthWrapper } from "@/plane-web/layouts/project-wrapper";
|
||||
import { WorkItemDetailRoot } from "@/plane-web/components/browse/workItem-detail";
|
||||
|
||||
import type { Route } from "./+types/page";
|
||||
|
||||
@@ -15,7 +15,8 @@ import { AppSidebarToggleButton } from "@/components/sidebar/sidebar-toggle-butt
|
||||
// hooks
|
||||
import { useAppTheme } from "@/hooks/store/use-app-theme";
|
||||
import { useProjectNavigationPreferences } from "@/hooks/use-navigation-preferences";
|
||||
import { ProjectAuthWrapper } from "@/plane-web/layouts/project-wrapper";
|
||||
// layouts
|
||||
import { ProjectAuthWrapper } from "@/layouts/auth-layout/project-wrapper";
|
||||
// local imports
|
||||
import type { Route } from "./+types/layout";
|
||||
|
||||
|
||||
@@ -10,8 +10,8 @@ import { Outlet } from "react-router";
|
||||
// components
|
||||
import { getProjectActivePath } from "@/components/settings/helper";
|
||||
import { SettingsMobileNav } from "@/components/settings/mobile/nav";
|
||||
// plane web imports
|
||||
import { ProjectAuthWrapper } from "@/plane-web/layouts/project-wrapper";
|
||||
// layouts
|
||||
import { ProjectAuthWrapper } from "@/layouts/auth-layout/project-wrapper";
|
||||
// types
|
||||
import type { Route } from "./+types/layout";
|
||||
import { ProjectSettingsSidebarRoot } from "@/components/settings/project/sidebar";
|
||||
|
||||
@@ -20,7 +20,6 @@ import { useProject } from "@/hooks/store/use-project";
|
||||
import { useUserPermissions } from "@/hooks/store/user";
|
||||
// plane web imports
|
||||
import { ProjectTeamspaceList } from "@/plane-web/components/projects/teamspaces/teamspace-list";
|
||||
import { getProjectSettingsPageLabelI18nKey } from "@/plane-web/helpers/project-settings";
|
||||
// local imports
|
||||
import type { Route } from "./+types/page";
|
||||
import { MembersProjectSettingsHeader } from "./header";
|
||||
@@ -49,7 +48,7 @@ function MembersSettingsPage({ params }: Route.ComponentProps) {
|
||||
return (
|
||||
<SettingsContentWrapper header={<MembersProjectSettingsHeader />} hugging>
|
||||
<PageHead title={pageTitle} />
|
||||
<SettingsHeading title={t(getProjectSettingsPageLabelI18nKey("members", "common.members"))} />
|
||||
<SettingsHeading title={t("common.members")} />
|
||||
<ProjectSettingsMemberDefaults projectId={projectId} workspaceSlug={workspaceSlug} />
|
||||
<ProjectTeamspaceList projectId={projectId} workspaceSlug={workspaceSlug} />
|
||||
<ProjectMemberList projectId={projectId} workspaceSlug={workspaceSlug} />
|
||||
|
||||
@@ -9,7 +9,7 @@ import { AuthenticationWrapper } from "@/lib/wrappers/authentication-wrapper";
|
||||
import { WorkspaceContentWrapper } from "@/plane-web/components/workspace/content-wrapper";
|
||||
import { AppRailVisibilityProvider } from "@/plane-web/hooks/app-rail";
|
||||
import { GlobalModals } from "@/plane-web/components/common/modal/global";
|
||||
import { WorkspaceAuthWrapper } from "@/plane-web/layouts/workspace-wrapper";
|
||||
import { WorkspaceAuthWrapper } from "@/layouts/auth-layout/workspace-wrapper";
|
||||
import type { Route } from "./+types/layout";
|
||||
|
||||
export default function WorkspaceLayout(props: Route.ComponentProps) {
|
||||
|
||||
@@ -18,17 +18,17 @@ import WorkspaceCreationDisabled from "@/app/assets/workspace/workspace-creation
|
||||
import { CreateWorkspaceForm } from "@/components/workspace/create-workspace-form";
|
||||
// hooks
|
||||
import { useUser, useUserProfile } from "@/hooks/store/user";
|
||||
import { useInstance } from "@/hooks/store/use-instance";
|
||||
import { useAppRouter } from "@/hooks/use-app-router";
|
||||
// wrappers
|
||||
import { AuthenticationWrapper } from "@/lib/wrappers/authentication-wrapper";
|
||||
// plane web helpers
|
||||
import { getIsWorkspaceCreationDisabled } from "@/plane-web/helpers/instance.helper";
|
||||
|
||||
const CreateWorkspacePage = observer(function CreateWorkspacePage() {
|
||||
const { t } = useTranslation();
|
||||
// router
|
||||
const router = useAppRouter();
|
||||
// store hooks
|
||||
const { config } = useInstance();
|
||||
const { data: currentUser } = useUser();
|
||||
const { updateUserProfile } = useUserProfile();
|
||||
// states
|
||||
@@ -38,7 +38,7 @@ const CreateWorkspacePage = observer(function CreateWorkspacePage() {
|
||||
organization_size: "",
|
||||
});
|
||||
// derived values
|
||||
const isWorkspaceCreationDisabled = getIsWorkspaceCreationDisabled();
|
||||
const isWorkspaceCreationDisabled = config?.is_workspace_creation_disabled ?? false;
|
||||
|
||||
// methods
|
||||
const getMailtoHref = () => {
|
||||
|
||||
@@ -1,112 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2023-present Plane Software, Inc. and contributors
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
* See the LICENSE file for details.
|
||||
*/
|
||||
|
||||
import type { TCommandPaletteActionList, TCommandPaletteShortcut, TCommandPaletteShortcutList } from "@plane/types";
|
||||
// store
|
||||
import { store } from "@/lib/store-context";
|
||||
|
||||
export const getGlobalShortcutsList: () => TCommandPaletteActionList = () => {
|
||||
const { toggleCreateIssueModal } = store.commandPalette;
|
||||
|
||||
return {
|
||||
c: {
|
||||
title: "Create a new work item",
|
||||
description: "Create a new work item in the current project",
|
||||
action: () => {
|
||||
toggleCreateIssueModal(true);
|
||||
},
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
export const getWorkspaceShortcutsList: () => TCommandPaletteActionList = () => {
|
||||
const { toggleCreateProjectModal } = store.commandPalette;
|
||||
|
||||
return {
|
||||
p: {
|
||||
title: "Create a new project",
|
||||
description: "Create a new project in the current workspace",
|
||||
action: () => {
|
||||
toggleCreateProjectModal(true);
|
||||
},
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
export const getProjectShortcutsList: () => TCommandPaletteActionList = () => {
|
||||
const {
|
||||
toggleCreatePageModal,
|
||||
toggleCreateModuleModal,
|
||||
toggleCreateCycleModal,
|
||||
toggleCreateViewModal,
|
||||
toggleBulkDeleteIssueModal,
|
||||
} = store.commandPalette;
|
||||
|
||||
return {
|
||||
d: {
|
||||
title: "Create a new page",
|
||||
description: "Create a new page in the current project",
|
||||
action: () => {
|
||||
toggleCreatePageModal({ isOpen: true });
|
||||
},
|
||||
},
|
||||
m: {
|
||||
title: "Create a new module",
|
||||
description: "Create a new module in the current project",
|
||||
action: () => {
|
||||
toggleCreateModuleModal(true);
|
||||
},
|
||||
},
|
||||
q: {
|
||||
title: "Create a new cycle",
|
||||
description: "Create a new cycle in the current project",
|
||||
action: () => {
|
||||
toggleCreateCycleModal(true);
|
||||
},
|
||||
},
|
||||
v: {
|
||||
title: "Create a new view",
|
||||
description: "Create a new view in the current project",
|
||||
action: () => {
|
||||
toggleCreateViewModal(true);
|
||||
},
|
||||
},
|
||||
backspace: {
|
||||
title: "Bulk delete work items",
|
||||
description: "Bulk delete work items in the current project",
|
||||
action: () => toggleBulkDeleteIssueModal(true),
|
||||
},
|
||||
delete: {
|
||||
title: "Bulk delete work items",
|
||||
description: "Bulk delete work items in the current project",
|
||||
action: () => toggleBulkDeleteIssueModal(true),
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
export const handleAdditionalKeyDownEvents = (e: KeyboardEvent) => null;
|
||||
|
||||
export const getNavigationShortcutsList = (): TCommandPaletteShortcut[] => [
|
||||
{ keys: "Ctrl,K", description: "Open command menu" },
|
||||
];
|
||||
|
||||
export const getCommonShortcutsList = (platform: string): TCommandPaletteShortcut[] => [
|
||||
{ keys: "P", description: "Create project" },
|
||||
{ keys: "C", description: "Create work item" },
|
||||
{ keys: "Q", description: "Create cycle" },
|
||||
{ keys: "M", description: "Create module" },
|
||||
{ keys: "V", description: "Create view" },
|
||||
{ keys: "D", description: "Create page" },
|
||||
{ keys: "Delete", description: "Bulk delete work items" },
|
||||
{ keys: "Shift,/", description: "Open shortcuts guide" },
|
||||
{
|
||||
keys: platform === "MacOS" ? "Ctrl,control,C" : "Ctrl,Alt,C",
|
||||
description: "Copy work item URL from the work item details page",
|
||||
},
|
||||
];
|
||||
|
||||
export const getAdditionalShortcutsList = (): TCommandPaletteShortcutList[] => [];
|
||||
@@ -1,21 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2023-present Plane Software, Inc. and contributors
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
* See the LICENSE file for details.
|
||||
*/
|
||||
|
||||
import type { TEpicAnalyticsGroup } from "@plane/types";
|
||||
|
||||
export const updateEpicAnalytics = () => {
|
||||
const updateAnalytics = (
|
||||
workspaceSlug: string,
|
||||
projectId: string,
|
||||
epicId: string,
|
||||
data: {
|
||||
incrementStateGroupCount?: TEpicAnalyticsGroup;
|
||||
decrementStateGroupCount?: TEpicAnalyticsGroup;
|
||||
}
|
||||
) => {};
|
||||
|
||||
return { updateAnalytics };
|
||||
};
|
||||
@@ -1,13 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2023-present Plane Software, Inc. and contributors
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
* See the LICENSE file for details.
|
||||
*/
|
||||
|
||||
import { store } from "@/lib/store-context";
|
||||
|
||||
export const getIsWorkspaceCreationDisabled = () => {
|
||||
const instanceConfig = store.instance.config;
|
||||
|
||||
return instanceConfig?.is_workspace_creation_disabled;
|
||||
};
|
||||
@@ -1,28 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2023-present Plane Software, Inc. and contributors
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
* See the LICENSE file for details.
|
||||
*/
|
||||
|
||||
import type { IssueActions } from "@/hooks/use-issues-actions";
|
||||
|
||||
export const useTeamIssueActions: () => IssueActions = () => ({
|
||||
fetchIssues: () => Promise.resolve(undefined),
|
||||
fetchNextIssues: () => Promise.resolve(undefined),
|
||||
removeIssue: () => Promise.resolve(undefined),
|
||||
updateFilters: () => Promise.resolve(undefined),
|
||||
});
|
||||
|
||||
export const useTeamViewIssueActions: () => IssueActions = () => ({
|
||||
fetchIssues: () => Promise.resolve(undefined),
|
||||
fetchNextIssues: () => Promise.resolve(undefined),
|
||||
removeIssue: () => Promise.resolve(undefined),
|
||||
updateFilters: () => Promise.resolve(undefined),
|
||||
});
|
||||
|
||||
export const useTeamProjectWorkItemsActions: () => IssueActions = () => ({
|
||||
fetchIssues: () => Promise.resolve(undefined),
|
||||
fetchNextIssues: () => Promise.resolve(undefined),
|
||||
removeIssue: () => Promise.resolve(undefined),
|
||||
updateFilters: () => Promise.resolve(undefined),
|
||||
});
|
||||
@@ -1,9 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2023-present Plane Software, Inc. and contributors
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
* See the LICENSE file for details.
|
||||
*/
|
||||
|
||||
export const hideFloatingBot = () => {};
|
||||
|
||||
export const showFloatingBot = () => {};
|
||||
@@ -1,13 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2023-present Plane Software, Inc. and contributors
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
* See the LICENSE file for details.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @description Get the i18n key for the project settings page label
|
||||
* @param _settingsKey - The key of the project settings page
|
||||
* @param defaultLabelKey - The default i18n key for the project settings page label
|
||||
* @returns The i18n key for the project settings page label
|
||||
*/
|
||||
export const getProjectSettingsPageLabelI18nKey = (_settingsKey: string, defaultLabelKey: string) => defaultLabelKey;
|
||||
@@ -1,26 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2023-present Plane Software, Inc. and contributors
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
* See the LICENSE file for details.
|
||||
*/
|
||||
|
||||
// plane imports
|
||||
import type { EIssuesStoreType } from "@plane/types";
|
||||
// plane web imports
|
||||
import type { TWorkItemFiltersEntityProps } from "@/plane-web/hooks/work-item-filters/use-work-item-filters-config";
|
||||
|
||||
export type TGetAdditionalPropsForProjectLevelFiltersHOCParams = {
|
||||
entityType: EIssuesStoreType;
|
||||
workspaceSlug: string;
|
||||
projectId: string;
|
||||
};
|
||||
|
||||
export type TGetAdditionalPropsForProjectLevelFiltersHOC = (
|
||||
params: TGetAdditionalPropsForProjectLevelFiltersHOCParams
|
||||
) => TWorkItemFiltersEntityProps;
|
||||
|
||||
export const getAdditionalProjectLevelFiltersHOCProps: TGetAdditionalPropsForProjectLevelFiltersHOC = ({
|
||||
workspaceSlug,
|
||||
}) => ({
|
||||
workspaceSlug,
|
||||
});
|
||||
@@ -1,8 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2023-present Plane Software, Inc. and contributors
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
* See the LICENSE file for details.
|
||||
*/
|
||||
|
||||
export type TRenderSettingsLink = (workspaceSlug: string, settingKey: string) => boolean;
|
||||
export const shouldRenderSettingLink: TRenderSettingsLink = (workspaceSlug, settingKey) => true;
|
||||
@@ -1,26 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2023-present Plane Software, Inc. and contributors
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
* See the LICENSE file for details.
|
||||
*/
|
||||
|
||||
import { observer } from "mobx-react";
|
||||
// layouts
|
||||
import { ProjectAuthWrapper as CoreProjectAuthWrapper } from "@/layouts/auth-layout/project-wrapper";
|
||||
|
||||
export type IProjectAuthWrapper = {
|
||||
workspaceSlug: string;
|
||||
projectId: string;
|
||||
children: React.ReactNode;
|
||||
};
|
||||
|
||||
export const ProjectAuthWrapper = observer(function ProjectAuthWrapper(props: IProjectAuthWrapper) {
|
||||
// props
|
||||
const { workspaceSlug, projectId, children } = props;
|
||||
|
||||
return (
|
||||
<CoreProjectAuthWrapper workspaceSlug={workspaceSlug} projectId={projectId}>
|
||||
{children}
|
||||
</CoreProjectAuthWrapper>
|
||||
);
|
||||
});
|
||||
@@ -1,21 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2023-present Plane Software, Inc. and contributors
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
* See the LICENSE file for details.
|
||||
*/
|
||||
|
||||
import type { FC } from "react";
|
||||
import { observer } from "mobx-react";
|
||||
// layouts
|
||||
import { WorkspaceAuthWrapper as CoreWorkspaceAuthWrapper } from "@/layouts/auth-layout/workspace-wrapper";
|
||||
|
||||
export type IWorkspaceAuthWrapper = {
|
||||
children: React.ReactNode;
|
||||
};
|
||||
|
||||
export const WorkspaceAuthWrapper = observer(function WorkspaceAuthWrapper(props: IWorkspaceAuthWrapper) {
|
||||
// props
|
||||
const { children } = props;
|
||||
|
||||
return <CoreWorkspaceAuthWrapper>{children}</CoreWorkspaceAuthWrapper>;
|
||||
});
|
||||
@@ -5,7 +5,6 @@
|
||||
*/
|
||||
|
||||
import { useMemo } from "react";
|
||||
import { useParams } from "next/navigation";
|
||||
// plane imports
|
||||
import { useTranslation } from "@plane/i18n";
|
||||
import { TOAST_TYPE, setToast } from "@plane/propel/toast";
|
||||
@@ -14,18 +13,12 @@ import { EIssueServiceType } from "@plane/types";
|
||||
import { copyUrlToClipboard } from "@plane/utils";
|
||||
// hooks
|
||||
import { useIssueDetail } from "@/hooks/store/use-issue-detail";
|
||||
import { useProjectState } from "@/hooks/store/use-project-state";
|
||||
// plane web helpers
|
||||
import { updateEpicAnalytics } from "@/plane-web/helpers/epic-analytics";
|
||||
|
||||
export const useSubIssueOperations = (issueServiceType: TIssueServiceType): TSubIssueOperations => {
|
||||
// router
|
||||
const { epicId: epicIdParam } = useParams();
|
||||
// translation
|
||||
const { t } = useTranslation();
|
||||
// store hooks
|
||||
const {
|
||||
issue: { getIssueById },
|
||||
subIssues: { setSubIssueHelpers },
|
||||
createSubIssues,
|
||||
fetchSubIssues,
|
||||
@@ -33,13 +26,6 @@ export const useSubIssueOperations = (issueServiceType: TIssueServiceType): TSub
|
||||
deleteSubIssue,
|
||||
removeSubIssue,
|
||||
} = useIssueDetail(issueServiceType);
|
||||
const { getStateById } = useProjectState();
|
||||
const { peekIssue: epicPeekIssue } = useIssueDetail(EIssueServiceType.EPICS);
|
||||
// const { updateEpicAnalytics } = useIssueTypes();
|
||||
const { updateAnalytics } = updateEpicAnalytics();
|
||||
|
||||
// derived values
|
||||
const epicId = epicIdParam || epicPeekIssue?.issueId;
|
||||
|
||||
const subIssueOperations: TSubIssueOperations = useMemo(
|
||||
() => ({
|
||||
@@ -110,30 +96,6 @@ export const useSubIssueOperations = (issueServiceType: TIssueServiceType): TSub
|
||||
try {
|
||||
setSubIssueHelpers(parentIssueId, "issue_loader", issueId);
|
||||
await updateSubIssue(workspaceSlug, projectId, parentIssueId, issueId, issueData, oldIssue, fromModal);
|
||||
|
||||
if (issueServiceType === EIssueServiceType.EPICS) {
|
||||
const oldState = getStateById(oldIssue?.state_id)?.group;
|
||||
|
||||
if (oldState && oldIssue && issueData && epicId) {
|
||||
// Check if parent_id is changed if yes then decrement the epic analytics count
|
||||
if (issueData.parent_id && oldIssue?.parent_id && issueData.parent_id !== oldIssue?.parent_id) {
|
||||
updateAnalytics(workspaceSlug, projectId, epicId.toString(), {
|
||||
decrementStateGroupCount: `${oldState}_issues`,
|
||||
});
|
||||
}
|
||||
|
||||
// Check if state_id is changed if yes then decrement the old state group count and increment the new state group count
|
||||
if (issueData.state_id) {
|
||||
const newState = getStateById(issueData.state_id)?.group;
|
||||
if (oldState && newState && oldState !== newState) {
|
||||
updateAnalytics(workspaceSlug, projectId, epicId.toString(), {
|
||||
decrementStateGroupCount: `${oldState}_issues`,
|
||||
incrementStateGroupCount: `${newState}_issues`,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
setToast({
|
||||
type: TOAST_TYPE.SUCCESS,
|
||||
title: t("toast.success"),
|
||||
@@ -152,16 +114,6 @@ export const useSubIssueOperations = (issueServiceType: TIssueServiceType): TSub
|
||||
try {
|
||||
setSubIssueHelpers(parentIssueId, "issue_loader", issueId);
|
||||
await removeSubIssue(workspaceSlug, projectId, parentIssueId, issueId);
|
||||
if (issueServiceType === EIssueServiceType.EPICS) {
|
||||
const issueBeforeRemoval = getIssueById(issueId);
|
||||
const oldState = getStateById(issueBeforeRemoval?.state_id)?.group;
|
||||
|
||||
if (epicId && oldState) {
|
||||
updateAnalytics(workspaceSlug, projectId, epicId.toString(), {
|
||||
decrementStateGroupCount: `${oldState}_issues`,
|
||||
});
|
||||
}
|
||||
}
|
||||
setToast({
|
||||
type: TOAST_TYPE.SUCCESS,
|
||||
title: t("toast.success"),
|
||||
@@ -189,9 +141,8 @@ export const useSubIssueOperations = (issueServiceType: TIssueServiceType): TSub
|
||||
deleteSubIssue: async (workspaceSlug, projectId, parentIssueId, issueId) => {
|
||||
try {
|
||||
setSubIssueHelpers(parentIssueId, "issue_loader", issueId);
|
||||
return deleteSubIssue(workspaceSlug, projectId, parentIssueId, issueId).then(() => {
|
||||
setSubIssueHelpers(parentIssueId, "issue_loader", issueId);
|
||||
});
|
||||
await deleteSubIssue(workspaceSlug, projectId, parentIssueId, issueId);
|
||||
setSubIssueHelpers(parentIssueId, "issue_loader", issueId);
|
||||
} catch (_error) {
|
||||
setToast({
|
||||
type: TOAST_TYPE.ERROR,
|
||||
@@ -209,15 +160,11 @@ export const useSubIssueOperations = (issueServiceType: TIssueServiceType): TSub
|
||||
[
|
||||
createSubIssues,
|
||||
deleteSubIssue,
|
||||
epicId,
|
||||
fetchSubIssues,
|
||||
getIssueById,
|
||||
getStateById,
|
||||
issueServiceType,
|
||||
removeSubIssue,
|
||||
setSubIssueHelpers,
|
||||
t,
|
||||
updateAnalytics,
|
||||
updateSubIssue,
|
||||
]
|
||||
);
|
||||
|
||||
@@ -6,15 +6,12 @@
|
||||
|
||||
import React from "react";
|
||||
import { observer } from "mobx-react";
|
||||
import { useParams } from "next/navigation";
|
||||
// plane constants
|
||||
import { ISSUE_DISPLAY_PROPERTIES } from "@plane/constants";
|
||||
// plane i18n
|
||||
import { useTranslation } from "@plane/i18n";
|
||||
// types
|
||||
import type { IIssueDisplayProperties } from "@plane/types";
|
||||
// plane web helpers
|
||||
import { shouldRenderDisplayProperty } from "@/plane-web/helpers/issue-filter.helper";
|
||||
// components
|
||||
import { FilterHeader } from "../helpers/filter-header";
|
||||
|
||||
@@ -38,12 +35,8 @@ export const FilterDisplayProperties = observer(function FilterDisplayProperties
|
||||
} = props;
|
||||
// hooks
|
||||
const { t } = useTranslation();
|
||||
// router
|
||||
const { workspaceSlug, projectId: routerProjectId } = useParams();
|
||||
// states
|
||||
const [previewEnabled, setPreviewEnabled] = React.useState(true);
|
||||
// derived values
|
||||
const projectId = routerProjectId ? routerProjectId?.toString() : undefined;
|
||||
|
||||
// Filter out "cycle" and "module" keys if cycleViewDisabled or moduleViewDisabled is true
|
||||
// Also filter out display properties that should not be rendered
|
||||
@@ -55,7 +48,7 @@ export const FilterDisplayProperties = observer(function FilterDisplayProperties
|
||||
case "modules":
|
||||
return !moduleViewDisabled;
|
||||
default:
|
||||
return shouldRenderDisplayProperty({ workspaceSlug: workspaceSlug?.toString(), projectId, key: property.key });
|
||||
return true;
|
||||
}
|
||||
}).map((property) => {
|
||||
if (isEpic && property.key === "sub_issue_count") {
|
||||
|
||||
@@ -10,7 +10,7 @@ import { observer } from "mobx-react";
|
||||
import type { IIssueDisplayProperties, TIssue } from "@plane/types";
|
||||
// components
|
||||
import { SPREADSHEET_COLUMNS } from "@/plane-web/components/issues/issue-layouts/utils";
|
||||
import { shouldRenderColumn } from "@/plane-web/helpers/issue-filter.helper";
|
||||
import { shouldRenderColumn } from "@/helpers/issue-filter.helper";
|
||||
import { WithDisplayPropertiesHOC } from "../properties/with-display-properties-HOC";
|
||||
|
||||
type Props = {
|
||||
|
||||
@@ -9,7 +9,7 @@ import { useRef } from "react";
|
||||
import { observer } from "mobx-react";
|
||||
import type { IIssueDisplayFilterOptions, IIssueDisplayProperties } from "@plane/types";
|
||||
//components
|
||||
import { shouldRenderColumn } from "@/plane-web/helpers/issue-filter.helper";
|
||||
import { shouldRenderColumn } from "@/helpers/issue-filter.helper";
|
||||
import { WithDisplayPropertiesHOC } from "../properties/with-display-properties-HOC";
|
||||
import { HeaderColumn } from "./columns/header-column";
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* See the LICENSE file for details.
|
||||
*/
|
||||
|
||||
import React, { useEffect, useState } from "react";
|
||||
import { useEffect, useState } from "react";
|
||||
import { observer } from "mobx-react";
|
||||
import { OctagonAlert } from "lucide-react";
|
||||
// plane imports
|
||||
@@ -13,8 +13,7 @@ import type { IWorkspaceMemberInvitation, TOnboardingSteps } from "@plane/types"
|
||||
import { LogoSpinner } from "@/components/common/logo-spinner";
|
||||
// hooks
|
||||
import { useUser } from "@/hooks/store/user";
|
||||
// plane web helpers
|
||||
import { getIsWorkspaceCreationDisabled } from "@/plane-web/helpers/instance.helper";
|
||||
import { useInstance } from "@/hooks/store/use-instance";
|
||||
// local imports
|
||||
import { CreateWorkspace } from "./create-workspace";
|
||||
import { Invitations } from "./invitations";
|
||||
@@ -33,13 +32,14 @@ type Props = {
|
||||
};
|
||||
|
||||
export const CreateOrJoinWorkspaces = observer(function CreateOrJoinWorkspaces(props: Props) {
|
||||
const { invitations, totalSteps, stepChange, finishOnboarding } = props;
|
||||
const { invitations, stepChange, finishOnboarding } = props;
|
||||
// states
|
||||
const [currentView, setCurrentView] = useState<ECreateOrJoinWorkspaceViews | null>(null);
|
||||
// store hooks
|
||||
const { data: user } = useUser();
|
||||
const { config } = useInstance();
|
||||
// derived values
|
||||
const isWorkspaceCreationEnabled = getIsWorkspaceCreationDisabled() === false;
|
||||
const isWorkspaceCreationDisabled = config?.is_workspace_creation_disabled ?? false;
|
||||
|
||||
useEffect(() => {
|
||||
if (invitations.length > 0) {
|
||||
@@ -66,7 +66,7 @@ export const CreateOrJoinWorkspaces = observer(function CreateOrJoinWorkspaces(p
|
||||
handleCurrentViewChange={() => setCurrentView(ECreateOrJoinWorkspaceViews.WORKSPACE_CREATE)}
|
||||
/>
|
||||
) : currentView === ECreateOrJoinWorkspaceViews.WORKSPACE_CREATE ? (
|
||||
isWorkspaceCreationEnabled ? (
|
||||
!isWorkspaceCreationDisabled ? (
|
||||
<CreateWorkspace
|
||||
stepChange={stepChange}
|
||||
user={user ?? undefined}
|
||||
|
||||
@@ -17,10 +17,10 @@ import type { IUser, IWorkspace } from "@plane/types";
|
||||
import { Spinner } from "@plane/ui";
|
||||
import { cn } from "@plane/utils";
|
||||
// hooks
|
||||
import { useInstance } from "@/hooks/store/use-instance";
|
||||
import { useWorkspace } from "@/hooks/store/use-workspace";
|
||||
import { useUserProfile, useUserSettings } from "@/hooks/store/user";
|
||||
// plane-web imports
|
||||
import { getIsWorkspaceCreationDisabled } from "@/plane-web/helpers/instance.helper";
|
||||
// services
|
||||
import { WorkspaceService } from "@/services/workspace.service";
|
||||
// local components
|
||||
import { CommonOnboardingHeader } from "../common";
|
||||
@@ -46,11 +46,12 @@ export const WorkspaceCreateStep = observer(function WorkspaceCreateStep({
|
||||
// plane hooks
|
||||
const { t } = useTranslation();
|
||||
// store hooks
|
||||
const { config } = useInstance();
|
||||
const { updateUserProfile } = useUserProfile();
|
||||
const { fetchCurrentUserSettings } = useUserSettings();
|
||||
const { createWorkspace, fetchWorkspaces } = useWorkspace();
|
||||
|
||||
const isWorkspaceCreationEnabled = getIsWorkspaceCreationDisabled() === false;
|
||||
const isWorkspaceCreationDisabled = config?.is_workspace_creation_disabled ?? false;
|
||||
|
||||
// form info
|
||||
const {
|
||||
@@ -113,7 +114,7 @@ export const WorkspaceCreateStep = observer(function WorkspaceCreateStep({
|
||||
|
||||
const isButtonDisabled = !isValid || invalidSlug || isSubmitting;
|
||||
|
||||
if (!isWorkspaceCreationEnabled) {
|
||||
if (isWorkspaceCreationDisabled) {
|
||||
return (
|
||||
<div className="flex flex-col gap-10">
|
||||
<span className="text-center text-14 text-tertiary">
|
||||
|
||||
@@ -15,8 +15,7 @@ import type { TPowerKCommandConfig, TPowerKContext } from "@/components/power-k/
|
||||
import { useCommandPalette } from "@/hooks/store/use-command-palette";
|
||||
import { useProject } from "@/hooks/store/use-project";
|
||||
import { useUser } from "@/hooks/store/user";
|
||||
// plane web imports
|
||||
import { getIsWorkspaceCreationDisabled } from "@/plane-web/helpers/instance.helper";
|
||||
import { useInstance } from "@/hooks/store/use-instance";
|
||||
|
||||
export type TPowerKCreationCommandKeys =
|
||||
| "create_work_item"
|
||||
@@ -32,6 +31,7 @@ export type TPowerKCreationCommandKeys =
|
||||
*/
|
||||
export const usePowerKCreationCommandsRecord = (): Record<TPowerKCreationCommandKeys, TPowerKCommandConfig> => {
|
||||
// store
|
||||
const { config } = useInstance();
|
||||
const {
|
||||
canPerformAnyCreateAction,
|
||||
permission: { allowPermissions },
|
||||
@@ -58,7 +58,7 @@ export const usePowerKCreationCommandsRecord = (): Record<TPowerKCreationCommand
|
||||
ctx.params.workspaceSlug?.toString(),
|
||||
ctx.params.projectId?.toString()
|
||||
);
|
||||
const isWorkspaceCreationDisabled = getIsWorkspaceCreationDisabled();
|
||||
const isWorkspaceCreationDisabled = config?.is_workspace_creation_disabled ?? false;
|
||||
|
||||
const getProjectDetails = (ctx: TPowerKContext) =>
|
||||
ctx.params.projectId ? getPartialProjectById(ctx.params.projectId.toString()) : undefined;
|
||||
|
||||
@@ -14,8 +14,6 @@ import { PowerKSettingsMenu } from "@/components/power-k/menus/settings";
|
||||
import { WORKSPACE_SETTINGS_ICONS } from "@/components/settings/workspace/sidebar/item-icon";
|
||||
// hooks
|
||||
import { useUserPermissions } from "@/hooks/store/user";
|
||||
// plane web imports
|
||||
import { shouldRenderSettingLink } from "@/plane-web/helpers/workspace.helper";
|
||||
|
||||
type Props = {
|
||||
context: TPowerKContext;
|
||||
@@ -32,7 +30,6 @@ export const PowerKOpenWorkspaceSettingsMenu = observer(function PowerKOpenWorks
|
||||
const settingsList = Object.values(WORKSPACE_SETTINGS).filter(
|
||||
(setting) =>
|
||||
context.params.workspaceSlug &&
|
||||
shouldRenderSettingLink(context.params.workspaceSlug?.toString(), setting.key) &&
|
||||
allowPermissions(setting.access, EUserPermissionsLevel.WORKSPACE, context.params.workspaceSlug?.toString())
|
||||
);
|
||||
const settingsListWithIcons = settingsList.map((setting) => ({
|
||||
|
||||
@@ -24,8 +24,6 @@ import { useProject } from "@/hooks/store/use-project";
|
||||
import { useProjectState } from "@/hooks/store/use-project-state";
|
||||
import { useProjectView } from "@/hooks/store/use-project-view";
|
||||
import { useUser, useUserPermissions } from "@/hooks/store/user";
|
||||
// plane web imports
|
||||
import { getAdditionalProjectLevelFiltersHOCProps } from "@/plane-web/helpers/work-item-filters/project-level";
|
||||
// local imports
|
||||
import { WorkItemFiltersHOC } from "./base";
|
||||
import type { TEnableSaveViewProps, TEnableUpdateViewProps, TSharedWorkItemFiltersHOCProps } from "./shared";
|
||||
@@ -203,11 +201,7 @@ export const ProjectLevelWorkItemFiltersHOC = observer(function ProjectLevelWork
|
||||
/>
|
||||
<WorkItemFiltersHOC
|
||||
{...props}
|
||||
{...getAdditionalProjectLevelFiltersHOCProps({
|
||||
entityType: props.entityType,
|
||||
workspaceSlug,
|
||||
projectId,
|
||||
})}
|
||||
workspaceSlug={workspaceSlug}
|
||||
cycleIds={getProjectCycleIds(projectId) ?? undefined}
|
||||
labelIds={getProjectLabelIds(projectId)}
|
||||
memberIds={getProjectMemberIds(projectId, false) ?? undefined}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* See the LICENSE file for details.
|
||||
*/
|
||||
|
||||
import React, { Fragment, useState, useEffect } from "react";
|
||||
import { Fragment, useState, useEffect } from "react";
|
||||
import { observer } from "mobx-react";
|
||||
import Link from "next/link";
|
||||
// icons
|
||||
@@ -24,8 +24,7 @@ import { AppSidebarItem } from "@/components/sidebar/sidebar-item";
|
||||
import { useAppTheme } from "@/hooks/store/use-app-theme";
|
||||
import { useWorkspace } from "@/hooks/store/use-workspace";
|
||||
import { useUser, useUserProfile } from "@/hooks/store/user";
|
||||
// plane web helpers
|
||||
import { getIsWorkspaceCreationDisabled } from "@/plane-web/helpers/instance.helper";
|
||||
import { useInstance } from "@/hooks/store/use-instance";
|
||||
// components
|
||||
import { WorkspaceLogo } from "../logo";
|
||||
import SidebarDropdownItem from "./dropdown-item";
|
||||
@@ -38,12 +37,13 @@ export const WorkspaceMenuRoot = observer(function WorkspaceMenuRoot(props: Work
|
||||
const { variant } = props;
|
||||
// store hooks
|
||||
const { toggleSidebar, toggleAnySidebarDropdown } = useAppTheme();
|
||||
const { config } = useInstance();
|
||||
const { data: currentUser } = useUser();
|
||||
const { signOut } = useUser();
|
||||
const { updateUserProfile } = useUserProfile();
|
||||
const { currentWorkspace: activeWorkspace, workspaces } = useWorkspace();
|
||||
// derived values
|
||||
const isWorkspaceCreationEnabled = getIsWorkspaceCreationDisabled() === false;
|
||||
const isWorkspaceCreationDisabled = config?.is_workspace_creation_disabled ?? false;
|
||||
// translation
|
||||
const { t } = useTranslation();
|
||||
// local state
|
||||
@@ -187,7 +187,7 @@ export const WorkspaceMenuRoot = observer(function WorkspaceMenuRoot(props: Work
|
||||
)}
|
||||
</div>
|
||||
<div className="w-full flex flex-col items-start justify-start gap-2 px-4 py-2 text-13">
|
||||
{isWorkspaceCreationEnabled && (
|
||||
{!isWorkspaceCreationDisabled && (
|
||||
<Link href="/create-workspace" className="w-full">
|
||||
<Menu.Item
|
||||
as="div"
|
||||
|
||||
@@ -21,11 +21,6 @@ import type {
|
||||
TSupportedFilterForUpdate,
|
||||
} from "@plane/types";
|
||||
import { EIssuesStoreType } from "@plane/types";
|
||||
import {
|
||||
useTeamIssueActions,
|
||||
useTeamProjectWorkItemsActions,
|
||||
useTeamViewIssueActions,
|
||||
} from "@/plane-web/helpers/issue-action-helper";
|
||||
import { useIssues } from "./store/use-issues";
|
||||
|
||||
export interface IssueActions {
|
||||
@@ -50,28 +45,21 @@ export interface IssueActions {
|
||||
}
|
||||
|
||||
export const useIssuesActions = (storeType: EIssuesStoreType): IssueActions => {
|
||||
const teamIssueActions = useTeamIssueActions();
|
||||
const projectIssueActions = useProjectIssueActions();
|
||||
const projectEpicsActions = useProjectEpicsActions();
|
||||
const cycleIssueActions = useCycleIssueActions();
|
||||
const moduleIssueActions = useModuleIssueActions();
|
||||
const teamViewIssueActions = useTeamViewIssueActions();
|
||||
const projectViewIssueActions = useProjectViewIssueActions();
|
||||
const globalIssueActions = useGlobalIssueActions();
|
||||
const profileIssueActions = useProfileIssueActions();
|
||||
const archivedIssueActions = useArchivedIssueActions();
|
||||
const workspaceDraftIssueActions = useWorkspaceDraftIssueActions();
|
||||
const teamProjectWorkItemsActions = useTeamProjectWorkItemsActions();
|
||||
|
||||
switch (storeType) {
|
||||
case EIssuesStoreType.TEAM_VIEW:
|
||||
return teamViewIssueActions;
|
||||
case EIssuesStoreType.PROJECT_VIEW:
|
||||
return projectViewIssueActions;
|
||||
case EIssuesStoreType.PROFILE:
|
||||
return profileIssueActions;
|
||||
case EIssuesStoreType.TEAM:
|
||||
return teamIssueActions;
|
||||
case EIssuesStoreType.ARCHIVED:
|
||||
return archivedIssueActions;
|
||||
case EIssuesStoreType.CYCLE:
|
||||
@@ -85,8 +73,6 @@ export const useIssuesActions = (storeType: EIssuesStoreType): IssueActions => {
|
||||
return workspaceDraftIssueActions;
|
||||
case EIssuesStoreType.EPIC:
|
||||
return projectEpicsActions;
|
||||
case EIssuesStoreType.TEAM_PROJECT_WORK_ITEMS:
|
||||
return teamProjectWorkItemsActions;
|
||||
case EIssuesStoreType.PROJECT:
|
||||
default:
|
||||
return projectIssueActions;
|
||||
|
||||
@@ -9,22 +9,6 @@ import type { IIssueDisplayProperties } from "@plane/types";
|
||||
// lib
|
||||
import { store } from "@/lib/store-context";
|
||||
|
||||
export type TShouldRenderDisplayProperty = {
|
||||
workspaceSlug: string;
|
||||
projectId: string | undefined;
|
||||
key: keyof IIssueDisplayProperties;
|
||||
};
|
||||
|
||||
export const shouldRenderDisplayProperty = (props: TShouldRenderDisplayProperty) => {
|
||||
const { key } = props;
|
||||
switch (key) {
|
||||
case "issue_type":
|
||||
return false;
|
||||
default:
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
export const shouldRenderColumn = (key: keyof IIssueDisplayProperties): boolean => {
|
||||
const isEstimateEnabled: boolean = store.projectRoot.project.currentProjectDetails?.estimate !== null;
|
||||
switch (key) {
|
||||
@@ -15,6 +15,7 @@ const VIEW_ACCESS_ICONS = {
|
||||
[EViewAccess.PUBLIC]: GlobeIcon,
|
||||
[EViewAccess.PRIVATE]: LockIcon,
|
||||
};
|
||||
|
||||
export const VIEW_ACCESS_SPECIFIERS: {
|
||||
key: EViewAccess;
|
||||
i18n_label: string;
|
||||
|
||||
@@ -175,10 +175,6 @@ export const ISSUE_DISPLAY_PROPERTIES: {
|
||||
key: "key",
|
||||
titleTranslationKey: "issue.display.properties.id",
|
||||
},
|
||||
{
|
||||
key: "issue_type",
|
||||
titleTranslationKey: "issue.display.properties.issue_type",
|
||||
},
|
||||
{
|
||||
key: "assignee",
|
||||
titleTranslationKey: "common.assignee",
|
||||
|
||||
Reference in New Issue
Block a user