]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-22011 Explain token creation for monorepo (#10935)
authorLucas <97296331+lucas-paulger-sonarsource@users.noreply.github.com>
Mon, 8 Apr 2024 09:33:33 +0000 (11:33 +0200)
committersonartech <sonartech@sonarsource.com>
Wed, 10 Apr 2024 20:02:55 +0000 (20:02 +0000)
server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/RepositoryVariables.tsx
server/sonar-web/src/main/js/components/tutorials/github-action/GitHubActionTutorial.tsx
server/sonar-web/src/main/js/components/tutorials/github-action/SecretStep.tsx
server/sonar-web/src/main/js/components/tutorials/test-utils.ts
sonar-core/src/main/resources/org/sonar/l10n/core.properties

index 90f68d92cc3dd760afbe1b7ada456140666d216c..6c6384c478def98f5dc02fa96c40853755bf7dbc 100644 (file)
  * along with this program; if not, write to the Free Software Foundation,
  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  */
-import {
-  BasicSeparator,
-  ClipboardIconButton,
-  NumberedList,
-  NumberedListItem,
-  StandoutLink,
-} from 'design-system';
+import { LinkStandalone } from '@sonarsource/echoes-react';
+import { BasicSeparator, ClipboardIconButton, NumberedList, NumberedListItem } from 'design-system';
 import * as React from 'react';
 import { FormattedMessage } from 'react-intl';
 import { translate } from '../../../helpers/l10n';
@@ -54,16 +49,15 @@ export default function RepositoryVariables(props: RepositoryVariablesProps) {
         values={{
           repository_variables:
             almBinding?.url && projectBinding?.repository ? (
-              <StandoutLink
+              <LinkStandalone
                 to={`${buildBitbucketCloudLink(
                   almBinding,
                   projectBinding,
                 )}/admin/addon/admin/pipelines/repository-variables`}
                 target="_blank"
-                rel="noopener noreferrer"
               >
                 {translate('onboarding.tutorial.with.bitbucket_pipelines.variables.intro.link')}
-              </StandoutLink>
+              </LinkStandalone>
             ) : (
               <span className="sw-body-sm-highlight">
                 {translate('onboarding.tutorial.with.bitbucket_pipelines.variables.intro.link')}
index 73ae10cb840927a8c1120324439a69b3a497190c..013652103b29d0ddf9f163a8557075ffb8f662f8 100644 (file)
@@ -50,13 +50,13 @@ export default function GitHubActionTutorial(props: GitHubActionTutorialProps) {
     willRefreshAutomatically,
   } = props;
 
-  const secretStepTitle = `onboarding.tutorial.with.github_action.create_secret.title${monorepo ? '.monorepo' : ''}`;
-
   return (
     <>
       <Title>{translate('onboarding.tutorial.with.github_ci.title')}</Title>
       <TutorialStepList className="sw-mb-8">
-        <TutorialStep title={translate(secretStepTitle)}>
+        <TutorialStep
+          title={translate('onboarding.tutorial.with.github_action.create_secret.title')}
+        >
           <SecretStep
             almBinding={almBinding}
             baseUrl={baseUrl}
index 3af2806b6fc3c85147dc5bbeca600e1b52ffc11e..385105e5179ebcb25fa885ad366550b8c8f34a7c 100644 (file)
  * along with this program; if not, write to the Free Software Foundation,
  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  */
+import { Link, LinkStandalone } from '@sonarsource/echoes-react';
 import {
   BasicSeparator,
   ClipboardIconButton,
   FlagMessage,
   NumberedList,
   NumberedListItem,
-  StandoutLink,
 } from 'design-system';
 import * as React from 'react';
 import { FormattedMessage } from 'react-intl';
 import { translate } from '../../../helpers/l10n';
+import { hasGlobalPermission } from '../../../helpers/users';
 import { useProjectBindingQuery } from '../../../queries/devops-integration';
 import { AlmSettingsInstance } from '../../../types/alm-settings';
+import { Permissions } from '../../../types/permissions';
 import { Component } from '../../../types/types';
 import { LoggedInUser } from '../../../types/users';
 import { InlineSnippet } from '../components/InlineSnippet';
@@ -57,13 +59,12 @@ export default function SecretStep(props: SecretStepProps) {
         values={{
           settings_secret:
             almBinding && projectBinding ? (
-              <StandoutLink
+              <LinkStandalone
                 to={`${buildGithubLink(almBinding, projectBinding)}/settings/secrets`}
                 target="_blank"
-                rel="noopener noreferrer"
               >
                 {translate('onboarding.tutorial.with.github_action.secret.intro.link')}
-              </StandoutLink>
+              </LinkStandalone>
             ) : (
               <span className="sw-body-sm-highlight">
                 {translate('onboarding.tutorial.with.github_action.secret.intro.link')}
@@ -85,6 +86,38 @@ export default function SecretStep(props: SecretStepProps) {
           />
           <InlineSnippet snippet="SONAR_TOKEN" className="sw-ml-1" />
           <ClipboardIconButton copyValue="SONAR_TOKEN" className="sw-ml-2 sw-align-sub" />
+          {monorepo && (
+            <FlagMessage variant="info" className="sw-block sw-w-fit sw-mt-4">
+              <FormattedMessage
+                defaultMessage={translate(
+                  'onboarding.tutorial.with.github_action.create_secret.monorepo_sonar_token',
+                )}
+                id="onboarding.tutorial.with.github_action.create_secret.monorepo_sonar_token"
+                values={{
+                  token_name: <InlineSnippet snippet="SONAR_TOKEN_1" className="sw-ml-1" />,
+                  global_secret: hasGlobalPermission(currentUser, Permissions.Scan) ? (
+                    <FormattedMessage
+                      defaultMessage={translate(
+                        'onboarding.tutorial.with.github_action.create_secret.monorepo_create_global_token',
+                      )}
+                      id="onboarding.tutorial.with.github_action.create_secret.monorepo_create_global_token"
+                      values={{
+                        link: (
+                          <Link to="/account/security" target="_blank" className="sw-mx-1">
+                            {translate(
+                              'onboarding.tutorial.with.github_action.create_secret.monorepo_create_global_token.link',
+                            )}
+                          </Link>
+                        ),
+                      }}
+                    />
+                  ) : (
+                    ''
+                  ),
+                }}
+              />
+            </FlagMessage>
+          )}
         </NumberedListItem>
         <NumberedListItem>
           <TokenStepGenerator component={component} currentUser={currentUser} />
index 894797b65229927c499ce4814dd0a1c7e7f565bb..62ee6baa08111af21890a711a928b759aa5975b8 100644 (file)
@@ -50,7 +50,7 @@ export function getCommonNodes(ci: TutorialModes) {
     linkToRepo: byRole('link', {
       name: `onboarding.tutorial.with.${CI_TRANSLATE_MAP[ci]}.${
         ci === TutorialModes.GitHubActions ? 'secret' : 'variables'
-      }.intro.link`,
+      }.intro.link open_in_new_window`,
     }),
     allSetSentence: byText('onboarding.tutorial.ci_outro.done'),
   };
index 9e89edd1f4df1c422e0f3a09ac4e65481e5cc261..461807b339c4459d40967d72af4633f93da418a7 100644 (file)
@@ -4619,8 +4619,10 @@ onboarding.tutorial.with.bitbucket_pipelines.variables.secured.sentence.secured=
 
 onboarding.tutorial.with.github_ci.title=Analyze your project with GitHub CI
 onboarding.tutorial.with.github_action.create_secret.title=Create GitHub Secrets
-onboarding.tutorial.with.github_action.create_secret.title.monorepo=Create GitHub Secrets (once per monorepository)
 onboarding.tutorial.with.github_action.create_secret.monorepo_info=If the secrets were created already for one of the projects in the mono repository, please skip this step
+onboarding.tutorial.with.github_action.create_secret.monorepo_sonar_token=Monorepository token names will need to be unique per project (e.g. {token_name}) {global_secret}
+onboarding.tutorial.with.github_action.create_secret.monorepo_create_global_token=or create a {link} for the monorepository
+onboarding.tutorial.with.github_action.create_secret.monorepo_create_global_token.link=global token
 onboarding.tutorial.with.github_action.monorepo.pre_see_yaml_instructions=(once per monorepository)
 onboarding.tutorial.with.github_action.monorepo.see_yaml_instructions=See the documentation to create the Workflow YAML file at the root of your repository
 onboarding.tutorial.with.github_action.secret.intro=In your GitHub repository, go to {settings_secret} and create two new secrets: