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

feat(global-header): added config for default header components #2263

Conversation

ciiay
Copy link
Member

@ciiay ciiay commented Jan 27, 2025

Description

  • Added config for default application header components
  • Added extra common icons
  • Updated support to "tech-preview"
  • Updated support to "production" as the new plugin version will be ready for production

Which issue(s) does this PR fix

PR acceptance criteria

Please make sure that the following steps are complete:

  • GitHub Actions are completed and successful
  • Unit Tests are updated and passing
  • E2E Tests are updated and passing
  • Documentation is updated if necessary (requirement for new features)
  • Add a screenshot if the change is UX/UI related

How to test changes / Special notes to the reviewer

  1. Pull changes in rhdh-plugins PR to your local and in workspaces/global-header/plugins/global-header/ directory run npx --yes @janus-idp/cli package export-dynamic-plugin --dynamic-plugins-root <path-to-your-rhdh>/dynamic-plugins-root --dev
  2. Pull changes in theme PR to your local
  3. Pull changes in this PR to your local rhdh, in packages/app/package.json, replace "@redhat-developer/red-hat-developer-hub-theme": "0.4.0", with "@redhat-developer/red-hat-developer-hub-theme": "file:path/to/your/red-hat-developer-hub-theme",
  4. In your rhdh app-config.local file:
Config ``` dynamicPlugins: rootDirectory: dynamic-plugins-root frontend: default.main-menu-items: menuItems: default.create: title: '' red-hat-developer-hub.backstage-plugin-global-header: mountPoints: - mountPoint: application/header importName: GlobalHeader config: position: above-main-content # above-main-content | below-main-content - mountPoint: global.header/component importName: SearchComponent config: priority: 100 - mountPoint: global.header/component importName: Spacer config: priority: 99 props: growFactor: 0 - mountPoint: global.header/component importName: HeaderIconButton config: priority: 90 props: title: Create... icon: add to: create - mountPoint: global.header/component importName: SupportButton config: priority: 80 - mountPoint: global.header/component importName: NotificationButton config: priority: 70 - mountPoint: global.header/component importName: Divider config: priority: 50 - mountPoint: global.header/component importName: ProfileDropdown config: priority: 10 - mountPoint: global.header/profile importName: MenuItemLink config: priority: 100 props: title: Settings link: /settings icon: manageAccounts - mountPoint: global.header/profile importName: LogoutButton config: priority: 10 ```
6*. If test on a cluster, add the following config to your app-config to hide the search modal and settings button in sidebar:
app-config.yaml
    # for testing notifications
    backend:
      auth:
        dangerouslyDisableDefaultAuthPolicy: true
        externalAccess:
          - type: static
            options:
              token: test-token
              subject: cicd-system-completion-events
helm chart with notifications plugin enabled
dynamic:
  includes:
    - dynamic-plugins.default.yaml
  plugins:
    - disabled: false
      package: ./dynamic-plugins/dist/backstage-plugin-notifications
      pluginConfig:
        app:
          sidebar:
            search: false
            settings: false
        dynamicPlugins:
          frontend:
            backstage.plugin-notifications:
              dynamicRoutes:
                - importName: NotificationsPage
                  path: /notifications
    - disabled: false
      package: ./dynamic-plugins/dist/backstage-plugin-notifications-backend-dynamic
    - disabled: false
      package: ./dynamic-plugins/dist/backstage-plugin-signals-backend-dynamic
    - disabled: false
      package: ./dynamic-plugins/dist/backstage-plugin-signals
      pluginConfig:
        dynamicPlugins:
          frontend:
            backstage.plugin-signals: {}
    - disabled: false
      package: >-
        ./dynamic-plugins/dist/red-hat-developer-hub-backstage-plugin-global-header
      pluginConfig:
        dynamicPlugins:
          frontend:
            default.main-menu-items:
              menuItems:
                default.create:
                  title: ''  # to hide the Create button from sidebar
            red-hat-developer-hub.backstage-plugin-global-header:
              mountPoints:
                - config:
                    position: above-main-content
                  importName: GlobalHeader
                  mountPoint: application/header
                - config:
                    priority: 100
                  importName: SearchComponent
                  mountPoint: global.header/component
                - config:
                    priority: 99
                    props:
                      growFactor: 0
                  importName: Spacer
                  mountPoint: global.header/component
                - config:
                    priority: 90
                    props:
                      icon: add
                      title: Create...
                      to: create
                  importName: HeaderIconButton
                  mountPoint: global.header/component
                - config:
                    priority: 80
                  importName: SupportButton
                  mountPoint: global.header/component
                - config:
                    priority: 70
                  importName: NotificationButton
                  mountPoint: global.header/component
                - config:
                    priority: 50
                  importName: Divider
                  mountPoint: global.header/component
                - config:
                    priority: 10
                  importName: ProfileDropdown
                  mountPoint: global.header/component
                - config:
                    priority: 100
                    props:
                      icon: manageAccounts
                      link: /settings
                      title: Settings
                  importName: MenuItemLink
                  mountPoint: global.header/profile
                - config:
                    priority: 10
                  importName: LogoutButton
                  mountPoint: global.header/profile

To test out the Notifications icon button, follow the below steps:
To set up notifications frontend, you can add to app-config.yaml:

dynamicPlugins:
  frontend:
    backstage.plugin-notifications:
      dynamicRoutes:
        - path: /notifications
          importName: NotificationsPage
          module: NotificationsPlugin
          menuItem:
            config:
              props:
                titleCounterEnabled: true
                webNotificationsEnabled: true
            icon: notificationsIcon
            text: Notifications

To send notifications, you can setup external service https://backstage.io/docs/auth/service-to-service-auth/#static-keys-for-plugin-to-plugin-auth like this:

backend:
  auth:
    externalAccess:
      - type: static
        options:
          token: ${EXTERNAL_SERVICE_TOKEN}
          subject: cicd-system-completion-events

(Make sure this is auth under backend and not the top level auth key)
Then you can use this to send notifications:

curl -X POST http://localhost:7007/api/notifications -H "Content-Type: application/json" -H "Authorization: Bearer ${EXTERNAL_SERVICE_TOKEN}" -d '{"recipients":{"type":"broadcast"},"payload": {"title": "Title of boradcast message","link": "http://foo.com/bar","severity": "high","topic": "The topic"}}'

Screen recording(uploaded Feb 7):

rhidp_5252_final.mp4

@ciiay ciiay requested review from debsmita1 and removed request for dzemanov January 27, 2025 21:02
Copy link
Contributor

@ciiay
Copy link
Member Author

ciiay commented Jan 28, 2025

/test e2e-tests

@ciiay ciiay force-pushed the rhidp-5252-add-default-header-components branch from 3c47b55 to bd34619 Compare January 28, 2025 18:18
Copy link
Contributor

@ciiay ciiay force-pushed the rhidp-5252-add-default-header-components branch 2 times, most recently from f54e4ea to b6c9481 Compare January 29, 2025 06:33
Copy link
Contributor

@ciiay ciiay force-pushed the rhidp-5252-add-default-header-components branch from 174e308 to 9439980 Compare January 29, 2025 14:22
Copy link
Contributor

Copy link
Contributor

Copy link
Contributor

Copy link
Member

@christoph-jerolimov christoph-jerolimov left a comment

Choose a reason for hiding this comment

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

Small change request

@ciiay ciiay force-pushed the rhidp-5252-add-default-header-components branch from 1e35b77 to 0bc2227 Compare January 31, 2025 21:17
Copy link
Contributor

Copy link
Member

@christoph-jerolimov christoph-jerolimov left a comment

Choose a reason for hiding this comment

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

The plugin doesn't define this components yet, so this code couldn't be found.

As discussed in Slack. You must update the plugin to the latest release as well.

I share this here so that others see that this PR is on hold until the plugin is updated. :)

@christoph-jerolimov
Copy link
Member

/retest

Copy link
Contributor

@christoph-jerolimov
Copy link
Member

/retest

Copy link
Contributor

Copy link
Member

@debsmita1 debsmita1 left a comment

Choose a reason for hiding this comment

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

verified this on a cluster
/lgtm

@teknaS47
Copy link
Contributor

Looks good. Verified on a cluster /lgtm

Copy link
Contributor

Copy link
Member

@christoph-jerolimov christoph-jerolimov left a comment

Choose a reason for hiding this comment

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

@ciiay and I've tested this on a cluster and this got lgtm from both of us.

The last e2e tests passed successfully:

image

The last change only includes a documentation change: a90c1f4

/lgtm

Copy link

openshift-ci bot commented Feb 18, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: christoph-jerolimov, debsmita1

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:
  • OWNERS [christoph-jerolimov,debsmita1]

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

Copy link
Contributor

@openshift-ci openshift-ci bot removed the lgtm label Feb 18, 2025
Copy link

openshift-ci bot commented Feb 18, 2025

New changes are detected. LGTM label has been removed.

Copy link
Contributor

@christoph-jerolimov
Copy link
Member

/cherry-pick release-1.5

@openshift-cherrypick-robot
Copy link
Contributor

@christoph-jerolimov: once the present PR merges, I will cherry-pick it on top of release-1.5 in a new PR and assign it to you.

In response to this:

/cherry-pick release-1.5

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@christoph-jerolimov christoph-jerolimov merged commit 12bb302 into redhat-developer:main Feb 18, 2025
9 of 11 checks passed
@openshift-cherrypick-robot
Copy link
Contributor

@christoph-jerolimov: #2263 failed to apply on top of branch "release-1.5":

Applying: feat(global-header): added config for default header components
Applying: prettier fix
Applying: hide header items in sidebar
Applying: resolve failed ci checks
Applying: resolve failed ci checks
Applying: updated header component mp name
Applying: added icons and updated global header config
Applying: addressed review comments
Applying: updated global header wrapper to take the latest release
Applying: removed default support button url
Applying: resolved merging conflicts
Applying: addressed review comments
Applying: updated theme package to pick up changes for global header
Applying: fix: align application header mountpoint with other mount points
Applying: fixed double scrollbar issue
Applying: small pickup
Applying: prettier fix
Applying: updated default global header config
Applying: fixed global header version
Applying: fixed default global header config
Applying: updated header package.json dependency
Applying: ignore the problematic link
Applying: updated yarn.lock
Using index info to reconstruct a base tree...
M	yarn.lock
Falling back to patching base and 3-way merge...
Auto-merging yarn.lock
CONFLICT (content): Merge conflict in yarn.lock
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
hint: When you have resolved this problem, run "git am --continue".
hint: If you prefer to skip this patch, run "git am --skip" instead.
hint: To restore the original branch and stop patching, run "git am --abort".
hint: Disable this message with "git config advice.mergeConflict false"
Patch failed at 0023 updated yarn.lock

In response to this:

/cherry-pick release-1.5

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

zdrapela pushed a commit to zdrapela/rhdh that referenced this pull request Feb 19, 2025
…at-developer#2263)

* feat(global-header): added config for default header components

Signed-off-by: Yi Cai <[email protected]>

* prettier fix

Signed-off-by: Yi Cai <[email protected]>

* hide header items in sidebar

Signed-off-by: Yi Cai <[email protected]>

* resolve failed ci checks

Signed-off-by: Yi Cai <[email protected]>

* resolve failed ci checks

Signed-off-by: Yi Cai <[email protected]>

* updated header component mp name

Signed-off-by: Yi Cai <[email protected]>

* added icons and updated global header config

Signed-off-by: Yi Cai <[email protected]>

* addressed review comments

Signed-off-by: Yi Cai <[email protected]>

* updated global header wrapper to take the latest release

Signed-off-by: Yi Cai <[email protected]>

* removed default support button url

Signed-off-by: Yi Cai <[email protected]>

* resolved merging conflicts

Signed-off-by: Yi Cai <[email protected]>

* addressed review comments

Signed-off-by: Yi Cai <[email protected]>

* updated theme package to pick up changes for global header

Signed-off-by: Yi Cai <[email protected]>

* fix: align application header mountpoint with other mount points

Signed-off-by: Christoph Jerolimov <[email protected]>

* fixed double scrollbar issue

Signed-off-by: Yi Cai <[email protected]>

* small pickup

Signed-off-by: Yi Cai <[email protected]>

* prettier fix

Signed-off-by: Yi Cai <[email protected]>

* updated default global header config

Signed-off-by: Yi Cai <[email protected]>

* fixed global header version

Signed-off-by: Yi Cai <[email protected]>

* fixed default global header config

Signed-off-by: Yi Cai <[email protected]>

* updated header package.json dependency

Signed-off-by: Yi Cai <[email protected]>

* ignore the problematic link

Signed-off-by: Yi Cai <[email protected]>

* updated yarn.lock

Signed-off-by: Yi Cai <[email protected]>

* code clean

Signed-off-by: Yi Cai <[email protected]>

* code clean

Signed-off-by: Yi Cai <[email protected]>

* added config to hide search and settings when header is enabled

Signed-off-by: Yi Cai <[email protected]>

* feat(global-header): use global-header 1.0.0

* feat(global-header): add optional layout config option for the header itself

* docs(global-header): small fix

* feat(global-header): enable new global-header plugin by default

* fix(global-header): fix duplicate scrollbar issues (incl. RHIDP-4637)

* chore(global-header): disable header in e2e tests for now

* fix(global-header): fix duplicate scrollbar issues (incl. RHIDP-4637)

* fix(global-header): fix duplicate scrollbar issues (incl. RHIDP-4637)

* fix(global-header): fix duplicate scrollbar issues (incl. RHIDP-4637)

* hide notifications from sidebar by default

Signed-off-by: Yi Cai <[email protected]>

---------

Signed-off-by: Yi Cai <[email protected]>
Signed-off-by: Christoph Jerolimov <[email protected]>
Co-authored-by: Christoph Jerolimov <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants