From 15dd0bc112acb6add831a197696d3b3dd861d815 Mon Sep 17 00:00:00 2001 From: Beth Legesse Date: Mon, 26 Jul 2021 12:18:41 -0500 Subject: [PATCH 1/8] fix: squashed all commit --- .../components/CustomApiTokenOverlay.tsx | 56 +++++++++++++++++++ .../CustomeApiTokenOverlay.test.tsx | 28 ++++++++++ 2 files changed, 84 insertions(+) create mode 100644 src/authorizations/components/CustomApiTokenOverlay.tsx create mode 100644 src/authorizations/components/CustomeApiTokenOverlay.test.tsx diff --git a/src/authorizations/components/CustomApiTokenOverlay.tsx b/src/authorizations/components/CustomApiTokenOverlay.tsx new file mode 100644 index 0000000000..9d7136fc6f --- /dev/null +++ b/src/authorizations/components/CustomApiTokenOverlay.tsx @@ -0,0 +1,56 @@ +import React, {FC, useState} from 'react' + +// Components +import { + Overlay, + Form, + Input, + FlexBox, + AlignItems, + FlexDirection, + ComponentSize, +} from '@influxdata/clockface' + +interface OwnProps { + onClose: () => void +} + +const CustomApiTokenOverlay: FC = props => { + const handleDismiss = () => { + props.onClose() + } + const [description, setDescription] = useState('') + + const handleInputChange = event => { + setDescription(event.target.value) + } + + return ( + + + +
+ + + + + +
+
+
+ ) +} + +export default CustomApiTokenOverlay diff --git a/src/authorizations/components/CustomeApiTokenOverlay.test.tsx b/src/authorizations/components/CustomeApiTokenOverlay.test.tsx new file mode 100644 index 0000000000..5b90933063 --- /dev/null +++ b/src/authorizations/components/CustomeApiTokenOverlay.test.tsx @@ -0,0 +1,28 @@ +import React from 'react' +import {render, fireEvent} from '@testing-library/react' +import CustomApiTokenOverlay from './CustomApiTokenOverlay'; + + +describe('CustomeApitokenDescription', () => { + const props = { + onClose: () => true, + }; + + it('displays description box', () => { + const { getByText } = render(); + + expect(getByText("Description")).toBeDefined(); + expect(getByText("Generate a Personal Api Token")).toBeDefined(); + }); + + describe('when user inputs something into the description box', () => { + it('should update the component\'s state', () => { + const { getByTestId } = render(); + + fireEvent.change(getByTestId("custome-api-token-input"), { target: { value: 'chocolate' } }); + + const element = getByTestId("custome-api-token-input"); + expect(element['value']).toEqual('chocolate'); + }); + }); +}) \ No newline at end of file From d74860fc3c89789f5b737a343dc0dade6df1d502 Mon Sep 17 00:00:00 2001 From: Beth Legesse Date: Tue, 27 Jul 2021 09:53:27 -0500 Subject: [PATCH 2/8] fix: prettier --- .../CustomeApiTokenOverlay.test.tsx | 39 ++++++++++--------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/src/authorizations/components/CustomeApiTokenOverlay.test.tsx b/src/authorizations/components/CustomeApiTokenOverlay.test.tsx index 5b90933063..ee8c17c90f 100644 --- a/src/authorizations/components/CustomeApiTokenOverlay.test.tsx +++ b/src/authorizations/components/CustomeApiTokenOverlay.test.tsx @@ -1,28 +1,29 @@ import React from 'react' import {render, fireEvent} from '@testing-library/react' -import CustomApiTokenOverlay from './CustomApiTokenOverlay'; - +import CustomApiTokenOverlay from './CustomApiTokenOverlay' describe('CustomeApitokenDescription', () => { - const props = { - onClose: () => true, - }; + const props = { + onClose: () => true, + } - it('displays description box', () => { - const { getByText } = render(); + it('displays description box', () => { + const {getByText} = render() - expect(getByText("Description")).toBeDefined(); - expect(getByText("Generate a Personal Api Token")).toBeDefined(); - }); + expect(getByText('Description')).toBeDefined() + expect(getByText('Generate a Personal Api Token')).toBeDefined() + }) - describe('when user inputs something into the description box', () => { - it('should update the component\'s state', () => { - const { getByTestId } = render(); + describe('when user inputs something into the description box', () => { + it("should update the component's state", () => { + const {getByTestId} = render() - fireEvent.change(getByTestId("custome-api-token-input"), { target: { value: 'chocolate' } }); + fireEvent.change(getByTestId('custome-api-token-input'), { + target: {value: 'chocolate'}, + }) - const element = getByTestId("custome-api-token-input"); - expect(element['value']).toEqual('chocolate'); - }); - }); -}) \ No newline at end of file + const element = getByTestId('custome-api-token-input') + expect(element['value']).toEqual('chocolate') + }) + }) +}) From 8be9df6643718f68af3536427e679f606527381f Mon Sep 17 00:00:00 2001 From: Beth Legesse Date: Tue, 27 Jul 2021 10:17:36 -0500 Subject: [PATCH 3/8] feat: token overlay input box --- .../redesigned/CustomApiTokenOverlay.tsx | 40 +++++++++++++++++-- 1 file changed, 37 insertions(+), 3 deletions(-) diff --git a/src/authorizations/components/redesigned/CustomApiTokenOverlay.tsx b/src/authorizations/components/redesigned/CustomApiTokenOverlay.tsx index 7688136341..9d7136fc6f 100644 --- a/src/authorizations/components/redesigned/CustomApiTokenOverlay.tsx +++ b/src/authorizations/components/redesigned/CustomApiTokenOverlay.tsx @@ -1,22 +1,56 @@ -import React, {FC} from 'react' +import React, {FC, useState} from 'react' // Components -import {Overlay} from '@influxdata/clockface' +import { + Overlay, + Form, + Input, + FlexBox, + AlignItems, + FlexDirection, + ComponentSize, +} from '@influxdata/clockface' interface OwnProps { onClose: () => void } -export const CustomApiTokenOverlay: FC = props => { +const CustomApiTokenOverlay: FC = props => { const handleDismiss = () => { props.onClose() } + const [description, setDescription] = useState('') + + const handleInputChange = event => { + setDescription(event.target.value) + } + return ( + +
+ + + + + +
+
) } + +export default CustomApiTokenOverlay From f77809c8447d1fa2d083b39200059ff11009e01c Mon Sep 17 00:00:00 2001 From: Beth Legesse Date: Tue, 27 Jul 2021 10:35:10 -0500 Subject: [PATCH 4/8] chore: clean up --- .../components/{ => redesigned}/CustomeApiTokenOverlay.test.tsx | 2 +- src/overlays/components/OverlayController.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) rename src/authorizations/components/{ => redesigned}/CustomeApiTokenOverlay.test.tsx (93%) diff --git a/src/authorizations/components/CustomeApiTokenOverlay.test.tsx b/src/authorizations/components/redesigned/CustomeApiTokenOverlay.test.tsx similarity index 93% rename from src/authorizations/components/CustomeApiTokenOverlay.test.tsx rename to src/authorizations/components/redesigned/CustomeApiTokenOverlay.test.tsx index ee8c17c90f..4baf862bf0 100644 --- a/src/authorizations/components/CustomeApiTokenOverlay.test.tsx +++ b/src/authorizations/components/redesigned/CustomeApiTokenOverlay.test.tsx @@ -1,6 +1,6 @@ import React from 'react' import {render, fireEvent} from '@testing-library/react' -import CustomApiTokenOverlay from './CustomApiTokenOverlay' +import CustomApiTokenOverlay from '../CustomApiTokenOverlay' describe('CustomeApitokenDescription', () => { const props = { diff --git a/src/overlays/components/OverlayController.tsx b/src/overlays/components/OverlayController.tsx index eed994e8d4..03bd8899a7 100644 --- a/src/overlays/components/OverlayController.tsx +++ b/src/overlays/components/OverlayController.tsx @@ -35,7 +35,7 @@ import NewThresholdCheckEO from 'src/checks/components/NewThresholdCheckEO' import NewDeadmanCheckEO from 'src/checks/components/NewDeadmanCheckEO' import AutoRefreshOverlay from 'src/dashboards/components/AutoRefreshOverlay' import CellCloneOverlay from 'src/shared/components/cells/CellCloneOverlay' -import {CustomApiTokenOverlay} from 'src/authorizations/components/redesigned/CustomApiTokenOverlay' +import CustomApiTokenOverlay from 'src/authorizations/components/redesigned/CustomApiTokenOverlay' // Actions import {dismissOverlay} from 'src/overlays/actions/overlays' From 7e0f833934931ce4a1f54441e5dd41f5d2cc49c9 Mon Sep 17 00:00:00 2001 From: Beth Legesse Date: Tue, 27 Jul 2021 15:12:08 -0500 Subject: [PATCH 5/8] chore: pr review changes --- src/authorizations/components/CustomApiTokenOverlay.tsx | 6 +++--- .../components/redesigned/CustomApiTokenOverlay.tsx | 6 +++--- src/overlays/components/OverlayController.tsx | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/authorizations/components/CustomApiTokenOverlay.tsx b/src/authorizations/components/CustomApiTokenOverlay.tsx index 9d7136fc6f..9bf5fe8613 100644 --- a/src/authorizations/components/CustomApiTokenOverlay.tsx +++ b/src/authorizations/components/CustomApiTokenOverlay.tsx @@ -15,7 +15,7 @@ interface OwnProps { onClose: () => void } -const CustomApiTokenOverlay: FC = props => { +export const CustomApiTokenOverlay: FC = props => { const handleDismiss = () => { props.onClose() } @@ -40,7 +40,7 @@ const CustomApiTokenOverlay: FC = props => { > = props => { ) } -export default CustomApiTokenOverlay + diff --git a/src/authorizations/components/redesigned/CustomApiTokenOverlay.tsx b/src/authorizations/components/redesigned/CustomApiTokenOverlay.tsx index 9d7136fc6f..9bf5fe8613 100644 --- a/src/authorizations/components/redesigned/CustomApiTokenOverlay.tsx +++ b/src/authorizations/components/redesigned/CustomApiTokenOverlay.tsx @@ -15,7 +15,7 @@ interface OwnProps { onClose: () => void } -const CustomApiTokenOverlay: FC = props => { +export const CustomApiTokenOverlay: FC = props => { const handleDismiss = () => { props.onClose() } @@ -40,7 +40,7 @@ const CustomApiTokenOverlay: FC = props => { > = props => { ) } -export default CustomApiTokenOverlay + diff --git a/src/overlays/components/OverlayController.tsx b/src/overlays/components/OverlayController.tsx index 03bd8899a7..eed994e8d4 100644 --- a/src/overlays/components/OverlayController.tsx +++ b/src/overlays/components/OverlayController.tsx @@ -35,7 +35,7 @@ import NewThresholdCheckEO from 'src/checks/components/NewThresholdCheckEO' import NewDeadmanCheckEO from 'src/checks/components/NewDeadmanCheckEO' import AutoRefreshOverlay from 'src/dashboards/components/AutoRefreshOverlay' import CellCloneOverlay from 'src/shared/components/cells/CellCloneOverlay' -import CustomApiTokenOverlay from 'src/authorizations/components/redesigned/CustomApiTokenOverlay' +import {CustomApiTokenOverlay} from 'src/authorizations/components/redesigned/CustomApiTokenOverlay' // Actions import {dismissOverlay} from 'src/overlays/actions/overlays' From fac14052c7e80a3dc2df8c3a0c7c2910db11b561 Mon Sep 17 00:00:00 2001 From: Beth Legesse Date: Tue, 27 Jul 2021 15:12:39 -0500 Subject: [PATCH 6/8] fix: prettier --- src/authorizations/components/CustomApiTokenOverlay.tsx | 2 -- .../components/redesigned/CustomApiTokenOverlay.tsx | 2 -- 2 files changed, 4 deletions(-) diff --git a/src/authorizations/components/CustomApiTokenOverlay.tsx b/src/authorizations/components/CustomApiTokenOverlay.tsx index 9bf5fe8613..497393874f 100644 --- a/src/authorizations/components/CustomApiTokenOverlay.tsx +++ b/src/authorizations/components/CustomApiTokenOverlay.tsx @@ -52,5 +52,3 @@ export const CustomApiTokenOverlay: FC = props => { ) } - - diff --git a/src/authorizations/components/redesigned/CustomApiTokenOverlay.tsx b/src/authorizations/components/redesigned/CustomApiTokenOverlay.tsx index 9bf5fe8613..497393874f 100644 --- a/src/authorizations/components/redesigned/CustomApiTokenOverlay.tsx +++ b/src/authorizations/components/redesigned/CustomApiTokenOverlay.tsx @@ -52,5 +52,3 @@ export const CustomApiTokenOverlay: FC = props => { ) } - - From 2acd75cb99941cb5a9afcb28741c73c34c022e18 Mon Sep 17 00:00:00 2001 From: Beth Legesse Date: Tue, 27 Jul 2021 15:20:44 -0500 Subject: [PATCH 7/8] chore: clean up --- .../components/redesigned/CustomeApiTokenOverlay.test.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/authorizations/components/redesigned/CustomeApiTokenOverlay.test.tsx b/src/authorizations/components/redesigned/CustomeApiTokenOverlay.test.tsx index 4baf862bf0..cdcd4cfdd6 100644 --- a/src/authorizations/components/redesigned/CustomeApiTokenOverlay.test.tsx +++ b/src/authorizations/components/redesigned/CustomeApiTokenOverlay.test.tsx @@ -1,6 +1,6 @@ import React from 'react' import {render, fireEvent} from '@testing-library/react' -import CustomApiTokenOverlay from '../CustomApiTokenOverlay' +import {CustomApiTokenOverlay} from '../CustomApiTokenOverlay' describe('CustomeApitokenDescription', () => { const props = { From 25a7bab20527e8ac8de1302bdca1eb207f30cd32 Mon Sep 17 00:00:00 2001 From: Beth Legesse Date: Thu, 29 Jul 2021 08:53:57 -0500 Subject: [PATCH 8/8] fix: clean up --- .../components/CustomApiTokenOverlay.tsx | 54 ------------------- ...est.tsx => CustomApiTokenOverlay.test.tsx} | 8 +-- .../redesigned/CustomApiTokenOverlay.tsx | 2 +- 3 files changed, 5 insertions(+), 59 deletions(-) delete mode 100644 src/authorizations/components/CustomApiTokenOverlay.tsx rename src/authorizations/components/redesigned/{CustomeApiTokenOverlay.test.tsx => CustomApiTokenOverlay.test.tsx} (74%) diff --git a/src/authorizations/components/CustomApiTokenOverlay.tsx b/src/authorizations/components/CustomApiTokenOverlay.tsx deleted file mode 100644 index 497393874f..0000000000 --- a/src/authorizations/components/CustomApiTokenOverlay.tsx +++ /dev/null @@ -1,54 +0,0 @@ -import React, {FC, useState} from 'react' - -// Components -import { - Overlay, - Form, - Input, - FlexBox, - AlignItems, - FlexDirection, - ComponentSize, -} from '@influxdata/clockface' - -interface OwnProps { - onClose: () => void -} - -export const CustomApiTokenOverlay: FC = props => { - const handleDismiss = () => { - props.onClose() - } - const [description, setDescription] = useState('') - - const handleInputChange = event => { - setDescription(event.target.value) - } - - return ( - - - -
- - - - - -
-
-
- ) -} diff --git a/src/authorizations/components/redesigned/CustomeApiTokenOverlay.test.tsx b/src/authorizations/components/redesigned/CustomApiTokenOverlay.test.tsx similarity index 74% rename from src/authorizations/components/redesigned/CustomeApiTokenOverlay.test.tsx rename to src/authorizations/components/redesigned/CustomApiTokenOverlay.test.tsx index cdcd4cfdd6..0ab0fd29f6 100644 --- a/src/authorizations/components/redesigned/CustomeApiTokenOverlay.test.tsx +++ b/src/authorizations/components/redesigned/CustomApiTokenOverlay.test.tsx @@ -1,8 +1,8 @@ import React from 'react' import {render, fireEvent} from '@testing-library/react' -import {CustomApiTokenOverlay} from '../CustomApiTokenOverlay' +import {CustomApiTokenOverlay} from './CustomApiTokenOverlay' -describe('CustomeApitokenDescription', () => { +describe('CustomApitokenDescription', () => { const props = { onClose: () => true, } @@ -18,11 +18,11 @@ describe('CustomeApitokenDescription', () => { it("should update the component's state", () => { const {getByTestId} = render() - fireEvent.change(getByTestId('custome-api-token-input'), { + fireEvent.change(getByTestId('custom-api-token-input'), { target: {value: 'chocolate'}, }) - const element = getByTestId('custome-api-token-input') + const element = getByTestId('custom-api-token-input') expect(element['value']).toEqual('chocolate') }) }) diff --git a/src/authorizations/components/redesigned/CustomApiTokenOverlay.tsx b/src/authorizations/components/redesigned/CustomApiTokenOverlay.tsx index 497393874f..2d03972e77 100644 --- a/src/authorizations/components/redesigned/CustomApiTokenOverlay.tsx +++ b/src/authorizations/components/redesigned/CustomApiTokenOverlay.tsx @@ -43,7 +43,7 @@ export const CustomApiTokenOverlay: FC = props => { placeholder="Describe this new token" value={description} onChange={handleInputChange} - testID="custome-api-token-input" + testID="custom-api-token-input" />