Skip to content

Commit 35947b4

Browse files
authored
hotfix/PIN-9167: clone operation cannot be handled if state === 'ARCHIVED' (#1658)
* hotfix: clone operation cannot be handled if state === 'ARCHIVED' * test: fix test about archive * bump: 1.6.4 * refactor: fix test description
1 parent 87a233f commit 35947b4

File tree

4 files changed

+10
-13
lines changed

4 files changed

+10
-13
lines changed

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "interop-dashboard-frontend",
3-
"version": "1.6.3",
3+
"version": "1.6.4",
44
"type": "module",
55
"scripts": {
66
"dev": "vite",

src/hooks/__tests__/useGetConsumerPurposesActions.test.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,11 @@ describe('check if useGetConsumerPurposesActions returns the correct actions bas
4444
expect(result.current.actions).toHaveLength(0)
4545
})
4646

47-
it('shoud only return clone action if an archived purpose is given', () => {
47+
it('should not return any action if the current state of purpose is ARHCIVED', () => {
4848
const purposeMock = createMockPurpose({ currentVersion: { state: 'ARCHIVED' } })
4949
const { result } = renderUseGetConsumerPurposesActionsHook(purposeMock)
5050

51-
const cloneAction = result.current.actions.find((action) => action.label === 'clone')
52-
53-
expect(result.current.actions).toHaveLength(1)
54-
expect(cloneAction).toBeTruthy()
51+
expect(result.current.actions).toHaveLength(0)
5552
})
5653

5754
it('should return the publish and delete functions if the current version is in draft', () => {

src/hooks/useGetConsumerPurposesActions.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -132,17 +132,17 @@ function useGetConsumerPurposesActions(purpose?: Purpose) {
132132
color: 'error',
133133
}
134134

135+
if (purpose.currentVersion?.state === 'ARCHIVED') {
136+
return { actions: [] }
137+
}
138+
135139
if (!purpose.currentVersion && purpose.waitingForApprovalVersion) {
136140
// The purpose is also suspendedByConsumer here when the provider re-activated a
137141
// suspended purpose associated with an overquota e-service
138142
return { actions: purpose.suspendedByConsumer ? [] : [deleteAction] }
139143
}
140144

141-
if (
142-
purpose.eservice.mode === 'DELIVER' &&
143-
((!purpose.currentVersion && purpose.rejectedVersion) ||
144-
purpose?.currentVersion?.state === 'ARCHIVED')
145-
) {
145+
if (purpose.eservice.mode === 'DELIVER' && !purpose.currentVersion && purpose.rejectedVersion) {
146146
return { actions: [cloneAction] }
147147
}
148148

0 commit comments

Comments
 (0)