Skip to content

Commit

Permalink
Hide DAM "Dependents" tab based on permission (#3127)
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasdax98 authored Jan 16, 2025
1 parent 535afe0 commit 0837c4c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/eighty-cheetahs-burn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@comet/cms-admin": patch
---

Hide the "Dependents" tab in the DAM for users without the permission `dependencies`
4 changes: 3 additions & 1 deletion packages/admin/cms-admin/src/dam/FileForm/EditFile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import { useContentScope } from "../../contentScope/Provider";
import { useDependenciesConfig } from "../../dependencies/DependenciesConfig";
import { DependencyList } from "../../dependencies/DependencyList";
import { GQLFocalPoint, GQLImageCropAreaInput, GQLLicenseInput } from "../../graphql.generated";
import { useUserPermissionCheck } from "../../userPermissions/hooks/currentUser";
import { useDamConfig } from "../config/useDamConfig";
import { LicenseValidityTags } from "../DataGrid/tags/LicenseValidityTags";
import Duplicates from "./Duplicates";
Expand Down Expand Up @@ -115,6 +116,7 @@ const EditFileInner = ({ file, id, contentScopeIndicator }: EditFileInnerProps)
const intl = useIntl();
const damConfig = useDamConfig();
const apolloClient = useApolloClient();
const isAllowed = useUserPermissionCheck();

const onSubmit = useCallback(
async (values: EditFileFormValues) => {
Expand Down Expand Up @@ -244,7 +246,7 @@ const EditFileInner = ({ file, id, contentScopeIndicator }: EditFileInnerProps)
>
<Duplicates fileId={file.id} />
</RouterTab>
{Object.keys(dependencyMap).length > 0 && (
{isAllowed("dependencies") && Object.keys(dependencyMap).length > 0 && (
<RouterTab
key="dependents"
label={intl.formatMessage({ id: "comet.dam.file.dependents", defaultMessage: "Dependents" })}
Expand Down

0 comments on commit 0837c4c

Please sign in to comment.