Skip to content

Commit 16312d7

Browse files
authored
Merge pull request #5719 from GauravD2t/backport-4484-to-dspace-7_x
[Port dspace-7_x] :Backport change DELETE to OBSOLETE (DELETE) and update view table (#4484)
2 parents c91bae4 + f995c38 commit 16312d7

5 files changed

Lines changed: 29 additions & 3 deletions

File tree

src/app/core/resource-policy/models/action-type.model.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export enum ActionType {
1515
/**
1616
* Action of deleting something
1717
*/
18-
DELETE = 'DELETE',
18+
DELETE = 'OBSOLETE (DELETE)',
1919

2020
/**
2121
* Action of adding something to a container

src/app/shared/resource-policies/entry/resource-policy-entry.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
</th>
1616
<td>{{entry.policy.name}}</td>
1717
<td>{{entry.policy.policyType}}</td>
18-
<td>{{entry.policy.action}}</td>
18+
<td>{{getActionDisplayLabel(entry.policy.action)}}</td>
1919
<td>
2020
{{ epersonName$ | async }}
2121
</td>

src/app/shared/resource-policies/entry/resource-policy-entry.component.spec.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,5 +218,16 @@ describe('ResourcePolicyEntryComponent', () => {
218218
checkbox.triggerEventHandler('ngModelChange', false);
219219
expect(comp.toggleCheckbox.emit).toHaveBeenCalledWith(false);
220220
});
221+
it('should return "DELETE" for ActionType.DELETE', () => {
222+
expect(comp.getActionDisplayLabel(ActionType.DELETE)).toBe('DELETE');
223+
});
224+
225+
it('should return string value for other action types', () => {
226+
expect(comp.getActionDisplayLabel(ActionType.READ)).toBe('READ');
227+
expect(comp.getActionDisplayLabel(ActionType.WRITE)).toBe('WRITE');
228+
expect(comp.getActionDisplayLabel(ActionType.ADD)).toBe('ADD');
229+
expect(comp.getActionDisplayLabel(ActionType.REMOVE)).toBe('REMOVE');
230+
expect(comp.getActionDisplayLabel(ActionType.ADMIN)).toBe('ADMIN');
231+
});
221232
});
222233
});

src/app/shared/resource-policies/entry/resource-policy-entry.component.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import { RemoteData } from '../../../core/data/remote-data';
1717
import { DSpaceObject } from '../../../core/shared/dspace-object.model';
1818
import { ActivatedRoute, Router } from '@angular/router';
1919
import { Group } from '../../../core/eperson/models/group.model';
20+
import { ActionType } from '../../../core/resource-policy/models/action-type.model';
2021
import { getGroupEditRoute } from '../../../access-control/access-control-routing-paths';
2122
import { GroupDataService } from '../../../core/eperson/group-data.service';
2223

@@ -76,6 +77,20 @@ export class ResourcePolicyEntryComponent implements OnInit {
7677
return isNotEmpty(date) ? dateToString(stringToNgbDateStruct(date)) : '';
7778
}
7879

80+
/**
81+
* Returns the display label for the action type.
82+
* Shows 'DELETE' instead of 'OBSOLETE (DELETE)' for better UX.
83+
*
84+
* @param action the ActionType value
85+
* @return a string with the display label
86+
*/
87+
getActionDisplayLabel(action: ActionType): string {
88+
if (action === ActionType.DELETE) {
89+
return 'DELETE';
90+
}
91+
return String(action);
92+
}
93+
7994
/**
8095
* Redirect to resource policy editing page
8196
*/

src/app/shared/resource-policies/form/resource-policy-form.model.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ const policyActionList: DynamicFormOptionConfig<any>[] = [
5252
value: ActionType.ADMIN
5353
},
5454
{
55-
label: ActionType.DELETE.toString(),
55+
label: 'DELETE',
5656
value: ActionType.DELETE
5757
},
5858
{

0 commit comments

Comments
 (0)