-
Notifications
You must be signed in to change notification settings - Fork 112
feat(okms): edit settings drawer #19487
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
3c3fe6c to
7c73003
Compare
7c73003 to
821b3a6
Compare
packages/manager/apps/okms/public/translations/secret-manager/Messages_fr_FR.json
Outdated
Show resolved
Hide resolved
ref: #MANAGER-17868 Signed-off-by: Mathieu Mousnier <[email protected]>
ref: #MANAGER-17868 Signed-off-by: Mathieu Mousnier <[email protected]>
821b3a6 to
9e1f2d7
Compare
| <label htmlFor={field.name} slot="label" className="mb-1"></label> | ||
| <label slot="label" className="flex items-center gap-2 relative mb-1"> | ||
| {t('deactivate_version_after')} | ||
| <HelpIconWithTooltip | ||
| label={t('form_tooltip_deactivate_version_after')} | ||
| /> | ||
| </label> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why htmlFor is necessary and not put it in child space ?
It's not strange to have 2 labels collapsed ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch. The empty label tag is some forgotten code.
| export const casRequiredToFormValue = ( | ||
| casRequired: boolean, | ||
| ): CasRequiredFormValue => { | ||
| return casRequired ? 'active' : 'inactive'; | ||
| }; | ||
|
|
||
| export const formValueToCasRequired = ( | ||
| formValue: CasRequiredFormValue, | ||
| ): boolean => { | ||
| return formValue === 'active'; | ||
| }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe to move in a utils file ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see you point, but these utility functions are purely related to the component and shouldn't be used if it is not while using the component.
When we are in this configuration I prefer to colocate the code.
| }; | ||
|
|
||
| return ( | ||
| <div className="flex flex-col h-full"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a section ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the drawer component already implements header, section and footer tags
| type QueryStringValue = string | number | boolean | undefined | null; | ||
|
|
||
| export const buildQueryString = (params: Record<string, QueryStringValue>) => { | ||
| const queryParams = new URLSearchParams(); | ||
| Object.entries(params).forEach(([key, value]) => { | ||
| if (value !== undefined && value !== null) { | ||
| queryParams.set(key, String(value)); | ||
| } | ||
| }); | ||
| const queryString = queryParams.toString(); | ||
| return queryString ? `?${queryString}` : null; | ||
| }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
May be a little unit test on it can be useful 👌
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done ✅
| export const addCurrentVersionToCas = ( | ||
| currentVersion: number, | ||
| casRequired: boolean, | ||
| isSettingCasRequired?: boolean, | ||
| ) => { | ||
| if (isSettingCasRequired || casRequired) { | ||
| return currentVersion; | ||
| } | ||
| return undefined; | ||
| }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As it's a very little function. I think a unit test can be quick to do and useful if you want implement refactor on future
| describe('deactivateVersionAfter field validation', () => { | ||
| it('should return error for invalid duration format', () => { | ||
| const invalidMetadata = { | ||
| ...MOCK_METADATA_VALID, | ||
| deactivateVersionAfter: 'invalid-duration', | ||
| }; | ||
| const result = getSchemaParsingResult(invalidMetadata); | ||
| expect(result.success).toBe(false); | ||
| expect(result.error.issues[0].path).toEqual(['deactivateVersionAfter']); | ||
| expect(result.error.issues[0].message).toBe( | ||
| labels.secretManager.error_invalid_duration, | ||
| ); | ||
| }); | ||
|
|
||
| it('should return error for duration with invalid units', () => { | ||
| const invalidMetadata = { | ||
| ...MOCK_METADATA_VALID, | ||
| deactivateVersionAfter: '30x', | ||
| }; | ||
| const result = getSchemaParsingResult(invalidMetadata); | ||
| expect(result.success).toBe(false); | ||
| expect(result.error.issues[0].path).toEqual(['deactivateVersionAfter']); | ||
| expect(result.error.issues[0].message).toBe( | ||
| labels.secretManager.error_invalid_duration, | ||
| ); | ||
| }); | ||
|
|
||
| it('should return error for duration with no unit', () => { | ||
| const invalidMetadata = { | ||
| ...MOCK_METADATA_VALID, | ||
| deactivateVersionAfter: '30', | ||
| }; | ||
| const result = getSchemaParsingResult(invalidMetadata); | ||
| expect(result.success).toBe(false); | ||
| expect(result.error.issues[0].path).toEqual(['deactivateVersionAfter']); | ||
| expect(result.error.issues[0].message).toBe( | ||
| labels.secretManager.error_invalid_duration, | ||
| ); | ||
| }); | ||
|
|
||
| it('should return error for empty string', () => { | ||
| const invalidMetadata = { | ||
| ...MOCK_METADATA_VALID, | ||
| deactivateVersionAfter: '', | ||
| }; | ||
| const result = getSchemaParsingResult(invalidMetadata); | ||
| expect(result.success).toBe(false); | ||
| expect(result.error.issues[0].path).toEqual(['deactivateVersionAfter']); | ||
| expect(result.error.issues[0].message).toBe( | ||
| labels.secretManager.error_invalid_duration, | ||
| ); | ||
| }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
May be you can reduce it with a it.each if you want
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done ✅
| import { NAMESPACES } from '@ovh-ux/manager-common-translations'; | ||
|
|
||
| export const MAX_VERSIONS_MIN_VALUE = 0; | ||
| export const MAX_VERSIONS_MAX_VALUE = 24000; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| export const MAX_VERSIONS_MAX_VALUE = 24000; | |
| export const MAX_VERSIONS_MAX_VALUE = 24_000; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done ✅
tibs245
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you can see If you want apply some suggestion. I think have 2 labels it's may be not the best for accessibility.
But else all is ok 👌
ref: #MANAGER-17868 Signed-off-by: Mathieu Mousnier <[email protected]>
Description
Ticket Reference: #MANAGER-17868
Additional Information