-
Notifications
You must be signed in to change notification settings - Fork 667
add Perspective extension and default admin perspective #1615
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 Perspective extension and default admin perspective #1615
Conversation
0a9bd5e to
81e3503
Compare
|
/retest |
spadgett
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| /* The perspective display icon. */ | ||
| icon: React.ReactNode; | ||
| /* The perspective landing page URL. */ | ||
| landingPageUrl: string; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: with current console naming conventions, this would be URL
| landingPageUrl: string; | |
| landingPageURL: string; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated to landingPageURL
| ...perspectives | ||
| .sort((a, b) => a.properties.name.localeCompare(b.properties.name)) | ||
| .map(p => ({ | ||
| label: <span>{p.properties.icon} {p.properties.name}</span>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
React.Fragment?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed to use React.Fragment
81de0c5 to
a66f1a5
Compare
vojtechszocs
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@christianvogt This looks great! Please see my inline comments.
| @@ -0,0 +1,25 @@ | |||
|
|
|||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit-pick: please remove leading newline.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed.
| @@ -8,5 +8,8 @@ | |||
| "@console/internal": "0.0.0-fixed", | |||
| "@console/plugin-sdk": "0.0.0-fixed", | |||
| "@console/shared": "0.0.0-fixed" | |||
| }, | |||
| "consolePlugin": { | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This means that Console application itself can contribute extensions, I like that 👍
As a follow-up, we can revisit supported extension types and represent related Console application code through console-app/src/plugin.tsx (e.g. all the base models).
This also means we'll likely need a way to order plugins before processing their extensions, i.e. console-app's models should be defined before any other models.
I was thinking about e.g. "order": "before:X" and "order": "after:X" within the consolePlugin object, where X is the name of the plugin or after:@console/app (if not specified, it would fallback to after:all).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can see value in having order but not for the current set of use cases we have.
If we can avoid introducing an order altogether for extensions I think it would be great to keep things simple.
| @@ -69,6 +69,17 @@ describe('codegen', () => { | |||
| { ...pluginPackages[0] }, | |||
| ]); | |||
| }); | |||
|
|
|||
| it('should include appPackage as a valid plugin package', () => { | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 on test-covering the change in getActivePluginPackages
| icon: React.ReactNode; | ||
| /* The perspective landing page URL. */ | ||
| landingPageURL: string; | ||
| /* Whether the perspective is the default. There can only be one default. */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens if:
- a plugin declares two perspectives each with
default: true - two plugins each declare a perspective with
default: true
This could be handled by taking the first default one and discarding the rest, or just omitting the default option and assume there will always be at least one perspective (added by Console application itself) and that one is the default (because it's declared as the first one).
@christianvogt @spadgett What are your thoughts on this?
This relates to my comment above, regarding plugin evaluation order, i.e. Console application's plugin should be processed before any other plugins.
Also, what happens if a plugin tries to redefine existing perspective (same id)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there should be a generic mechanism for each extension owner (if we ever support plugins providing their own extensions then we'll have more than console core owning extensions) to define their own extension processor. This would allow the owner to validate the contributed extensions. Duplicate perspective IDs or multiple defined as a default would be runtime errors.
Maybe we should create an ExtensionProcessor extension :) wherein you contribute a function to process extensions by type. The function would receive the list of contributed extensions and it could throw an error in case of duplicate IDs. It could also log warnings. The return value is an array of extensions in case the processor chose to add or subtract from the list. This mechanism could be used to contribute CRD based extensions in the future. eg a mega-menu extension will get extra values contributed via CRDs.
| } from '@console/plugin-sdk'; | ||
|
|
||
| type ConsumedExtensions = | ||
| | Perspective; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we want to add a Perspective extension example to console-demo-plugin too?
(I was thinking of a unit test that checks if demo plugin uses all supported extension types.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a sample perspective.
a66f1a5 to
dc6e54a
Compare
|
/retest |
0c34c36 to
3610511
Compare
|
@vojtechszocs @spadgett I've updated this PR with the suggested changes. |
3610511 to
1fea925
Compare
spadgett
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: christianvogt, spadgett The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Adds a new extension for contributing a
Perspective. This is for supporting the developer perspective.Changes includes:
Administratorperspective.fyi @rohitkrai03