aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-web/src/main/js/apps/create
diff options
context:
space:
mode:
Diffstat (limited to 'server/sonar-web/src/main/js/apps/create')
-rw-r--r--server/sonar-web/src/main/js/apps/create/components/UpgradeOrganizationModal.tsx4
-rw-r--r--server/sonar-web/src/main/js/apps/create/components/__tests__/__snapshots__/UpgradeOrganizationModal-test.tsx.snap2
-rw-r--r--server/sonar-web/src/main/js/apps/create/organization/AutoOrganizationCreate.tsx14
-rw-r--r--server/sonar-web/src/main/js/apps/create/organization/RemoteOrganizationChoose.tsx2
-rw-r--r--server/sonar-web/src/main/js/apps/create/organization/__tests__/AutoOrganizationCreate-test.tsx27
-rw-r--r--server/sonar-web/src/main/js/apps/create/organization/__tests__/__snapshots__/AutoOrganizationCreate-test.tsx.snap14
-rw-r--r--server/sonar-web/src/main/js/apps/create/organization/__tests__/__snapshots__/RemoteOrganizationChoose-test.tsx.snap1
-rw-r--r--server/sonar-web/src/main/js/apps/create/organization/__tests__/actions-test.ts8
-rw-r--r--server/sonar-web/src/main/js/apps/create/organization/actions.ts16
9 files changed, 56 insertions, 32 deletions
diff --git a/server/sonar-web/src/main/js/apps/create/components/UpgradeOrganizationModal.tsx b/server/sonar-web/src/main/js/apps/create/components/UpgradeOrganizationModal.tsx
index dfaca7bc0f0..27467f3420f 100644
--- a/server/sonar-web/src/main/js/apps/create/components/UpgradeOrganizationModal.tsx
+++ b/server/sonar-web/src/main/js/apps/create/components/UpgradeOrganizationModal.tsx
@@ -72,10 +72,10 @@ export default class UpgradeOrganizationModal extends React.PureComponent<Props,
return (
<Modal
contentLabel={header}
- medium={true}
noBackdrop={this.props.insideModal}
onRequestClose={this.props.onClose}
- shouldCloseOnOverlayClick={false}>
+ shouldCloseOnOverlayClick={false}
+ size={'medium'}>
<div className="modal-head">
<h2>{header}</h2>
</div>
diff --git a/server/sonar-web/src/main/js/apps/create/components/__tests__/__snapshots__/UpgradeOrganizationModal-test.tsx.snap b/server/sonar-web/src/main/js/apps/create/components/__tests__/__snapshots__/UpgradeOrganizationModal-test.tsx.snap
index 3043cc08b5f..4d294fc1497 100644
--- a/server/sonar-web/src/main/js/apps/create/components/__tests__/__snapshots__/UpgradeOrganizationModal-test.tsx.snap
+++ b/server/sonar-web/src/main/js/apps/create/components/__tests__/__snapshots__/UpgradeOrganizationModal-test.tsx.snap
@@ -3,9 +3,9 @@
exports[`should render correctly 1`] = `
<Modal
contentLabel="billing.upgrade_box.upgrade_to_paid_plan"
- medium={true}
onRequestClose={[MockFunction]}
shouldCloseOnOverlayClick={false}
+ size="medium"
>
<div
className="modal-head"
diff --git a/server/sonar-web/src/main/js/apps/create/organization/AutoOrganizationCreate.tsx b/server/sonar-web/src/main/js/apps/create/organization/AutoOrganizationCreate.tsx
index bce0bcb2c21..3a40718de56 100644
--- a/server/sonar-web/src/main/js/apps/create/organization/AutoOrganizationCreate.tsx
+++ b/server/sonar-web/src/main/js/apps/create/organization/AutoOrganizationCreate.tsx
@@ -77,12 +77,17 @@ export default class AutoOrganizationCreate extends React.PureComponent<Props, S
};
handleCreateOrganization = () => {
- const { organization } = this.props;
+ const { almApplication, almOrganization, organization } = this.props;
if (!organization) {
return Promise.reject();
}
return this.props.createOrganization({
...organization,
+ alm: {
+ key: almApplication.key,
+ membersSync: true,
+ url: almOrganization.almUrl
+ },
installationId: this.props.almInstallId
});
};
@@ -169,10 +174,13 @@ export default class AutoOrganizationCreate extends React.PureComponent<Props, S
)}
</p>
<a
- href={getAlmMembersUrl(almOrganization.key, almOrganization.almUrl)}
+ href={getAlmMembersUrl(almApplication.key, almOrganization.almUrl)}
rel="noopener noreferrer"
target="_blank">
- {translate('onboarding.import_organization.see_who_has_access')}
+ {translateWithParameters(
+ 'organization.members.see_all_members_on_x',
+ translate(almKey)
+ )}
</a>
</Alert>
}
diff --git a/server/sonar-web/src/main/js/apps/create/organization/RemoteOrganizationChoose.tsx b/server/sonar-web/src/main/js/apps/create/organization/RemoteOrganizationChoose.tsx
index 4c086a58779..33d9fcc8d79 100644
--- a/server/sonar-web/src/main/js/apps/create/organization/RemoteOrganizationChoose.tsx
+++ b/server/sonar-web/src/main/js/apps/create/organization/RemoteOrganizationChoose.tsx
@@ -168,7 +168,7 @@ export class RemoteOrganizationChoose extends React.PureComponent<Props & WithRo
</div>
<form className="big-spacer-top big-spacer-bottom" onSubmit={this.handleSubmit}>
<div className="form-field abs-width-400">
- <label htmlFor="select-unbound-installation">
+ <label className="text-normal" htmlFor="select-unbound-installation">
{translateWithParameters(
'onboarding.import_organization.choose_unbound_installation_x',
translate(sanitizeAlmId(almApplication.key))
diff --git a/server/sonar-web/src/main/js/apps/create/organization/__tests__/AutoOrganizationCreate-test.tsx b/server/sonar-web/src/main/js/apps/create/organization/__tests__/AutoOrganizationCreate-test.tsx
index 8ac2a9e1a07..b3fe16d362c 100644
--- a/server/sonar-web/src/main/js/apps/create/organization/__tests__/AutoOrganizationCreate-test.tsx
+++ b/server/sonar-web/src/main/js/apps/create/organization/__tests__/AutoOrganizationCreate-test.tsx
@@ -22,7 +22,7 @@ import { shallow } from 'enzyme';
import AutoOrganizationCreate from '../AutoOrganizationCreate';
import { Step } from '../utils';
import { bindAlmOrganization } from '../../../../api/alm-integration';
-import { mockAlmOrganization } from '../../../../helpers/testMocks';
+import { mockAlmOrganization, mockAlmApplication } from '../../../../helpers/testMocks';
import { waitAndUpdate, click } from '../../../../helpers/testUtils';
jest.mock('../../../../api/alm-integration', () => ({
@@ -34,7 +34,14 @@ const organization = mockAlmOrganization();
it('should render prefilled and create org', async () => {
const createOrganization = jest.fn().mockResolvedValue({ key: 'foo' });
const handleOrgDetailsFinish = jest.fn();
- const wrapper = shallowRender({ createOrganization, handleOrgDetailsFinish });
+ const almApplication = mockAlmApplication({ key: 'github' });
+ const almOrganization = mockAlmOrganization({ almUrl: 'http://github.com/thing' });
+ const wrapper = shallowRender({
+ almApplication,
+ almOrganization,
+ createOrganization,
+ handleOrgDetailsFinish
+ });
expect(wrapper).toMatchSnapshot();
@@ -44,7 +51,13 @@ it('should render prefilled and create org', async () => {
wrapper.setProps({ organization });
wrapper.find('PlanStep').prop<Function>('createOrganization')();
- expect(createOrganization).toBeCalledWith({ ...organization, installationId: 'id-foo' });
+
+ const alm = {
+ key: 'github',
+ membersSync: true,
+ url: 'http://github.com/thing'
+ };
+ expect(createOrganization).toBeCalledWith({ ...organization, alm, installationId: 'id-foo' });
});
it('should allow to cancel org import', () => {
@@ -86,13 +99,7 @@ it('should bind existing organization', async () => {
function shallowRender(props: Partial<AutoOrganizationCreate['props']> = {}) {
return shallow(
<AutoOrganizationCreate
- almApplication={{
- backgroundColor: '#0052CC',
- iconPath: '"/static/authbitbucket/bitbucket.svg"',
- installationUrl: 'https://bitbucket.org/install/app',
- key: 'bitbucket',
- name: 'BitBucket'
- }}
+ almApplication={mockAlmApplication()}
almInstallId="id-foo"
almOrganization={{ ...organization, personal: false }}
createOrganization={jest.fn()}
diff --git a/server/sonar-web/src/main/js/apps/create/organization/__tests__/__snapshots__/AutoOrganizationCreate-test.tsx.snap b/server/sonar-web/src/main/js/apps/create/organization/__tests__/__snapshots__/AutoOrganizationCreate-test.tsx.snap
index d16fbc70263..ca0868ae105 100644
--- a/server/sonar-web/src/main/js/apps/create/organization/__tests__/__snapshots__/AutoOrganizationCreate-test.tsx.snap
+++ b/server/sonar-web/src/main/js/apps/create/organization/__tests__/__snapshots__/AutoOrganizationCreate-test.tsx.snap
@@ -121,7 +121,7 @@ exports[`should render prefilled and create org 1`] = `
"avatar": <img
alt="BitBucket"
className="little-spacer-left"
- src="/images/sonarcloud/bitbucket.svg"
+ src="/images/sonarcloud/github.svg"
width={16}
/>,
"name": <strong>
@@ -144,21 +144,21 @@ exports[`should render prefilled and create org 1`] = `
variant="info"
>
<p>
- onboarding.import_organization.members_sync_info_x.organization.bitbucket.foo.bitbucket
+ onboarding.import_organization.members_sync_info_x.organization.github.foo.github
</p>
<a
- href="https://github.com/foo/profile/members"
+ href="http://github.com/orgs/thing/people"
rel="noopener noreferrer"
target="_blank"
>
- onboarding.import_organization.see_who_has_access
+ organization.members.see_all_members_on_x.github
</a>
</Alert>
}
onContinue={[MockFunction]}
organization={
Object {
- "almUrl": "https://github.com/foo",
+ "almUrl": "http://github.com/thing",
"avatar": "http://example.com/avatar",
"description": "description-foo",
"key": "foo",
@@ -178,13 +178,13 @@ exports[`should render prefilled and create org 1`] = `
"backgroundColor": "#0052CC",
"iconPath": "\\"/static/authbitbucket/bitbucket.svg\\"",
"installationUrl": "https://bitbucket.org/install/app",
- "key": "bitbucket",
+ "key": "github",
"name": "BitBucket",
}
}
almOrganization={
Object {
- "almUrl": "https://github.com/foo",
+ "almUrl": "http://github.com/thing",
"avatar": "http://example.com/avatar",
"description": "description-foo",
"key": "foo",
diff --git a/server/sonar-web/src/main/js/apps/create/organization/__tests__/__snapshots__/RemoteOrganizationChoose-test.tsx.snap b/server/sonar-web/src/main/js/apps/create/organization/__tests__/__snapshots__/RemoteOrganizationChoose-test.tsx.snap
index 8cd6afa0fd3..cae179cdd68 100644
--- a/server/sonar-web/src/main/js/apps/create/organization/__tests__/__snapshots__/RemoteOrganizationChoose-test.tsx.snap
+++ b/server/sonar-web/src/main/js/apps/create/organization/__tests__/__snapshots__/RemoteOrganizationChoose-test.tsx.snap
@@ -124,6 +124,7 @@ exports[`should display unbound installations 1`] = `
className="form-field abs-width-400"
>
<label
+ className="text-normal"
htmlFor="select-unbound-installation"
>
onboarding.import_organization.choose_unbound_installation_x.github
diff --git a/server/sonar-web/src/main/js/apps/create/organization/__tests__/actions-test.ts b/server/sonar-web/src/main/js/apps/create/organization/__tests__/actions-test.ts
index 26800ae126a..f95556451f8 100644
--- a/server/sonar-web/src/main/js/apps/create/organization/__tests__/actions-test.ts
+++ b/server/sonar-web/src/main/js/apps/create/organization/__tests__/actions-test.ts
@@ -51,9 +51,13 @@ describe('#createOrganization', () => {
});
it('should create and sync members', async () => {
- const org = mockOrganizationWithAlm({}, { membersSync: true });
+ const { alm, ...org } = mockOrganizationWithAlm(
+ {},
+ { key: 'github', membersSync: true, url: 'https://github.com/foo' }
+ );
+
(createOrganization as jest.Mock).mockResolvedValueOnce(org);
- const promise = actions.createOrganization(org)(dispatch);
+ const promise = actions.createOrganization({ alm, ...org })(dispatch);
expect(createOrganization).toHaveBeenCalledWith(org);
await promise;
diff --git a/server/sonar-web/src/main/js/apps/create/organization/actions.ts b/server/sonar-web/src/main/js/apps/create/organization/actions.ts
index 400de6cdf61..38b90fff706 100644
--- a/server/sonar-web/src/main/js/apps/create/organization/actions.ts
+++ b/server/sonar-web/src/main/js/apps/create/organization/actions.ts
@@ -21,17 +21,21 @@ import { Dispatch } from 'redux';
import { bindAlmOrganization } from '../../../api/alm-integration';
import * as api from '../../../api/organizations';
import * as actions from '../../../store/organizations';
+import { isGithub } from '../../../helpers/almIntegrations';
-export function createOrganization(organization: T.Organization & { installationId?: string }) {
+export function createOrganization({
+ alm,
+ ...organization
+}: T.Organization & { installationId?: string }) {
return (dispatch: Dispatch) => {
return api
.createOrganization({ ...organization, name: organization.name || organization.key })
- .then((organization: T.Organization) => {
- dispatch(actions.createOrganization(organization));
- if (organization.alm && organization.alm.membersSync) {
- api.syncMembers(organization.key);
+ .then((newOrganization: T.Organization) => {
+ dispatch(actions.createOrganization({ ...newOrganization, alm }));
+ if (alm && alm.membersSync && isGithub(alm.key)) {
+ api.syncMembers(newOrganization.key);
}
- return organization.key;
+ return newOrganization.key;
});
};
}