Skip to content

Commit 672d358

Browse files
authored
Merge pull request #5718 from GauravD2t/backport-4484-to-dspace-8_x
[Port dspace-8_x] :Backport change DELETE to OBSOLETE (DELETE) and update view table (#4484)
2 parents ac575d9 + 162c5a8 commit 672d358

5 files changed

Lines changed: 30 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: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,5 +220,17 @@ describe('ResourcePolicyEntryComponent', () => {
220220
checkbox.triggerEventHandler('ngModelChange', false);
221221
expect(comp.toggleCheckbox.emit).toHaveBeenCalledWith(false);
222222
});
223+
224+
it('should return "DELETE" for ActionType.DELETE', () => {
225+
expect(comp.getActionDisplayLabel(ActionType.DELETE)).toBe('DELETE');
226+
});
227+
228+
it('should return string value for other action types', () => {
229+
expect(comp.getActionDisplayLabel(ActionType.READ)).toBe('READ');
230+
expect(comp.getActionDisplayLabel(ActionType.WRITE)).toBe('WRITE');
231+
expect(comp.getActionDisplayLabel(ActionType.ADD)).toBe('ADD');
232+
expect(comp.getActionDisplayLabel(ActionType.REMOVE)).toBe('REMOVE');
233+
expect(comp.getActionDisplayLabel(ActionType.ADMIN)).toBe('ADMIN');
234+
});
223235
});
224236
});

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
@@ -30,6 +30,7 @@ import { DSONameService } from '../../../core/breadcrumbs/dso-name.service';
3030
import { RemoteData } from '../../../core/data/remote-data';
3131
import { GroupDataService } from '../../../core/eperson/group-data.service';
3232
import { Group } from '../../../core/eperson/models/group.model';
33+
import { ActionType } from '../../../core/resource-policy/models/action-type.model';
3334
import { ResourcePolicy } from '../../../core/resource-policy/models/resource-policy.model';
3435
import { DSpaceObject } from '../../../core/shared/dspace-object.model';
3536
import {
@@ -110,6 +111,20 @@ export class ResourcePolicyEntryComponent implements OnInit {
110111
return isNotEmpty(date) ? dateToString(stringToNgbDateStruct(date)) : '';
111112
}
112113

114+
/**
115+
* Returns the display label for the action type.
116+
* Shows 'DELETE' instead of 'OBSOLETE (DELETE)' for better UX.
117+
*
118+
* @param action the ActionType value
119+
* @return a string with the display label
120+
*/
121+
getActionDisplayLabel(action: ActionType): string {
122+
if (action === ActionType.DELETE) {
123+
return 'DELETE';
124+
}
125+
return String(action);
126+
}
127+
113128
/**
114129
* Redirect to resource policy editing page
115130
*/

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)