Skip to content

Commit

Permalink
feat(api-headless-cms): make usePermission hook decoratable
Browse files Browse the repository at this point in the history
  • Loading branch information
Pavel910 committed Jun 13, 2024
1 parent 83cba97 commit 26c54ad
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/app-headless-cms/src/admin/hooks/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export * from "./useQueryLocale";
export { default as useLazyQuery } from "./useLazyQuery";
export { default as useMutation } from "./useMutation";
export { default as useApolloClient } from "./useApolloClient";
export { default as usePermission } from "./usePermission";
export { usePermission } from "./usePermission";
export { useModel } from "../components/ModelProvider";
export { useModelEditor } from "../components/ContentModelEditor";
export { useParentField, ParentFieldProvider } from "../components/ContentEntryForm/ParentValue";
Expand Down
6 changes: 4 additions & 2 deletions packages/app-headless-cms/src/admin/hooks/usePermission.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { useCallback, useMemo } from "react";
import { useSecurity } from "@webiny/app-security";
import { useI18N } from "@webiny/app-i18n/hooks/useI18N";
import { CmsGroup, CmsIdentity, CmsModel, CmsSecurityPermission } from "~/types";
import { makeDecoratable } from "@webiny/react-composition";

export interface CreatableItem {
createdBy?: Pick<CmsIdentity, "id">;
Expand All @@ -14,7 +15,7 @@ interface CanReadEntriesCallableParams {
contentModel: CmsModel;
}

export const usePermission = () => {
export const usePermission = makeDecoratable(() => {
const { identity, getIdentityId, getPermission, getPermissions } = useSecurity();
const { getCurrentLocale } = useI18N();

Expand Down Expand Up @@ -293,7 +294,8 @@ export const usePermission = () => {
canCreateContentModelGroups,
canAccessManageEndpoint
};
};
});

/**
* Default export is deprecated, use the named one.
* @deprecated
Expand Down

0 comments on commit 26c54ad

Please sign in to comment.