-
Notifications
You must be signed in to change notification settings - Fork 63
[EMB-153] Add maintenance-banner component #101
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
[EMB-153] Add maintenance-banner component #101
Conversation
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.
Your test is failing...
aaxelb
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 quickfiles navbar covers the maintenance banner (opacity manually squidgied):

I think the right thing is probably taking this opportunity to improve the osf-navbar component. It could support a generic secondary navbar (used for quickfiles nav, project nav, anything else that comes up), and be in charge of pushing the rest of the page down as far as its height. That hardcoded offset should burn...
| {{#if maintenance}} | ||
| <div class="scripted alert alert-dismissible {{alertClass}} MaintenanceBanner" role="alert"> | ||
| <button type="button" class="close" data-dismiss="alert" aria-label="Close"> | ||
| <span aria-hidden="true">{{fa-icon 'times'}}</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.
{{fa-icon}} already puts aria-hidden on for us
| {{#if maintenance.message.length}} | ||
| {{maintenance.message}} | ||
| {{else}} | ||
| {{t 'maintenance.line1'}} <strong>{{start}} {{t 'general.and'}} {{end}}</strong> ({{utc}}). |
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.
We should generally avoid splitting up sentences like this. It assumes all translations will be structured like english, and makes the template harder for eyes to parse. ember-i18n has handlebars-style interpolation for just this sort of thing:
// translations.ts
maintenance: {
line1: 'The site will undergo maintenance between <strong>{{start}} and {{end}}</strong> ({{utc}}).',
}{{! maintenance-banner/template.hbs }}
{{t 'maintenance.line1' start=start end=end utc=utc}}…r-osf-web into feature/maintenance
…ponse to code review
|
I think one component could be in charge of both rendering the navbar and claiming the space behind it. It'd be easier to reason about if it were split into subcomponents, maybe like: {{! components/osf-navbar/template.hbs }}
{{osf-navbar/primary-nav}} {{! fixed to the top, basically the old `new-osf-navbar` component }}
<div class='PrimaryBuffer'></div>
{{#if secondaryLinks}}
{{osf-navbar/secondary-nav links=secondaryLinks}} {{! fixed under the primary nav }}
<div class='SecondaryBuffer'></div>
{{/if}}
{{! everything below (the whole app) will be pushed down by the buffer divs }}
{{osf-navbar/maintenance-banner}} {{! could also be invoked in `application/template.hbs`, doesn't matter }}(I imagine // styles/_variables.scss
$navbar-primary-height = 50px;
$navbar-secondary-height = 50px;
// components/osf-navbar/styles.scss
.PrimaryBuffer {
height: $navbar-primary-height;
}
.SecondaryBuffer {
height: $navbar-secondary-height;
}
// components/osf-navbar/primary-nav/styles.scss
.NavBar {
height: $navbar-primary-height;
}
// components/osf-navbar/secondary-nav/styles.scss
.NavBar {
height: $navbar-secondary-height;
}I don't know; what do you think? |
|
@aaxelb, I really like the idea. My one concern with it is, unless I'm misunderstanding it, that we would need to generalize the secondary navbar, allowing for (when we do the contributors page) different secondary navbars. For example, the project page would need to eventually allow for the comments panel. So, instead of passing down the secondaryLinks, it would make more sense to pass down a component representing the secondary navbar. We've definitely done that before, with preprints, where the generalized discover page took components as arguments to render different filters within the discover component. So, possible, but might be a little more complex than a secondaryLinks service implies. Thoughts? |
|
@hmoco Hmm, good point. I still like the idea of a navbar service, but passing it a component name would be way cleaner than the list of objects and dynamically generated links I was imagining... Something like this? // services/navbar.ts
setNavbarState(secondaryNavComponent, secondaryNavContext) { // but not those names, something better
this.setProperties({ secondaryNavComponent, secondaryNavContext });
}
clearNavbarState() { ... }{{! components/osf-navbar/template.hbs }}
{{component navbar.secondaryNavComponent context=navbar.secondaryNavContext}}// guid-user/quickfiles/route.ts
activate() {
this.get('navbar').setNavbarState('quickfiles-nav', this.modelFor('guid-user'));
}
deactivate() {
this.get('navbar').clearNavbarState();
}// guid-node/route.ts
activate() {
this.get('navbar').setNavbarState('project-nav', this.modelFor('guid-node'));
}// guid-file/route.ts
activate() {
// might be some trickery if the file hasn't loaded yet...
// could do it in the model task instead? or pass the task itself?
if (isQuickfile) {
this.get('navbar').setNavbarState('quickfiles-nav', ...);
} else {
this.get('navbar').setNavbarState('project-nav', ...);
}
} |
|
I'm not convinced that adding secondary navbar logic to the main navbar is worth dealing with, as you've shown in your examples, activate/deactivate logic in the route, and dealing with model states. A static check in the component scope seems simpler, although I agree that the maintenance banner should not be statically included in every template (the secondary navbar tradeoff is including relevant navbars on each template that uses it or delegate so that each route passes it to the primary navbar). Will look into solutions for adding the maintenance bar. Let me know if you have further thoughts or want to sit down and find a solution |
…wing banner to be placed bellow it
…r-osf-web into feature/maintenance
jamescdavis
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.
Please resolve conflict. (see: #111)
|
Passing build: https://travis-ci.org/hmoco/ember-osf-web/builds/351509837 |

Purpose
Support maintenance messages when they are needed.
Summary of Changes
Added
maintenance-bannercomponent, to display the maintenance banner when needed.Also added support to use ember-wormhole for upcoming secondary navbars.
Ticket
https://openscience.atlassian.net/browse/EMB-153
Reviewer Checklist
CHANGELOG.md