Use resource alias mutations in compliance page
Update the compliance page alias field and list items to call the generic setResourceAlias and removeResourceAlias mutations instead of the trust-center-specific ones, and drop the now-removed audit alias field usage. Signed-off-by: Bryan Frimin <bryan@probo.com>
This commit is contained in:
@@ -19,12 +19,12 @@ import { graphql } from "relay-runtime";
|
||||
|
||||
import { useMutationWithToasts } from "#/hooks/useMutationWithToasts";
|
||||
|
||||
const setTrustCenterAliasMutation = graphql`
|
||||
mutation CompliancePageAliasField_setTrustCenterAliasMutation(
|
||||
$input: SetTrustCenterAliasInput!
|
||||
const setResourceAliasMutation = graphql`
|
||||
mutation CompliancePageAliasField_setResourceAliasMutation(
|
||||
$input: SetResourceAliasInput!
|
||||
) {
|
||||
setTrustCenterAlias(input: $input) {
|
||||
alias {
|
||||
setResourceAlias(input: $input) {
|
||||
resourceAlias {
|
||||
resourceId
|
||||
alias
|
||||
}
|
||||
@@ -32,11 +32,11 @@ const setTrustCenterAliasMutation = graphql`
|
||||
}
|
||||
`;
|
||||
|
||||
const removeTrustCenterAliasMutation = graphql`
|
||||
mutation CompliancePageAliasField_removeTrustCenterAliasMutation(
|
||||
$input: RemoveTrustCenterAliasInput!
|
||||
const removeResourceAliasMutation = graphql`
|
||||
mutation CompliancePageAliasField_removeResourceAliasMutation(
|
||||
$input: RemoveResourceAliasInput!
|
||||
) {
|
||||
removeTrustCenterAlias(input: $input) {
|
||||
removeResourceAlias(input: $input) {
|
||||
deletedResourceId
|
||||
}
|
||||
}
|
||||
@@ -57,15 +57,15 @@ export function CompliancePageAliasField(props: {
|
||||
setValue(alias ?? "");
|
||||
}, [alias]);
|
||||
|
||||
const [setTrustCenterAlias, isSettingAlias] = useMutationWithToasts(
|
||||
setTrustCenterAliasMutation,
|
||||
const [setResourceAlias, isSettingAlias] = useMutationWithToasts(
|
||||
setResourceAliasMutation,
|
||||
{
|
||||
successMessage: __("Alias updated successfully."),
|
||||
errorMessage: __("Failed to update alias"),
|
||||
},
|
||||
);
|
||||
const [removeTrustCenterAlias, isRemovingAlias] = useMutationWithToasts(
|
||||
removeTrustCenterAliasMutation,
|
||||
const [removeResourceAlias, isRemovingAlias] = useMutationWithToasts(
|
||||
removeResourceAliasMutation,
|
||||
{
|
||||
successMessage: __("Alias removed successfully."),
|
||||
errorMessage: __("Failed to remove alias"),
|
||||
@@ -83,7 +83,7 @@ export function CompliancePageAliasField(props: {
|
||||
try {
|
||||
if (trimmed === "") {
|
||||
if (current !== "" && canRemoveAlias) {
|
||||
await removeTrustCenterAlias({
|
||||
await removeResourceAlias({
|
||||
variables: {
|
||||
input: {
|
||||
resourceId,
|
||||
@@ -100,7 +100,7 @@ export function CompliancePageAliasField(props: {
|
||||
return;
|
||||
}
|
||||
|
||||
await setTrustCenterAlias({
|
||||
await setResourceAlias({
|
||||
variables: {
|
||||
input: {
|
||||
resourceId,
|
||||
@@ -111,7 +111,7 @@ export function CompliancePageAliasField(props: {
|
||||
} catch {
|
||||
// useMutationWithToasts already shows an error toast.
|
||||
}
|
||||
}, [alias, canRemoveAlias, canSetAlias, removeTrustCenterAlias, resourceId, setTrustCenterAlias, value]);
|
||||
}, [alias, canRemoveAlias, canSetAlias, removeResourceAlias, resourceId, setResourceAlias, value]);
|
||||
|
||||
const canEdit = canSetAlias || (canRemoveAlias && (alias ?? "") !== "");
|
||||
|
||||
|
||||
@@ -53,14 +53,13 @@ export function CompliancePageAuditList(props: { fragmentRef: CompliancePageAudi
|
||||
<Th>{__("Name")}</Th>
|
||||
<Th>{__("Valid Until")}</Th>
|
||||
<Th>{__("State")}</Th>
|
||||
<Th>{__("Alias")}</Th>
|
||||
<Th>{__("Visibility")}</Th>
|
||||
</Tr>
|
||||
</Thead>
|
||||
<Tbody>
|
||||
{audits.edges.length === 0 && (
|
||||
<Tr>
|
||||
<Td colSpan={6} className="text-center text-txt-secondary">
|
||||
<Td colSpan={5} className="text-center text-txt-secondary">
|
||||
{__("No audits available")}
|
||||
</Td>
|
||||
</Tr>
|
||||
|
||||
@@ -25,8 +25,6 @@ import type { CompliancePageAuditListItem_updateAuditVisibilityMutation } from "
|
||||
import { useMutationWithToasts } from "#/hooks/useMutationWithToasts";
|
||||
import { useOrganizationId } from "#/hooks/useOrganizationId";
|
||||
|
||||
import { CompliancePageAliasField } from "../../_components/CompliancePageAliasField";
|
||||
|
||||
const compliancePageFragment = graphql`
|
||||
fragment CompliancePageAuditListItem_compliancePageFragment on TrustCenter {
|
||||
canUpdate: permission(action: "core:trust-center:update")
|
||||
@@ -37,9 +35,6 @@ const auditFragment = graphql`
|
||||
fragment CompliancePageAuditListItem_auditFragment on Audit {
|
||||
id
|
||||
name
|
||||
alias
|
||||
canSetAlias: permission(action: "core:trust-center-alias:set")
|
||||
canRemoveAlias: permission(action: "core:trust-center-alias:remove")
|
||||
framework {
|
||||
name
|
||||
}
|
||||
@@ -116,14 +111,6 @@ export function CompliancePageAuditListItem(props: {
|
||||
{getAuditStateLabel(__, audit.state)}
|
||||
</Badge>
|
||||
</Td>
|
||||
<Td noLink>
|
||||
<CompliancePageAliasField
|
||||
resourceId={audit.id}
|
||||
alias={audit.alias}
|
||||
canSetAlias={audit.canSetAlias}
|
||||
canRemoveAlias={audit.canRemoveAlias}
|
||||
/>
|
||||
</Td>
|
||||
<Td noLink width={130} className="pr-0">
|
||||
<Field
|
||||
type="select"
|
||||
|
||||
@@ -36,8 +36,8 @@ const documentFragment = graphql`
|
||||
fragment CompliancePageDocumentListItem_documentFragment on Document {
|
||||
id
|
||||
alias
|
||||
canSetAlias: permission(action: "core:trust-center-alias:set")
|
||||
canRemoveAlias: permission(action: "core:trust-center-alias:remove")
|
||||
canSetAlias: permission(action: "resourcealias:alias:set")
|
||||
canRemoveAlias: permission(action: "resourcealias:alias:remove")
|
||||
trustCenterVisibility
|
||||
latestPublishedVersion: versions(
|
||||
first: 1
|
||||
|
||||
@@ -37,8 +37,8 @@ const fileFragment = graphql`
|
||||
id
|
||||
name
|
||||
alias
|
||||
canSetAlias: permission(action: "core:trust-center-alias:set")
|
||||
canRemoveAlias: permission(action: "core:trust-center-alias:remove")
|
||||
canSetAlias: permission(action: "resourcealias:alias:set")
|
||||
canRemoveAlias: permission(action: "resourcealias:alias:remove")
|
||||
category
|
||||
file {
|
||||
downloadUrl
|
||||
|
||||
Reference in New Issue
Block a user