Skip to content

Commit

Permalink
Merge pull request #10360 from linode/staging
Browse files Browse the repository at this point in the history
Release v1.116.1 - `staging` → `master`
  • Loading branch information
jaalah-akamai authored Apr 8, 2024
2 parents 988469d + a7e8f31 commit d7b1caa
Show file tree
Hide file tree
Showing 6 changed files with 155 additions and 190 deletions.
7 changes: 7 additions & 0 deletions packages/manager/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/).

## [2024-04-08] - v1.116.1

### Fixed:

- Search indefinitely loading on large accounts ([#10351](https://github.com/linode/manager/pull/10351))
- Returning proper scope when selecting all perms ([#10359](https://github.com/linode/manager/pull/10359))

## [2024-04-01] - v1.116.0

### Changed:
Expand Down
2 changes: 1 addition & 1 deletion packages/manager/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "linode-manager",
"author": "Linode",
"description": "The Linode Manager website",
"version": "1.116.0",
"version": "1.116.1",
"private": true,
"type": "module",
"bugs": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,9 @@ import {
StyledSelectCell,
} from './APITokenDrawer.styles';
import {
basePermNameMap as _basePermNameMap,
Permission,
allScopesAreTheSame,
filterPermsNameMap,
basePermNameMap,
permTuplesToScopeString,
scopeStringToPermTuples,
} from './utils';
Expand Down Expand Up @@ -103,8 +102,6 @@ export const CreateAPITokenDrawer = (props: Props) => {

const { data: profile } = useProfile();

const isParentUser = profile?.user_type === 'parent';

const {
error,
isLoading,
Expand All @@ -115,17 +112,6 @@ export const CreateAPITokenDrawer = (props: Props) => {
globalGrantType: 'child_account_access',
});

const hasParentChildAccountAccess = Boolean(flags.parentChildAccountAccess);

// @TODO: Parent/Child - once in GA, remove _basePermNameMap logic and references.
// Just use the basePermNameMap import directly w/o any manipulation.
const basePermNameMap = filterPermsNameMap(_basePermNameMap, [
{
name: 'child_account',
shouldBeIncluded: hasParentChildAccountAccess,
},
]);

const form = useFormik<{
expiry: string;
label: string;
Expand Down Expand Up @@ -164,10 +150,7 @@ export const CreateAPITokenDrawer = (props: Props) => {
e: React.SyntheticEvent<RadioButton>
): void => {
const value = +e.currentTarget.value;
const newScopes = (showFilteredPermissions
? filteredPermissions
: allPermissions
).map(
const newScopes = form.values.scopes.map(
(scope): Permission => {
// Check the excluded scopes object to see if the current scope will have its own defaults.
const indexOfExcludedScope = excludedScopesFromSelectAll.findIndex(
Expand Down Expand Up @@ -217,16 +200,11 @@ export const CreateAPITokenDrawer = (props: Props) => {
// Filter permissions for all users except parent user accounts.
const allPermissions = form.values.scopes;

// Filter permissions for all users *except* parent user accounts with access to child accounts enabled.
const showFilteredPermissions =
!flags.parentChildAccountAccess ||
(flags.parentChildAccountAccess &&
(!isParentUser || isChildAccountAccessRestricted));

const filteredPermissions = allPermissions.filter(
// @TODO: Parent/Child - Once feature is released and all perms are always returned, use basePermNameMap[scopeTup[0]] !== 'Child Account Access'.
(scopeTup) => scopeTup[0] !== 'child_account'
);
// Visually hide the "Child Account Access" permission even though it's still part of the base perms.
const hideChildAccountAccessScope =
profile?.user_type !== 'parent' ||
isChildAccountAccessRestricted ||
!flags.parentChildAccountAccess;

return (
<Drawer onClose={onClose} open={open} title="Add Personal Access Token">
Expand Down Expand Up @@ -312,65 +290,67 @@ export const CreateAPITokenDrawer = (props: Props) => {
/>
</StyledPermissionsCell>
</TableRow>
{(showFilteredPermissions ? filteredPermissions : allPermissions).map(
(scopeTup) => {
if (!basePermNameMap[scopeTup[0]]) {
return null;
}

const scopeIsForVPC = scopeTup[0] === 'vpc';
{allPermissions.map((scopeTup) => {
if (
!basePermNameMap[scopeTup[0]] ||
(hideChildAccountAccessScope &&
basePermNameMap[scopeTup[0]] === 'Child Account Access')
) {
return null;
}

return (
<TableRow
data-qa-row={basePermNameMap[scopeTup[0]]}
key={scopeTup[0]}
const scopeIsForVPC = scopeTup[0] === 'vpc';

return (
<TableRow
data-qa-row={basePermNameMap[scopeTup[0]]}
key={scopeTup[0]}
>
<StyledAccessCell padding="checkbox" parentColumn="Access">
{basePermNameMap[scopeTup[0]]}
</StyledAccessCell>
<StyledPermissionsCell padding="checkbox" parentColumn="None">
<AccessCell
active={scopeTup[1] === 0}
disabled={false}
onChange={handleScopeChange}
scope="0"
scopeDisplay={scopeTup[0]}
viewOnly={false}
/>
</StyledPermissionsCell>
<StyledPermissionsCell
padding="checkbox"
parentColumn="Read Only"
>
<StyledAccessCell padding="checkbox" parentColumn="Access">
{basePermNameMap[scopeTup[0]]}
</StyledAccessCell>
<StyledPermissionsCell padding="checkbox" parentColumn="None">
<AccessCell
active={scopeTup[1] === 0}
disabled={false}
onChange={handleScopeChange}
scope="0"
scopeDisplay={scopeTup[0]}
viewOnly={false}
/>
</StyledPermissionsCell>
<StyledPermissionsCell
padding="checkbox"
parentColumn="Read Only"
>
<AccessCell
tooltipText={
scopeIsForVPC ? VPC_READ_ONLY_TOOLTIP : undefined
}
active={scopeTup[1] === 1}
disabled={scopeIsForVPC} // "Read Only" is not a valid scope for VPC
onChange={handleScopeChange}
scope="1"
scopeDisplay={scopeTup[0]}
viewOnly={false}
/>
</StyledPermissionsCell>
<StyledPermissionsCell
padding="checkbox"
parentColumn="Read/Write"
>
<AccessCell
active={scopeTup[1] === 2}
disabled={false}
onChange={handleScopeChange}
scope="2"
scopeDisplay={scopeTup[0]}
viewOnly={false}
/>
</StyledPermissionsCell>
</TableRow>
);
}
)}
<AccessCell
tooltipText={
scopeIsForVPC ? VPC_READ_ONLY_TOOLTIP : undefined
}
active={scopeTup[1] === 1}
disabled={scopeIsForVPC} // "Read Only" is not a valid scope for VPC
onChange={handleScopeChange}
scope="1"
scopeDisplay={scopeTup[0]}
viewOnly={false}
/>
</StyledPermissionsCell>
<StyledPermissionsCell
padding="checkbox"
parentColumn="Read/Write"
>
<AccessCell
active={scopeTup[1] === 2}
disabled={false}
onChange={handleScopeChange}
scope="2"
scopeDisplay={scopeTup[0]}
viewOnly={false}
/>
</StyledPermissionsCell>
</TableRow>
);
})}
</TableBody>
</StyledPermsTable>
{errorMap.scopes && (
Expand Down
140 changes: 56 additions & 84 deletions packages/manager/src/features/Profile/APITokens/ViewAPITokenDrawer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,7 @@ import {
StyledPermissionsCell,
StyledPermsTable,
} from './APITokenDrawer.styles';
import {
basePermNameMap as _basePermNameMap,
filterPermsNameMap,
scopeStringToPermTuples,
} from './utils';
import { basePermNameMap, scopeStringToPermTuples } from './utils';

interface Props {
onClose: () => void;
Expand All @@ -39,39 +35,13 @@ export const ViewAPITokenDrawer = (props: Props) => {
globalGrantType: 'child_account_access',
});

const hasParentChildAccountAccess = Boolean(flags.parentChildAccountAccess);

// @TODO: Parent/Child - once in GA, remove _basePermNameMap logic and references.
// Just use the basePermNameMap import directly w/o any manipulation.
const basePermNameMap = filterPermsNameMap(_basePermNameMap, [
{
name: 'child_account',
shouldBeIncluded: hasParentChildAccountAccess,
},
]);

const allPermissions = scopeStringToPermTuples(token?.scopes ?? '');

/**
* A parent user with child_account_access can issue a PAT with child_account scope.
* If access is later revoked, we'll still display this scope for existing PATs, but not for new ones.
* */
const hideChildAccountAccessScope = allPermissions.some(
(scope) =>
scope[0] === 'child_account' &&
scope[1] === 0 &&
isChildAccountAccessRestricted
);

// Filter permissions for all users except parent user accounts.
const showFilteredPermissions =
!flags.parentChildAccountAccess ||
// Visually hide the "Child Account Access" permission even though it's still part of the base perms.
const hideChildAccountAccessScope =
profile?.user_type !== 'parent' ||
hideChildAccountAccessScope;

const filteredPermissions = allPermissions.filter(
(scopeTup) => basePermNameMap[scopeTup[0]] !== 'Child Account Access'
);
isChildAccountAccessRestricted ||
!flags.parentChildAccountAccess;

return (
<Drawer onClose={onClose} open={open} title={token?.label ?? 'Token'}>
Expand All @@ -95,56 +65,58 @@ export const ViewAPITokenDrawer = (props: Props) => {
</TableRow>
</TableHead>
<TableBody>
{(showFilteredPermissions ? filteredPermissions : allPermissions).map(
(scopeTup) => {
if (!basePermNameMap[scopeTup[0]]) {
return null;
}
return (
<TableRow
data-qa-row={basePermNameMap[scopeTup[0]]}
key={scopeTup[0]}
>
<StyledAccessCell padding="checkbox" parentColumn="Access">
{basePermNameMap[scopeTup[0]]}
</StyledAccessCell>
<StyledPermissionsCell padding="checkbox" parentColumn="None">
<AccessCell
active={scopeTup[1] === 0}
disabled={false}
onChange={() => null}
scope="0"
scopeDisplay={scopeTup[0]}
viewOnly={true}
/>
</StyledPermissionsCell>
<StyledPermissionsCell
padding="checkbox"
parentColumn="Read Only"
>
<AccessCell
active={scopeTup[1] === 1}
disabled={false}
onChange={() => null}
scope="1"
scopeDisplay={scopeTup[0]}
viewOnly={true}
/>
</StyledPermissionsCell>
<TableCell padding="checkbox" parentColumn="Read/Write">
<AccessCell
active={scopeTup[1] === 2}
disabled={false}
onChange={() => null}
scope="2"
scopeDisplay={scopeTup[0]}
viewOnly={true}
/>
</TableCell>
</TableRow>
);
{allPermissions.map((scopeTup) => {
if (
!basePermNameMap[scopeTup[0]] ||
(hideChildAccountAccessScope &&
basePermNameMap[scopeTup[0]] === 'Child Account Access')
) {
return null;
}
)}
return (
<TableRow
data-qa-row={basePermNameMap[scopeTup[0]]}
key={scopeTup[0]}
>
<StyledAccessCell padding="checkbox" parentColumn="Access">
{basePermNameMap[scopeTup[0]]}
</StyledAccessCell>
<StyledPermissionsCell padding="checkbox" parentColumn="None">
<AccessCell
active={scopeTup[1] === 0}
disabled={false}
onChange={() => null}
scope="0"
scopeDisplay={scopeTup[0]}
viewOnly={true}
/>
</StyledPermissionsCell>
<StyledPermissionsCell
padding="checkbox"
parentColumn="Read Only"
>
<AccessCell
active={scopeTup[1] === 1}
disabled={false}
onChange={() => null}
scope="1"
scopeDisplay={scopeTup[0]}
viewOnly={true}
/>
</StyledPermissionsCell>
<TableCell padding="checkbox" parentColumn="Read/Write">
<AccessCell
active={scopeTup[1] === 2}
disabled={false}
onChange={() => null}
scope="2"
scopeDisplay={scopeTup[0]}
viewOnly={true}
/>
</TableCell>
</TableRow>
);
})}
</TableBody>
</StyledPermsTable>
</Drawer>
Expand Down
Loading

0 comments on commit d7b1caa

Please sign in to comment.