diff options
author | Grégoire Aubert <gregoire.aubert@sonarsource.com> | 2019-02-27 10:26:55 +0100 |
---|---|---|
committer | sonartech <sonartech@sonarsource.com> | 2019-03-06 11:30:43 +0100 |
commit | 27bd7ce2f9b558ebde4173cd37d315edec2f7c5f (patch) | |
tree | c25326bcda44c1de2d26b6fbb1df8ba95bc4991f | |
parent | b6f9782ddc5ba713af26801d281be3ecf999ba89 (diff) | |
download | sonarqube-27bd7ce2f9b558ebde4173cd37d315edec2f7c5f.tar.gz sonarqube-27bd7ce2f9b558ebde4173cd37d315edec2f7c5f.zip |
SONARCLOUD-379 Display user sync warning message only if there are other members already
6 files changed, 32 insertions, 11 deletions
diff --git a/server/sonar-web/src/main/js/apps/organizationMembers/MembersPageHeader.tsx b/server/sonar-web/src/main/js/apps/organizationMembers/MembersPageHeader.tsx index 5bf10ce8799..89fe2e97ce9 100644 --- a/server/sonar-web/src/main/js/apps/organizationMembers/MembersPageHeader.tsx +++ b/server/sonar-web/src/main/js/apps/organizationMembers/MembersPageHeader.tsx @@ -53,7 +53,12 @@ export default function MembersPageHeader(props: Props) { {almKey && isGithub(almKey) && !showSyncNotif && ( - <SyncMemberForm organization={organization} refreshMembers={refreshMembers} /> + <SyncMemberForm + buttonText={translate('organization.members.config_synchro')} + hasOtherMembers={members && members.length > 1} + organization={organization} + refreshMembers={refreshMembers} + /> )} {!hasMemberSync && ( <div className="display-inline-block spacer-left spacer-bottom"> @@ -91,7 +96,12 @@ export default function MembersPageHeader(props: Props) { translate('organization', almKey) )} <span className="spacer-left"> - <SyncMemberForm organization={organization} refreshMembers={refreshMembers} /> + <SyncMemberForm + buttonText={translate('configure')} + hasOtherMembers={members && members.length > 1} + organization={organization} + refreshMembers={refreshMembers} + /> </span> </Alert> )} diff --git a/server/sonar-web/src/main/js/apps/organizationMembers/SyncMemberForm.tsx b/server/sonar-web/src/main/js/apps/organizationMembers/SyncMemberForm.tsx index 826f70a4b1c..5f38c424a8f 100644 --- a/server/sonar-web/src/main/js/apps/organizationMembers/SyncMemberForm.tsx +++ b/server/sonar-web/src/main/js/apps/organizationMembers/SyncMemberForm.tsx @@ -30,7 +30,9 @@ import { translate, translateWithParameters } from '../../helpers/l10n'; import { fetchOrganization } from '../../store/rootActions'; interface Props { + buttonText: string; fetchOrganization: (key: string) => void; + hasOtherMembers?: boolean; organization: T.Organization; refreshMembers: () => Promise<void>; } @@ -91,8 +93,9 @@ export class SyncMemberForm extends React.PureComponent<Props, State> { renderModalBody = () => { const { membersSync } = this.state; - const { organization } = this.props; + const { hasOtherMembers, organization } = this.props; const almKey = organization.alm && sanitizeAlmId(organization.alm.key); + const showWarning = hasOtherMembers && organization.alm && !organization.alm.membersSync; return ( <div className="display-flex-stretch big-spacer-top"> <RadioCard @@ -136,11 +139,15 @@ export class SyncMemberForm extends React.PureComponent<Props, State> { <li>{translate('organization.members.management.choose_members_permissions')}</li> </ul> </div> - {(!organization.alm || !organization.alm.membersSync) && ( - <Alert className="big-spacer-top" variant="warning"> - {translate('organization.members.management.automatic.warning')} - </Alert> - )} + {almKey && + showWarning && ( + <Alert className="big-spacer-top" variant="warning"> + {translateWithParameters( + 'organization.members.management.automatic.warning_x', + translate('organization', almKey) + )} + </Alert> + )} </RadioCard> </div> ); @@ -159,7 +166,7 @@ export class SyncMemberForm extends React.PureComponent<Props, State> { modalHeaderDescription={this.renderModalDescription()} onConfirm={this.handleConfirm} size={'medium'}> - {({ onClick }) => <Button onClick={onClick}>{translate('configure')}</Button>} + {({ onClick }) => <Button onClick={onClick}>{this.props.buttonText}</Button>} </ConfirmButton> ); } diff --git a/server/sonar-web/src/main/js/apps/organizationMembers/__tests__/SyncMemberForm-test.tsx b/server/sonar-web/src/main/js/apps/organizationMembers/__tests__/SyncMemberForm-test.tsx index 2d959fdb109..8d9d9b55d25 100644 --- a/server/sonar-web/src/main/js/apps/organizationMembers/__tests__/SyncMemberForm-test.tsx +++ b/server/sonar-web/src/main/js/apps/organizationMembers/__tests__/SyncMemberForm-test.tsx @@ -69,7 +69,9 @@ it('should allow to switch to manual mode', async () => { function shallowRender(props: Partial<SyncMemberForm['props']> = {}) { return shallow<SyncMemberForm>( <SyncMemberForm + buttonText="configure" fetchOrganization={jest.fn()} + hasOtherMembers={true} organization={mockOrganizationWithAlm()} refreshMembers={jest.fn().mockResolvedValue({})} {...props} diff --git a/server/sonar-web/src/main/js/apps/organizationMembers/__tests__/__snapshots__/MembersPageHeader-test.tsx.snap b/server/sonar-web/src/main/js/apps/organizationMembers/__tests__/__snapshots__/MembersPageHeader-test.tsx.snap index ca7ac6f19fb..9cc1eb93b37 100644 --- a/server/sonar-web/src/main/js/apps/organizationMembers/__tests__/__snapshots__/MembersPageHeader-test.tsx.snap +++ b/server/sonar-web/src/main/js/apps/organizationMembers/__tests__/__snapshots__/MembersPageHeader-test.tsx.snap @@ -174,6 +174,8 @@ exports[`should render for GitHub bound organization without sync 1`] = ` className="spacer-left" > <Connect(SyncMemberForm) + buttonText="configure" + hasOtherMembers={false} organization={ Object { "actions": Object { diff --git a/server/sonar-web/src/main/js/apps/organizationMembers/__tests__/__snapshots__/SyncMemberForm-test.tsx.snap b/server/sonar-web/src/main/js/apps/organizationMembers/__tests__/__snapshots__/SyncMemberForm-test.tsx.snap index c0a6253566e..66187c5588d 100644 --- a/server/sonar-web/src/main/js/apps/organizationMembers/__tests__/__snapshots__/SyncMemberForm-test.tsx.snap +++ b/server/sonar-web/src/main/js/apps/organizationMembers/__tests__/__snapshots__/SyncMemberForm-test.tsx.snap @@ -63,7 +63,7 @@ exports[`should allow to switch to automatic mode 1`] = ` className="big-spacer-top" variant="warning" > - organization.members.management.automatic.warning + organization.members.management.automatic.warning_x.organization.github </Alert> </RadioCard> </div> 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 0aa845d5b52..6b3891f56d3 100644 --- a/sonar-core/src/main/resources/org/sonar/l10n/core.properties +++ b/sonar-core/src/main/resources/org/sonar/l10n/core.properties @@ -2689,7 +2689,7 @@ organization.members.management.manual.add_members_manually=Admin add members ma organization.members.management.automatic=Automatic sync with {0} organization.members.management.automatic.synchronized_from_x=Members are synchronized automatically from your {0} organization.members.management.automatic.members_changes_reflected.github=If you add or remove a member on GitHub, SonarCloud immediately reflects the changes -organization.members.management.automatic.warning=This will override your current Members and Permissions configuration +organization.members.management.automatic.warning_x=This will override your current Members, removing those that are not part of your {0}. organization.members.management.choose_members_permissions=Admin manages permissions for each member in SonarCloud organization.paid_plan.badge=Paid plan organization.default_visibility_of_new_projects=Default visibility of new projects: |