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

Add an option to create a namespace #1489

Merged
merged 4 commits into from
Jan 30, 2020
Merged

Add an option to create a namespace #1489

merged 4 commits into from
Jan 30, 2020

Conversation

andresmgot
Copy link
Contributor

Description of the change

Follow up of #1483

Add an item to the namespace selector to create a namespace. This opens a modal to introduce the new namespace:

Screencast-2020-01-29-173829

In the case of error, it's shown to the user:

Screenshot from 2020-01-29 17-43-34

Applicable issues

This is not fixing #1364 yet because it only allows you to create a namespace but you are still able to select a non-existing namespace and try to create an application there (which returns a wrong error).

Copy link
Contributor

@absoludity absoludity left a comment

Choose a reason for hiding this comment

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

Excellent stuff Andres. That's much clearer and explicit. Thanks!

@@ -20,7 +20,8 @@ class PermissionsErrorPage extends React.Component<IPermissionsErrorPage> {
<UnexpectedErrorAlert
title={
<span>
You don't have sufficient permissions to {action} in {namespaceText(namespace)}
You don't have sufficient permissions to {action}{" "}
{namespace && <>in {namespaceText(namespace)}</>}
Copy link
Contributor

Choose a reason for hiding this comment

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

Much clearer :)

if (to === pathname) {
setNamespace(ns);
} else {
setNamespace(ns);
Copy link
Contributor

Choose a reason for hiding this comment

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

This change just means that setNamespace is also called when the path changes, rather than only when it didn't change? Why was it only calling setNamespace when it hadn't changed in the first place?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, the logic was: If we are in a route that doesn't contain the namespace (e.g. /catalog) just call setNamespace. In other case, it was relying that a change in the route would trigger the setNamespace action by someone else (I assume). But the second was never happening and setNamespace was not being called.

options: [
{ label: "All Namespaces", value: "_all" },
{ label: defaultProps.defaultNamespace, value: defaultProps.defaultNamespace },
{ label: "Create New", value: "new" },
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm wondering if we need to show the option to "Create New" namespace if we know the user cannot do this. One simple, but not perfect, way is that we could only show the option to create a new namespace when there are more than 2 options in the selector already. It's not perfect as it only indicates the user can read namespaces, but is trivial to implement (EDIT: Actually, forget that, as we can assign RBAC to write namespaces without read, I assume). Not sure if it's worth considering returning this info when getting namespaces, but either way, it'd be another PR. See what you think.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

IMO hiding things may lead to a worse UX. If I am an unprivileged user and I want to create a namespace, I get a clear error that I don't have enough permissions to do so. If we hide the option it's not clear if I cannot do it or if it's the tool the one that doesn't support it.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yep, good point.

if (value.value === "new") {
this.setState({ modalIsOpen: true });
return;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Out of interest, what happens if I create a new namespace named "new", and then try to select it? :P (depending on the answer, you might need a token which is not a valid namespace).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good catch!
I always wondered why the All Namespaces choice used _all (it does because _all is an invalid namespace name).

@andresmgot andresmgot merged commit d2a1df2 into master Jan 30, 2020
@fabianschwarzfritz
Copy link
Contributor

Very cool feature and very beneficial when KubeAps is use with Helm3. Thanks @andresmgot !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants