Skip to content

Commit 81e4071

Browse files
authored
fix: use react router links in lieu of redirect for gh main menu subelements (#5828)
1 parent 640f9c6 commit 81e4071

File tree

3 files changed

+62
-39
lines changed

3 files changed

+62
-39
lines changed

cypress/e2e/cloud/globalHeader.test.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,6 @@ describe('change-account change-org global header', () => {
117117
})
118118

119119
it('navigates to the org members page', () => {
120-
makeQuartzUseIDPEOrgID()
121120
makeQuartzUseIDPEOrgID()
122121
cy.getByTestID('globalheader--org-dropdown')
123122
.should('be.visible')
@@ -243,6 +242,12 @@ describe('change-account change-org global header', () => {
243242
})
244243

245244
describe('user profile avatar', {scrollBehavior: false}, () => {
245+
before(() => {
246+
makeQuartzUseIDPEOrgID()
247+
cy.setFeatureFlags(globalHeaderFeatureFlags)
248+
cy.visit('/')
249+
})
250+
246251
it('navigates to the `user profile` page', () => {
247252
makeQuartzUseIDPEOrgID()
248253
cy.getByTestID('global-header--user-avatar').should('be.visible').click()
Lines changed: 39 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,14 @@
11
@import '@influxdata/clockface/dist/variables.scss';
22

3-
.global-header--dropdown-button {
4-
background: transparent;
5-
}
6-
.global-header--typeahead-item {
7-
width: 100%;
8-
padding-left: 14px;
3+
.button-icon {
4+
color: $cf-grey-75;
5+
margin-right: 8px;
6+
font-size: 18px;
7+
width: 18px;
98
}
109

11-
.global-header--typeahead-input {
12-
margin-top: 4px;
13-
margin-bottom: 8px;
14-
margin-left: 0;
15-
margin-right: 0;
16-
z-index: 0;
10+
.global-header--dropdown-button {
11+
background: transparent;
1712
}
1813

1914
.global-header--list {
@@ -25,11 +20,6 @@
2520
width: 4px !important;
2621
}
2722

28-
.global-header--list::-webkit-scrollbar-track {
29-
background-color: rgba($cf-grey-95, 0.15);
30-
border-radius: 20px;
31-
}
32-
3323
.global-header--list::-webkit-scrollbar-thumb {
3424
background: linear-gradient(
3525
to right,
@@ -39,23 +29,44 @@
3929
border-radius: 20px;
4030
}
4131

42-
.button-icon {
43-
color: $cf-grey-75;
44-
margin-right: 8px;
45-
font-size: 18px;
46-
width: 18px;
47-
}
48-
49-
.line-break {
50-
margin: 6px 0;
51-
background-color: rgba(241, 241, 243, 0.1);
32+
.global-header--list::-webkit-scrollbar-track {
33+
background-color: rgba($cf-grey-95, 0.15);
34+
border-radius: 20px;
5235
}
5336

54-
.global-header--align-center {
37+
.global-header--main-dropdown-item {
5538
display: flex;
5639
align-items: center;
40+
width: 100%;
41+
}
42+
43+
.global-header--main-dropdown-item-link {
44+
width: 100%;
45+
border-radius: 2px;
46+
color: #ffffff !important;
47+
display: flex !important;
48+
font-weight: 400 !important;
49+
padding: 0px;
5750
}
5851

5952
.global-header--switch-button {
6053
background-color: transparent !important;
6154
}
55+
56+
.global-header--typeahead-input {
57+
margin-top: 4px;
58+
margin-bottom: 8px;
59+
margin-left: 0;
60+
margin-right: 0;
61+
z-index: 0;
62+
}
63+
64+
.global-header--typeahead-item {
65+
width: 100%;
66+
padding-left: 14px;
67+
}
68+
69+
.line-break {
70+
margin: 6px 0;
71+
background-color: rgba(241, 241, 243, 0.1);
72+
}

src/identity/components/GlobalHeader/GlobalHeaderDropdown/index.tsx

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// Libraries
22
import React, {MouseEvent} from 'react'
3+
import {Link} from 'react-router-dom'
34

45
// Components
56
import {
@@ -112,7 +113,7 @@ export class GlobalHeaderDropdown extends React.Component<Props, State> {
112113
this.setState({showTypeAheadMenu: !showTypeAheadMenu})
113114
}
114115

115-
private renderMainMenuOptions = () => {
116+
private renderMainMenuOptions = (onCollapse: VoidFunction) => {
116117
const {mainMenuOptions} = this.props
117118
return (
118119
<div>
@@ -126,15 +127,21 @@ export class GlobalHeaderDropdown extends React.Component<Props, State> {
126127
onClick={this.sendMainMenuEvent(menuItem.name)}
127128
key={`eventWrapper.${menuItem.name}`}
128129
>
129-
<Dropdown.HrefItem
130-
className="global-header--align-center"
130+
<Dropdown.LinkItem
131+
className="global-header--main-dropdown-item"
131132
key={menuItem.name}
132-
href={menuItem.href}
133133
testID={`${this.props.mainMenuTestID}-${menuItem.name}`}
134+
selected={false}
134135
>
135-
{iconEl}
136-
{textEl}
137-
</Dropdown.HrefItem>
136+
<Link
137+
to={menuItem.href}
138+
className="global-header--main-dropdown-item-link"
139+
onClick={onCollapse}
140+
>
141+
{iconEl}
142+
{textEl}
143+
</Link>
144+
</Dropdown.LinkItem>
138145
</div>
139146
)
140147
})}
@@ -164,7 +171,7 @@ export class GlobalHeaderDropdown extends React.Component<Props, State> {
164171
)
165172
}
166173

167-
private renderMenu = () => {
174+
private renderMenu = (onCollapse: VoidFunction) => {
168175
const {
169176
dropdownMenuStyle,
170177
dropdownMenuTheme = DropdownMenuTheme.None,
@@ -216,7 +223,7 @@ export class GlobalHeaderDropdown extends React.Component<Props, State> {
216223
)}
217224
{showTypeAheadMenu
218225
? this.renderTypeAheadMenu()
219-
: this.renderMainMenuOptions()}
226+
: this.renderMainMenuOptions(onCollapse)}
220227
</Dropdown.Menu>
221228
)
222229
}
@@ -230,7 +237,7 @@ export class GlobalHeaderDropdown extends React.Component<Props, State> {
230237
{...dropdownProps}
231238
button={this.dropdownButton}
232239
disableAutoFocus
233-
menu={this.renderMenu}
240+
menu={onCollapse => this.renderMenu(onCollapse)}
234241
testID={this.props.testID}
235242
/>
236243
)

0 commit comments

Comments
 (0)