diff --git a/apps/console/src/__generated__/core/TrustCenterGraphQuery.graphql.ts b/apps/console/src/__generated__/core/TrustCenterGraphQuery.graphql.ts index d66066abf..17c19eb73 100644 --- a/apps/console/src/__generated__/core/TrustCenterGraphQuery.graphql.ts +++ b/apps/console/src/__generated__/core/TrustCenterGraphQuery.graphql.ts @@ -1,5 +1,5 @@ /** - * @generated SignedSource<<18ee21b1b07c34808fb34640fd0eee77>> + * @generated SignedSource<> * @lightSyntaxTransform * @nogrep */ @@ -810,7 +810,20 @@ return { "name": "showOnTrustCenter", "storageKey": null }, - (v6/*: any*/) + (v6/*: any*/), + { + "alias": "canUpdate", + "args": [ + { + "kind": "Literal", + "name": "action", + "value": "core:vendor:update" + } + ], + "kind": "ScalarField", + "name": "permission", + "storageKey": "permission(action:\"core:vendor:update\")" + } ], "storageKey": null } @@ -916,7 +929,7 @@ return { ] }, "params": { - "cacheID": "6af8bc39a3654fa715f0f235bcb5f488", + "cacheID": "0e95539cb6609d5698a7311262b81a99", "id": null, "metadata": { "connection": [ @@ -933,7 +946,7 @@ return { }, "name": "TrustCenterGraphQuery", "operationKind": "query", - "text": "query TrustCenterGraphQuery(\n $organizationId: ID!\n) {\n organization: node(id: $organizationId) {\n __typename\n ... on Organization {\n id\n name\n canCreateTrustCenterFile: permission(action: \"core:trust-center-file:create\")\n customDomain {\n id\n domain\n }\n trustCenter {\n id\n active\n ndaFileName\n ndaFileUrl\n createdAt\n updatedAt\n canUpdate: permission(action: \"core:trust-center:update\")\n canGetNDA: permission(action: \"core:trust-center:get-nda\")\n canUploadNDA: permission(action: \"core:trust-center:upload-nda\")\n canDeleteNDA: permission(action: \"core:trust-center:delete-nda\")\n canCreateReference: permission(action: \"core:trust-center-reference:create\")\n }\n documents(first: 100) {\n edges {\n node {\n id\n ...TrustCenterDocumentsCardFragment\n }\n }\n }\n audits(first: 100) {\n edges {\n node {\n id\n ...TrustCenterAuditsCardFragment\n }\n }\n }\n vendors(first: 100) {\n edges {\n node {\n id\n ...TrustCenterVendorsCardFragment\n }\n }\n }\n trustCenterFiles(first: 100) {\n edges {\n node {\n id\n ...TrustCenterFilesCardFragment\n __typename\n }\n cursor\n }\n pageInfo {\n endCursor\n hasNextPage\n }\n }\n slackConnections(first: 100) {\n edges {\n node {\n id\n channel\n channelId\n createdAt\n updatedAt\n }\n }\n }\n }\n id\n }\n}\n\nfragment TrustCenterAuditsCardFragment on Audit {\n id\n name\n framework {\n name\n id\n }\n validFrom\n validUntil\n state\n trustCenterVisibility\n createdAt\n}\n\nfragment TrustCenterDocumentsCardFragment on Document {\n id\n title\n createdAt\n documentType\n trustCenterVisibility\n versions(first: 1) {\n edges {\n node {\n id\n status\n }\n }\n }\n}\n\nfragment TrustCenterFilesCardFragment on TrustCenterFile {\n id\n name\n category\n fileUrl\n trustCenterVisibility\n createdAt\n updatedAt\n canUpdate: permission(action: \"core:trust-center-file:update\")\n canDelete: permission(action: \"core:trust-center-file:delete\")\n}\n\nfragment TrustCenterVendorsCardFragment on Vendor {\n id\n name\n category\n description\n showOnTrustCenter\n createdAt\n}\n" + "text": "query TrustCenterGraphQuery(\n $organizationId: ID!\n) {\n organization: node(id: $organizationId) {\n __typename\n ... on Organization {\n id\n name\n canCreateTrustCenterFile: permission(action: \"core:trust-center-file:create\")\n customDomain {\n id\n domain\n }\n trustCenter {\n id\n active\n ndaFileName\n ndaFileUrl\n createdAt\n updatedAt\n canUpdate: permission(action: \"core:trust-center:update\")\n canGetNDA: permission(action: \"core:trust-center:get-nda\")\n canUploadNDA: permission(action: \"core:trust-center:upload-nda\")\n canDeleteNDA: permission(action: \"core:trust-center:delete-nda\")\n canCreateReference: permission(action: \"core:trust-center-reference:create\")\n }\n documents(first: 100) {\n edges {\n node {\n id\n ...TrustCenterDocumentsCardFragment\n }\n }\n }\n audits(first: 100) {\n edges {\n node {\n id\n ...TrustCenterAuditsCardFragment\n }\n }\n }\n vendors(first: 100) {\n edges {\n node {\n id\n ...TrustCenterVendorsCardFragment\n }\n }\n }\n trustCenterFiles(first: 100) {\n edges {\n node {\n id\n ...TrustCenterFilesCardFragment\n __typename\n }\n cursor\n }\n pageInfo {\n endCursor\n hasNextPage\n }\n }\n slackConnections(first: 100) {\n edges {\n node {\n id\n channel\n channelId\n createdAt\n updatedAt\n }\n }\n }\n }\n id\n }\n}\n\nfragment TrustCenterAuditsCardFragment on Audit {\n id\n name\n framework {\n name\n id\n }\n validFrom\n validUntil\n state\n trustCenterVisibility\n createdAt\n}\n\nfragment TrustCenterDocumentsCardFragment on Document {\n id\n title\n createdAt\n documentType\n trustCenterVisibility\n versions(first: 1) {\n edges {\n node {\n id\n status\n }\n }\n }\n}\n\nfragment TrustCenterFilesCardFragment on TrustCenterFile {\n id\n name\n category\n fileUrl\n trustCenterVisibility\n createdAt\n updatedAt\n canUpdate: permission(action: \"core:trust-center-file:update\")\n canDelete: permission(action: \"core:trust-center-file:delete\")\n}\n\nfragment TrustCenterVendorsCardFragment on Vendor {\n id\n name\n category\n description\n showOnTrustCenter\n createdAt\n canUpdate: permission(action: \"core:vendor:update\")\n}\n" } }; })(); diff --git a/apps/console/src/__generated__/core/TrustCenterVendorGraphUpdateMutation.graphql.ts b/apps/console/src/__generated__/core/TrustCenterVendorGraphUpdateMutation.graphql.ts index 049ace17f..8e6ad5f65 100644 --- a/apps/console/src/__generated__/core/TrustCenterVendorGraphUpdateMutation.graphql.ts +++ b/apps/console/src/__generated__/core/TrustCenterVendorGraphUpdateMutation.graphql.ts @@ -1,5 +1,5 @@ /** - * @generated SignedSource<<567e11259c74ac403d44cad1a86c887d>> + * @generated SignedSource<> * @lightSyntaxTransform * @nogrep */ @@ -172,6 +172,19 @@ return { "kind": "ScalarField", "name": "createdAt", "storageKey": null + }, + { + "alias": "canUpdate", + "args": [ + { + "kind": "Literal", + "name": "action", + "value": "core:vendor:update" + } + ], + "kind": "ScalarField", + "name": "permission", + "storageKey": "permission(action:\"core:vendor:update\")" } ], "storageKey": null @@ -182,12 +195,12 @@ return { ] }, "params": { - "cacheID": "92823eef2e21ea731d8f37dbf9cd5da3", + "cacheID": "b2d05d661624daec04a081aebf2dd4e2", "id": null, "metadata": {}, "name": "TrustCenterVendorGraphUpdateMutation", "operationKind": "mutation", - "text": "mutation TrustCenterVendorGraphUpdateMutation(\n $input: UpdateVendorInput!\n) {\n updateVendor(input: $input) {\n vendor {\n id\n showOnTrustCenter\n ...TrustCenterVendorsCardFragment\n }\n }\n}\n\nfragment TrustCenterVendorsCardFragment on Vendor {\n id\n name\n category\n description\n showOnTrustCenter\n createdAt\n}\n" + "text": "mutation TrustCenterVendorGraphUpdateMutation(\n $input: UpdateVendorInput!\n) {\n updateVendor(input: $input) {\n vendor {\n id\n showOnTrustCenter\n ...TrustCenterVendorsCardFragment\n }\n }\n}\n\nfragment TrustCenterVendorsCardFragment on Vendor {\n id\n name\n category\n description\n showOnTrustCenter\n createdAt\n canUpdate: permission(action: \"core:vendor:update\")\n}\n" } }; })(); diff --git a/apps/console/src/__generated__/core/TrustCenterVendorsCardFragment.graphql.ts b/apps/console/src/__generated__/core/TrustCenterVendorsCardFragment.graphql.ts index 39dd28be8..c1e9b1f51 100644 --- a/apps/console/src/__generated__/core/TrustCenterVendorsCardFragment.graphql.ts +++ b/apps/console/src/__generated__/core/TrustCenterVendorsCardFragment.graphql.ts @@ -1,5 +1,5 @@ /** - * @generated SignedSource<> + * @generated SignedSource<<0584af25ba02b2b7138cc14ba4efc1b6>> * @lightSyntaxTransform * @nogrep */ @@ -12,6 +12,7 @@ import { ReaderFragment } from 'relay-runtime'; export type VendorCategory = "ANALYTICS" | "CLOUD_MONITORING" | "CLOUD_PROVIDER" | "COLLABORATION" | "CUSTOMER_SUPPORT" | "DATA_STORAGE_AND_PROCESSING" | "DOCUMENT_MANAGEMENT" | "EMPLOYEE_MANAGEMENT" | "ENGINEERING" | "FINANCE" | "IDENTITY_PROVIDER" | "IT" | "MARKETING" | "OFFICE_OPERATIONS" | "OTHER" | "PASSWORD_MANAGEMENT" | "PRODUCT_AND_DESIGN" | "PROFESSIONAL_SERVICES" | "RECRUITING" | "SALES" | "SECURITY" | "VERSION_CONTROL"; import { FragmentRefs } from "relay-runtime"; export type TrustCenterVendorsCardFragment$data = { + readonly canUpdate: boolean; readonly category: VendorCategory; readonly createdAt: any; readonly description: string | null | undefined; @@ -72,12 +73,25 @@ const node: ReaderFragment = { "kind": "ScalarField", "name": "createdAt", "storageKey": null + }, + { + "alias": "canUpdate", + "args": [ + { + "kind": "Literal", + "name": "action", + "value": "core:vendor:update" + } + ], + "kind": "ScalarField", + "name": "permission", + "storageKey": "permission(action:\"core:vendor:update\")" } ], "type": "Vendor", "abstractKey": null }; -(node as any).hash = "72b637589fd9299b5e982450fccbfd12"; +(node as any).hash = "bac8046182ce2402a5a20ce27a25f7e6"; export default node; diff --git a/apps/console/src/components/trustCenter/TrustCenterVendorsCard.tsx b/apps/console/src/components/trustCenter/TrustCenterVendorsCard.tsx index 57915895c..f88f9ca35 100644 --- a/apps/console/src/components/trustCenter/TrustCenterVendorsCard.tsx +++ b/apps/console/src/components/trustCenter/TrustCenterVendorsCard.tsx @@ -14,11 +14,10 @@ import { } from "@probo/ui"; import { useTranslate } from "@probo/i18n"; import { useFragment } from "react-relay"; -import { useMemo, useState, use } from "react"; +import { useMemo, useState } from "react"; import { sprintf } from "@probo/helpers"; import { useOrganizationId } from "/hooks/useOrganizationId"; import type { TrustCenterVendorsCardFragment$key } from "/__generated__/core/TrustCenterVendorsCardFragment.graphql"; -import { PermissionsContext } from "/providers/PermissionsContext"; const trustCenterVendorFragment = graphql` fragment TrustCenterVendorsCardFragment on Vendor { @@ -28,6 +27,7 @@ const trustCenterVendorFragment = graphql` description showOnTrustCenter createdAt + canUpdate: permission(action: "core:vendor:update") } `; @@ -50,8 +50,6 @@ type Props = { export function TrustCenterVendorsCard(props: Props) { const { __ } = useTranslate(); const [limit, setLimit] = useState(100); - const { isAuthorized } = use(PermissionsContext); - const canUpdate = isAuthorized("Vendor", "updateVendor"); const vendors = useMemo(() => { return limit ? props.vendors.slice(0, limit) : props.vendors; }, [props.vendors, limit]); @@ -77,16 +75,13 @@ export function TrustCenterVendorsCard(props: Props) { {__("Name")} {__("Category")} {__("Visibility")} - {canUpdate && } + {vendors.length === 0 && ( - + {__("No vendors available")} @@ -97,7 +92,6 @@ export function TrustCenterVendorsCard(props: Props) { vendor={vendor} onToggleVisibility={onToggleVisibility} disabled={props.disabled} - canUpdate={canUpdate} /> ))} @@ -120,7 +114,6 @@ function VendorRow(props: { vendor: TrustCenterVendorsCardFragment$key; onToggleVisibility: (vendorId: string, showOnTrustCenter: boolean) => void; disabled?: boolean; - canUpdate: boolean; }) { const vendor = useFragment(trustCenterVendorFragment, props.vendor); const organizationId = useOrganizationId(); @@ -139,8 +132,8 @@ function VendorRow(props: { {vendor.showOnTrustCenter ? __("Visible") : __("None")} - {props.canUpdate && ( - + + {vendor.canUpdate && ( - - )} + )} + ); }