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 Plugin Settings Detail View and Plugin Config Store #1678

Merged
merged 10 commits into from
Feb 29, 2024
Merged

Conversation

yolossn
Copy link
Contributor

@yolossn yolossn commented Jan 29, 2024

This PR adds Plugin Settings Details View and Plugin Config Store that can be used by plugin developers to store and retrieve plugin configurations.

To Do:

  • Documentation (Pausing this to get first round of reviews to avoid redoing it later)
  • Examples
  • Debug an import issue related to ConfigStore that occures when using the ConfigStore in Plugins.

Demo:
https://github.com/headlamp-k8s/headlamp/assets/22731013/8a43a75c-014c-4884-b641-ca9d5396b3be

How to test:

  1. Run headlamp frontend and backend.
  2. Run the change-logo and pod-counter plugins.
  3. Either navigate to http://localhost:3000/settings/plugins or Click on Settings>Plugin in the side bar to view the Plugin Settings page.

backend/pkg/plugins/plugins.go Fixed Show resolved Hide resolved
@yolossn yolossn force-pushed the plugin_config branch 2 times, most recently from c9265e5 to ef90abd Compare January 31, 2024 19:31
@yolossn yolossn marked this pull request as ready for review January 31, 2024 19:32
@yolossn yolossn requested review from illume, ashu8912 and joaquimrocha and removed request for illume and ashu8912 January 31, 2024 19:34
frontend/src/plugin/pluginsSlice.ts Outdated Show resolved Hide resolved
frontend/src/plugin/pluginsSlice.ts Outdated Show resolved Hide resolved
frontend/src/plugin/pluginsSlice.ts Show resolved Hide resolved
plugins/headlamp-plugin/src/index.ts Outdated Show resolved Hide resolved
backend/cmd/headlamp.go Outdated Show resolved Hide resolved
frontend/src/lib/router.tsx Outdated Show resolved Hide resolved
frontend/src/plugin/registry.tsx Outdated Show resolved Hide resolved
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.

Nice work @yolossn, added some suggestions.

backend/pkg/plugins/plugins.go Outdated Show resolved Hide resolved
backend/pkg/plugins/plugins_test.go Show resolved Hide resolved
frontend/src/lib/k8s/apiProxy.ts Outdated Show resolved Hide resolved
frontend/src/plugin/configStore.ts Outdated Show resolved Hide resolved
frontend/src/plugin/pluginConfigSlice.ts Show resolved Hide resolved
frontend/src/plugin/registry.tsx Show resolved Hide resolved
Copy link
Collaborator

@illume illume left a comment

Choose a reason for hiding this comment

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

Added a few notes, will look more later. DCO and conflicts.

frontend/src/lib/k8s/apiProxy.ts Outdated Show resolved Hide resolved
plugins/examples/change-logo/src/index.tsx Outdated Show resolved Hide resolved
plugins/examples/change-logo/src/index.tsx Outdated Show resolved Hide resolved
plugins/examples/change-logo/src/index.tsx Show resolved Hide resolved
frontend/src/plugin/pluginsSlice.ts Show resolved Hide resolved
backend/cmd/headlamp.go Outdated Show resolved Hide resolved
@yolossn yolossn force-pushed the plugin_config branch 5 times, most recently from fda3ee5 to 0d2d8ea Compare February 9, 2024 06:40
@headlamp-k8s headlamp-k8s deleted a comment from github-actions bot Feb 9, 2024
@headlamp-k8s headlamp-k8s deleted a comment from github-actions bot Feb 9, 2024
@headlamp-k8s headlamp-k8s deleted a comment from github-actions bot Feb 9, 2024
@yolossn yolossn force-pushed the plugin_config branch 2 times, most recently from 167bb59 to 8a71f4b Compare February 9, 2024 07:16
@yolossn yolossn requested a review from illume February 9, 2024 07:32
@headlamp-k8s headlamp-k8s deleted a comment from github-actions bot Feb 9, 2024
Copy link

github-actions bot commented Feb 9, 2024

Backend Code coverage changed from 55.5% to 56.1%. Change: .6% 😃.

@yolossn yolossn requested a review from joaquimrocha February 9, 2024 08:13
@yolossn yolossn linked an issue Feb 28, 2024 that may be closed by this pull request
Copy link

Backend Code coverage changed from 55.5% to 56.1%. Change: .6% 😃.

Copy link

Backend Code coverage changed from 55.5% to 56.2%. Change: .7% 😃.

backend/cmd/headlamp.go Show resolved Hide resolved
frontend/src/plugin/pluginConfigSlice.ts Show resolved Hide resolved
frontend/src/plugin/pluginConfigSlice.ts Outdated Show resolved Hide resolved
frontend/src/lib/k8s/apiProxy.ts Outdated Show resolved Hide resolved
frontend/src/lib/router.tsx Show resolved Hide resolved
docs/development/plugins/functionality.md Outdated Show resolved Hide resolved
frontend/src/lib/router.tsx Show resolved Hide resolved
this patch adds plugin config store that is
responsible for handling the storage and
retrieval of plugin configs

Signed-off-by: yolossn <[email protected]>
this patch adds deletePlugin function to
apiProxy, it calls the delete plugin endpoint
with all necessary headers to handle auth.

Signed-off-by: yolossn <[email protected]>
this patch updates the plugin settings view,
filter is added to the table, Origin now
can be configured to link to a custom URL and
enable buttons UI is improved.

Signed-off-by: yolossn <[email protected]>
this commit adds PluginDetails page and
storybook for it.

Signed-off-by: yolossn <[email protected]>
this patch adds plugin settings component which
can be used by the user to configure custom
logo by providing the URL.

Signed-off-by: yolossn <[email protected]>
this patch registers a Settings Detail Component
which allows the user to set the error message to
be displayed when the pods count cannot be
retrieved.

Signed-off-by: yolossn <[email protected]>
this patch adds docs for registerPluginSettings and
its related types.

Signed-off-by: yolossn <[email protected]>
this patch makes the plugin settings available in
all modes, earlier it wasn't available in in-cluster
mode.

Signed-off-by: yolossn <[email protected]>
Copy link

Backend Code coverage changed from 55.4% to 56.0%. Change: .6% 😃.

@yolossn yolossn requested a review from joaquimrocha February 28, 2024 19:21
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.

I think this LGTM now.
BTW, I thought the "now enabled" routes were initially added here and that was a mistake as you mentioned @yolossn . But making the routes available does mean users will see the "disable" button, and I think disabling plugins shouldn't work unless in the app mode.
This can be added in a second PR, but maybe it's important to have it for the release?
WDYT @illume ?

@yolossn
Copy link
Contributor Author

yolossn commented Feb 29, 2024

@yolossn . But making the routes available does mean users will see the "disable" button, and I think disabling plugins shouldn't work unless in the app mode.

A check is added to make sure the Delete plugin is only visible in the app mode. So the button wont be visible to the user. And similarly check is added in the backend to make sure the delete API route isn't available in the in-cluster mode.

https://github.com/headlamp-k8s/headlamp/pull/1678/files#diff-4803c78d91a225f18ee5bd4c6eda6e00b92e0f7055f9b91f909af685d725a71dR191

Copy link
Collaborator

@illume illume left a comment

Choose a reason for hiding this comment

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

🎉🎈

@illume illume changed the title Add Plugin Settings Detail View and Plugin Config Store. Add Plugin Settings Detail View and Plugin Config Store Feb 29, 2024
@illume illume added enhancement New feature or request backend Issues related to the backend frontend Issues related to the frontend plugins labels Feb 29, 2024
@yolossn yolossn merged commit b159e3c into main Feb 29, 2024
11 checks passed
@yolossn yolossn deleted the plugin_config branch February 29, 2024 13:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend Issues related to the backend enhancement New feature or request frontend Issues related to the frontend plugins
Projects
None yet
Development

Successfully merging this pull request may close these issues.

RFC: Add settings for plugins
4 participants