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 optional rootWindow option to route plugin #5645

Closed

Conversation

yaacov
Copy link
Member

@yaacov yaacov commented Jun 2, 2020

Description
Add an optional option to render routes in root window instead of inside the layout.

Rational
Some plugin and currently internal views can benefit from "full screen" views.

Current use cases

  • For the kubevirt-plugin we want to render the VNC terminal using a detached window [1] [2] , having the possibility to add a "full screen" route in the plugin. will give us the option to maintaine the VNC console without the need to mange the hard coded route in the common app.

  • We currently have a /terminal path hard-coded to the app root paths, this approach can give developers the option to move the terminal view into a plugin structure if they will want to.

IMHO oc terminal view and VNC console view are just examples for a common need, maybe other users can think of other use cases like a "full screen" topology or monitoring views ?

Example
Route with rootWindow: true

  {
    type: 'Page/Route',
    properties: {
      exact: true,
      path: '/test-root',
      rootWindow: true,
      render: () => <h1>Test Root Window Page</h1>,
    },
  },

Screenshot
Peek 2020-06-03 00-22

[1] RFE: https://bugzilla.redhat.com/show_bug.cgi?id=1837677
[2] #5593

Signed-off-by: yaacov <kobi.zamir@gmail.com>
@openshift-ci-robot openshift-ci-robot added the component/core Related to console core functionality label Jun 2, 2020
@openshift-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: yaacov
To complete the pull request process, please assign rawagner
You can assign the PR to them by writing /assign @rawagner in a comment when ready.

The full list of commands accepted by this bot can be found 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

@openshift-ci-robot openshift-ci-robot added the component/sdk Related to console-plugin-sdk label Jun 2, 2020
@yaacov
Copy link
Member Author

yaacov commented Jun 2, 2020

@spadgett @vojtechszocs @glekner please review

@yaacov
Copy link
Member Author

yaacov commented Jun 2, 2020

/test e2e-gcp-console

@@ -187,6 +187,16 @@ const plugin: Plugin<ConsumedExtensions> = [
},
},
},
{
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you demonstrate this new functionality by migrating the /terminal route instead of creating a test route?

Copy link
Member Author

Choose a reason for hiding this comment

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

Nice 👍
For this PR I want to have smallest footprint, a simple route show how to use it while adding minimal code ... maybe we can do a variant of the VNC terminal PR that use this plugin option ?

Copy link
Contributor

Choose a reason for hiding this comment

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

Agreed with @glekner - if we're introducing a mechanism to support "full screen" pages (rendered outside the standard Console <App> layout) then we should also refactor existing code to utilize this mechanism for better consistency.

Right now, our React router has two top-level routes:

<Route path="/terminal" component={CloudShellTab} />
<Route path="/" component={App} />

@yaacov @spadgett @christianvogt Does it make sense to move "cloud shell" (<CloudShellExec> / xterm based CLI) functionality to one of the existing Console packages?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes let's convert the cloud shell to use this extension.

Copy link
Contributor

@glekner glekner left a comment

Choose a reason for hiding this comment

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

This is Great!

@@ -187,6 +187,16 @@ const plugin: Plugin<ConsumedExtensions> = [
},
},
},
{
Copy link
Contributor

Choose a reason for hiding this comment

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

Agreed with @glekner - if we're introducing a mechanism to support "full screen" pages (rendered outside the standard Console <App> layout) then we should also refactor existing code to utilize this mechanism for better consistency.

Right now, our React router has two top-level routes:

<Route path="/terminal" component={CloudShellTab} />
<Route path="/" component={App} />

@yaacov @spadgett @christianvogt Does it make sense to move "cloud shell" (<CloudShellExec> / xterm based CLI) functionality to one of the existing Console packages?

@@ -63,6 +63,8 @@ namespace ExtensionProperties {
path: string | string[];
/** Perspective id to which this page belongs to. */
perspective?: string;
/** rootWindow indicate rendering as root window instead of layout content. */
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
/** rootWindow indicate rendering as root window instead of layout content. */
/** Whether to render this page outside the standard Console page layout. */

@@ -99,6 +100,15 @@ const getPluginPageRoutes = (activePerspective: string, flags: FlagsObject) =>
return <Component {...r.properties} key={Array.from(r.properties.path).join(',')} />;
});

const getPluginRootWindowRoutes = () =>
plugins.registry.getRoutePages().map((r) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
plugins.registry.getRoutePages().map((r) => {
plugins.registry.getRoutePages()
.filter((r) => r.properties?.rootWindow)
.map((r) => {

Copy link
Contributor

Choose a reason for hiding this comment

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

Let's move to useExtensions

@@ -99,6 +100,15 @@ const getPluginPageRoutes = (activePerspective: string, flags: FlagsObject) =>
return <Component {...r.properties} key={Array.from(r.properties.path).join(',')} />;
});

const getPluginRootWindowRoutes = () =>
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
const getPluginRootWindowRoutes = () =>
const getPluginTopLevelRoutes = () =>

@@ -63,6 +63,8 @@ namespace ExtensionProperties {
path: string | string[];
/** Perspective id to which this page belongs to. */
perspective?: string;
/** rootWindow indicate rendering as root window instead of layout content. */
rootWindow?: boolean;
Copy link
Contributor

Choose a reason for hiding this comment

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

I think rootWindow is a bit ambiguous. Maybe noLayout ?

Copy link
Contributor

Choose a reason for hiding this comment

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

Honestly i don't think a concise variable name will be descriptive enough.
IMO I'd suggest root?: boolean as rootWindow doesn't provide any more description than the other.
OR to make it even more useful for other uses, we could do context?: string and let the consumer of the extension supply the context.

@@ -99,6 +100,15 @@ const getPluginPageRoutes = (activePerspective: string, flags: FlagsObject) =>
return <Component {...r.properties} key={Array.from(r.properties.path).join(',')} />;
});

const getPluginRootWindowRoutes = () =>
plugins.registry.getRoutePages().map((r) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's move to useExtensions

@@ -215,6 +215,7 @@ render(
<Provider store={store}>
<Router history={history} basename={window.SERVER_FLAGS.basePath}>
<Switch>
{getPluginRootWindowRoutes()}
<Route path="/terminal" component={CloudShellTab} />
Copy link
Contributor

Choose a reason for hiding this comment

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

Convert /terminal to use this new extension.

@@ -63,6 +63,8 @@ namespace ExtensionProperties {
path: string | string[];
/** Perspective id to which this page belongs to. */
perspective?: string;
/** rootWindow indicate rendering as root window instead of layout content. */
rootWindow?: boolean;
Copy link
Contributor

Choose a reason for hiding this comment

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

Honestly i don't think a concise variable name will be descriptive enough.
IMO I'd suggest root?: boolean as rootWindow doesn't provide any more description than the other.
OR to make it even more useful for other uses, we could do context?: string and let the consumer of the extension supply the context.

@@ -187,6 +187,16 @@ const plugin: Plugin<ConsumedExtensions> = [
},
},
},
{
Copy link
Contributor

Choose a reason for hiding this comment

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

Yes let's convert the cloud shell to use this extension.

@openshift-ci-robot openshift-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jun 13, 2020
@openshift-ci-robot
Copy link
Contributor

@yaacov: PR needs rebase.

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/test-infra repository.

@spadgett spadgett removed their request for review June 24, 2020 13:55
@yaacov
Copy link
Member Author

yaacov commented Aug 4, 2020

This request was initiated to help with the VNC viewer PR, that is now low priority for us,
Closing since I do not have time to continue with this PR at this time.

@yaacov yaacov closed this Aug 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/core Related to console core functionality component/sdk Related to console-plugin-sdk needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants