From 614553f4d0b7ca613855cda736bf067557cc6de0 Mon Sep 17 00:00:00 2001 From: Kevin Silva Date: Mon, 17 Jul 2023 16:02:38 +0200 Subject: [PATCH] SONAR-19923 Onboarding Tutorial - Token modal --- .../src/components/modal/Modal.tsx | 6 +- .../src/components/modal/ModalBody.tsx | 15 +- .../__snapshots__/ModalBody-test.tsx.snap | 4 + server/sonar-web/src/main/js/app/theme.js | 2 +- .../tutorials/components/EditTokenModal.tsx | 226 +++++++++--------- server/sonar-web/tailwind.base.config.js | 2 +- 6 files changed, 137 insertions(+), 118 deletions(-) diff --git a/server/sonar-web/design-system/src/components/modal/Modal.tsx b/server/sonar-web/design-system/src/components/modal/Modal.tsx index db54a652555..c2e1ce8ed6a 100644 --- a/server/sonar-web/design-system/src/components/modal/Modal.tsx +++ b/server/sonar-web/design-system/src/components/modal/Modal.tsx @@ -38,6 +38,7 @@ interface CommonProps { closeOnOverlayClick?: boolean; isLarge?: boolean; isOpen?: boolean; + isOverflowVisible?: boolean; isScrollable?: boolean; onClose: VoidFunction; } @@ -77,6 +78,7 @@ export function Modal({ closeOnOverlayClick = true, isLarge, isOpen = true, + isOverflowVisible = false, isScrollable = true, onClose, ...props @@ -102,7 +104,9 @@ export function Modal({ <> - {props.body} + + {props.body} + {children}; +export function ModalBody({ children, isScrollable = true, isOverflowVisible = false }: Props) { + return ( + + {children} + + ); } const StyledMain = styled.div` @@ -45,4 +52,8 @@ const StyledMain = styled.div` &.scrollable { overflow-y: auto; } + + &.overflowVisible { + overflow: visible; + } `; diff --git a/server/sonar-web/design-system/src/components/modal/__tests__/__snapshots__/ModalBody-test.tsx.snap b/server/sonar-web/design-system/src/components/modal/__tests__/__snapshots__/ModalBody-test.tsx.snap index 4d41d0c95e2..32d0bdc498b 100644 --- a/server/sonar-web/design-system/src/components/modal/__tests__/__snapshots__/ModalBody-test.tsx.snap +++ b/server/sonar-web/design-system/src/components/modal/__tests__/__snapshots__/ModalBody-test.tsx.snap @@ -20,6 +20,10 @@ exports[`renders with children 1`] = ` overflow-y: auto; } +.emotion-0.overflowVisible { + overflow: visible; +} +
{ }; handleTokenNameChange = (event: React.ChangeEvent) => { - this.setState({ - tokenName: event.target.value, - }); + this.setState({ tokenName: event.currentTarget.value }); }; - handleTokenExpirationChange = ({ value }: { value: TokenExpiration }) => { + handleTokenExpirationChange = (value: TokenExpiration) => { this.setState({ tokenExpiration: value }); }; @@ -154,118 +160,112 @@ export default class EditTokenModal extends React.PureComponent { } }; - render() { + renderForm(type: TokenType) { const { loading, token, tokenName, tokenExpiration, tokenExpirationOptions } = this.state; - - const type = this.getTokenType(); - const header = translate('onboarding.token.generate', type); const intro = translate('onboarding.token.text', type); return ( - - {({ onCloseClick }) => ( +
+ + {translate('onboarding.token.text.user_account')} + + ), + }} + /> + + {token ? ( <> -
-

{header}

+ + {tokenName} + {': '} + +
+ + +
- -
-

- - {translate('onboarding.token.text.user_account')} - - ), - }} - /> -

- - {token ? ( - <> - - {tokenName} - {': '} - -
- {token} - - - - + {translateWithParameters('users.tokens.new_token_created', token)} + + + ) : ( + <> +
+ +
+ + +
+
+ +
+ ) => + this.handleTokenExpirationChange(data.value) + } + options={tokenExpirationOptions} + value={tokenExpirationOptions.find( + (option) => option.value === tokenExpiration + )} /> + + {translate('onboarding.token.generate')} +
- - - {translateWithParameters('users.tokens.new_token_created', token)} - - - ) : ( - <> -
- {loading ? ( - - ) : ( - <> -
- - -
-
- -
-