diff --git a/ui/cypress/e2e/buckets.test.ts b/ui/cypress/e2e/buckets.test.ts index d04f81a57f0..ecb53eb2bf5 100644 --- a/ui/cypress/e2e/buckets.test.ts +++ b/ui/cypress/e2e/buckets.test.ts @@ -22,7 +22,7 @@ describe('Buckets', () => { const newBucket = '🅱️ucket' cy.getByTestID('table-row').should('have.length', 1) - cy.contains('Create').click() + cy.getByTestID('Create Bucket').click() cy.getByTestID('overlay--container').within(() => { cy.getByInputName('name').type(newBucket) cy.get('.button') diff --git a/ui/src/buckets/components/BucketsTab.tsx b/ui/src/buckets/components/BucketsTab.tsx index 1ea98ab971a..90b47c5320e 100644 --- a/ui/src/buckets/components/BucketsTab.tsx +++ b/ui/src/buckets/components/BucketsTab.tsx @@ -72,6 +72,7 @@ class BucketsTab extends PureComponent { icon={IconFont.Plus} color={ComponentColor.Primary} onClick={this.handleOpenModal} + testID="Create Bucket" /> diff --git a/ui/src/index.tsx b/ui/src/index.tsx index b7c04767dfe..2cc9fab2758 100644 --- a/ui/src/index.tsx +++ b/ui/src/index.tsx @@ -53,7 +53,7 @@ import VariableImportOverlay from 'src/variables/components/VariableImportOverla import OrgVariableExportOverlay from 'src/organizations/components/OrgVariableExportOverlay' import SetOrg from 'src/shared/containers/SetOrg' import RouteToOrg from 'src/shared/containers/RouteToOrg' - +import CreateOrgOverlay from 'src/organizations/components/CreateOrgOverlay' import TokensIndex from 'src/authorizations/containers/TokensIndex' // Actions @@ -117,8 +117,9 @@ class Root extends PureComponent { - - + + + async ( } export const createOrg = (org: Organization) => async ( - dispatch: Dispatch + dispatch: Dispatch ): Promise => { try { const createdOrg = await client.organizations.create(org) @@ -134,9 +144,14 @@ export const createOrg = (org: Organization) => async ( ...defaultTemplates.systemTemplate(), orgID: createdOrg.id, }) + dispatch(addOrg(createdOrg)) + dispatch(push(`/orgs/${createdOrg.id}`)) + + dispatch(notify(orgCreateSuccess())) } catch (e) { console.error(e) + dispatch(notify(orgCreateFailed())) } } diff --git a/ui/src/organizations/components/CreateOrgOverlay.tsx b/ui/src/organizations/components/CreateOrgOverlay.tsx index 4121c2ed302..e915c0442e7 100644 --- a/ui/src/organizations/components/CreateOrgOverlay.tsx +++ b/ui/src/organizations/components/CreateOrgOverlay.tsx @@ -99,7 +99,6 @@ class CreateOrgOverlay extends PureComponent { const {createOrg} = this.props await createOrg(org) - this.closeModal() } private closeModal = () => { diff --git a/ui/src/pageLayout/containers/Nav.tsx b/ui/src/pageLayout/containers/Nav.tsx index 259141de5c2..5dd2d4eaae4 100644 --- a/ui/src/pageLayout/containers/Nav.tsx +++ b/ui/src/pageLayout/containers/Nav.tsx @@ -7,6 +7,8 @@ import _ from 'lodash' // Components import NavMenu from 'src/pageLayout/components/NavMenu' import CloudNav from 'src/pageLayout/components/CloudNav' +import CloudExclude from 'src/shared/components/cloud/CloudExclude' +import AccountNavSubItem from 'src/pageLayout/components/AccountNavSubItem' // Utils import {getNavItemActivation} from 'src/pageLayout/utils' @@ -16,13 +18,14 @@ import {AppState} from 'src/types' import {IconFont} from 'src/clockface' import {Organization} from '@influxdata/influx' +// Decorators import {ErrorHandling} from 'src/shared/decorators/errors' -import AccountNavSubItem from 'src/pageLayout/components/AccountNavSubItem' interface StateProps { isHidden: boolean me: AppState['me'] orgs: Organization[] + orgName: string } interface State { @@ -47,6 +50,7 @@ class SideNav extends PureComponent { me, params: {orgID}, orgs, + orgName, } = this.props if (isHidden) { return null @@ -57,7 +61,7 @@ class SideNav extends PureComponent { return ( { active={getNavItemActivation(['tasks'], location.pathname)} /> + > + + + + ) } - private get orgName(): string { - const { - params: {orgID}, - orgs, - } = this.props - return orgs.find(org => { - return org.id === orgID - }).name - } - private toggleOrganizationsView = (): void => { this.setState({showOrganizations: !this.state.showOrganizations}) } @@ -114,9 +116,13 @@ class SideNav extends PureComponent { const mstp = (state: AppState): StateProps => { const isHidden = state.app.ephemeral.inPresentationMode - const {me, orgs} = state + const { + me, + orgs, + orgs: {org}, + } = state - return {isHidden, me, orgs: orgs.items} + return {isHidden, me, orgs: orgs.items, orgName: _.get(org, 'name', '')} } export default connect(mstp)(withRouter(SideNav)) diff --git a/ui/src/shared/copy/v2/notifications.ts b/ui/src/shared/copy/v2/notifications.ts index b8a444a66bb..625c26ab320 100644 --- a/ui/src/shared/copy/v2/notifications.ts +++ b/ui/src/shared/copy/v2/notifications.ts @@ -163,6 +163,16 @@ export const bucketUpdateFailed = (bucketName: string): Notification => ({ message: `Failed to update bucket: "${bucketName}"`, }) +export const orgCreateSuccess = (): Notification => ({ + ...defaultSuccessNotification, + message: 'Organization was successfully created', +}) + +export const orgCreateFailed = (): Notification => ({ + ...defaultErrorNotification, + message: 'Failed to create organization', +}) + export const scraperDeleteSuccess = (scraperName: string): Notification => ({ ...defaultSuccessNotification, message: `Scraper "${scraperName}" was successfully deleted`,