Skip to content

Commit

Permalink
refactor(ui): move users & about nav items
Browse files Browse the repository at this point in the history
  • Loading branch information
mavarius committed Apr 23, 2020
1 parent d764ca3 commit e08860b
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 64 deletions.
37 changes: 37 additions & 0 deletions ui/src/pageLayout/components/UserWidget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
CLOUD_URL,
CLOUD_USAGE_PATH,
CLOUD_BILLING_PATH,
CLOUD_USERS_PATH,
} from 'src/shared/constants'

// Types
Expand All @@ -24,6 +25,7 @@ import {MeState} from 'src/shared/reducers/me'

// Selectors
import {getOrg} from 'src/organizations/selectors'
import {getNavItemActivation} from '../utils'

interface StateProps {
org: Organization
Expand Down Expand Up @@ -51,6 +53,8 @@ const UserWidget: FC<Props> = ({
handleShowOverlay('switch-organizations', {}, handleDismissOverlay)
}

const orgPrefix = `/orgs/${org.id}`

return (
<TreeNav.User username={me.name} team={org.name}>
<CloudOnly>
Expand All @@ -71,8 +75,41 @@ const UserWidget: FC<Props> = ({
/>
)}
/>
<TreeNav.UserItem
id="users"
label="Users"
linkElement={className => (
<a
className={className}
href={`${CLOUD_URL}/organizations/${org.id}${CLOUD_USERS_PATH}`}
/>
)}
/>
<TreeNav.UserItem
id="about"
label="About"
linkElement={className => (
<Link className={className} to="/orgs/new" />
)}
/>
</CloudOnly>
<CloudExclude>
<TreeNav.UserItem
id="members"
label="Members"
active={getNavItemActivation(['members'], location.pathname)}
linkElement={className => (
<Link className={className} to={`${orgPrefix}/members`} />
)}
/>
<TreeNav.UserItem
id="about"
label="About"
active={getNavItemActivation(['about'], location.pathname)}
linkElement={className => (
<Link className={className} to={`${orgPrefix}/about`} />
)}
/>
<TreeNav.UserItem
id="switch-orgs"
label="Switch Organizations"
Expand Down
64 changes: 0 additions & 64 deletions ui/src/pageLayout/constants/navigationHierarchy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,70 +121,6 @@ export const generateNavItems = (orgID: string): NavItem[] => {
},
activeKeywords: ['data-explorer'],
},
{
id: 'org',
testID: 'nav-item-org',
icon: IconFont.UsersTrio,
label: 'Organization',
shortLabel: 'Org',
link: {
type: 'link',
location: `${orgPrefix}/members`,
},
cloudExclude: true,
activeKeywords: ['members', 'about'],
menu: [
{
id: 'members',
testID: 'nav-subitem-members',
label: 'Members',
link: {
type: 'link',
location: `${orgPrefix}/members`,
},
},
{
id: 'about',
testID: 'nav-subitem-about',
label: 'About',
link: {
type: 'link',
location: `${orgPrefix}/about`,
},
},
],
},
{
id: 'org-quartz',
testID: 'nav-item-quartz-org',
icon: IconFont.UsersTrio,
label: 'Organization',
shortLabel: 'Org',
cloudOnly: true,
link: quartzMembersHeaderLink,
activeKeywords: ['members', 'about'],
menu: [
{
id: 'users',
testID: 'nav-subitem-users',
label: 'Members',
featureFlag: 'multiUser',
link: {
type: 'href',
location: `${CLOUD_URL}/organizations/${orgID}${CLOUD_USERS_PATH}`,
},
},
{
id: 'about',
testID: 'nav-subitem-about',
label: 'About',
link: {
type: 'link',
location: `${orgPrefix}/about`,
},
},
],
},
{
id: 'dashboards',
testID: 'nav-item-dashboards',
Expand Down

0 comments on commit e08860b

Please sign in to comment.