-
Notifications
You must be signed in to change notification settings - Fork 6
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
COR-680: Tenant Switcher #522
Conversation
…for displaying tenant list
…er to hold sidenav classes
…Rails.authenticityToken() api to obtain CSRF token
} from 'dashboard/elements/loaders' | ||
|
||
const TenantItem = ({name, subdomain}, tenantClicked) => ( | ||
<li key={subdomain} className="mdl-list__item" onClick={tenantClicked}> |
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 think you'd need to add the button role (among other things, such as tabindex
) to make this accessible: https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/ARIA_Techniques/Using_the_button_role
More important for Employer than Cortex, but accessability issues are something we want to avoid regardless
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.
Ok I will add
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 catch here! Could the contents of the li
be a button
or a
tag instead? Then you wouldn't need the button role. Before adding ARIA roles consider if there is a way to make the HTML more semantic
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.
@arelia I just used the mdl https://getmdl.io/components/index.html#lists-section examples for list items and if I were to add a button inside of the list item I would have to add extra styling to override the default browser stylings and well as account for potential overriding of any default behaviors. I just tried wrapping the list items and it would require a lot of extra styling:
- button
…tainer to remove sidebar--tenant-display class from #layout_wrapper on successful tenant switch
… method to index and create a lookup object for tenants by organization
…enant to tenant if null
…on_displayed back to selected_tenant organization
@MKwenhua The main issue I'm seeing so far is that there's no way to select a top-level tenant/org - if you click it, it expands to display sub-tenants, but does not allow you to select the top-level tenant itself. Most of our users will be interacting with top-level tenants, so this we'll need to sort out how this works prior to merge. Let's whiteboard this and discuss. |
@toastercup Oh yeah! How did I miss that, when you get the time let's discuss the implementation details |
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 don't think I need to re-review for any of my comments, since all of this is temporary. The only thing I'm really concerned about is making sure there are li
s nested in the ul
tags and not span
s
}); | ||
// $(document).ready(function(){ | ||
// $('#sidebar__toggle-button').on('click', function() { | ||
// $('body').toggleClass('sidebar--collapsed'); |
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.
Either way is fine with me, but since you've commented this out, if you're planning to bring this back later should the class name go back to being .layout__container
so that it works if you un-comment this?
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.
Oh actually I was planning on removing that code completely, but yeah I have changed it to having a parent conatianer over .layout__container
called #layout_wrapper
which is used for the three Dashboard layout states 'no class', .sidebar--collapsed
, and .sidebar--tentant-display
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.
👍
height: 11em; | ||
border-radius: 50%; | ||
background: $color-teal; | ||
background: -moz-linear-gradient(left, $color-teal 10%, rgba(0,255,255, 0) 42%); |
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.
this doesn't reallly matter since all of this will eventually be redone, but Cortex only supports newer browsers and newer browsers don't need the prefixed version of linear-gradient
, so you only need line 22
same for animation
transform
and @keyframes
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 didn't write this I just copied and pasted the css code I found here: https://projects.lukehaas.me/css-loaders/ pretty much all of the styles I have added are just temporary placeholders.
But with that said I will go back and remove the vendor prefixes.
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.
👍
if (environment === 'production') return null | ||
const flagClass = `mdl-navigation__link nav__item environment environment--${environment}` | ||
return ( | ||
<div className={flagClass}> |
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.
instead of rendering both div
s, could you wrap them in an if/else?
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.
Technically yes, but already in the CSS . environment__full
is hidden and . environment__abbreviated
is displayed when it has a parent with .sidebar--collapsed
.
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.
👍 ok that's fine, it was just a thought since you're adding React
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.
Oh yeah, but I realized the logic was already accounted for so I just rendered out the HTML. Glad that the logic was already there so that I wouldn't have to account for it when creating the components
} from 'dashboard/elements/loaders' | ||
|
||
const TenantItem = ({name, subdomain}, tenantClicked) => ( | ||
<li key={subdomain} className="mdl-list__item" onClick={tenantClicked}> |
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 catch here! Could the contents of the li
be a button
or a
tag instead? Then you wouldn't need the button role. Before adding ARIA roles consider if there is a way to make the HTML more semantic
let {org_tenant, sub_tenants } = OrganizationLookup[org_id] | ||
return ( | ||
<span key={org_tenant.subdomain + '_org'}> | ||
<li role="button" className={ "mdl-list__item organization--label" + (organization_displayed === org_tenant.id ? ' active' : '' ) } tabIndex={index} onClick={organizationClicked(org_id)}><strong>{org_tenant.name}</strong></li> |
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.
return OrganizationLookup.organizations.map((org_id, index) => { | ||
let {org_tenant, sub_tenants } = OrganizationLookup[org_id] | ||
return ( | ||
<span key={org_tenant.subdomain + '_org'}> |
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.
Since these are going to get rendered into a ul
, which can only take li
s as children, can you move the key
attribute to the li
tag?
Add the subtenent ul
before the closing li
tag (because it's a list nested inside a list, right?), or move it into it's own component if you have to (if it's not meant to be nested), and that way you'll still have everything wrapped inside of one tag
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.
@arelia Ok good catch! I changed it to UL
instead.
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.
@MKwenhua I don't think the span
needs to be a ul
, just move the </li>
so that is is after the </ul>
and remove the spans
, like this
return (
<li key={org_tenant.subdomain + '_org'} role="button" className={ "mdl-list__item organization--label" + (organization_displayed === org_tenant.id ? ' active' : '' ) } tabIndex={index} onClick={organizationClicked(org_id)}>
<strong>{org_tenant.name}</strong>
<ul className={ organization_displayed === org_tenant.id ? "demo-list-icon mdl-list" : "hidden"}>
{ sub_tenants.map((tenant) => TenantItem(tenant, () => selectTenant(tenant)) )}
</ul>
</li>
)
The subtenant list is a sub-list of the org tenant list, and so you can wrap that ul
completely in the li
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.
@arelia yeah, using li
was my first approach but there is some default hover state and styling set to list items so I ended up creating a class to offset it called .organization-tenants-list
but then I decided that a UL would be easier, in fact I should probably remove the wrapping <ul className="demo-list-icon mdl-list">
and have the resulting HTML output like <ul>org 1 list</ul><ul>org 2 list</ul><ul>org 3 list</ul>
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 think semantically it makes sense to have it all wrapped in <ul className="demo-list-icon mdl-list">
but again, since we'll re-do all of this do whatever works and is easiest, that's fine with me! So if you don't make any more changes, I'm okay with that
…l legacy concerns (API, Localizations, Doorkeeper, Abilities, etc)
…ancyLookup to tenantLookupTable
…ant FK to correct table, start to integrate with Tenant Switcher component
…tenant list header
… to base record class, simplify and correct various associations
…ble ContentItems per-tenant, implement basic Org logic, simplify active_tenant behavior, refresh upon tenant switch, prepare seeds
CE-154: Tenancy
CE-188: Tenancy Pagination Logic & UI
Purpose:
Have a tenant switcher so that users can easily change the Cortex Tenant like CircleCI
JIRA:
https://cb-content-enablement.atlassian.net/browse/COR-680
Steps to Take On Prod
Changes:
Changes to setup
bundle exec rake db:migrate
Architectural changes
*
Migrations
User
active_tenant
Library changes
cortex-plugins
Side effects
*
Screenshots
Before
After
QA Links:
http://web.cortex-3.development.c66.me/
How to Verify These Changes
Specific pages to visit
*
Steps to take
*
Relevant PRs/Dependencies:
cortex-cms/cortex-plugins-core#60
Additional Information
A few things to note: classes like
.sidebar--tentant-display
are temporary and should be removed once both the side bar and the content area are rendered within React.