Fix no link button when list is empty
Signed-off-by: Bryan Frimin <bryan@getprobo.com>
This commit is contained in:
committed by
Sacha Al Himdani
parent
06aa781bb2
commit
ad1998a540
@@ -17,6 +17,12 @@ export const controlsFragment = graphql`
|
||||
)
|
||||
@refetchable(queryName: "MeasureControlsTabControlsQuery") {
|
||||
id
|
||||
canCreateControlMeasureMapping: permission(
|
||||
action: "core:control:create-measure-mapping"
|
||||
)
|
||||
canDeleteControlMeasureMapping: permission(
|
||||
action: "core:control:delete-measure-mapping"
|
||||
)
|
||||
controls(
|
||||
first: $first
|
||||
after: $after
|
||||
@@ -29,12 +35,6 @@ export const controlsFragment = graphql`
|
||||
edges {
|
||||
node {
|
||||
id
|
||||
canCreateMeasureMapping: permission(
|
||||
action: "core:control:create-measure-mapping"
|
||||
)
|
||||
canDeleteMeasureMapping: permission(
|
||||
action: "core:control:delete-measure-mapping"
|
||||
)
|
||||
...LinkedControlsCardFragment
|
||||
}
|
||||
}
|
||||
@@ -77,12 +77,8 @@ export default function MeasureControlsTab() {
|
||||
const connectionId = data.controls.__id;
|
||||
const controls = data.controls?.edges?.map(edge => edge.node) ?? [];
|
||||
|
||||
const canLinkControl = controls.some(
|
||||
({ canCreateMeasureMapping }) => canCreateMeasureMapping,
|
||||
);
|
||||
const canUnlinkControl = controls.some(
|
||||
({ canDeleteMeasureMapping }) => canDeleteMeasureMapping,
|
||||
);
|
||||
const canLinkControl = data.canCreateControlMeasureMapping;
|
||||
const canUnlinkControl = data.canDeleteControlMeasureMapping;
|
||||
const readOnly = !canLinkControl && !canUnlinkControl;
|
||||
|
||||
const incrementOptions = {
|
||||
|
||||
@@ -8,17 +8,17 @@ import { useMutationWithIncrement } from "#/hooks/useMutationWithIncrement";
|
||||
export const risksFragment = graphql`
|
||||
fragment MeasureRisksTabFragment on Measure {
|
||||
id
|
||||
canCreateRiskMeasureMapping: permission(
|
||||
action: "core:risk:create-measure-mapping"
|
||||
)
|
||||
canDeleteRiskMeasureMapping: permission(
|
||||
action: "core:risk:delete-measure-mapping"
|
||||
)
|
||||
risks(first: 100) @connection(key: "Measure__risks") {
|
||||
__id
|
||||
edges {
|
||||
node {
|
||||
id
|
||||
canCreateMeasureMapping: permission(
|
||||
action: "core:risk:create-measure-mapping"
|
||||
)
|
||||
canDeleteMeasureMapping: permission(
|
||||
action: "core:risk:delete-measure-mapping"
|
||||
)
|
||||
...LinkedRisksCardFragment
|
||||
}
|
||||
}
|
||||
@@ -61,12 +61,8 @@ export default function MeasureRisksTab() {
|
||||
const connectionId = data.risks.__id;
|
||||
const risks = data.risks?.edges?.map(edge => edge.node) ?? [];
|
||||
|
||||
const canLinkRisk = risks.some(
|
||||
({ canCreateMeasureMapping }) => canCreateMeasureMapping,
|
||||
);
|
||||
const canUnlinkRisk = risks.some(
|
||||
({ canDeleteMeasureMapping }) => canDeleteMeasureMapping,
|
||||
);
|
||||
const canLinkRisk = data.canCreateRiskMeasureMapping;
|
||||
const canUnlinkRisk = data.canDeleteRiskMeasureMapping;
|
||||
const readOnly = !canLinkRisk && !canUnlinkRisk;
|
||||
|
||||
const incrementOptions = {
|
||||
|
||||
Reference in New Issue
Block a user