-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Conversation
/assign @avdaredevil |
/test kubeflow-presubmit |
}); | ||
} | ||
|
||
app.use(express.json()); | ||
app.use(express.static(frontEnd)); | ||
|
||
app.get("/api", (req: express.Request, res: express.Response) => { |
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.
Can we please seperate API's to ./api.ts
and import it here as
import apiRoutes from './api'
/* blah blah */
app.use(apiRoutes);
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.
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; |
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.
Could technically also do:
activities.sort((a, b) => b.time - a.time)
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.
Good suggestion. I like the succinctness.
@@ -6,6 +6,7 @@ | |||
"extends": ["eslint:recommended", "google"], | |||
"globals": { | |||
"VERSION": true, |
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.
Shouldn't version be a string
perhaps "dev-build"
?
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.
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.
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 see, thanks!
_onResponse(responseEvent) { | ||
const {status, response} = responseEvent.detail; | ||
this.activities = []; | ||
if (status === 200) { |
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.
Can we invert this condition and decrease code depth:
if (status != 200) return;
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.
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/', |
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.
Could we go with href
? Not all are guaranteed to open in the iframe (ie. this one!)
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 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.
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.
In your new PR please also move out the docs page, thanks!
text: 'Kubeflow docs', | ||
href: '/docs', |
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.
Let's call this route
so it's clear this is a route for the current page rather than a Hypertext REFerence.
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.
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(); |
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.
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
.
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.
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}}') | ||
|
||
|
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.
One too many extra whitespaces
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.
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]] |
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.
Revert change on this line
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.
My editor is set to trim trailing whitespace which would be a common setting many users would have. I added the  
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 |
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.
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.
9896909
to
7b3fad3
Compare
@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. |
7b3fad3
to
b6c8df8
Compare
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 |
/lgtm |
[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 |
- 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.
b6c8df8
to
4ea2c5b
Compare
@avdaredevil Merge conflict fixed. PTAL. |
/lgtm |
…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
…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
…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
Iframed pages reflect a URL to the browser that makes them
linkable but hides the internal page.
activities view.
by the layout header.
activities to eventually be replaced with real data.
Addresses #2614 and #2615
This change is![Reviewable](https://camo.githubusercontent.com/23b05f5fb48215c989e92cc44cf6512512d083132bd3daf689867c8d9d386888/68747470733a2f2f72657669657761626c652e696f2f7265766965775f627574746f6e2e737667)