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

Separate front-end components and add mock activities service. #2626

Merged
merged 3 commits into from
Mar 8, 2019

Conversation

prodonjs
Copy link
Contributor

@prodonjs prodonjs commented Mar 5, 2019

  • Adds deep-link routing behavior for all front-end pages.
    Iframed pages reflect a URL to the browser that makes them
    linkable but hides the internal page.
  • Seperates the front-end into subcomponents, including an
    activities view.
  • Fix iframe view behavior to have it cover the space voided
    by the layout header.
  • Adds /api/activities endpoint to the Express server for
    activities to eventually be replaced with real data.
  • Sets the _devMode flag to true based on the webpack build env.

Addresses #2614 and #2615


This change is Reviewable

@prodonjs
Copy link
Contributor Author

prodonjs commented Mar 5, 2019

/assign @avdaredevil

@prodonjs
Copy link
Contributor Author

prodonjs commented Mar 5, 2019

/test kubeflow-presubmit

});
}

app.use(express.json());
app.use(express.static(frontEnd));

app.get("/api", (req: express.Request, res: express.Response) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we please seperate API's to ./api.ts and import it here as

import apiRoutes from './api'
/* blah blah */
app.use(apiRoutes);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Understood. I intend to break this apart with the PR that addresses #2615 as it will require some additional changes in the API layer.

});
}
return activities.sort((a, b) => {
return a.time > b.time ? -1 : 1;
Copy link
Contributor

Choose a reason for hiding this comment

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

Could technically also do:

activities.sort((a, b) => b.time - a.time)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good suggestion. I like the succinctness.

@@ -6,6 +6,7 @@
"extends": ["eslint:recommended", "google"],
"globals": {
"VERSION": true,
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't version be a string perhaps "dev-build"?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually, this is just indicating to ESLint that the value is considered to be in-scope at runtime so the linter doesn't complain.

Based on the docs, it looks like the best option is to set them to readonly.

Copy link
Contributor

Choose a reason for hiding this comment

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

I see, thanks!

_onResponse(responseEvent) {
const {status, response} = responseEvent.detail;
this.activities = [];
if (status === 200) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we invert this condition and decrease code depth:

if (status != 200) return;

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good call. I think we'll want to add some kind of means for surfacing an request failure as well so that block will be expanded.

{
link: 'https://www.kubeflow.org/docs/about/kubeflow/',
iframeUrl: 'https://www.kubeflow.org/docs/about/kubeflow/',
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we go with href? Not all are guaranteed to open in the iframe (ie. this one!)

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 introduced href to be the attribute that is used when setting the anchor tag's href property on our UI to indicate the local "route". I changed link to iframeUrl since it was being assigned to the component's iframeUrl property. Other than the Home link which I moved out of the menuLinks list, all of the other ones opened in the iframe view in the existing code.

Copy link
Contributor

Choose a reason for hiding this comment

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

In your new PR please also move out the docs page, thanks!

text: 'Kubeflow docs',
href: '/docs',
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 call this route so it's clear this is a route for the current page rather than a Hypertext REFerence.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

See my above comment for my rationale. I'm not opposed to this change but LMK what you think.

const url = new URL(e.currentTarget.href);
window.history.pushState({}, null, `_${url.pathname}`);
window.dispatchEvent(new CustomEvent('location-changed'));
e.preventDefault();
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this actually work in the cluster? If it's a matter of unique routes, we can prefix all our routes with d/ for dashboard.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It does. I also considered the anchor links approach which can be configured in app-location. That's a more futureproof solution if we are concerned about collisions.

app-location(route='{{route}}')
app-route(route='{{route}}', pattern='/:page', data='{{routeData}}', tail='{{subRouteData}}')


Copy link
Contributor

Choose a reason for hiding this comment

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

One too many extra whitespaces

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Got it..

section.build build version
span(title="Build: v[[buildVersion]] | Dashboard: v[[dashVersion]]") v[[buildVersion]]
section.build build version
span(title="Build: v[[buildVersion]] | Dashboard: v[[dashVersion]]") v[[buildVersion]]
Copy link
Contributor

Choose a reason for hiding this comment

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

Revert change on this line

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My editor is set to trim trailing whitespace which would be a common setting many users would have. I added the &nbsp to be explicit.

paper-tab(page='dashboard', link)
a.link(tabindex='-1', href='/') DASHBOARD
paper-tab(page='activity', link,hidden$='[[!_devMode]]')
a.link(tabindex='-1', href='/activity') ACTIVITY
Copy link
Contributor

Choose a reason for hiding this comment

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

The case doesn't match the mock:
image

Also great job with simplifying the neon-animatable-pages with the app-router! 🎉

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks. I think I got caught up viewing the GCP console Dashboard and Activity tabs which use all caps.
cczvgbouvu8

With respect to the namespace selector, ours has never included the rounded border shown in the mock, but I didn't make any changes to it in this PR.

@prodonjs
Copy link
Contributor Author

prodonjs commented Mar 8, 2019

@avdaredevil PTAL when you can. This merges the changes from #2651. If possible, I'd like to get this change in since it separates the front-end components and makes it easier to divide work going forward.

@prodonjs
Copy link
Contributor Author

prodonjs commented Mar 8, 2019

Also, the responsiveness doesn't work particularly well on mobile if that's a concern at this point. This was true of the code that I merged from as well. I don't think we need to address it here but it shouldn't be too tough to give it a flex layout with wrapping.

p7yjt6ey6zx

@avdaredevil
Copy link
Contributor

Responsiveness isn't a required feature (in fact it's not even in the pipeline as most of our clients are on Desktop / Laptops). However, I decided to make it slightly responsive for those screens for the sake of 800px to 1600px screens

@avdaredevil
Copy link
Contributor

/lgtm
/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: avdaredevil

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:

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

- Adds deep-link routing behavior for all front-end pages.
  Iframed pages reflect a URL to the browser that makes them
  linkable but hides the internal page.
- Seperates the front-end into subcomponents, including an
  activities view.
- Fix iframe view behavior to have it cover the space voided
  by the layout header.
- Adds /api/activities endpoint to the Express server for
  activities to eventually be replaced with real data.
- Sets the _devMode flag to true based on the webpack build env.
@prodonjs
Copy link
Contributor Author

prodonjs commented Mar 8, 2019

@avdaredevil Merge conflict fixed. PTAL.

@avdaredevil
Copy link
Contributor

/lgtm

@k8s-ci-robot k8s-ci-robot merged commit 3f4f39f into kubeflow:master Mar 8, 2019
kkasravi pushed a commit to kkasravi/kubeflow that referenced this pull request Mar 8, 2019
…low#2626)

* Separate front-end components and add mock activities service.

- Adds deep-link routing behavior for all front-end pages.
  Iframed pages reflect a URL to the browser that makes them
  linkable but hides the internal page.
- Seperates the front-end into subcomponents, including an
  activities view.
- Fix iframe view behavior to have it cover the space voided
  by the layout header.
- Adds /api/activities endpoint to the Express server for
  activities to eventually be replaced with real data.
- Sets the _devMode flag to true based on the webpack build env.

* Address PR comments

* Merge changes from PR kubeflow#2651
@prodonjs prodonjs deleted the routing-and-activities branch March 19, 2019 14:27
saffaalvi pushed a commit to StatCan/kubeflow that referenced this pull request Feb 11, 2021
…low#2626)

* Separate front-end components and add mock activities service.

- Adds deep-link routing behavior for all front-end pages.
  Iframed pages reflect a URL to the browser that makes them
  linkable but hides the internal page.
- Seperates the front-end into subcomponents, including an
  activities view.
- Fix iframe view behavior to have it cover the space voided
  by the layout header.
- Adds /api/activities endpoint to the Express server for
  activities to eventually be replaced with real data.
- Sets the _devMode flag to true based on the webpack build env.

* Address PR comments

* Merge changes from PR kubeflow#2651
saffaalvi pushed a commit to StatCan/kubeflow that referenced this pull request Feb 12, 2021
…low#2626)

* Separate front-end components and add mock activities service.

- Adds deep-link routing behavior for all front-end pages.
  Iframed pages reflect a URL to the browser that makes them
  linkable but hides the internal page.
- Seperates the front-end into subcomponents, including an
  activities view.
- Fix iframe view behavior to have it cover the space voided
  by the layout header.
- Adds /api/activities endpoint to the Express server for
  activities to eventually be replaced with real data.
- Sets the _devMode flag to true based on the webpack build env.

* Address PR comments

* Merge changes from PR kubeflow#2651
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants