forked from github/plane
chore: issue layout quick add issue button permission validation
This commit is contained in:
parent
361ee16567
commit
43cbe44a35
@ -27,11 +27,21 @@ type Props = {
|
|||||||
viewId?: string
|
viewId?: string
|
||||||
) => Promise<IIssue | undefined>;
|
) => Promise<IIssue | undefined>;
|
||||||
viewId?: string;
|
viewId?: string;
|
||||||
|
disableIssueCreation?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const IssueGanttSidebar: React.FC<Props> = (props) => {
|
export const IssueGanttSidebar: React.FC<Props> = (props) => {
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||||
const { title, blockUpdateHandler, blocks, enableReorder, enableQuickIssueCreate, quickAddCallback, viewId } = props;
|
const {
|
||||||
|
title,
|
||||||
|
blockUpdateHandler,
|
||||||
|
blocks,
|
||||||
|
enableReorder,
|
||||||
|
enableQuickIssueCreate,
|
||||||
|
quickAddCallback,
|
||||||
|
viewId,
|
||||||
|
disableIssueCreation,
|
||||||
|
} = props;
|
||||||
|
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const { cycleId } = router.query;
|
const { cycleId } = router.query;
|
||||||
@ -160,7 +170,7 @@ export const IssueGanttSidebar: React.FC<Props> = (props) => {
|
|||||||
)}
|
)}
|
||||||
{droppableProvided.placeholder}
|
{droppableProvided.placeholder}
|
||||||
</>
|
</>
|
||||||
{enableQuickIssueCreate && (
|
{enableQuickIssueCreate && !disableIssueCreation && (
|
||||||
<GanttInlineCreateIssueForm quickAddCallback={quickAddCallback} viewId={viewId} />
|
<GanttInlineCreateIssueForm quickAddCallback={quickAddCallback} viewId={viewId} />
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
@ -16,6 +16,8 @@ import {
|
|||||||
IProjectIssuesFilterStore,
|
IProjectIssuesFilterStore,
|
||||||
IViewIssuesFilterStore,
|
IViewIssuesFilterStore,
|
||||||
} from "store/issues";
|
} from "store/issues";
|
||||||
|
// constants
|
||||||
|
import { EUserWorkspaceRoles } from "constants/workspace";
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
issuesFilterStore:
|
issuesFilterStore:
|
||||||
@ -41,7 +43,14 @@ export const CalendarChart: React.FC<Props> = observer((props) => {
|
|||||||
const { issuesFilterStore, issues, groupedIssueIds, layout, showWeekends, quickActions, quickAddCallback, viewId } =
|
const { issuesFilterStore, issues, groupedIssueIds, layout, showWeekends, quickActions, quickAddCallback, viewId } =
|
||||||
props;
|
props;
|
||||||
|
|
||||||
const { calendar: calendarStore } = useMobxStore();
|
const {
|
||||||
|
calendar: calendarStore,
|
||||||
|
projectIssues: issueStore,
|
||||||
|
user: { currentProjectRole },
|
||||||
|
} = useMobxStore();
|
||||||
|
|
||||||
|
const { enableIssueCreation } = issueStore?.viewFlags || {};
|
||||||
|
const isEditingAllowed = !!currentProjectRole && currentProjectRole >= EUserWorkspaceRoles.MEMBER;
|
||||||
|
|
||||||
const calendarPayload = calendarStore.calendarPayload;
|
const calendarPayload = calendarStore.calendarPayload;
|
||||||
|
|
||||||
@ -71,6 +80,7 @@ export const CalendarChart: React.FC<Props> = observer((props) => {
|
|||||||
issues={issues}
|
issues={issues}
|
||||||
groupedIssueIds={groupedIssueIds}
|
groupedIssueIds={groupedIssueIds}
|
||||||
enableQuickIssueCreate
|
enableQuickIssueCreate
|
||||||
|
disableIssueCreation={!enableIssueCreation || !isEditingAllowed}
|
||||||
quickActions={quickActions}
|
quickActions={quickActions}
|
||||||
quickAddCallback={quickAddCallback}
|
quickAddCallback={quickAddCallback}
|
||||||
viewId={viewId}
|
viewId={viewId}
|
||||||
@ -85,6 +95,7 @@ export const CalendarChart: React.FC<Props> = observer((props) => {
|
|||||||
issues={issues}
|
issues={issues}
|
||||||
groupedIssueIds={groupedIssueIds}
|
groupedIssueIds={groupedIssueIds}
|
||||||
enableQuickIssueCreate
|
enableQuickIssueCreate
|
||||||
|
disableIssueCreation={!enableIssueCreation || !isEditingAllowed}
|
||||||
quickActions={quickActions}
|
quickActions={quickActions}
|
||||||
quickAddCallback={quickAddCallback}
|
quickAddCallback={quickAddCallback}
|
||||||
viewId={viewId}
|
viewId={viewId}
|
||||||
|
@ -26,6 +26,7 @@ type Props = {
|
|||||||
groupedIssueIds: IGroupedIssues;
|
groupedIssueIds: IGroupedIssues;
|
||||||
quickActions: (issue: IIssue, customActionButton?: React.ReactElement) => React.ReactNode;
|
quickActions: (issue: IIssue, customActionButton?: React.ReactElement) => React.ReactNode;
|
||||||
enableQuickIssueCreate?: boolean;
|
enableQuickIssueCreate?: boolean;
|
||||||
|
disableIssueCreation?: boolean;
|
||||||
quickAddCallback?: (
|
quickAddCallback?: (
|
||||||
workspaceSlug: string,
|
workspaceSlug: string,
|
||||||
projectId: string,
|
projectId: string,
|
||||||
@ -43,6 +44,7 @@ export const CalendarDayTile: React.FC<Props> = observer((props) => {
|
|||||||
groupedIssueIds,
|
groupedIssueIds,
|
||||||
quickActions,
|
quickActions,
|
||||||
enableQuickIssueCreate,
|
enableQuickIssueCreate,
|
||||||
|
disableIssueCreation,
|
||||||
quickAddCallback,
|
quickAddCallback,
|
||||||
viewId,
|
viewId,
|
||||||
} = props;
|
} = props;
|
||||||
@ -86,7 +88,7 @@ export const CalendarDayTile: React.FC<Props> = observer((props) => {
|
|||||||
ref={provided.innerRef}
|
ref={provided.innerRef}
|
||||||
>
|
>
|
||||||
<CalendarIssueBlocks issues={issues} issueIdList={issueIdList} quickActions={quickActions} />
|
<CalendarIssueBlocks issues={issues} issueIdList={issueIdList} quickActions={quickActions} />
|
||||||
{enableQuickIssueCreate && (
|
{enableQuickIssueCreate && !disableIssueCreation && (
|
||||||
<div className="px-2 py-1">
|
<div className="px-2 py-1">
|
||||||
<CalendarQuickAddIssueForm
|
<CalendarQuickAddIssueForm
|
||||||
formKey="target_date"
|
formKey="target_date"
|
||||||
|
@ -25,6 +25,7 @@ type Props = {
|
|||||||
week: ICalendarWeek | undefined;
|
week: ICalendarWeek | undefined;
|
||||||
quickActions: (issue: IIssue, customActionButton?: React.ReactElement) => React.ReactNode;
|
quickActions: (issue: IIssue, customActionButton?: React.ReactElement) => React.ReactNode;
|
||||||
enableQuickIssueCreate?: boolean;
|
enableQuickIssueCreate?: boolean;
|
||||||
|
disableIssueCreation?: boolean;
|
||||||
quickAddCallback?: (
|
quickAddCallback?: (
|
||||||
workspaceSlug: string,
|
workspaceSlug: string,
|
||||||
projectId: string,
|
projectId: string,
|
||||||
@ -42,6 +43,7 @@ export const CalendarWeekDays: React.FC<Props> = observer((props) => {
|
|||||||
week,
|
week,
|
||||||
quickActions,
|
quickActions,
|
||||||
enableQuickIssueCreate,
|
enableQuickIssueCreate,
|
||||||
|
disableIssueCreation,
|
||||||
quickAddCallback,
|
quickAddCallback,
|
||||||
viewId,
|
viewId,
|
||||||
} = props;
|
} = props;
|
||||||
@ -69,6 +71,7 @@ export const CalendarWeekDays: React.FC<Props> = observer((props) => {
|
|||||||
groupedIssueIds={groupedIssueIds}
|
groupedIssueIds={groupedIssueIds}
|
||||||
quickActions={quickActions}
|
quickActions={quickActions}
|
||||||
enableQuickIssueCreate={enableQuickIssueCreate}
|
enableQuickIssueCreate={enableQuickIssueCreate}
|
||||||
|
disableIssueCreation={disableIssueCreation}
|
||||||
quickAddCallback={quickAddCallback}
|
quickAddCallback={quickAddCallback}
|
||||||
viewId={viewId}
|
viewId={viewId}
|
||||||
/>
|
/>
|
||||||
|
@ -51,6 +51,7 @@ export const BaseGanttRoot: React.FC<IBaseGanttRoot> = observer((props: IBaseGan
|
|||||||
|
|
||||||
const issuesResponse = issueStore.getIssues;
|
const issuesResponse = issueStore.getIssues;
|
||||||
const issueIds = (issueStore.getIssuesIds ?? []) as TUnGroupedIssues;
|
const issueIds = (issueStore.getIssuesIds ?? []) as TUnGroupedIssues;
|
||||||
|
const { enableIssueCreation } = issueStore?.viewFlags || {};
|
||||||
|
|
||||||
const issues = issueIds.map((id) => issuesResponse?.[id]);
|
const issues = issueIds.map((id) => issuesResponse?.[id]);
|
||||||
|
|
||||||
@ -87,6 +88,7 @@ export const BaseGanttRoot: React.FC<IBaseGanttRoot> = observer((props: IBaseGan
|
|||||||
quickAddCallback={issueStore.quickAddIssue}
|
quickAddCallback={issueStore.quickAddIssue}
|
||||||
viewId={viewId}
|
viewId={viewId}
|
||||||
enableQuickIssueCreate
|
enableQuickIssueCreate
|
||||||
|
disableIssueCreation={!enableIssueCreation || !isAllowed}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
enableBlockLeftResize={isAllowed}
|
enableBlockLeftResize={isAllowed}
|
||||||
|
@ -330,7 +330,7 @@ export const BaseKanBanRoot: React.FC<IBaseKanBanLayout> = observer((props: IBas
|
|||||||
projects={workspaceProjects}
|
projects={workspaceProjects}
|
||||||
showEmptyGroup={userDisplayFilters?.show_empty_groups || true}
|
showEmptyGroup={userDisplayFilters?.show_empty_groups || true}
|
||||||
isDragStarted={isDragStarted}
|
isDragStarted={isDragStarted}
|
||||||
disableIssueCreation={true}
|
disableIssueCreation={!enableIssueCreation || !isEditingAllowed}
|
||||||
enableQuickIssueCreate={enableQuickAdd}
|
enableQuickIssueCreate={enableQuickAdd}
|
||||||
currentStore={currentStore}
|
currentStore={currentStore}
|
||||||
quickAddCallback={issueStore?.quickAddIssue}
|
quickAddCallback={issueStore?.quickAddIssue}
|
||||||
|
@ -149,7 +149,7 @@ const GroupByKanBan: React.FC<IGroupByKanBan> = observer((props) => {
|
|||||||
</Droppable>
|
</Droppable>
|
||||||
|
|
||||||
<div className="sticky bottom-0 z-[0] w-full flex-shrink-0 bg-custom-background-90 py-1">
|
<div className="sticky bottom-0 z-[0] w-full flex-shrink-0 bg-custom-background-90 py-1">
|
||||||
{enableQuickIssueCreate && (
|
{enableQuickIssueCreate && !disableIssueCreation && (
|
||||||
<KanBanQuickAddIssueForm
|
<KanBanQuickAddIssueForm
|
||||||
formKey="name"
|
formKey="name"
|
||||||
groupId={getValueFromObject(_list, listKey) as string}
|
groupId={getValueFromObject(_list, listKey) as string}
|
||||||
|
@ -109,7 +109,7 @@ const GroupByList: React.FC<IGroupByList> = (props) => {
|
|||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{enableIssueQuickAdd && (
|
{enableIssueQuickAdd && !disableIssueCreation && (
|
||||||
<div className="sticky bottom-0 z-[1] w-full flex-shrink-0">
|
<div className="sticky bottom-0 z-[1] w-full flex-shrink-0">
|
||||||
<ListQuickAddIssueForm
|
<ListQuickAddIssueForm
|
||||||
prePopulatedData={prePopulateQuickAddData(group_by, getValueFromObject(_list, listKey))}
|
prePopulatedData={prePopulateQuickAddData(group_by, getValueFromObject(_list, listKey))}
|
||||||
|
@ -50,7 +50,7 @@ export const BaseSpreadsheetRoot = observer((props: IBaseSpreadsheetRoot) => {
|
|||||||
user: userStore,
|
user: userStore,
|
||||||
} = useMobxStore();
|
} = useMobxStore();
|
||||||
|
|
||||||
const { enableInlineEditing, enableQuickAdd } = issueStore?.viewFlags || {};
|
const { enableInlineEditing, enableQuickAdd, enableIssueCreation } = issueStore?.viewFlags || {};
|
||||||
|
|
||||||
const { currentProjectRole } = userStore;
|
const { currentProjectRole } = userStore;
|
||||||
const isEditingAllowed = !!currentProjectRole && currentProjectRole >= EUserWorkspaceRoles.MEMBER;
|
const isEditingAllowed = !!currentProjectRole && currentProjectRole >= EUserWorkspaceRoles.MEMBER;
|
||||||
@ -120,6 +120,7 @@ export const BaseSpreadsheetRoot = observer((props: IBaseSpreadsheetRoot) => {
|
|||||||
quickAddCallback={issueStore.quickAddIssue}
|
quickAddCallback={issueStore.quickAddIssue}
|
||||||
viewId={viewId}
|
viewId={viewId}
|
||||||
enableQuickCreateIssue={enableQuickAdd}
|
enableQuickCreateIssue={enableQuickAdd}
|
||||||
|
disableIssueCreation={!enableIssueCreation || !isEditingAllowed}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
@ -33,6 +33,7 @@ type Props = {
|
|||||||
viewId?: string;
|
viewId?: string;
|
||||||
canEditProperties: (projectId: string | undefined) => boolean;
|
canEditProperties: (projectId: string | undefined) => boolean;
|
||||||
enableQuickCreateIssue?: boolean;
|
enableQuickCreateIssue?: boolean;
|
||||||
|
disableIssueCreation?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const SpreadsheetView: React.FC<Props> = observer((props) => {
|
export const SpreadsheetView: React.FC<Props> = observer((props) => {
|
||||||
@ -50,6 +51,7 @@ export const SpreadsheetView: React.FC<Props> = observer((props) => {
|
|||||||
viewId,
|
viewId,
|
||||||
canEditProperties,
|
canEditProperties,
|
||||||
enableQuickCreateIssue,
|
enableQuickCreateIssue,
|
||||||
|
disableIssueCreation,
|
||||||
} = props;
|
} = props;
|
||||||
// states
|
// states
|
||||||
const [expandedIssues, setExpandedIssues] = useState<string[]>([]);
|
const [expandedIssues, setExpandedIssues] = useState<string[]>([]);
|
||||||
@ -147,7 +149,7 @@ export const SpreadsheetView: React.FC<Props> = observer((props) => {
|
|||||||
|
|
||||||
<div className="border-t border-custom-border-100">
|
<div className="border-t border-custom-border-100">
|
||||||
<div className="z-5 sticky bottom-0 left-0 mb-3">
|
<div className="z-5 sticky bottom-0 left-0 mb-3">
|
||||||
{enableQuickCreateIssue && (
|
{enableQuickCreateIssue && !disableIssueCreation && (
|
||||||
<SpreadsheetQuickAddIssueForm formKey="name" quickAddCallback={quickAddCallback} viewId={viewId} />
|
<SpreadsheetQuickAddIssueForm formKey="name" quickAddCallback={quickAddCallback} viewId={viewId} />
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user