From: Wouter Admiraal Date: Tue, 27 Apr 2021 12:42:18 +0000 (+0200) Subject: SONAR-13765 Fix permissions page minimum width X-Git-Tag: 8.9.0.43852~35 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=3f09e6fe1ad7be2bfca54d5b1f3e32294b4f7e51;p=sonarqube.git SONAR-13765 Fix permissions page minimum width --- diff --git a/server/sonar-web/src/main/js/apps/permissions/shared/components/GroupHolder.tsx b/server/sonar-web/src/main/js/apps/permissions/shared/components/GroupHolder.tsx index 16ec9611353..1c71b4e11e8 100644 --- a/server/sonar-web/src/main/js/apps/permissions/shared/components/GroupHolder.tsx +++ b/server/sonar-web/src/main/js/apps/permissions/shared/components/GroupHolder.tsx @@ -68,15 +68,15 @@ export default class GroupHolder extends React.PureComponent { return ( -
- -
-
-
- {group.name} -
-
- {group.description} +
+ +
+
+ {group.name} +
+
+ {group.description} +
diff --git a/server/sonar-web/src/main/js/apps/permissions/shared/components/UserHolder.tsx b/server/sonar-web/src/main/js/apps/permissions/shared/components/UserHolder.tsx index 61c4f40eef7..40e7cb648cb 100644 --- a/server/sonar-web/src/main/js/apps/permissions/shared/components/UserHolder.tsx +++ b/server/sonar-web/src/main/js/apps/permissions/shared/components/UserHolder.tsx @@ -21,7 +21,6 @@ import { without } from 'lodash'; import * as React from 'react'; import { translate } from 'sonar-ui-common/helpers/l10n'; import Avatar from '../../../../components/ui/Avatar'; -import { isSonarCloud } from '../../../../helpers/system'; import { isPermissionDefinitionGroup } from '../../utils'; import PermissionCell from './PermissionCell'; @@ -81,17 +80,11 @@ export default class UserHolder extends React.PureComponent { return ( -
-
- {user.name} -
-
- {translate( - isSonarCloud() - ? 'permission_templates.project_creators.explanation.sonarcloud' - : 'permission_templates.project_creators.explanation' - )} -
+
+ {user.name} +
+
+ {translate('permission_templates.project_creators.explanation')}
{permissionCells} @@ -102,29 +95,20 @@ export default class UserHolder extends React.PureComponent { return ( - -
- {isSonarCloud() ? ( - <> -
- {user.name} -
-
{user.login}
- - ) : ( - <> -
- {user.name} - {user.login} -
-
{user.email}
- - )} +
+ +
+
+ {user.name} + {user.login} +
+
{user.email}
+
{permissionCells} diff --git a/server/sonar-web/src/main/js/apps/permissions/shared/components/__tests__/GroupHolder-test.tsx b/server/sonar-web/src/main/js/apps/permissions/shared/components/__tests__/GroupHolder-test.tsx index 9c0eb397044..08889d8210e 100644 --- a/server/sonar-web/src/main/js/apps/permissions/shared/components/__tests__/GroupHolder-test.tsx +++ b/server/sonar-web/src/main/js/apps/permissions/shared/components/__tests__/GroupHolder-test.tsx @@ -20,39 +20,15 @@ import { shallow } from 'enzyme'; import * as React from 'react'; import { waitAndUpdate } from 'sonar-ui-common/helpers/testUtils'; +import { mockPermissionGroup } from '../../../../../helpers/mocks/permissions'; import GroupHolder from '../GroupHolder'; -const group = { - id: 'foobar', - name: 'Foobar', - permissions: ['bar'] -}; - -const groupHolder = ( - Promise.resolve())} - permissions={[ - { - category: 'admin', - permissions: [ - { key: 'foo', name: 'Foo', description: '' }, - { key: 'bar', name: 'Bar', description: '' } - ] - }, - { key: 'baz', name: 'Baz', description: '' } - ]} - selectedPermission="bar" - /> -); - it('should render correctly', () => { - expect(shallow(groupHolder)).toMatchSnapshot(); + expect(shallowRender()).toMatchSnapshot('default'); }); -it('should disabled PermissionCell checkboxes when waiting for promise to return', async () => { - const wrapper = shallow(groupHolder); +it('should disable PermissionCell checkboxes when waiting for promise to return', async () => { + const wrapper = shallowRender(); expect(wrapper.state().loading).toEqual([]); wrapper.instance().handleCheck(true, 'baz'); @@ -66,3 +42,24 @@ it('should disabled PermissionCell checkboxes when waiting for promise to return await waitAndUpdate(wrapper); expect(wrapper.state().loading).toEqual([]); }); + +function shallowRender(props: Partial = {}) { + return shallow( + + ); +} diff --git a/server/sonar-web/src/main/js/apps/permissions/shared/components/__tests__/UserHolder-test.tsx b/server/sonar-web/src/main/js/apps/permissions/shared/components/__tests__/UserHolder-test.tsx index 2458c2338e1..da48b3cc454 100644 --- a/server/sonar-web/src/main/js/apps/permissions/shared/components/__tests__/UserHolder-test.tsx +++ b/server/sonar-web/src/main/js/apps/permissions/shared/components/__tests__/UserHolder-test.tsx @@ -20,43 +20,18 @@ import { shallow } from 'enzyme'; import * as React from 'react'; import { waitAndUpdate } from 'sonar-ui-common/helpers/testUtils'; -import { isSonarCloud } from '../../../../../helpers/system'; +import { mockPermissionUser } from '../../../../../helpers/mocks/permissions'; import UserHolder from '../UserHolder'; -jest.mock('../../../../../helpers/system', () => ({ isSonarCloud: jest.fn() })); - -const user = { - email: 'john.doe@sonarsource.com', - login: 'john doe', - name: 'John Doe', - permissions: ['bar'] -}; - -const userHolder = ( - Promise.resolve())} - permissions={[ - { - category: 'admin', - permissions: [ - { key: 'foo', name: 'Foo', description: '' }, - { key: 'bar', name: 'Bar', description: '' } - ] - }, - { key: 'baz', name: 'Baz', description: '' } - ]} - selectedPermission="bar" - user={user} - /> -); - it('should render correctly', () => { - expect(shallow(userHolder)).toMatchSnapshot(); + expect(shallowRender()).toMatchSnapshot('default'); + expect(shallowRender({ user: mockPermissionUser({ login: '' }) })).toMatchSnapshot( + 'creator' + ); }); it('should disabled PermissionCell checkboxes when waiting for promise to return', async () => { - const wrapper = shallow(userHolder); + const wrapper = shallowRender(); expect(wrapper.state().loading).toEqual([]); wrapper.instance().handleCheck(true, 'baz'); @@ -71,16 +46,23 @@ it('should disabled PermissionCell checkboxes when waiting for promise to return expect(wrapper.state().loading).toEqual([]); }); -it('should show user details for SonarQube', () => { - (isSonarCloud as jest.Mock).mockReturnValue(false); - - const wrapper = shallow(userHolder); - expect(wrapper.find('.display-inline-block.text-middle')).toMatchSnapshot(); -}); - -it('should show user details for SonarCloud', () => { - (isSonarCloud as jest.Mock).mockReturnValue(true); - - const wrapper = shallow(userHolder); - expect(wrapper.find('.display-inline-block.text-middle')).toMatchSnapshot(); -}); +function shallowRender(props: Partial = {}) { + return shallow( + + ); +} diff --git a/server/sonar-web/src/main/js/apps/permissions/shared/components/__tests__/__snapshots__/GroupHolder-test.tsx.snap b/server/sonar-web/src/main/js/apps/permissions/shared/components/__tests__/__snapshots__/GroupHolder-test.tsx.snap index 25b18f84153..c8d55b33e47 100644 --- a/server/sonar-web/src/main/js/apps/permissions/shared/components/__tests__/__snapshots__/GroupHolder-test.tsx.snap +++ b/server/sonar-web/src/main/js/apps/permissions/shared/components/__tests__/__snapshots__/GroupHolder-test.tsx.snap @@ -1,31 +1,35 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`should render correctly 1`] = ` +exports[`should render correctly: default 1`] = `
- -
-
-
- - Foobar - -
+
+
+ + sonar-admins + +
+
+ /> +
- +
+ + johndoe + +
-
- - John Doe - - - john doe - -
+ permission_templates.project_creators.explanation +
+ + ", + "name": "johndoe", + "permissions": Array [ + "provisioning", + ], + } + } + selectedPermission="bar" + /> + ", + "name": "johndoe", + "permissions": Array [ + "provisioning", + ], + } + } + selectedPermission="bar" + /> + +`; + +exports[`should render correctly: default 1`] = ` + + +
+
- john.doe@sonarsource.com +
+ + John Doe + + + john.doe + +
+
+ john.doe@sonarsource.com +
@@ -53,11 +141,13 @@ exports[`should render correctly 1`] = ` } permissionItem={ Object { + "active": true, "email": "john.doe@sonarsource.com", - "login": "john doe", + "local": true, + "login": "john.doe", "name": "John Doe", "permissions": Array [ - "bar", + "provisioning", ], } } @@ -76,11 +166,13 @@ exports[`should render correctly 1`] = ` } permissionItem={ Object { + "active": true, "email": "john.doe@sonarsource.com", - "login": "john doe", + "local": true, + "login": "john.doe", "name": "John Doe", "permissions": Array [ - "bar", + "provisioning", ], } } @@ -88,42 +180,3 @@ exports[`should render correctly 1`] = ` /> `; - -exports[`should show user details for SonarCloud 1`] = ` -
-
- - John Doe - -
-
- john doe -
-
-`; - -exports[`should show user details for SonarQube 1`] = ` -
-
- - John Doe - - - john doe - -
-
- john.doe@sonarsource.com -
-
-`; diff --git a/server/sonar-web/src/main/js/apps/permissions/styles.css b/server/sonar-web/src/main/js/apps/permissions/styles.css index b138769cb14..c0ab97ffd83 100644 --- a/server/sonar-web/src/main/js/apps/permissions/styles.css +++ b/server/sonar-web/src/main/js/apps/permissions/styles.css @@ -22,7 +22,7 @@ } .permissions-table .permission-column-inner { - width: 100px; + width: 90px; } .permissions-table .divider { @@ -36,3 +36,7 @@ height: 1px; width: 100%; } + +.permissions-table td:first-of-type { + max-width: 320px; +}