From 21d115f99864091d587cf7abdb949a0d6b765664 Mon Sep 17 00:00:00 2001 From: Jeremy Davis Date: Wed, 21 Sep 2022 16:43:35 +0200 Subject: [PATCH] SONAR-17359 Fix bitbucket link --- .../project/PersonalAccessTokenForm.tsx | 255 ++++++++++-------- .../PersonalAccessTokenForm-test.tsx.snap | 11 +- .../resources/org/sonar/l10n/core.properties | 4 + 3 files changed, 155 insertions(+), 115 deletions(-) diff --git a/server/sonar-web/src/main/js/apps/create/project/PersonalAccessTokenForm.tsx b/server/sonar-web/src/main/js/apps/create/project/PersonalAccessTokenForm.tsx index 8e3b32acdb3..8845249264e 100644 --- a/server/sonar-web/src/main/js/apps/create/project/PersonalAccessTokenForm.tsx +++ b/server/sonar-web/src/main/js/apps/create/project/PersonalAccessTokenForm.tsx @@ -50,7 +50,7 @@ interface State { function getPatUrl(alm: AlmKeys, url = '') { if (alm === AlmKeys.BitbucketServer) { - return `${url.replace(/\/$/, '')}/plugins/servlet/access-tokens/add`; + return `${url.replace(/\/$/, '')}/account`; } else if (alm === AlmKeys.BitbucketCloud) { return 'https://bitbucket.org/account/settings/app-passwords/new'; } else if (alm === AlmKeys.GitLab) { @@ -166,10 +166,150 @@ export default class PersonalAccessTokenForm extends React.PureComponent + {alm === AlmKeys.BitbucketCloud && ( + <> +

+ {translate( + 'onboarding.create_project.pat_help.instructions_username.bitbucketcloud.title' + )} +

+

+ {translate('onboarding.create_project.pat_help.instructions_username.bitbucketcloud')} +

+ +
+ + + {translate( + 'onboarding.create_project.pat_help.instructions_username.bitbucketcloud.link' + )} + +
+ + )} + +

{translate(`onboarding.create_project.pat_help${suffixTranslationKey}.title`)}

+ +

+ {alm === AlmKeys.BitbucketServer ? ( + + {translate('onboarding.create_project.pat_help.bitbucket.instructions.menu')} + + ), + button: ( + + {translate('onboarding.create_project.pat_help.bitbucket.instructions.button')} + + ) + }} + /> + ) : ( + + )} +

+ + {(url || alm === AlmKeys.BitbucketCloud) && ( +
+ + + {translate(`onboarding.create_project.pat_help${suffixTranslationKey}.link`)} + +
+ )} + +

+ {translate('onboarding.create_project.pat_help.instructions2', alm)} +

+ + + + ); + } + + render() { + const { + almSetting: { alm } + } = this.props; const { checkingPat, submitting, @@ -255,116 +395,7 @@ export default class PersonalAccessTokenForm extends React.PureComponent - - {alm === AlmKeys.BitbucketCloud && ( - <> -

- {translate( - 'onboarding.create_project.pat_help.instructions_username.bitbucketcloud.title' - )} -

-

- {translate( - 'onboarding.create_project.pat_help.instructions_username.bitbucketcloud' - )} -

- -
- - - {translate( - 'onboarding.create_project.pat_help.instructions_username.bitbucketcloud.link' - )} - -
- - )} - -

{translate(`onboarding.create_project.pat_help${suffixTranslationKey}.title`)}

- -

- -

- - {(url || alm === AlmKeys.BitbucketCloud) && ( -
- - - {translate(`onboarding.create_project.pat_help${suffixTranslationKey}.link`)} - -
- )} - -

- {translate('onboarding.create_project.pat_help.instructions2', alm)} -

- -
    - {alm === AlmKeys.BitbucketServer && ( -
  • - - {translate('onboarding.create_project.pat_help.read_permission')} - - ) - }} - /> -
  • - )} - {(alm === AlmKeys.BitbucketServer || alm === AlmKeys.BitbucketCloud) && ( -
  • - - {translate('onboarding.create_project.pat_help.read_permission')} - - ) - }} - /> -
  • - )} - - {alm === AlmKeys.GitLab && ( -
  • - - {translate('onboarding.create_project.pat_help.gitlab.read_api_permission')} - -
  • - )} -
-
+ {this.renderHelpBox(suffixTranslationKey)} ); } diff --git a/server/sonar-web/src/main/js/apps/create/project/__tests__/__snapshots__/PersonalAccessTokenForm-test.tsx.snap b/server/sonar-web/src/main/js/apps/create/project/__tests__/__snapshots__/PersonalAccessTokenForm-test.tsx.snap index 65a05306be2..2072f4e8815 100644 --- a/server/sonar-web/src/main/js/apps/create/project/__tests__/__snapshots__/PersonalAccessTokenForm-test.tsx.snap +++ b/server/sonar-web/src/main/js/apps/create/project/__tests__/__snapshots__/PersonalAccessTokenForm-test.tsx.snap @@ -66,11 +66,16 @@ exports[`should render correctly: bitbucket 1`] = ` className="big-spacer-top big-spacer-bottom" > + onboarding.create_project.pat_help.bitbucket.instructions.button + , + "menu": + onboarding.create_project.pat_help.bitbucket.instructions.menu + , } } /> @@ -85,7 +90,7 @@ exports[`should render correctly: bitbucket 1`] = ` src="/images/alm/bitbucket.svg" /> diff --git a/sonar-core/src/main/resources/org/sonar/l10n/core.properties b/sonar-core/src/main/resources/org/sonar/l10n/core.properties index 3f32b313fea..9fe2a9d9d77 100644 --- a/sonar-core/src/main/resources/org/sonar/l10n/core.properties +++ b/sonar-core/src/main/resources/org/sonar/l10n/core.properties @@ -3504,6 +3504,10 @@ onboarding.create_project.pat_help.instructions.link.azure=personal access token onboarding.create_project.pat_help.instructions=Click the following link to generate a token in {alm}, and copy-paste it into the personal access token field. onboarding.create_project.pat_help.bitbucketcloud.instructions=Click the following link to generate an app password, and copy-paste it into the app password field. +onboarding.create_project.pat_help.bitbucket.instructions=Click the following link and go to {menu} and click {button} to generate a token. Then, copy-paste it into the personal access token field. +onboarding.create_project.pat_help.bitbucket.instructions.menu=HTTP access tokens +onboarding.create_project.pat_help.bitbucket.instructions.button=Create token + onboarding.create_project.pat_help.instructions2.bitbucket=Set a name, for example "SonarQube", and select the following permissions: onboarding.create_project.pat_help.instructions2.bitbucketcloud=Set a name, for example "SonarQube", and select the following permissions: -- 2.39.5