Fix trust center references tab permissions handling
Signed-off-by: Émile Ré <nemile.re@gmail.com>
This commit is contained in:
@@ -26,22 +26,9 @@ export const trustCenterQuery = graphql`
|
||||
canGetNDA: permission(action: "core:trust-center:get-nda")
|
||||
canUploadNDA: permission(action: "core:trust-center:upload-nda")
|
||||
canDeleteNDA: permission(action: "core:trust-center:delete-nda")
|
||||
references(
|
||||
first: 100
|
||||
orderBy: { field: CREATED_AT, direction: DESC }
|
||||
) {
|
||||
edges {
|
||||
node {
|
||||
id
|
||||
name
|
||||
description
|
||||
websiteUrl
|
||||
logoUrl
|
||||
createdAt
|
||||
updatedAt
|
||||
}
|
||||
}
|
||||
}
|
||||
canCreateReference: permission(
|
||||
action: "core:trust-center-reference:create"
|
||||
)
|
||||
}
|
||||
documents(first: 100) {
|
||||
edges {
|
||||
|
||||
@@ -1,10 +1,5 @@
|
||||
import { graphql } from "react-relay";
|
||||
import { useLazyLoadQuery } from "react-relay";
|
||||
import { useMutationWithToasts } from "/hooks/useMutationWithToasts";
|
||||
import type {
|
||||
TrustCenterReferenceGraphQuery,
|
||||
TrustCenterReferenceGraphQuery$data,
|
||||
} from "/__generated__/core/TrustCenterReferenceGraphQuery.graphql";
|
||||
import type { TrustCenterReferenceGraphCreateMutation } from "/__generated__/core/TrustCenterReferenceGraphCreateMutation.graphql";
|
||||
import type { TrustCenterReferenceGraphUpdateMutation } from "/__generated__/core/TrustCenterReferenceGraphUpdateMutation.graphql";
|
||||
import type { TrustCenterReferenceGraphUpdateRankMutation } from "/__generated__/core/TrustCenterReferenceGraphUpdateRankMutation.graphql";
|
||||
@@ -13,10 +8,12 @@ import type { TrustCenterReferenceGraphDeleteMutation } from "/__generated__/cor
|
||||
export const trustCenterReferencesQuery = graphql`
|
||||
query TrustCenterReferenceGraphQuery($trustCenterId: ID!) {
|
||||
node(id: $trustCenterId) {
|
||||
__typename
|
||||
... on TrustCenter {
|
||||
id
|
||||
references(first: 100, orderBy: { field: RANK, direction: ASC })
|
||||
@connection(key: "TrustCenterReferencesSection_references") {
|
||||
@connection(key: "TrustCenterReferencesSection_references")
|
||||
@required(action: THROW) {
|
||||
__id
|
||||
pageInfo {
|
||||
hasNextPage
|
||||
@@ -24,7 +21,7 @@ export const trustCenterReferencesQuery = graphql`
|
||||
startCursor
|
||||
endCursor
|
||||
}
|
||||
edges {
|
||||
edges @required(action: THROW) {
|
||||
cursor
|
||||
node {
|
||||
id
|
||||
@@ -35,6 +32,12 @@ export const trustCenterReferencesQuery = graphql`
|
||||
rank
|
||||
createdAt
|
||||
updatedAt
|
||||
canUpdate: permission(
|
||||
action: "core:trust-center-reference:update"
|
||||
)
|
||||
canDelete: permission(
|
||||
action: "core:trust-center-reference:delete"
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -60,6 +63,8 @@ export const createTrustCenterReferenceMutation = graphql`
|
||||
rank
|
||||
createdAt
|
||||
updatedAt
|
||||
canUpdate: permission(action: "core:trust-center-reference:update")
|
||||
canDelete: permission(action: "core:trust-center-reference:delete")
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -80,6 +85,8 @@ export const updateTrustCenterReferenceMutation = graphql`
|
||||
rank
|
||||
createdAt
|
||||
updatedAt
|
||||
canUpdate: permission(action: "core:trust-center-reference:update")
|
||||
canDelete: permission(action: "core:trust-center-reference:delete")
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -96,19 +103,6 @@ export const deleteTrustCenterReferenceMutation = graphql`
|
||||
}
|
||||
`;
|
||||
|
||||
export function useTrustCenterReferences(
|
||||
trustCenterId: string,
|
||||
refetchKey = 0,
|
||||
): TrustCenterReferenceGraphQuery$data | null {
|
||||
const data = useLazyLoadQuery<TrustCenterReferenceGraphQuery>(
|
||||
trustCenterReferencesQuery,
|
||||
{ trustCenterId: trustCenterId || "" },
|
||||
{ fetchPolicy: "network-only", fetchKey: refetchKey },
|
||||
);
|
||||
|
||||
return trustCenterId ? data : null;
|
||||
}
|
||||
|
||||
export function useCreateTrustCenterReferenceMutation() {
|
||||
return useMutationWithToasts<TrustCenterReferenceGraphCreateMutation>(
|
||||
createTrustCenterReferenceMutation,
|
||||
|
||||
Reference in New Issue
Block a user