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

The +Add extension url can be parametrized for namespace #4940

Closed
wants to merge 3 commits into from
Closed

The +Add extension url can be parametrized for namespace #4940

wants to merge 3 commits into from

Conversation

mareklibra
Copy link
Contributor

@mareklibra mareklibra commented Apr 7, 2020

With this patch, the AddAction extension of dev-console can be parametrized for namespace by using :namespace placeholder within the URL.

Example:

  {
    type: 'AddAction',
    flags: {
      required: [FLAG_KUBEVIRT],
    },
    properties: {
      url: '/k8s/ns/:namespace/virtualization/~new-wizard?mode=import',
      label: 'Import Virtual Machine',
      description: 'Import a virtual machine from external hypervisor',
      icon: virtualMachineIcon,
    },
  }

Depends on:


First commit will be removed once #4933 lands.

@mareklibra
Copy link
Contributor Author

Cc @christianvogt

@openshift-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: mareklibra
To complete the pull request process, please assign christianvogt
You can assign the PR to them by writing /assign @christianvogt in a comment when ready.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci-robot openshift-ci-robot added the component/core Related to console core functionality label Apr 7, 2020
@openshift-ci-robot openshift-ci-robot added component/dev-console Related to dev-console component/knative Related to knative-plugin labels Apr 7, 2020
@@ -31,12 +31,15 @@ const Item: React.FC<ItemProps> = ({
// eslint-disable-next-line react-hooks/rules-of-hooks
.map((descriptor) => useAccessReview({ namespace, ...descriptor }))
.every((x) => x);

const resolvedUrl = url ? url.replace(':namespace', namespace) : undefined;
Copy link
Contributor

Choose a reason for hiding this comment

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

Good idea.
URL by definition of the type is always defined.
What about using a stricter regex replacement such as this:

Suggested change
const resolvedUrl = url ? url.replace(':namespace', namespace) : undefined;
const resolvedUrl = url.replace(/:namespace\b/g, namespace);

Currently we do not show this page within the all namespaces selection. So we are ok to ensure that there is always a valid namespace option for replacement.

@mareklibra
Copy link
Contributor Author

This change has been incorporated into #4933, so closing here.

@mareklibra mareklibra closed this Apr 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/core Related to console core functionality component/dev-console Related to dev-console component/knative Related to knative-plugin
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants