]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-17359 Fix bitbucket link
authorJeremy Davis <jeremy.davis@sonarsource.com>
Wed, 21 Sep 2022 14:43:35 +0000 (16:43 +0200)
committersonartech <sonartech@sonarsource.com>
Thu, 22 Sep 2022 20:03:32 +0000 (20:03 +0000)
server/sonar-web/src/main/js/apps/create/project/PersonalAccessTokenForm.tsx
server/sonar-web/src/main/js/apps/create/project/__tests__/__snapshots__/PersonalAccessTokenForm-test.tsx.snap
sonar-core/src/main/resources/org/sonar/l10n/core.properties

index 8e3b32acdb30d348b4bfadeaecef1887c3d755a0..8845249264e87a00e7ee997353385d5f80e8fbf2 100644 (file)
@@ -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<Props,
     }
   };
 
-  render() {
+  renderHelpBox(suffixTranslationKey: string) {
     const {
       almSetting: { alm, url }
     } = this.props;
+
+    return (
+      <Alert className="big-spacer-left width-50" display="block" variant="info">
+        {alm === AlmKeys.BitbucketCloud && (
+          <>
+            <h3>
+              {translate(
+                'onboarding.create_project.pat_help.instructions_username.bitbucketcloud.title'
+              )}
+            </h3>
+            <p className="big-spacer-top big-spacer-bottom">
+              {translate('onboarding.create_project.pat_help.instructions_username.bitbucketcloud')}
+            </p>
+
+            <div className="text-middle big-spacer-bottom">
+              <img
+                alt="" // Should be ignored by screen readers
+                className="spacer-right"
+                height="16"
+                src={`${getBaseUrl()}/images/alm/${AlmKeys.BitbucketServer}.svg`}
+              />
+              <a
+                href="https://bitbucket.org/account/settings/"
+                rel="noopener noreferrer"
+                target="_blank">
+                {translate(
+                  'onboarding.create_project.pat_help.instructions_username.bitbucketcloud.link'
+                )}
+              </a>
+            </div>
+          </>
+        )}
+
+        <h3>{translate(`onboarding.create_project.pat_help${suffixTranslationKey}.title`)}</h3>
+
+        <p className="big-spacer-top big-spacer-bottom">
+          {alm === AlmKeys.BitbucketServer ? (
+            <FormattedMessage
+              id="onboarding.create_project.pat_help.instructions"
+              defaultMessage={translate(
+                `onboarding.create_project.pat_help.bitbucket.instructions`
+              )}
+              values={{
+                menu: (
+                  <strong>
+                    {translate('onboarding.create_project.pat_help.bitbucket.instructions.menu')}
+                  </strong>
+                ),
+                button: (
+                  <strong>
+                    {translate('onboarding.create_project.pat_help.bitbucket.instructions.button')}
+                  </strong>
+                )
+              }}
+            />
+          ) : (
+            <FormattedMessage
+              id="onboarding.create_project.pat_help.instructions"
+              defaultMessage={translate(
+                `onboarding.create_project.pat_help${suffixTranslationKey}.instructions`
+              )}
+              values={{
+                alm: translate('onboarding.alm', alm)
+              }}
+            />
+          )}
+        </p>
+
+        {(url || alm === AlmKeys.BitbucketCloud) && (
+          <div className="text-middle">
+            <img
+              alt="" // Should be ignored by screen readers
+              className="spacer-right"
+              height="16"
+              src={`${getBaseUrl()}/images/alm/${
+                alm === AlmKeys.BitbucketCloud ? AlmKeys.BitbucketServer : alm
+              }.svg`}
+            />
+            <a href={getPatUrl(alm, url)} rel="noopener noreferrer" target="_blank">
+              {translate(`onboarding.create_project.pat_help${suffixTranslationKey}.link`)}
+            </a>
+          </div>
+        )}
+
+        <p className="big-spacer-top big-spacer-bottom">
+          {translate('onboarding.create_project.pat_help.instructions2', alm)}
+        </p>
+
+        <ul>
+          {alm === AlmKeys.BitbucketServer && (
+            <li>
+              <FormattedMessage
+                defaultMessage={translate(
+                  'onboarding.create_project.pat_help.bbs_permission_projects'
+                )}
+                id="onboarding.create_project.pat_help.bbs_permission_projects"
+                values={{
+                  perm: (
+                    <strong>
+                      {translate('onboarding.create_project.pat_help.read_permission')}
+                    </strong>
+                  )
+                }}
+              />
+            </li>
+          )}
+          {(alm === AlmKeys.BitbucketServer || alm === AlmKeys.BitbucketCloud) && (
+            <li>
+              <FormattedMessage
+                defaultMessage={translate(
+                  'onboarding.create_project.pat_help.bbs_permission_repos'
+                )}
+                id="onboarding.create_project.pat_help.bbs_permission_repos"
+                values={{
+                  perm: (
+                    <strong>
+                      {translate('onboarding.create_project.pat_help.read_permission')}
+                    </strong>
+                  )
+                }}
+              />
+            </li>
+          )}
+
+          {alm === AlmKeys.GitLab && (
+            <li className="spacer-bottom">
+              <strong>
+                {translate('onboarding.create_project.pat_help.gitlab.read_api_permission')}
+              </strong>
+            </li>
+          )}
+        </ul>
+      </Alert>
+    );
+  }
+
+  render() {
+    const {
+      almSetting: { alm }
+    } = this.props;
     const {
       checkingPat,
       submitting,
@@ -255,116 +395,7 @@ export default class PersonalAccessTokenForm extends React.PureComponent<Props,
           </ValidationInput>
         </form>
 
-        <Alert className="big-spacer-left width-50" display="block" variant="info">
-          {alm === AlmKeys.BitbucketCloud && (
-            <>
-              <h3>
-                {translate(
-                  'onboarding.create_project.pat_help.instructions_username.bitbucketcloud.title'
-                )}
-              </h3>
-              <p className="big-spacer-top big-spacer-bottom">
-                {translate(
-                  'onboarding.create_project.pat_help.instructions_username.bitbucketcloud'
-                )}
-              </p>
-
-              <div className="text-middle big-spacer-bottom">
-                <img
-                  alt="" // Should be ignored by screen readers
-                  className="spacer-right"
-                  height="16"
-                  src={`${getBaseUrl()}/images/alm/${AlmKeys.BitbucketServer}.svg`}
-                />
-                <a
-                  href="https://bitbucket.org/account/settings/"
-                  rel="noopener noreferrer"
-                  target="_blank">
-                  {translate(
-                    'onboarding.create_project.pat_help.instructions_username.bitbucketcloud.link'
-                  )}
-                </a>
-              </div>
-            </>
-          )}
-
-          <h3>{translate(`onboarding.create_project.pat_help${suffixTranslationKey}.title`)}</h3>
-
-          <p className="big-spacer-top big-spacer-bottom">
-            <FormattedMessage
-              id="onboarding.create_project.pat_help.instructions"
-              defaultMessage={translate(
-                `onboarding.create_project.pat_help${suffixTranslationKey}.instructions`
-              )}
-              values={{ alm: translate('onboarding.alm', alm) }}
-            />
-          </p>
-
-          {(url || alm === AlmKeys.BitbucketCloud) && (
-            <div className="text-middle">
-              <img
-                alt="" // Should be ignored by screen readers
-                className="spacer-right"
-                height="16"
-                src={`${getBaseUrl()}/images/alm/${
-                  alm === AlmKeys.BitbucketCloud ? AlmKeys.BitbucketServer : alm
-                }.svg`}
-              />
-              <a href={getPatUrl(alm, url)} rel="noopener noreferrer" target="_blank">
-                {translate(`onboarding.create_project.pat_help${suffixTranslationKey}.link`)}
-              </a>
-            </div>
-          )}
-
-          <p className="big-spacer-top big-spacer-bottom">
-            {translate('onboarding.create_project.pat_help.instructions2', alm)}
-          </p>
-
-          <ul>
-            {alm === AlmKeys.BitbucketServer && (
-              <li>
-                <FormattedMessage
-                  defaultMessage={translate(
-                    'onboarding.create_project.pat_help.bbs_permission_projects'
-                  )}
-                  id="onboarding.create_project.pat_help.bbs_permission_projects"
-                  values={{
-                    perm: (
-                      <strong>
-                        {translate('onboarding.create_project.pat_help.read_permission')}
-                      </strong>
-                    )
-                  }}
-                />
-              </li>
-            )}
-            {(alm === AlmKeys.BitbucketServer || alm === AlmKeys.BitbucketCloud) && (
-              <li>
-                <FormattedMessage
-                  defaultMessage={translate(
-                    'onboarding.create_project.pat_help.bbs_permission_repos'
-                  )}
-                  id="onboarding.create_project.pat_help.bbs_permission_repos"
-                  values={{
-                    perm: (
-                      <strong>
-                        {translate('onboarding.create_project.pat_help.read_permission')}
-                      </strong>
-                    )
-                  }}
-                />
-              </li>
-            )}
-
-            {alm === AlmKeys.GitLab && (
-              <li className="spacer-bottom">
-                <strong>
-                  {translate('onboarding.create_project.pat_help.gitlab.read_api_permission')}
-                </strong>
-              </li>
-            )}
-          </ul>
-        </Alert>
+        {this.renderHelpBox(suffixTranslationKey)}
       </div>
     );
   }
index 65a05306be285056f70eb95a490bc563fefefca2..2072f4e88158ed64524ba794cf3f3b35b90625b6 100644 (file)
@@ -66,11 +66,16 @@ exports[`should render correctly: bitbucket 1`] = `
       className="big-spacer-top big-spacer-bottom"
     >
       <FormattedMessage
-        defaultMessage="onboarding.create_project.pat_help.instructions"
+        defaultMessage="onboarding.create_project.pat_help.bitbucket.instructions"
         id="onboarding.create_project.pat_help.instructions"
         values={
           Object {
-            "alm": "onboarding.alm.bitbucket",
+            "button": <strong>
+              onboarding.create_project.pat_help.bitbucket.instructions.button
+            </strong>,
+            "menu": <strong>
+              onboarding.create_project.pat_help.bitbucket.instructions.menu
+            </strong>,
           }
         }
       />
@@ -85,7 +90,7 @@ exports[`should render correctly: bitbucket 1`] = `
         src="/images/alm/bitbucket.svg"
       />
       <a
-        href="http://www.example.com/plugins/servlet/access-tokens/add"
+        href="http://www.example.com/account"
         rel="noopener noreferrer"
         target="_blank"
       >
index 3f32b313fea7f36c65fea1b42c9a3f15f4b3f708..9fe2a9d9d771df3f08361c628e761d548ec8c66c 100644 (file)
@@ -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: