From f4a18cda6087a8262e1370608e293bb51761da99 Mon Sep 17 00:00:00 2001 From: Brandon Farmer Date: Tue, 19 Mar 2019 16:53:02 -0700 Subject: [PATCH] Remove labels tab and give default org id to new labels --- .../components/ConfigurationPage.tsx | 10 - .../components/CreateLabelOverlay.tsx | 21 +- ui/src/mockState.tsx | 5 +- ui/src/organizations/components/BucketRow.tsx | 3 +- .../organizations/components/Buckets.test.tsx | 38 --- .../__snapshots__/Buckets.test.tsx.snap | 217 ------------------ ui/src/pageLayout/containers/Nav.tsx | 8 +- .../inlineLabels/InlineLabels.test.tsx | 4 +- .../inlineLabels/InlineLabelsEditor.test.tsx | 6 +- ui/src/tasks/components/TaskCard.test.tsx | 4 +- 10 files changed, 31 insertions(+), 285 deletions(-) delete mode 100644 ui/src/organizations/components/Buckets.test.tsx delete mode 100644 ui/src/organizations/components/__snapshots__/Buckets.test.tsx.snap diff --git a/ui/src/configuration/components/ConfigurationPage.tsx b/ui/src/configuration/components/ConfigurationPage.tsx index 679e19625a..fc69ec2224 100644 --- a/ui/src/configuration/components/ConfigurationPage.tsx +++ b/ui/src/configuration/components/ConfigurationPage.tsx @@ -9,7 +9,6 @@ import GetResources, { } from 'src/configuration/components/GetResources' import TabbedPageSection from 'src/shared/components/tabbed_page/TabbedPageSection' import TabbedPage from 'src/shared/components/tabbed_page/TabbedPage' -import Labels from 'src/configuration/components/Labels' import Settings from 'src/me/components/account/Settings' import Tokens from 'src/me/components/account/Tokens' import Buckets from 'src/configuration/components/Buckets' @@ -48,15 +47,6 @@ class ConfigurationPage extends Component { parentUrl={`/configuration`} activeTabUrl={tab} > - - - - - void onCreateLabel: (label: ILabel) => void @@ -22,6 +25,12 @@ interface Props { overrideDefaultName?: string } +interface StateProps { + orgID: string +} + +type Props = OwnProps & StateProps + interface State { label: ILabel colorStatus: ComponentStatus @@ -93,7 +102,7 @@ class CreateLabelOverlay extends Component { const {onCreateLabel, onDismiss} = this.props try { - onCreateLabel(this.state.label) + onCreateLabel({...this.state.label, orgID: this.props.orgID}) // clear form on successful submit this.resetForm() } finally { @@ -138,4 +147,10 @@ class CreateLabelOverlay extends Component { } } -export default CreateLabelOverlay +const mstp = (state: AppState) => { + const {orgs} = state + + return {orgID: _.get(orgs, '0.id', '')} +} + +export default connect(mstp)(CreateLabelOverlay) diff --git a/ui/src/mockState.tsx b/ui/src/mockState.tsx index 1dbb5fc767..829cbd7aac 100644 --- a/ui/src/mockState.tsx +++ b/ui/src/mockState.tsx @@ -12,6 +12,7 @@ const localState = { }, persisted: {autoRefresh: 0, showTemplateControlBar: false}, }, + orgs: [{orgID: 'orgid'}], VERSION: '2.0.0', ranges: [ { @@ -32,10 +33,8 @@ export function renderWithRedux(ui, initialState = s => s) { const seedState = seedStore.getState() const store = configureStore(initialState(seedState), history) - const provider = {ui} - return { - ...render(provider), + ...render({ui}), store, } } diff --git a/ui/src/organizations/components/BucketRow.tsx b/ui/src/organizations/components/BucketRow.tsx index 00f6b47381..43601dc14a 100644 --- a/ui/src/organizations/components/BucketRow.tsx +++ b/ui/src/organizations/components/BucketRow.tsx @@ -1,6 +1,7 @@ // Libraries import React, {PureComponent} from 'react' import {withRouter, WithRouterProps} from 'react-router' +import _ from 'lodash' // Components import {IndexList, ConfirmationButton, Context} from 'src/clockface' @@ -93,7 +94,7 @@ class BucketRow extends PureComponent { } private get organization(): JSX.Element { - if (!this.props.params.orgID) { + if (!_.get(this.props, 'params.orgID')) { return {this.props.bucket.organization} } } diff --git a/ui/src/organizations/components/Buckets.test.tsx b/ui/src/organizations/components/Buckets.test.tsx deleted file mode 100644 index 8c884521bb..0000000000 --- a/ui/src/organizations/components/Buckets.test.tsx +++ /dev/null @@ -1,38 +0,0 @@ -// Libraries -import React from 'react' -import {renderWithRedux} from 'src/mockState' - -// Components -import BucketList from 'src/organizations/components/BucketList' - -// Constants -import {buckets} from 'mocks/dummyData' -import {DataLoaderType} from 'src/types/v2/dataLoaders' -import {withRouterProps} from 'mocks/dummyData' - -const setup = (override?) => { - const props = { - ...withRouterProps, - buckets, - emptyState: <>, - onUpdateBucket: jest.fn(), - onDeleteBucket: jest.fn(), - onSetBucketInfo: jest.fn(), - onSetDataLoadersType: jest.fn(), - dataLoaderType: DataLoaderType.Streaming, - ...override, - } - - const wrapper = renderWithRedux() - - return {wrapper} -} - -describe('BucketList', () => { - describe('rendering', () => { - it('renders', () => { - const {wrapper} = setup() - expect(wrapper).toMatchSnapshot() - }) - }) -}) diff --git a/ui/src/organizations/components/__snapshots__/Buckets.test.tsx.snap b/ui/src/organizations/components/__snapshots__/Buckets.test.tsx.snap deleted file mode 100644 index a396237ce7..0000000000 --- a/ui/src/organizations/components/__snapshots__/Buckets.test.tsx.snap +++ /dev/null @@ -1,217 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`BucketList rendering renders 1`] = ` -Object { - "asFragment": [Function], - "baseElement": -
- - - - - - - - -

- An InfluxDB error has occurred. Please report the issue  - - here - - . -

-
- Name - - Retention - - -
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- , - "container":
- - - - - - - - -

- An InfluxDB error has occurred. Please report the issue  - - here - - . -

-
- Name - - Retention - - -
-
-
-
-
-
-
-
-
-
-
-
-
-
-
, - "debug": [Function], - "getAllByAltText": [Function], - "getAllByDisplayValue": [Function], - "getAllByLabelText": [Function], - "getAllByPlaceholderText": [Function], - "getAllByRole": [Function], - "getAllBySelectText": [Function], - "getAllByTestId": [Function], - "getAllByText": [Function], - "getAllByTitle": [Function], - "getAllByValue": [Function], - "getByAltText": [Function], - "getByDisplayValue": [Function], - "getByLabelText": [Function], - "getByPlaceholderText": [Function], - "getByRole": [Function], - "getBySelectText": [Function], - "getByTestId": [Function], - "getByText": [Function], - "getByTitle": [Function], - "getByValue": [Function], - "queryAllByAltText": [Function], - "queryAllByDisplayValue": [Function], - "queryAllByLabelText": [Function], - "queryAllByPlaceholderText": [Function], - "queryAllByRole": [Function], - "queryAllBySelectText": [Function], - "queryAllByTestId": [Function], - "queryAllByText": [Function], - "queryAllByTitle": [Function], - "queryAllByValue": [Function], - "queryByAltText": [Function], - "queryByDisplayValue": [Function], - "queryByLabelText": [Function], - "queryByPlaceholderText": [Function], - "queryByRole": [Function], - "queryBySelectText": [Function], - "queryByTestId": [Function], - "queryByText": [Function], - "queryByTitle": [Function], - "queryByValue": [Function], - "rerender": [Function], - "store": Object { - "dispatch": [Function], - "getState": [Function], - "replaceReducer": [Function], - "subscribe": [Function], - Symbol(observable): [Function], - }, - "unmount": [Function], -} -`; diff --git a/ui/src/pageLayout/containers/Nav.tsx b/ui/src/pageLayout/containers/Nav.tsx index db2876f162..dc2bf22de3 100644 --- a/ui/src/pageLayout/containers/Nav.tsx +++ b/ui/src/pageLayout/containers/Nav.tsx @@ -79,17 +79,11 @@ class SideNav extends PureComponent { /> - { ...override, } - return render() + return renderWithRedux() } describe('Shared.Components.InlineLabels', () => { diff --git a/ui/src/shared/components/inlineLabels/InlineLabelsEditor.test.tsx b/ui/src/shared/components/inlineLabels/InlineLabelsEditor.test.tsx index bc4dad40ab..fd31c23a34 100644 --- a/ui/src/shared/components/inlineLabels/InlineLabelsEditor.test.tsx +++ b/ui/src/shared/components/inlineLabels/InlineLabelsEditor.test.tsx @@ -1,6 +1,6 @@ // Libraries import React from 'react' -import {render, fireEvent} from 'react-testing-library' +import {fireEvent} from 'react-testing-library' // Components import InlineLabelsEditor from 'src/shared/components/inlineLabels/InlineLabelsEditor' @@ -9,6 +9,8 @@ import InlineLabelsEditor from 'src/shared/components/inlineLabels/InlineLabelsE import {labels} from 'mocks/dummyData' const selectedLabels = [labels[0]] +import {renderWithRedux} from 'src/mockState' + const setup = (override = {}) => { const props = { selectedLabels, @@ -18,7 +20,7 @@ const setup = (override = {}) => { ...override, } - return render() + return renderWithRedux() } describe('Shared.Components.InlineLabelsEditor', () => { diff --git a/ui/src/tasks/components/TaskCard.test.tsx b/ui/src/tasks/components/TaskCard.test.tsx index de6f1b83c5..2686bd2ca0 100644 --- a/ui/src/tasks/components/TaskCard.test.tsx +++ b/ui/src/tasks/components/TaskCard.test.tsx @@ -1,6 +1,6 @@ // Libraries import React from 'react' -import {render} from 'react-testing-library' +import {renderWithRedux} from 'src/mockState' // Components import {TaskCard} from 'src/tasks/components/TaskCard' @@ -28,7 +28,7 @@ const setup = (override = {}) => { ...override, } - return render() + return renderWithRedux() } describe('Tasks.Components.TaskCard', () => {