Disable delete for in-use licenses, add tooltip#137
Open
amadulhaxxani wants to merge 3 commits intoclarin-v7from
Open
Disable delete for in-use licenses, add tooltip#137amadulhaxxani wants to merge 3 commits intoclarin-v7from
amadulhaxxani wants to merge 3 commits intoclarin-v7from
Conversation
Prevent deleting licenses that are attached to bitstreams by disabling the Delete button and showing a tooltip explaining why. Adds UI markup (ngbTooltip wrapper, aria-label, dsBtnDisabled and guarded click), a new isSelectedLicenseInUse() helper and a check in deleteLicense(). Adds unit tests covering disabled/enabled states and click behavior, and provides i18n strings for English and Czech for the disabled-tooltip.
There was a problem hiding this comment.
Pull request overview
Prevents administrators from deleting CLARIN licenses that are currently referenced by bitstreams by disabling the delete action and explaining the reason via a tooltip, while also adding unit coverage and i18n strings.
Changes:
- Disable the “Delete License” button when the selected license has
bitstreams > 0, and show a tooltip explaining why. - Add
isSelectedLicenseInUse()helper and a guard indeleteLicense()to block deletion for in-use licenses. - Add unit tests for disabled/enabled states and click behavior; add EN/CZ translations for the tooltip.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/assets/i18n/en.json5 | Adds English tooltip text for disabled delete button |
| src/assets/i18n/cs.json5 | Adds Czech tooltip text for disabled delete button |
| src/app/clarin-licenses/clarin-license-table/clarin-license-table.component.ts | Adds “in use” helper + deletion guard |
| src/app/clarin-licenses/clarin-license-table/clarin-license-table.component.html | Disables delete via dsBtnDisabled and adds tooltip wrapper |
| src/app/clarin-licenses/clarin-license-table/clarin-license-table.component.spec.ts | Adds tests for delete button state and click behavior |
Replace isNull with hasNoValue when validating selectedLicense.id in deleteLicense to correctly handle undefined/null values. Also add hasNoValue to the imports from shared/empty.util.
Update clarin-license-table component spec to import NgbTooltip and retrieve the tooltip instance from the delete wrapper's injector. Replace the previous assertion that inspected the DOM's ng-reflect-ngb-tooltip attribute with an assertion on deleteTooltip.ngbTooltip to verify the expected translation key. This makes the test more robust by avoiding reliance on Angular's rendered reflection attribute.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Prevent deleting licenses that are attached to bitstreams
Disable the Delete button for licenses with attached bitstreams and display a tooltip explaining why deletion is prevented. Adds UI markup (ngbTooltip wrapper, aria-label, dsBtnDisabled and guarded click), a new isSelectedLicenseInUse() helper and a check in deleteLicense(). Adds unit tests covering disabled/enabled states and click behavior, and provides i18n strings for English and Czech for the disabled-tooltip.
Problem description
Administrators need protection against accidentally deleting licenses that are currently attached to one or more bitstreams. Without this safeguard, deleting an in-use license could leave orphaned bitstream-to-license mappings and create data inconsistency.
Analysis
The frontend license model already includes a
bitstreams: numberproperty (from the backend REST serialization). This field reflects the count of non-deleted mapped bitstreams and is available on every license in the paginated table. No backend change and no extra frontend API call is required.The existing license-label delete flow in the same component already demonstrates the correct accessibility pattern: a wrapper
spanwithngbTooltip, conditionaltabindex="0", and a button using[dsBtnDisabled]. This pattern is reused verbatim for the license delete button.The current license delete button is a bottom action (not per-row), so the disable rule is applied to
selectedLicense?.bitstreams > 0. The button remains disabled when no license is selected.Changes made
clarin-license-table.component.html — Replaced native
[disabled]with the label-delete wrapper + tooltip +dsBtnDisabledpattern. AddedngbTooltipbound to the disabled-tooltip i18n key (only shown whenbitstreams > 0). Added wrappertabindex="0"for accessibility when disabled. Added icon (fas fa-trash) and aria-label to the button. Guarded click handler withselectedLicense != null && !isSelectedLicenseInUse().clarin-license-table.component.ts — Added
isSelectedLicenseInUse(): booleanhelper method returningthis.selectedLicense?.bitstreams > 0. Added optional guard at the start ofdeleteLicense()to return ifthis.isSelectedLicenseInUse()is true.en.json5 — Added i18n key:
"clarin-license.button.delete-license.disabled-tooltip": "License \"{{name}}\" cannot be deleted because it is attached to one or more bitstreams."cs.json5 — Added i18n key:
"clarin-license.button.delete-license.disabled-tooltip": "Licenci \"{{name}}\" nelze smazat, protože jsou k ní připojeny jeden nebo více bitstreamů."clarin-license-table.component.spec.ts — Added test group "license delete button" covering:
bitstreams > 0bitstreams === 0Problems
None encountered. All changes compile, lint, and pass unit tests (5369 tests completed, 0 failed).
Sync verification
Copilot review