From 11e2001d0394973ca546459732c87aa064f10290 Mon Sep 17 00:00:00 2001 From: Deniz Kusefoglu Date: Tue, 2 Apr 2019 23:00:25 -0700 Subject: [PATCH] Add tokens to former org view --- ui/src/authorizations/actions/index.ts | 2 +- .../components/TokenList.tsx} | 11 +--- .../components}/TokenRow.tsx | 0 .../components/TokensTab.tsx} | 46 ++++---------- .../components}/ViewTokenOverlay.test.tsx | 2 +- .../components}/ViewTokenOverlay.tsx | 4 -- .../authorizations/containers/TokensIndex.tsx | 61 +++++++++++++++++++ .../components/ConfigurationPage.tsx | 8 --- .../configuration/components/GetResources.tsx | 6 -- ui/src/index.tsx | 2 + ui/src/me/components/account/Account.tsx | 8 --- .../components/OrganizationNavigation.tsx | 6 ++ 12 files changed, 87 insertions(+), 69 deletions(-) rename ui/src/{me/components/account/TokensList.tsx => authorizations/components/TokenList.tsx} (89%) rename ui/src/{me/components/account => authorizations/components}/TokenRow.tsx (100%) rename ui/src/{me/components/account/Tokens.tsx => authorizations/components/TokensTab.tsx} (68%) rename ui/src/{me/components/account => authorizations/components}/ViewTokenOverlay.test.tsx (87%) rename ui/src/{me/components/account => authorizations/components}/ViewTokenOverlay.tsx (96%) create mode 100644 ui/src/authorizations/containers/TokensIndex.tsx diff --git a/ui/src/authorizations/actions/index.ts b/ui/src/authorizations/actions/index.ts index 403d6b34a4..b12df8dccc 100644 --- a/ui/src/authorizations/actions/index.ts +++ b/ui/src/authorizations/actions/index.ts @@ -81,7 +81,7 @@ export const getAuthorizations = () => async (dispatch: Dispatch) => { try { dispatch(setAuthorizations(RemoteDataState.Loading)) - const authorizations = (await client.authorizations.getAll()) as Authorization[] + const authorizations = await client.authorizations.getAll() dispatch(setAuthorizations(RemoteDataState.Done, authorizations)) } catch (e) { diff --git a/ui/src/me/components/account/TokensList.tsx b/ui/src/authorizations/components/TokenList.tsx similarity index 89% rename from ui/src/me/components/account/TokensList.tsx rename to ui/src/authorizations/components/TokenList.tsx index 8c1b5631b2..8ea88ed155 100644 --- a/ui/src/me/components/account/TokensList.tsx +++ b/ui/src/authorizations/components/TokenList.tsx @@ -4,19 +4,15 @@ import React, {PureComponent} from 'react' // Components import {EmptyState} from '@influxdata/clockface' import {IndexList, Overlay} from 'src/clockface' -import TokenRow from 'src/me/components/account/TokenRow' +import TokenRow from 'src/authorizations/components/TokenRow' +import ViewTokenOverlay from 'src/authorizations/components/ViewTokenOverlay' // Types import {Authorization} from '@influxdata/influx' import {ComponentSize} from '@influxdata/clockface' -import ViewTokenOverlay from './ViewTokenOverlay' - -// Actions -import {NotificationAction} from 'src/types' interface Props { auths: Authorization[] - onNotify: NotificationAction searchTerm: string } @@ -35,7 +31,7 @@ export default class TokenList extends PureComponent { } public render() { - const {auths, onNotify} = this.props + const {auths} = this.props const {isTokenOverlayVisible, authInView} = this.state return ( @@ -59,7 +55,6 @@ export default class TokenList extends PureComponent { diff --git a/ui/src/me/components/account/TokenRow.tsx b/ui/src/authorizations/components/TokenRow.tsx similarity index 100% rename from ui/src/me/components/account/TokenRow.tsx rename to ui/src/authorizations/components/TokenRow.tsx diff --git a/ui/src/me/components/account/Tokens.tsx b/ui/src/authorizations/components/TokensTab.tsx similarity index 68% rename from ui/src/me/components/account/Tokens.tsx rename to ui/src/authorizations/components/TokensTab.tsx index c45c2a9466..1b5aaa9964 100644 --- a/ui/src/me/components/account/Tokens.tsx +++ b/ui/src/authorizations/components/TokensTab.tsx @@ -4,37 +4,29 @@ import {connect} from 'react-redux' // Components import {Input} from '@influxdata/clockface' -import TokenList from 'src/me/components/account/TokensList' +import TokenList from 'src/authorizations/components/TokenList' import FilterList from 'src/shared/components/Filter' import TabbedPageHeader from 'src/shared/components/tabbed_page/TabbedPageHeader' -// Actions -import * as notifyActions from 'src/shared/actions/notifications' - // Types import {Authorization} from '@influxdata/influx' import {IconFont} from '@influxdata/clockface' - -interface State { - searchTerm: string -} +import {AppState} from 'src/types' enum AuthSearchKeys { Description = 'description', Status = 'status', } +interface State { + searchTerm: string +} + interface StateProps { tokens: Authorization[] } -interface DispatchProps { - notify: typeof notifyActions.notify -} - -type Props = StateProps & DispatchProps - -export class Tokens extends PureComponent { +class TokensTab extends PureComponent { constructor(props) { super(props) this.state = { @@ -44,7 +36,7 @@ export class Tokens extends PureComponent { public render() { const {searchTerm} = this.state - const {tokens, notify} = this.props + const {tokens} = this.props return ( <> @@ -63,11 +55,7 @@ export class Tokens extends PureComponent { searchKeys={this.searchKeys} > {filteredAuths => ( - + )} @@ -83,17 +71,9 @@ export class Tokens extends PureComponent { } } -const mdtp = { - notify: notifyActions.notify, -} +const mstp = ({tokens}: AppState) => ({tokens: tokens.list}) -const mstp = ({tokens}) => { - return { - tokens: tokens.list, - } -} - -export default connect( +export default connect( mstp, - mdtp -)(Tokens) + null +)(TokensTab) diff --git a/ui/src/me/components/account/ViewTokenOverlay.test.tsx b/ui/src/authorizations/components/ViewTokenOverlay.test.tsx similarity index 87% rename from ui/src/me/components/account/ViewTokenOverlay.test.tsx rename to ui/src/authorizations/components/ViewTokenOverlay.test.tsx index ad57bea577..2828b87304 100644 --- a/ui/src/me/components/account/ViewTokenOverlay.test.tsx +++ b/ui/src/authorizations/components/ViewTokenOverlay.test.tsx @@ -3,7 +3,7 @@ import React from 'react' import {shallow} from 'enzyme' // Components -import ViewTokenOverlay from 'src/me/components/account/ViewTokenOverlay' +import ViewTokenOverlay from 'src/authorizations/components/ViewTokenOverlay' // Fixtures import {authorization as auth} from 'src/authorizations/apis/__mocks__/data' diff --git a/ui/src/me/components/account/ViewTokenOverlay.tsx b/ui/src/authorizations/components/ViewTokenOverlay.tsx similarity index 96% rename from ui/src/me/components/account/ViewTokenOverlay.tsx rename to ui/src/authorizations/components/ViewTokenOverlay.tsx index 9c3ba59098..1ebf8ac655 100644 --- a/ui/src/me/components/account/ViewTokenOverlay.tsx +++ b/ui/src/authorizations/components/ViewTokenOverlay.tsx @@ -13,11 +13,7 @@ import CodeSnippet from 'src/shared/components/CodeSnippet' // Types import {Authorization, Permission} from '@influxdata/influx' -// Actions -import {NotificationAction} from 'src/types' - interface Props { - onNotify: NotificationAction auth: Authorization onDismissOverlay: () => void } diff --git a/ui/src/authorizations/containers/TokensIndex.tsx b/ui/src/authorizations/containers/TokensIndex.tsx new file mode 100644 index 0000000000..e4f8e55779 --- /dev/null +++ b/ui/src/authorizations/containers/TokensIndex.tsx @@ -0,0 +1,61 @@ +// Libraries +import React, {Component} from 'react' +import {connect} from 'react-redux' + +// Components +import {ErrorHandling} from 'src/shared/decorators/errors' +import OrganizationNavigation from 'src/organizations/components/OrganizationNavigation' +import OrgHeader from 'src/organizations/containers/OrgHeader' +import {Tabs} from 'src/clockface' +import {Page} from 'src/pageLayout' +import TabbedPageSection from 'src/shared/components/tabbed_page/TabbedPageSection' +import GetResources, { + ResourceTypes, +} from 'src/configuration/components/GetResources' +import TokensTab from 'src/authorizations/components/TokensTab' + +// Types +import {Organization} from '@influxdata/influx' +import {AppState} from 'src/types' + +interface StateProps { + org: Organization +} + +@ErrorHandling +class TokensIndex extends Component { + public render() { + const {org} = this.props + + return ( + + + +
+ + + + + + + + + + +
+
+
+ ) + } +} + +const mstp = ({orgs: {org}}: AppState) => ({org}) + +export default connect( + mstp, + null +)(TokensIndex) diff --git a/ui/src/configuration/components/ConfigurationPage.tsx b/ui/src/configuration/components/ConfigurationPage.tsx index 3baf446b35..0893aa241a 100644 --- a/ui/src/configuration/components/ConfigurationPage.tsx +++ b/ui/src/configuration/components/ConfigurationPage.tsx @@ -10,7 +10,6 @@ import GetResources, { import TabbedPageSection from 'src/shared/components/tabbed_page/TabbedPageSection' import TabbedPage from 'src/shared/components/tabbed_page/TabbedPage' import Settings from 'src/me/components/account/Settings' -import Tokens from 'src/me/components/account/Tokens' import Telegrafs from 'src/configuration/components/Telegrafs' import Variables from 'src/configuration/components/Variables' import Scrapers from 'src/configuration/components/Scrapers' @@ -81,13 +80,6 @@ class ConfigurationPage extends Component { - - - { } const mstp = ({ - orgs, labels, buckets, telegrafs, @@ -126,8 +123,6 @@ const mstp = ({ tokens, dashboards, }: AppState): StateProps => { - const org = orgs[0] - return { labels, buckets, @@ -136,7 +131,6 @@ const mstp = ({ variables, scrapers, tokens, - org, } } diff --git a/ui/src/index.tsx b/ui/src/index.tsx index c82acdae48..8c63756587 100644 --- a/ui/src/index.tsx +++ b/ui/src/index.tsx @@ -52,6 +52,7 @@ import OrgScrapersIndex from 'src/organizations/containers/OrgScrapersIndex' import VariableImportOverlay from 'src/variables/components/VariableImportOverlay' import OrgVariableExportOverlay from 'src/organizations/components/OrgVariableExportOverlay' import SetOrg from 'src/shared/containers/SetOrg' +import TokensIndex from 'src/authorizations/containers/TokensIndex' // Actions import {disablePresentationMode} from 'src/shared/actions/app' @@ -178,6 +179,7 @@ class Root extends PureComponent { + { > - - - diff --git a/ui/src/organizations/components/OrganizationNavigation.tsx b/ui/src/organizations/components/OrganizationNavigation.tsx index bf8121fc95..e658c3db63 100644 --- a/ui/src/organizations/components/OrganizationNavigation.tsx +++ b/ui/src/organizations/components/OrganizationNavigation.tsx @@ -61,6 +61,12 @@ class OrganizationNavigation extends PureComponent { url={`${route}/templates`} active={'templates' === tab} /> + ) }