diff options
author | Julien Lancelot <julien.lancelot@sonarsource.com> | 2018-10-23 16:39:20 +0200 |
---|---|---|
committer | SonarTech <sonartech@sonarsource.com> | 2018-11-16 20:21:04 +0100 |
commit | f714aa7a66fd87a39898390edd0c15f0c77dd248 (patch) | |
tree | b65a64780009f497e3c9f4263af07df51cea2f10 /server/sonar-web/src/main/js | |
parent | f0e05b42339d0736bf117c631bde4530cc1f356a (diff) | |
download | sonarqube-f714aa7a66fd87a39898390edd0c15f0c77dd248.tar.gz sonarqube-f714aa7a66fd87a39898390edd0c15f0c77dd248.zip |
SONAR-11323 Return personal organization info
* Return personalOrganization in api/users/current
* Replace type by personal in api/alm_integrations/show_org
* Update AlmOrganization type with personal flag instead of type field
Diffstat (limited to 'server/sonar-web/src/main/js')
8 files changed, 19 insertions, 19 deletions
diff --git a/server/sonar-web/src/main/js/app/types.ts b/server/sonar-web/src/main/js/app/types.ts index df5915bbfd0..01b41f6dbfd 100644 --- a/server/sonar-web/src/main/js/app/types.ts +++ b/server/sonar-web/src/main/js/app/types.ts @@ -28,7 +28,7 @@ export interface AlmApplication extends IdentityProvider { } export interface AlmOrganization extends OrganizationBase { key: string; - type: 'ORGANIZATION' | 'USER'; + personal: boolean; } export interface AlmRepository { 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 4d6539e500c..b58cd5adf3d 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 @@ -44,7 +44,7 @@ it('should render prefilled and create org', async () => { const onOrgCreated = jest.fn(); const wrapper = shallowRender({ almInstallId: 'id-foo', - almOrganization: { ...organization, type: 'ORGANIZATION' }, + almOrganization: { ...organization, personal: false }, createOrganization, onOrgCreated }); @@ -61,7 +61,7 @@ it('should render prefilled and create org', async () => { it('should display choice between import or creation', () => { const wrapper = shallowRender({ almInstallId: 'id-foo', - almOrganization: { ...organization, type: 'ORGANIZATION' }, + almOrganization: { ...organization, personal: false }, unboundOrganizations: [organization] }); expect(wrapper).toMatchSnapshot(); @@ -79,7 +79,7 @@ it('should bind existing organization', async () => { const onOrgCreated = jest.fn(); const wrapper = shallowRender({ almInstallId: 'id-foo', - almOrganization: { ...organization, type: 'ORGANIZATION' }, + almOrganization: { ...organization, personal: false }, onOrgCreated, unboundOrganizations: [organization] }); diff --git a/server/sonar-web/src/main/js/apps/create/organization/__tests__/AutoPersonalOrganizationBind-test.tsx b/server/sonar-web/src/main/js/apps/create/organization/__tests__/AutoPersonalOrganizationBind-test.tsx index d735122f941..dd1eebc4620 100644 --- a/server/sonar-web/src/main/js/apps/create/organization/__tests__/AutoPersonalOrganizationBind-test.tsx +++ b/server/sonar-web/src/main/js/apps/create/organization/__tests__/AutoPersonalOrganizationBind-test.tsx @@ -57,7 +57,7 @@ function shallowRender(props: Partial<AutoPersonalOrganizationBind['props']> = { description: 'description-foo', key: 'key-foo', name: 'name-foo', - type: 'USER', + personal: true, url: 'http://example.com/foo' }} importPersonalOrg={{ key: 'personalorg', name: 'Personal Org' }} diff --git a/server/sonar-web/src/main/js/apps/create/organization/__tests__/CreateOrganization-test.tsx b/server/sonar-web/src/main/js/apps/create/organization/__tests__/CreateOrganization-test.tsx index 8aa237fc1d0..eb9fce91998 100644 --- a/server/sonar-web/src/main/js/apps/create/organization/__tests__/CreateOrganization-test.tsx +++ b/server/sonar-web/src/main/js/apps/create/organization/__tests__/CreateOrganization-test.tsx @@ -34,20 +34,20 @@ jest.mock('../../../../api/billing', () => ({ jest.mock('../../../../api/alm-integration', () => ({ getAlmAppInfo: jest.fn().mockResolvedValue({ application: { - installationUrl: 'https://alm.installation.url', backgroundColor: 'blue', iconPath: 'icon/path', + installationUrl: 'https://alm.installation.url', key: 'github', name: 'GitHub' } }), getAlmOrganization: jest.fn().mockResolvedValue({ + avatar: 'https://avatars3.githubusercontent.com/u/37629810?v=4', + description: 'Continuous Code Quality', key: 'sonarsource', name: 'SonarSource', - description: 'Continuous Code Quality', - url: 'https://www.sonarsource.com', - avatar: 'https://avatars3.githubusercontent.com/u/37629810?v=4', - type: 'ORGANIZATION' + personal: false, + url: 'https://www.sonarsource.com' }) })); @@ -95,7 +95,7 @@ it('should render with auto personal organization bind page', async () => { key: 'foo', name: 'Foo', avatar: 'https://avatars3.githubusercontent.com/u/37629810?v=4', - type: 'USER' + personal: true }); const wrapper = shallowRender({ currentUser: { ...user, externalProvider: 'github', personalOrganization: 'foo' }, 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 f11e164d3a1..56a6fe28fbb 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 @@ -11,7 +11,7 @@ exports[`should display choice between import or creation 1`] = ` "description": "description-foo", "key": "key-foo", "name": "name-foo", - "type": "ORGANIZATION", + "personal": false, "url": "http://example.com/foo", } } @@ -73,7 +73,7 @@ exports[`should render prefilled and create org 1`] = ` "description": "description-foo", "key": "key-foo", "name": "name-foo", - "type": "ORGANIZATION", + "personal": false, "url": "http://example.com/foo", } } @@ -111,7 +111,7 @@ exports[`should render prefilled and create org 1`] = ` "description": "description-foo", "key": "key-foo", "name": "name-foo", - "type": "ORGANIZATION", + "personal": false, "url": "http://example.com/foo", } } diff --git a/server/sonar-web/src/main/js/apps/create/organization/__tests__/__snapshots__/CreateOrganization-test.tsx.snap b/server/sonar-web/src/main/js/apps/create/organization/__tests__/__snapshots__/CreateOrganization-test.tsx.snap index d43925de3dc..11acf9d7aba 100644 --- a/server/sonar-web/src/main/js/apps/create/organization/__tests__/__snapshots__/CreateOrganization-test.tsx.snap +++ b/server/sonar-web/src/main/js/apps/create/organization/__tests__/__snapshots__/CreateOrganization-test.tsx.snap @@ -64,7 +64,7 @@ exports[`should render with auto personal organization bind page 2`] = ` "avatar": "https://avatars3.githubusercontent.com/u/37629810?v=4", "key": "foo", "name": "Foo", - "type": "USER", + "personal": true, } } importPersonalOrg={ @@ -244,7 +244,7 @@ exports[`should render with auto tab selected and manual disabled 2`] = ` "description": "Continuous Code Quality", "key": "sonarsource", "name": "SonarSource", - "type": "ORGANIZATION", + "personal": false, "url": "https://www.sonarsource.com", } } diff --git a/server/sonar-web/src/main/js/helpers/__tests__/almIntegrations-test.ts b/server/sonar-web/src/main/js/helpers/__tests__/almIntegrations-test.ts index 7a54b6b68bd..cfaba659431 100644 --- a/server/sonar-web/src/main/js/helpers/__tests__/almIntegrations-test.ts +++ b/server/sonar-web/src/main/js/helpers/__tests__/almIntegrations-test.ts @@ -36,8 +36,8 @@ it('#isVSTS', () => { }); it('#isPersonal', () => { - expect(isPersonal({ key: 'foo', name: 'Foo', type: 'USER' })).toBeTruthy(); - expect(isPersonal({ key: 'foo', name: 'Foo', type: 'ORGANIZATION' })).toBeFalsy(); + expect(isPersonal({ key: 'foo', name: 'Foo', personal: true })).toBeTruthy(); + expect(isPersonal({ key: 'foo', name: 'Foo', personal: false })).toBeFalsy(); }); it('#sanitizeAlmId', () => { diff --git a/server/sonar-web/src/main/js/helpers/almIntegrations.ts b/server/sonar-web/src/main/js/helpers/almIntegrations.ts index fdfe7abd17c..29af8561f5a 100644 --- a/server/sonar-web/src/main/js/helpers/almIntegrations.ts +++ b/server/sonar-web/src/main/js/helpers/almIntegrations.ts @@ -39,7 +39,7 @@ export function isVSTS(almKey?: string) { } export function isPersonal(organization?: AlmOrganization) { - return Boolean(organization && organization.type === 'USER'); + return Boolean(organization && organization.personal); } export function sanitizeAlmId(almKey?: string) { |