Skip to content

Conversation

@christianvogt
Copy link
Contributor

@christianvogt christianvogt commented May 25, 2019

Adds a new extension for contributing a Perspective. This is for supporting the developer perspective.

  export interface Perspective {
    id: string;
    name: string;
    icon: React.ReactElement;
    landingPageURL: string;
    default?: boolean;
  }

Changes includes:

  • Contribution of default Administrator perspective.
  • Ability to switch perspectives from the application launcher menu in the masthead as a temporary solution until PF4 and UX settle on a design for the mega-menu. Unless there are multiple perspectives registered, the actions will not show up in this menu. Therefore until we have the developer perspective merged into the repo, there won't be able visible UI related to perspectives.
  • Adds redux actions, reducers, and selectors for working with perspectives.
  • When the perspective is set, its ID is stored in localStorage such that a returning user will be in their last active perspective. This functionality is similar to active namespace.

fyi @rohitkrai03

@openshift-ci-robot openshift-ci-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label May 25, 2019
@christianvogt
Copy link
Contributor Author

/cc @vojtechszocs @spadgett

@christianvogt
Copy link
Contributor Author

/retest

@spadgett spadgett added this to the v4.2 milestone May 27, 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.

Looks good. Will need rebase.

@vojtechszocs PTAL

/approve

/* The perspective display icon. */
icon: React.ReactNode;
/* The perspective landing page URL. */
landingPageUrl: string;
Copy link
Member

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

Suggested change
landingPageUrl: string;
landingPageURL: string;

Copy link
Contributor Author

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>,
Copy link
Member

Choose a reason for hiding this comment

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

React.Fragment?

Copy link
Contributor Author

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

@openshift-ci-robot openshift-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label May 28, 2019
@christianvogt christianvogt force-pushed the perspectives branch 2 times, most recently from 81de0c5 to a66f1a5 Compare May 28, 2019 15:14
Copy link
Contributor

@vojtechszocs vojtechszocs left a 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 @@

Copy link
Contributor

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.

Copy link
Contributor Author

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": {
Copy link
Contributor

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).

Copy link
Contributor Author

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', () => {
Copy link
Contributor

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. */
Copy link
Contributor

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)?

Copy link
Contributor Author

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;
Copy link
Contributor

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.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added a sample perspective.

@christianvogt
Copy link
Contributor Author

/retest

@christianvogt christianvogt force-pushed the perspectives branch 4 times, most recently from 0c34c36 to 3610511 Compare May 29, 2019 01:50
@christianvogt
Copy link
Contributor Author

@vojtechszocs @spadgett I've updated this PR with the suggested changes.

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

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label May 29, 2019
@openshift-ci-robot
Copy link
Contributor

[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

Details 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-merge-robot openshift-merge-robot merged commit ec53265 into openshift:master May 29, 2019
@christianvogt christianvogt deleted the perspectives branch June 5, 2019 13:35
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. lgtm Indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants