forked from linode/manager
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
upcoming: [M3-7696] - Edit Access key Drawer - Fix Save button is dis…
…abled (linode#10118) * upcoming: [M3-7696] - Edit Access key Drawer - Save Edit Access key Drawer - Fix save button is disabled. * Remove unused imports * Added changeset: Edit Access key Drawer - Fix Save button is disabled. * code cleanup * Update utils.ts * PR - feedback * PR feedback - @abailly-akamai * Update packages/manager/.changeset/pr-10118-upcoming-features-1706544516803.md Co-authored-by: Dajahi Wiley <[email protected]> * PR - feedback - @DevDW * Remove error when regions are selected. --------- Co-authored-by: Dajahi Wiley <[email protected]>
- Loading branch information
1 parent
e33c125
commit 165b5bf
Showing
11 changed files
with
285 additions
and
39 deletions.
There are no files selected for viewing
This file contains 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
5 changes: 5 additions & 0 deletions
5
packages/manager/.changeset/pr-10118-upcoming-features-1706544516803.md
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@linode/manager": Upcoming Features | ||
--- | ||
|
||
"Save" button in Edit Access Key drawer disabled unless field values are changed ([#10118](https://github.com/linode/manager/pull/10118)) |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
98 changes: 98 additions & 0 deletions
98
packages/manager/src/features/ObjectStorage/AccessKeyLanding/utils.test.ts
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
import { ObjectStorageKey } from '@linode/api-v4/lib/object-storage'; | ||
|
||
import { FormState } from './OMC_AccessKeyDrawer'; | ||
import { generateUpdatePayload, hasLabelOrRegionsChanged } from './utils'; | ||
|
||
describe('generateUpdatePayload', () => { | ||
const initialValues: FormState = { | ||
bucket_access: [], | ||
label: 'initialLabel', | ||
regions: ['region1', 'region2'], | ||
}; | ||
|
||
it('should return empty object if no changes', () => { | ||
const updatedValues = { ...initialValues }; | ||
expect(generateUpdatePayload(updatedValues, initialValues)).toEqual({}); | ||
}); | ||
|
||
it('should return updated label if only label changed', () => { | ||
const updatedValues = { ...initialValues, label: 'newLabel' }; | ||
expect(generateUpdatePayload(updatedValues, initialValues)).toEqual({ | ||
label: 'newLabel', | ||
}); | ||
}); | ||
|
||
it('should return updated regions if only regions changed', () => { | ||
const updatedValues = { ...initialValues, regions: ['region3', 'region4'] }; | ||
expect(generateUpdatePayload(updatedValues, initialValues)).toEqual({ | ||
regions: ['region3', 'region4'], | ||
}); | ||
}); | ||
|
||
it('should return updated label and regions if both changed', () => { | ||
const updatedValues = { | ||
bucket_access: [], | ||
label: 'newLabel', | ||
regions: ['region3', 'region4'], | ||
}; | ||
expect(generateUpdatePayload(updatedValues, initialValues)).toEqual({ | ||
label: 'newLabel', | ||
regions: ['region3', 'region4'], | ||
}); | ||
}); | ||
}); | ||
|
||
describe('hasLabelOrRegionsChanged', () => { | ||
const updatedValues: FormState = { | ||
bucket_access: [], | ||
label: 'initialLabel', | ||
regions: ['region3', 'region4'], | ||
}; | ||
const initialValues: ObjectStorageKey = { | ||
access_key: '', | ||
bucket_access: null, | ||
id: 0, | ||
label: updatedValues.label, | ||
limited: false, | ||
regions: [ | ||
{ id: 'region3', s3_endpoint: '' }, | ||
{ id: 'region4', s3_endpoint: '' }, | ||
], | ||
|
||
secret_key: '', | ||
}; | ||
|
||
it('returns false when both label and regions are unchanged', () => { | ||
expect(hasLabelOrRegionsChanged(updatedValues, initialValues)).toBe(false); | ||
}); | ||
|
||
it('returns true when only the label has changed', () => { | ||
expect( | ||
hasLabelOrRegionsChanged( | ||
{ ...updatedValues, label: 'newLabel' }, | ||
initialValues | ||
) | ||
).toBe(true); | ||
}); | ||
|
||
it('returns true when only the regions have changed', () => { | ||
expect( | ||
hasLabelOrRegionsChanged( | ||
{ | ||
...updatedValues, | ||
regions: ['region5'], | ||
}, | ||
initialValues | ||
) | ||
).toBe(true); | ||
}); | ||
|
||
it('returns true when both label and regions have changed', () => { | ||
expect( | ||
hasLabelOrRegionsChanged( | ||
{ ...updatedValues, label: 'newLabel', regions: ['region5'] }, | ||
initialValues | ||
) | ||
).toBe(true); | ||
}); | ||
}); |
Oops, something went wrong.