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 NamespaceDashboard option to ConsoleLink #2698

Merged
merged 1 commit into from
Sep 26, 2019

Conversation

rhamilto
Copy link
Member

@rhamilto rhamilto commented Sep 12, 2019

Replaces #2579 as this PR does not include Cluster dashboard per @beanh66.

Note: the Launcher sections only appear if ConsoleLinks with location NamespaceDashboard exist (and optionally match the current namespace).

Screen Shot 2019-09-12 at 9 48 19 AM
Screen Shot 2019-09-12 at 9 47 53 AM

Screen Shot 2019-09-12 at 9 48 36 AM
Screen Shot 2019-09-12 at 9 49 01 AM

Updated ConsoleLink CRD:

apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
  name: consolelinks.console.openshift.io
  annotations:
    displayName: ConsoleLinks
    description: Extension for customizing OpenShift web console links
spec:
  scope: Cluster
  group: console.openshift.io
  versions:
  - name: v1
    served: true
    storage: true
  names:
    plural: consolelinks
    singular: consolelink
    kind: ConsoleLink
    listKind: ConsoleLinkList
  additionalPrinterColumns:
  - name: Text
    type: string
    JSONPath: .spec.text
  - name: URL
    type: string
    JSONPath: .spec.href
  - name: Menu
    type: string
    JSONPath: .spec.menu
  - name: Age
    type: date
    JSONPath: .metadata.creationTimestamp
  subresources:
    status: {}
  validation:
    openAPIV3Schema:
      properties:
        spec:
          type: object
          description: Represents console link customizations spec
          required:
          - text
          - href
          - location
          properties:
            text:
              type: string
              description: Text of the link
            href:
              type: string
              description: Absolute secure URL for the link (must use https)
              pattern: '^https://([\w-]+.)+[\w-]+(/[\w- ./?%&=])?$'
            location:
              type: string
              description: Determines where the link is added (ApplicationMenu, HelpMenu, UserMenu, NamespaceDashboard)
              pattern: ^(ApplicationMenu|HelpMenu|UserMenu|NamespaceDashboard)$
            applicationMenu:
              type: object
              description: Object that holds application menu properties if the location is set to ApplicationMenu
              required:
                - section
              properties:
                section:
                  type: string
                  description: The section of the application menu in which the link should appear
                imageURL:
                  type: string
                  description: The URL for the icon used in front of the link in the application menu.  The URL must be an HTTPS URL or a Data URI. The image should be square and will be shown at 24x24 pixels.
            namespaceDashboard:
              type: object
              description: Object that holds namespace dashboard link properties if the location is set to NamespaceDashboard
              properties:
                namespaces:
                  type: array
                  description: The namespaces in which the dashboard link should appear.  If not specified, the link will appear in all namespaces.

@openshift-ci-robot openshift-ci-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. component/core Related to console core functionality approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Sep 12, 2019
@spadgett spadgett added this to the v4.3 milestone Sep 12, 2019
@rhamilto
Copy link
Member Author

cc: @jhadvig

@serenamarie125
Copy link
Contributor

FYI @sspeiche

if (link.spec.location !== 'NamespaceDashboard') {
return false;
}
const namespaces = _.get(link, ['spec', 'namespaceDashboard', 'namespaces']);
Copy link
Member

Choose a reason for hiding this comment

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

Do we also wanna cover case where the array is empty ?

@spadgett
Copy link
Member

/kind feature

@openshift-ci-robot openshift-ci-robot added the kind/feature Categorizes issue or PR as related to a new feature. label Sep 17, 2019
@openshift-ci-robot openshift-ci-robot added component/ceph Related to ceph-storage-plugin component/dashboard Related to dashboard labels Sep 23, 2019
@rhamilto rhamilto changed the base branch from master to master-4.3 September 23, 2019 13:09
@openshift-ci-robot openshift-ci-robot added component/dev-console Related to dev-console component/kubevirt Related to kubevirt-plugin component/metal3 Related to metal3-plugin component/monitoring Related to monitoring component/noobaa Related to noobaa-storage-plugin component/olm Related to OLM component/sdk Related to console-plugin-sdk labels Sep 23, 2019
@rhamilto rhamilto changed the title [WIP] Add NamespaceLink option to ConsoleLink [WIP] Add NamespaceDashboard option to ConsoleLink Sep 23, 2019
@rhamilto rhamilto changed the title [WIP] Add NamespaceDashboard option to ConsoleLink Add NamespaceDashboard option to ConsoleLink Sep 23, 2019
@openshift-ci-robot openshift-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Sep 23, 2019
Copy link
Member

@spadgett spadgett left a comment

Choose a reason for hiding this comment

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

Thanks, @rhamilto. A few comments

return false;
}
const namespaces = _.get(link, ['spec', 'namespaceDashboard', 'namespaces']);
return !namespaces || _.includes(namespaces, ns.metadata.name);
Copy link
Member

Choose a reason for hiding this comment

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

You want to handle both empty arrays and null/undefined. _.isEmpty works for both.

Suggested change
return !namespaces || _.includes(namespaces, ns.metadata.name);
return _.isEmpty(namsepaces) || _.includes(namespaces, ns.metadata.name);

if (link.spec.location !== 'NamespaceDashboard') {
return false;
}
const namespaces = _.get(link, ['spec', 'namespaceDashboard', 'namespaces']);
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
const namespaces = _.get(link, ['spec', 'namespaceDashboard', 'namespaces']);
const namespaces: string[] = _.get(link, ['spec', 'namespaceDashboard', 'namespaces']);


export const ConsoleLinks: React.FC<ConsoleLinksProps> = ({consoleLinks}) => {
return <ul className="list-unstyled">
{_.map(_.sortBy(consoleLinks, 'spec.text'), link => {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
{_.map(_.sortBy(consoleLinks, 'spec.text'), link => {
{_.map(_.sortBy(consoleLinks, 'spec.text'), (link: K8sResourceKind) => {

@@ -44,6 +45,38 @@ const OverviewNamespaceSummary = ({ns}) => <div className="group">
</div>
</div>;

export const getNamespaceDashboardConsoleLinks = (ns, consoleLinks) => {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
export const getNamespaceDashboardConsoleLinks = (ns, consoleLinks) => {
export const getNamespaceDashboardConsoleLinks = (ns: K8sResourceKind, consoleLinks: K8sResourceKind[]): K8sResourceKind[] => {

<OverviewHealth ns={ns} />
<OverviewResourceQuotas ns={ns} />
<OverviewResourceUsage ns={ns} />
<OverviewLinks ns={ns} consoleLinks={consoleLinks} />
Copy link
Member

Choose a reason for hiding this comment

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

It would be better to connect OverviewLinks instead of the entire OverviewNamespaceDashboard. You generally want to connect only the child component that needs the data when possible.

@spadgett spadgett removed component/ceph Related to ceph-storage-plugin component/dashboard Related to dashboard component/dev-console Related to dev-console component/kubevirt Related to kubevirt-plugin component/metal3 Related to metal3-plugin component/monitoring Related to monitoring component/noobaa Related to noobaa-storage-plugin component/olm Related to OLM component/sdk Related to console-plugin-sdk labels Sep 24, 2019
@rhamilto
Copy link
Member Author

Thanks, @spadgett. Updated.

Copy link
Member

@spadgett spadgett left a comment

Choose a reason for hiding this comment

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

/lgtm
/hold

@openshift-ci-robot openshift-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Sep 24, 2019
@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Sep 24, 2019
@openshift-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: rhamilto, spadgett

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

The pull request process is described 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

@spadgett spadgett changed the base branch from master-4.3 to master September 25, 2019 18:40
@spadgett
Copy link
Member

/hold cancel

@openshift-ci-robot openshift-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Sep 25, 2019
@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

2 similar comments
@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-merge-robot openshift-merge-robot merged commit 5a79bc5 into openshift:master Sep 26, 2019
@rhamilto rhamilto deleted the namespace-links branch September 26, 2019 12:58
@abkieling
Copy link

@rhamilto Is this feature included in OpenShfit 4.2?

@rhamilto
Copy link
Member Author

@rhamilto Is this feature included in OpenShfit 4.2?

No. This is a 4.3 feature.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. component/core Related to console core functionality kind/feature Categorizes issue or PR as related to a new feature. lgtm Indicates that a PR is ready to be merged. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants