fix: issue detail widget user role permission added (#5131)

This commit is contained in:
Anmol Singh Bhatia 2024-07-16 15:57:14 +05:30 committed by GitHub
parent 5464e62a03
commit f2733ab4df
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 37 additions and 17 deletions

View file

@ -23,30 +23,35 @@ export const IssueDetailWidgetActionButtons: FC<Props> = (props) => {
<div className="flex items-center flex-wrap gap-2">
<SubIssuesActionButton
issueId={issueId}
disabled={disabled}
customButton={
<IssueDetailWidgetButton
title="Add sub-issues"
icon={<Layers className="h-3.5 w-3.5 flex-shrink-0 text-custom-text-300" strokeWidth={2} />}
icon={<Layers className="h-3.5 w-3.5 flex-shrink-0" strokeWidth={2} />}
disabled={disabled}
/>
}
disabled={disabled}
/>
<RelationActionButton
issueId={issueId}
customButton={
<IssueDetailWidgetButton
title="Add Relation"
icon={<Waypoints className="h-3.5 w-3.5 flex-shrink-0 text-custom-text-300" strokeWidth={2} />}
icon={<Waypoints className="h-3.5 w-3.5 flex-shrink-0" strokeWidth={2} />}
disabled={disabled}
/>
}
disabled={disabled}
/>
<IssueLinksActionButton
customButton={
<IssueDetailWidgetButton
title="Add Links"
icon={<Link className="h-3.5 w-3.5 flex-shrink-0 text-custom-text-300" strokeWidth={2} />}
icon={<Link className="h-3.5 w-3.5 flex-shrink-0" strokeWidth={2} />}
disabled={disabled}
/>
}
disabled={disabled}
/>
<IssueAttachmentActionButton
workspaceSlug={workspaceSlug}
@ -55,9 +60,11 @@ export const IssueDetailWidgetActionButtons: FC<Props> = (props) => {
customButton={
<IssueDetailWidgetButton
title="Attach"
icon={<Paperclip className="h-3.5 w-3.5 flex-shrink-0 text-custom-text-300" strokeWidth={2} />}
icon={<Paperclip className="h-3.5 w-3.5 flex-shrink-0" strokeWidth={2} />}
disabled={disabled}
/>
}
disabled={disabled}
/>
</div>
);

View file

@ -42,12 +42,14 @@ export const IssueAttachmentsCollapsibleTitle: FC<Props> = observer((props) => {
title="Attachments"
indicatorElement={indicatorElement}
actionItemElement={
<IssueAttachmentActionButton
workspaceSlug={workspaceSlug}
projectId={projectId}
issueId={issueId}
disabled={disabled}
/>
!disabled && (
<IssueAttachmentActionButton
workspaceSlug={workspaceSlug}
projectId={projectId}
issueId={issueId}
disabled={disabled}
/>
)
}
/>
);

View file

@ -40,7 +40,7 @@ export const IssueLinksCollapsibleTitle: FC<Props> = observer((props) => {
isOpen={isOpen}
title="Links"
indicatorElement={indicatorElement}
actionItemElement={<IssueLinksActionButton disabled={disabled} />}
actionItemElement={!disabled && <IssueLinksActionButton disabled={disabled} />}
/>
);
});

View file

@ -39,7 +39,7 @@ export const RelationsCollapsibleTitle: FC<Props> = observer((props) => {
isOpen={isOpen}
title="Relations"
indicatorElement={indicatorElement}
actionItemElement={<RelationActionButton issueId={issueId} disabled={disabled} />}
actionItemElement={!disabled && <RelationActionButton issueId={issueId} disabled={disabled} />}
/>
);
});

View file

@ -50,7 +50,7 @@ export const SubIssuesCollapsibleTitle: FC<Props> = observer((props) => {
isOpen={isOpen}
title="Sub-issues"
indicatorElement={indicatorElement}
actionItemElement={<SubIssuesActionButton issueId={parentIssueId} disabled={disabled} />}
actionItemElement={!disabled && <SubIssuesActionButton issueId={parentIssueId} disabled={disabled} />}
/>
);
});

View file

@ -1,17 +1,28 @@
"use client";
import React, { FC } from "react";
// helpers
import { cn } from "@/helpers/common.helper";
type Props = {
icon: JSX.Element;
title: string;
disabled?: boolean;
};
export const IssueDetailWidgetButton: FC<Props> = (props) => {
const { icon, title } = props;
const { icon, title, disabled = false } = props;
return (
<div className="h-full w-min whitespace-nowrap flex items-center gap-2 border border-custom-border-200 hover:bg-custom-background-80 rounded px-3 py-1.5">
<div
className={cn(
"h-full w-min whitespace-nowrap flex items-center gap-2 border border-custom-border-200 rounded px-3 py-1.5",
{
"cursor-not-allowed text-custom-text-400 bg-custom-background-90": disabled,
"cursor-pointer text-custom-text-300 hover:bg-custom-background-80": !disabled,
}
)}
>
{icon && icon}
<span className="text-sm font-medium text-custom-text-300">{title}</span>
<span className="text-sm font-medium">{title}</span>
</div>
);
};