-
Notifications
You must be signed in to change notification settings - Fork 367
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
fix: [M3-7571] - Missing label for Full Account Access Toggle #10931
Merged
Merged
Changes from 2 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
16011c3
fix: [M3-7571] - Missing label for Full Account Access Toggle
carrillo-erik 9c66182
Add changeset
carrillo-erik 362e60c
Update e2e tests
carrillo-erik 1a84ef3
Update headers based on PR feedback and lighthouse results
carrillo-erik f1597cc
Merge branch 'develop' of https://github.com/linode/manager into fix/β¦
carrillo-erik a8fa11c
Merge branch 'develop' of https://github.com/linode/manager into fix/β¦
carrillo-erik File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@linode/manager": Fixed | ||
--- | ||
|
||
Missing label for Full Account Toggle ([#10931](https://github.com/linode/manager/pull/10931)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,19 @@ | ||
import { | ||
GlobalGrantTypes, | ||
Grant, | ||
GrantLevel, | ||
GrantType, | ||
Grants, | ||
User, | ||
getGrants, | ||
getUser, | ||
updateGrants, | ||
updateUser, | ||
} from '@linode/api-v4/lib/account'; | ||
import { APIError } from '@linode/api-v4/lib/types'; | ||
import { Paper } from '@mui/material'; | ||
import Grid from '@mui/material/Unstable_Grid2'; | ||
import { QueryClient } from '@tanstack/react-query'; | ||
import { enqueueSnackbar } from 'notistack'; | ||
import { compose, flatten, lensPath, omit, set } from 'ramda'; | ||
import * as React from 'react'; | ||
|
||
import { ActionsPanel } from 'src/components/ActionsPanel/ActionsPanel'; | ||
import { Box } from 'src/components/Box'; | ||
import { CircleProgress } from 'src/components/CircleProgress'; | ||
// import { Button } from 'src/components/Button/Button'; | ||
import { DocumentTitleSegment } from 'src/components/DocumentTitle'; | ||
import { Item } from 'src/components/EnhancedSelect/Select'; | ||
import { FormControlLabel } from 'src/components/FormControlLabel'; | ||
import { Notice } from 'src/components/Notice/Notice'; | ||
import { SelectionCard } from 'src/components/SelectionCard/SelectionCard'; | ||
|
@@ -34,14 +24,8 @@ import { TabPanels } from 'src/components/Tabs/TabPanels'; | |
import { Tabs } from 'src/components/Tabs/Tabs'; | ||
import { Toggle } from 'src/components/Toggle/Toggle'; | ||
import { Typography } from 'src/components/Typography'; | ||
import { | ||
WithFeatureFlagProps, | ||
withFeatureFlags, | ||
} from 'src/containers/flags.container'; | ||
import { | ||
WithQueryClientProps, | ||
withQueryClient, | ||
} from 'src/containers/withQueryClient.container'; | ||
import { withFeatureFlags } from 'src/containers/flags.container'; | ||
import { withQueryClient } from 'src/containers/withQueryClient.container'; | ||
import { PARENT_USER, grantTypeMap } from 'src/features/Account/constants'; | ||
import { accountQueries } from 'src/queries/account/queries'; | ||
import { getAPIErrorOrDefault } from 'src/utilities/errorUtils'; | ||
|
@@ -51,14 +35,28 @@ import { scrollErrorIntoViewV2 } from 'src/utilities/scrollErrorIntoViewV2'; | |
import { | ||
StyledCircleProgress, | ||
StyledDivWrapper, | ||
StyledFullAccountAccessToggleGrid, | ||
StyledHeaderGrid, | ||
StyledPaper, | ||
StyledPermPaper, | ||
StyledSelect, | ||
StyledSubHeaderGrid, | ||
StyledUnrestrictedGrid, | ||
} from './UserPermissions.styles'; | ||
import { UserPermissionsEntitySection } from './UserPermissionsEntitySection'; | ||
|
||
import type { | ||
GlobalGrantTypes, | ||
Grant, | ||
GrantLevel, | ||
GrantType, | ||
Grants, | ||
User, | ||
} from '@linode/api-v4/lib/account'; | ||
import type { APIError } from '@linode/api-v4/lib/types'; | ||
import type { QueryClient } from '@tanstack/react-query'; | ||
import type { Item } from 'src/components/EnhancedSelect/Select'; | ||
import type { WithFeatureFlagProps } from 'src/containers/flags.container'; | ||
import type { WithQueryClientProps } from 'src/containers/withQueryClient.container'; | ||
interface Props { | ||
accountUsername?: string; | ||
currentUsername?: string; | ||
|
@@ -91,30 +89,6 @@ interface State { | |
type CombinedProps = Props & WithQueryClientProps & WithFeatureFlagProps; | ||
|
||
class UserPermissions extends React.Component<CombinedProps, State> { | ||
componentDidMount() { | ||
this.getUserGrants(); | ||
this.getUserType(); | ||
} | ||
|
||
componentDidUpdate(prevProps: CombinedProps) { | ||
if (prevProps.currentUsername !== this.props.currentUsername) { | ||
this.getUserGrants(); | ||
this.getUserType(); | ||
} | ||
} | ||
|
||
render() { | ||
const { loading } = this.state; | ||
const { currentUsername } = this.props; | ||
|
||
return ( | ||
<div ref={this.formContainerRef}> | ||
<DocumentTitleSegment segment={`${currentUsername} - Permissions`} /> | ||
{loading ? <CircleProgress /> : this.renderBody()} | ||
</div> | ||
); | ||
} | ||
|
||
billingPermOnClick = (value: null | string) => () => { | ||
const lp = lensPath(['grants', 'global', 'account_access']); | ||
this.setState(set(lp, value)); | ||
|
@@ -371,7 +345,7 @@ class UserPermissions extends React.Component<CombinedProps, State> { | |
spacing={2} | ||
> | ||
<Grid> | ||
<Typography data-qa-permissions-header="billing" variant="h3"> | ||
<Typography data-qa-permissions-header="billing" variant="h2"> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same - the headings composition was already correct There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
Billing Access | ||
</Typography> | ||
</Grid> | ||
|
@@ -445,32 +419,41 @@ class UserPermissions extends React.Component<CombinedProps, State> { | |
textTransform: 'capitalize', | ||
}} | ||
data-qa-restrict-access={restricted} | ||
variant="h2" | ||
variant="h1" | ||
> | ||
{isProxyUser ? PARENT_USER : 'General'} Permissions | ||
</Typography> | ||
</StyledHeaderGrid> | ||
<StyledSubHeaderGrid> | ||
<Toggle | ||
tooltipText={ | ||
currentUsername === accountUsername | ||
? 'You cannot restrict the current active user.' | ||
: '' | ||
<StyledFullAccountAccessToggleGrid> | ||
<FormControlLabel | ||
control={ | ||
<Toggle | ||
inputProps={{ | ||
'aria-label': 'Toggle Full Account Access', | ||
}} | ||
tooltipText={ | ||
currentUsername === accountUsername | ||
? 'You cannot restrict the current active user.' | ||
: '' | ||
} | ||
checked={!restricted} | ||
disabled={currentUsername === accountUsername} | ||
onChange={this.onChangeRestricted} | ||
/> | ||
} | ||
aria-label="Toggle Full Account Access" | ||
checked={!restricted} | ||
disabled={currentUsername === accountUsername} | ||
onChange={this.onChangeRestricted} | ||
slotProps={{ | ||
typography: { | ||
sx: (theme) => ({ | ||
fontFamily: theme.font.bold, | ||
fontSize: '16px', | ||
}), | ||
}, | ||
}} | ||
label="Full Account Access" | ||
labelPlacement="end" | ||
value={restricted} | ||
/> | ||
</StyledSubHeaderGrid> | ||
<Grid sx={{ padding: 0 }}> | ||
<Typography | ||
sx={{ fontFamily: (theme) => theme.font.bold }} | ||
variant="subtitle2" | ||
> | ||
Full Account Access | ||
</Typography> | ||
</Grid> | ||
</StyledFullAccountAccessToggleGrid> | ||
</Grid> | ||
</StyledPaper> | ||
{restricted ? this.renderPermissions() : this.renderUnrestricted()} | ||
|
@@ -531,7 +514,7 @@ class UserPermissions extends React.Component<CombinedProps, State> { | |
<StyledPermPaper data-qa-global-section> | ||
<Typography | ||
data-qa-permissions-header="Global Permissions" | ||
variant="subtitle2" | ||
variant="body2" | ||
> | ||
Configure the specific rights and privileges this user has within the | ||
account.{<br />}Remember that permissions related to actions with the | ||
|
@@ -606,12 +589,11 @@ class UserPermissions extends React.Component<CombinedProps, State> { | |
<Grid> | ||
<Typography | ||
data-qa-permissions-header="Specific Permissions" | ||
variant="h2" | ||
variant="h1" | ||
carrillo-erik marked this conversation as resolved.
Show resolved
Hide resolved
|
||
> | ||
Specific Permissions | ||
</Typography> | ||
</Grid> | ||
|
||
<Grid style={{ marginTop: 5 }}> | ||
<StyledSelect | ||
defaultValue={defaultPerm} | ||
|
@@ -679,9 +661,6 @@ class UserPermissions extends React.Component<CombinedProps, State> { | |
<Typography data-qa-unrestricted-msg> | ||
This user has unrestricted access to the account. | ||
</Typography> | ||
{/* <Button buttonType="primary" onClick={this.onChangeRestricted}> | ||
Save | ||
</Button> */} | ||
</StyledUnrestrictedGrid> | ||
</Paper> | ||
); | ||
|
@@ -823,6 +802,30 @@ class UserPermissions extends React.Component<CombinedProps, State> { | |
setAllPerm: 'null', | ||
userType: null, | ||
}; | ||
|
||
componentDidMount() { | ||
this.getUserGrants(); | ||
this.getUserType(); | ||
} | ||
|
||
componentDidUpdate(prevProps: CombinedProps) { | ||
if (prevProps.currentUsername !== this.props.currentUsername) { | ||
this.getUserGrants(); | ||
this.getUserType(); | ||
} | ||
} | ||
|
||
render() { | ||
const { loading } = this.state; | ||
const { currentUsername } = this.props; | ||
|
||
return ( | ||
<div ref={this.formContainerRef}> | ||
<DocumentTitleSegment segment={`${currentUsername} - Permissions`} /> | ||
{loading ? <CircleProgress /> : this.renderBody()} | ||
</div> | ||
); | ||
} | ||
} | ||
|
||
export default withQueryClient(withFeatureFlags(UserPermissions)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 might be a dumb question, but wouldn't the fact that we switched to
findByText
overfindByLabelText
indicate that it isn't accessible? Is it expected we can't usefindByLabelText
?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.
@bnussman-akamai It's a valid question and I was confused by this as well. The error from running the cypress debug command states "The element is not visible because it has CSS property:
opacity: 0
."Looking at the Cypress docs, as a best practice, they recommend using
data-*
attributes to provide context to selectors and isolate them from CSS or JS changes. With that in mind, I went ahead and implemented this and confirmed the tests are still passing and VoiceOver works as expected.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! Thanks for the context π