Skip to content
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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

vyncent-t
Copy link
Contributor

@vyncent-t vyncent-t commented Feb 19, 2024

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

  • Added a 'Create' button (+ sign) next to the title of the namespaces list view.
  • Implemented a dialog box that prompts the user to enter the name of the new namespace.
  • Added functionality to create a new namespace upon clicking the 'Create' button in the dialog box.

Verification

  • Tested the 'Create' button to ensure it triggers the dialog box as expected.
  • Verified the dialog box accepts input and allows for the creation of a new namespace.
  • Confirmed that the new namespace appears in the namespaces list view upon creation.

Screenshots

image
image

@vyncent-t
Copy link
Contributor Author

  • push to fix build failures and translations

@vyncent-t vyncent-t added enhancement New feature or request frontend Issues related to the frontend labels Feb 19, 2024
@vyncent-t vyncent-t self-assigned this Feb 19, 2024
@vyncent-t vyncent-t marked this pull request as ready for review February 19, 2024 21:16
Copy link
Contributor

@knrt10 knrt10 left a 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

@vyncent-t vyncent-t marked this pull request as draft February 20, 2024 15:33
@vyncent-t vyncent-t force-pushed the namespace-creation-ui branch 2 times, most recently from 4103f4e to c199d1c Compare February 21, 2024 16:32
@vyncent-t vyncent-t marked this pull request as ready for review February 21, 2024 16:52
Copy link
Collaborator

@joaquimrocha joaquimrocha left a 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.).

Copy link
Collaborator

@joaquimrocha joaquimrocha left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Req changes.

@vyncent-t vyncent-t force-pushed the namespace-creation-ui branch 2 times, most recently from d626eb9 to 564b556 Compare February 27, 2024 18:01
@vyncent-t
Copy link
Contributor Author

  • last push removes notes

@vyncent-t
Copy link
Contributor Author

vyncent-t commented Feb 27, 2024

last push

  • moved create namespace button and dialog to module
  • make create namespace process able to quit

@vyncent-t
Copy link
Contributor Author

  • last push is still needing some fixes, when creating a namespace item it is almost instant at this current implementation.

maybe artificially adding a timer would allow it to be slow enough to react to a quit action?

frontend/src/i18n/locales/de/translation.json Outdated Show resolved Hide resolved
@vyncent-t vyncent-t marked this pull request as draft March 1, 2024 13:48
@vyncent-t vyncent-t force-pushed the namespace-creation-ui branch 2 times, most recently from 486fc30 to 3e9fd01 Compare March 1, 2024 16:35
@illume illume modified the milestones: v0.23.0, v0.24.0 Mar 1, 2024
Copy link
Collaborator

@joaquimrocha joaquimrocha left a 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.

@vyncent-t
Copy link
Contributor Author

rebased and changed Namespace to namespace

@joaquimrocha joaquimrocha marked this pull request as ready for review May 20, 2024 14:44
@vyncent-t vyncent-t force-pushed the namespace-creation-ui branch 2 times, most recently from b48eee9 to 874eb6a Compare May 20, 2024 19:14
@vyncent-t
Copy link
Contributor Author

Fixed some changes and should be ready for review again

@vyncent-t
Copy link
Contributor Author

Added name input filter

Copy link
Collaborator

@joaquimrocha joaquimrocha left a 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])?$/;
Copy link
Collaborator

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.

Comment on lines +31 to +67
// 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;
}
Copy link
Collaborator

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}`,
Copy link
Collaborator

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;
Copy link
Collaborator

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...)

Comment on lines +319 to +321
"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 -": "",
Copy link
Collaborator

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)

Comment on lines +322 to +326
"Creating namespace {{ name }}…": "",
"Cancelled creation of {{ name }}.": "",
"Created namespace {{ name }}.": "",
"Error creating namespace {{ name }}.": "",
"Create Namespace": "",
Copy link
Collaborator

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request frontend Issues related to the frontend
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants