[WEB-3287]fix: label creation in global views (#6541)

* fix: label creation on enter

* fix: update label creation permissions

---------

Co-authored-by: sriram veeraghanta <veeraghanta.sriram@gmail.com>
This commit is contained in:
Vamsi Krishna
2025-02-10 19:35:04 +05:30
committed by GitHub
parent 8efe692c80
commit dff12729c0
2 changed files with 6 additions and 4 deletions

View File

@@ -36,7 +36,8 @@ export const IssueLabelSelect: React.FC<IIssueLabelSelect> = observer((props) =>
const [query, setQuery] = useState(""); const [query, setQuery] = useState("");
const [submitting, setSubmitting] = useState<boolean>(false); const [submitting, setSubmitting] = useState<boolean>(false);
const canCreateLabel = allowPermissions([EUserProjectRoles.ADMIN], EUserPermissionsLevel.PROJECT); const canCreateLabel =
projectId && allowPermissions([EUserPermissions.ADMIN], EUserPermissionsLevel.PROJECT, workspaceSlug, projectId);
const projectLabels = getProjectLabels(projectId); const projectLabels = getProjectLabels(projectId);
@@ -98,7 +99,7 @@ export const IssueLabelSelect: React.FC<IIssueLabelSelect> = observer((props) =>
setQuery(""); setQuery("");
} }
if (query !== "" && e.key === "Enter") { if (query !== "" && e.key === "Enter" && canCreateLabel) {
e.stopPropagation(); e.stopPropagation();
e.preventDefault(); e.preventDefault();
await handleAddLabel(query); await handleAddLabel(query);

View File

@@ -81,7 +81,8 @@ export const LabelDropdown = (props: ILabelDropdownProps) => {
const storeLabels = getProjectLabels(projectId); const storeLabels = getProjectLabels(projectId);
const { allowPermissions } = useUserPermissions(); const { allowPermissions } = useUserPermissions();
const canCreateLabel = allowPermissions([EUserProjectRoles.ADMIN], EUserPermissionsLevel.PROJECT); const canCreateLabel =
projectId && allowPermissions([EUserPermissions.ADMIN], EUserPermissionsLevel.PROJECT, workspaceSlug, projectId);
let projectLabels: IIssueLabel[] = defaultOptions; let projectLabels: IIssueLabel[] = defaultOptions;
if (storeLabels && storeLabels.length > 0) projectLabels = storeLabels; if (storeLabels && storeLabels.length > 0) projectLabels = storeLabels;
@@ -157,7 +158,7 @@ export const LabelDropdown = (props: ILabelDropdownProps) => {
setQuery(""); setQuery("");
} }
if (query !== "" && e.key === "Enter") { if (query !== "" && e.key === "Enter" && canCreateLabel) {
e.preventDefault(); e.preventDefault();
await handleAddLabel(query); await handleAddLabel(query);
} }