diff --git a/ui/src/me/components/account/ViewTokenOverlay.tsx b/ui/src/me/components/account/ViewTokenOverlay.tsx index 12de3c3e07d..096e267586c 100644 --- a/ui/src/me/components/account/ViewTokenOverlay.tsx +++ b/ui/src/me/components/account/ViewTokenOverlay.tsx @@ -15,21 +15,26 @@ import {Authorization, Permission} from '@influxdata/influx' // Actions import {NotificationAction} from 'src/types' -const {Write, Read} = Permission.ActionEnum - interface Props { onNotify: NotificationAction auth: Authorization onDismissOverlay: () => void } -const actions = [Read, Write] - export default class ViewTokenOverlay extends PureComponent { public render() { const {description, permissions} = this.props.auth const {onNotify} = this.props + const obj = {} + for (const key of permissions) { + if (obj[key.resource.type]) { + obj[key.resource.type].push(key.action) + } else { + obj[key.resource.type] = [key.action] + } + } + return ( @@ -39,20 +44,20 @@ export default class ViewTokenOverlay extends PureComponent { mode={PermissionsWidgetMode.Read} heightPixels={500} > - {permissions.map((p, i) => { + {Object.keys(obj).map((p, i) => { return ( - {actions.map((a, i) => ( + {obj[p].map((a, i) => ( ))} @@ -64,39 +69,15 @@ export default class ViewTokenOverlay extends PureComponent { ) } - private selected = ( - permission: Permission, - action: Permission.ActionEnum - ): PermissionsWidgetSelection => { - if (permission.action === action) { - return PermissionsWidgetSelection.Selected - } - - return PermissionsWidgetSelection.Unselected - } - private itemID = ( - permission: Permission, + permission: string, action: Permission.ActionEnum ): string => { - return `${permission.resource.type}-${action}-${permission.resource.id || - '*'}-${permission.resource.orgID || '*'}` - } - - private id = (permission: Permission): string => { - return permission.resource.type + return `${permission}-${action}-${permission || '*'}-${permission || '*'}` } - private title = (permission: Permission): string => { - const org = permission.resource.org || '*' - const name = permission.resource.name || '*' - const type = permission.resource.type - - if (permission.resource.name || permission.resource.org) { - return `${org}:${type}:${name}` - } - - return `${permission.resource.type}:*` + private title = (permission: string): string => { + return `${permission}:*` } private handleDismiss = () => { diff --git a/ui/src/me/components/account/__snapshots__/ViewTokenOverlay.test.tsx.snap b/ui/src/me/components/account/__snapshots__/ViewTokenOverlay.test.tsx.snap index 9caf12e0b61..c2fe5d63ddf 100644 --- a/ui/src/me/components/account/__snapshots__/ViewTokenOverlay.test.tsx.snap +++ b/ui/src/me/components/account/__snapshots__/ViewTokenOverlay.test.tsx.snap @@ -314,33 +314,8 @@ exports[`Account rendering renders! 1`] = ` className="permissions-widget--section-list" > -
  • -
    - -
    - -
  • -
    - -
  • -
    - -
    - -
  • -
    -