Skip to content

Delete is permanently disabled for entities with no references #364

Description

@JohnRDOrazio

Problem

The Delete confirmation dialog in the editor can never be confirmed for an entity that has zero cross-references — the safe, common case. The Delete button stays disabled and the only way out is Cancel.

Root cause

DeleteImpactAnalysis pushes the gate state upward from a mount effect:

// components/editor/DeleteImpactAnalysis.tsx
useEffect(() => {
  ...
  setIsLoading(true);
  setAcknowledged(false);
  onAcknowledge(false);      // ← parent's gate goes false on every open
  ...
  qualityApi.getCrossReferences(...).then(setData)...
}, [entityIri, projectId, accessToken, branch]);

The parent gates on that flag directly:

// app/projects/[id]/editor/page.tsx
const [deleteImpactAcknowledged, setDeleteImpactAcknowledged] = useState(true);
...
confirmDisabled={!deleteImpactAcknowledged}

ConfirmDialog renders its children inside DialogContent, so they mount each time the dialog opens. The effect therefore fires and sets the flag to false. The only thing that ever sets it back to true is the acknowledgement checkbox — and when total === 0 the component returns null before rendering any checkbox. Nothing re-enables the button.

Reproduction

  1. Open a project in the editor.
  2. Right-click a class that nothing else references, choose Delete.
  3. The dialog shows no impact warning (correct — there are no references), but Delete is greyed out.

Confirmed with a probe against current dev: after the query resolves with total: 0, onAcknowledge has been called exactly once, with false, and never again.

ZERO-REF onAcknowledge calls: [ [ false ] ]

Expected

With no references, the impact panel stays hidden and Delete is enabled immediately.

Fix

Being fixed as part of #200 Category A cleanup — see PR referenced below. The gate is derived in the editor page from the same useCrossReferences query the panel renders (React Query dedupes the two observers onto one fetch), so it engages only while the check is pending, when it errored, or when references were actually found. DeleteImpactAnalysis reports acknowledgement solely from the checkbox.

Note on the error case

The pending and error paths keep today's behaviour — Delete stays disabled. On error the panel says "Failed to check references. Proceed with caution", which reads like it should let the user through, but no checkbox is offered. Left as-is rather than changed silently; worth a separate decision.

Done criteria

  • Deleting an entity with zero references works from the confirm dialog.
  • An entity with references still requires the acknowledgement checkbox.
  • Regression test covering the zero-reference case.
  • Decide whether the error path should allow proceeding.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions