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
frontend: Add create namespace ui #1727
base: main
Are you sure you want to change the base?
Conversation
4840332
to
9304a84
Compare
|
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.
Some suggestions for translations
4103f4e
to
c199d1c
Compare
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.
Thanks Vincent.
Can you move the dialog/button into its own module? So it's more isolated and also in case we want to show it in a different view.
For consistency with the rest of the UX, I think the create button should trigger a cancellable action (like the Editor's apply / Delete / Scale / etc.).
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.
Req changes.
d626eb9
to
564b556
Compare
|
last push
|
564b556
to
763ae21
Compare
maybe artificially adding a timer would allow it to be slow enough to react to a quit action? |
486fc30
to
3e9fd01
Compare
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.
Left a few more comments.
3e9fd01
to
54c7b29
Compare
rebased and changed Namespace to namespace |
b48eee9
to
874eb6a
Compare
Fixed some changes and should be ready for review again |
874eb6a
to
58bbf86
Compare
Signed-off-by: Vincent T <[email protected]>
58bbf86
to
526527e
Compare
Added name input filter |
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.
Left a few notes. Please take a look.
|
||
function createNewNamespace() { | ||
function validateNamespaceName(namespaceName: string) { | ||
const namespaceRegex = /^[a-z]([-a-z0-9]*[a-z0-9])?$/; |
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.
We have a function for this at SettingsCluster.tsx. We should add this as a static method to the Namespace class so we can reuse it when needed.
// Check if the namespace name is too long | ||
if (namespaceName.length > 63) { | ||
alert(t('translation|Invalid namespace name: name must be 63 characters or shorter')); | ||
return false; | ||
} | ||
|
||
// Check if the namespace name starts with a alphanumeric character | ||
const startsAlphanumeric = /^[a-z0-9]/.test(namespaceName); | ||
if (!startsAlphanumeric) { | ||
alert( | ||
t('translation|Invalid namespace name: name must start with an alphanumeric character') | ||
); | ||
return false; | ||
} | ||
|
||
// Check if the namespace name ends with an alphanumeric character | ||
const endsAlphanumeric = /[a-z0-9]$/.test(namespaceName); | ||
if (!endsAlphanumeric) { | ||
alert( | ||
t('translation|Invalid namespace name: name must end with an alphanumeric character') | ||
); | ||
return false; | ||
} | ||
|
||
// Check if the namespace name contains only lowercase letters, numbers, or hyphens | ||
const validChars = namespaceRegex.test(namespaceName); | ||
if (!validChars) { | ||
alert( | ||
t( | ||
'translation|Invalid namespace name: name must consist of lower case alphanumeric characters or -' | ||
) | ||
); | ||
return false; | ||
} | ||
|
||
return true; | ||
} |
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.
See my comment about the function we have in SettingsCluster.tsx.
async function namespaceRequest() { | ||
try { | ||
const response = await post('/api/v1/namespaces', newNamespaceData, true, { | ||
cluster: `${cluster}`, |
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.
You shouldn't use a string literal here (because if cluster is null
, it will result in a cluster called "null"
). You can use getCluster() || ''
when you declare the var up there.
const response = await post('/api/v1/namespaces', newNamespaceData, true, { | ||
cluster: `${cluster}`, | ||
}); | ||
return response; |
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.
You can return without having to declare a var in between (return await post...
)
"Invalid namespace name: name must start with an alphanumeric character": "", | ||
"Invalid namespace name: name must end with an alphanumeric character": "", | ||
"Invalid namespace name: name must consist of lower case alphanumeric characters or -": "", |
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.
Can you reuse the string we already have for SettingsCluster? So we don't have to translate these? (We are missing the 63 chars one, so maybe keep that or adapt the new one)
"Creating namespace {{ name }}…": "", | ||
"Cancelled creation of {{ name }}.": "", | ||
"Created namespace {{ name }}.": "", | ||
"Error creating namespace {{ name }}.": "", | ||
"Create Namespace": "", |
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 wonder if in the interest of not having to translate 5 strings per resource, we can reuse the string "Failed to create {{ kind }} {{ name }}." and similar.
Add Create Namespace Feature to UI
Solves issue #1705
Description
This PR introduces a new feature to the UI that allows users to create namespaces directly from the namespaces list view. A 'Create' button (represented by a + sign) has been added next to the title of the namespaces list view. Upon clicking this button, users are presented with a dialog box where they can input the name for the new namespace. Submitting this by clicking the 'Create' button will create the new namespace.
Changes
Verification
Screenshots