]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-12796: Fix alignment and scoll for permission template. In addition fix consite...
authorMathieu Suen <mathieu.suen@sonarsource.com>
Wed, 8 Jan 2020 14:51:43 +0000 (15:51 +0100)
committerSonarTech <sonartech@sonarsource.com>
Fri, 21 Feb 2020 19:46:15 +0000 (20:46 +0100)
12 files changed:
server/sonar-web/src/main/js/app/styles/init/misc.css
server/sonar-web/src/main/js/apps/permission-templates/components/ListHeader.tsx
server/sonar-web/src/main/js/apps/permission-templates/components/ListItem.tsx
server/sonar-web/src/main/js/apps/permission-templates/components/NameCell.tsx
server/sonar-web/src/main/js/apps/permission-templates/components/PermissionCell.tsx
server/sonar-web/src/main/js/apps/permission-templates/components/__tests__/ListItem-test.tsx [new file with mode: 0644]
server/sonar-web/src/main/js/apps/permission-templates/components/__tests__/__snapshots__/ListItem-test.tsx.snap [new file with mode: 0644]
server/sonar-web/src/main/js/apps/permissions/styles.css
server/sonar-web/src/main/js/apps/users/components/UserListItem.tsx
server/sonar-web/src/main/js/apps/users/components/UserListItemIdentity.tsx
server/sonar-web/src/main/js/apps/users/components/__tests__/__snapshots__/UserListItem-test.tsx.snap
server/sonar-web/src/main/js/apps/users/components/__tests__/__snapshots__/UserListItemIdentity-test.tsx.snap

index f0d3ca414c5940fcd09791bc14e738a3371a2b1c..9dd45c38a90fa5d1738fdbfe82c0f6a1f1c4e202 100644 (file)
@@ -152,6 +152,18 @@ th.hide-overflow {
   padding-top: calc(var(--gridSize) / 2) !important;
 }
 
+.little-padded-right {
+  padding-right: calc(var(--gridSize) / 2) !important;
+}
+
+.little-padded-bottom {
+  padding-bottom: calc(var(--gridSize) / 2) !important;
+}
+
+.little-padded-left {
+  padding-left: calc(var(--gridSize) / 2) !important;
+}
+
 .big-padded-top {
   padding-top: calc(2 * var(--gridSize));
 }
index 73a7e55c956bbf129c18c7cf7dd4abec397f810f..ae00435f1b48f4a907c2b98329a675453494419d 100644 (file)
@@ -44,7 +44,9 @@ export default class ListHeader extends React.PureComponent<Props> {
 
   render() {
     const cells = this.props.permissions.map(permission => (
-      <th className="permission-column" key={permission.key}>
+      <th
+        className="permission-column little-padding-left little-padding-right"
+        key={permission.key}>
         <div className="permission-column-inner">
           <span className="text-middle">{translate('projects_role', permission.key)}</span>
           <HelpTooltip className="spacer-left" overlay={this.renderTooltip(permission)} />
@@ -55,9 +57,11 @@ export default class ListHeader extends React.PureComponent<Props> {
     return (
       <thead>
         <tr>
-          <th>&nbsp;</th>
+          <th className="little-padding-left little-padding-right">&nbsp;</th>
           {cells}
-          <th className="thin nowrap text-right">&nbsp;</th>
+          <th className="thin nowrap text-right little-padding-left little-padding-right">
+            &nbsp;
+          </th>
         </tr>
       </thead>
     );
index e81d1cfc6c6c6ac881024b294e6bc05e530cfb00..9a5012783a7969acf701113570af646a42c8d129 100644 (file)
@@ -40,7 +40,7 @@ export default function ListItem(props: Props) {
 
       {permissions}
 
-      <td className="nowrap thin text-right">
+      <td className="nowrap thin text-right text-top little-padding-left little-padding-right">
         <ActionsCell
           organization={props.organization}
           permissionTemplate={props.template}
index dd4b383a215213b848ceec203674459236763841..bb8c91e73f886816beb88d48d44d2e68c3521275 100644 (file)
@@ -32,7 +32,7 @@ export default function NameCell({ template, organization }: Props) {
     : '/permission_templates';
 
   return (
-    <td>
+    <td className="little-padding-left little-padding-right">
       <Link to={{ pathname, query: { id: template.id } }}>
         <strong className="js-name">{template.name}</strong>
       </Link>
index 77612ab9caadb1cbda350c80758f26b2761ce916..45867520958c26d834227263fbff3ca1dea0a448 100644 (file)
@@ -33,7 +33,7 @@ interface Props {
 
 export default function PermissionCell({ permission: p }: Props) {
   return (
-    <td className="permission-column" data-permission={p.key}>
+    <td className="permission-column little-padding-left little-padding-right">
       <div className="permission-column-inner">
         <ul>
           {p.withProjectCreator && (
diff --git a/server/sonar-web/src/main/js/apps/permission-templates/components/__tests__/ListItem-test.tsx b/server/sonar-web/src/main/js/apps/permission-templates/components/__tests__/ListItem-test.tsx
new file mode 100644 (file)
index 0000000..ee94600
--- /dev/null
@@ -0,0 +1,44 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2020 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+import { shallow } from 'enzyme';
+import * as React from 'react';
+import ListItem from '../ListItem';
+
+it('render correctly', () => {
+  expect(shallowRender()).toMatchSnapshot();
+});
+
+function shallowRender() {
+  return shallow(
+    <ListItem
+      key="1"
+      organization={undefined}
+      refresh={async () => {}}
+      template={{
+        id: '1',
+        createdAt: '2020-01-01',
+        name: 'test',
+        defaultFor: [],
+        permissions: []
+      }}
+      topQualifiers={[]}
+    />
+  );
+}
diff --git a/server/sonar-web/src/main/js/apps/permission-templates/components/__tests__/__snapshots__/ListItem-test.tsx.snap b/server/sonar-web/src/main/js/apps/permission-templates/components/__tests__/__snapshots__/ListItem-test.tsx.snap
new file mode 100644 (file)
index 0000000..cce4308
--- /dev/null
@@ -0,0 +1,37 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[`render correctly 1`] = `
+<tr
+  data-id="1"
+  data-name="test"
+>
+  <NameCell
+    template={
+      Object {
+        "createdAt": "2020-01-01",
+        "defaultFor": Array [],
+        "id": "1",
+        "name": "test",
+        "permissions": Array [],
+      }
+    }
+  />
+  <td
+    className="nowrap thin text-right text-top little-padding-left little-padding-right"
+  >
+    <withRouter(ActionsCell)
+      permissionTemplate={
+        Object {
+          "createdAt": "2020-01-01",
+          "defaultFor": Array [],
+          "id": "1",
+          "name": "test",
+          "permissions": Array [],
+        }
+      }
+      refresh={[Function]}
+      topQualifiers={Array []}
+    />
+  </td>
+</tr>
+`;
index fca51c63b426cb48c2356cb984b5b750fa7c245a..dc18e18cda46f237283da73e3f2cccfa94340077 100644 (file)
@@ -22,7 +22,6 @@
 }
 
 .permissions-table .permission-column-inner {
-  display: inline-block;
   width: 100px;
 }
 
index 6bc2236c286a79ead635fbf6031d40c5d6861ca9..c54d7b1e9c2ed500f1936841e8009e1f581aff60 100644 (file)
@@ -53,22 +53,22 @@ export default class UserListItem extends React.PureComponent<Props, State> {
 
     return (
       <tr>
-        <td className="thin nowrap">
+        <td className="thin nowrap text-middle">
           <Avatar hash={user.avatar} name={user.name} size={36} />
         </td>
         <UserListItemIdentity identityProvider={identityProvider} user={user} />
-        <td>
+        <td className="thin nowrap text-middle">
           <UserScmAccounts scmAccounts={user.scmAccounts || []} />
         </td>
-        <td>
+        <td className="thin nowrap text-middle">
           <DateFromNowHourPrecision date={user.lastConnectionDate} />
         </td>
         {!organizationsEnabled && (
-          <td>
+          <td className="thin nowrap text-middle">
             <UserGroups groups={user.groups || []} onUpdateUsers={onUpdateUsers} user={user} />
           </td>
         )}
-        <td>
+        <td className="thin nowrap text-middle">
           {user.tokensCount}
           <ButtonIcon
             className="js-user-tokens spacer-left button-small"
@@ -77,7 +77,7 @@ export default class UserListItem extends React.PureComponent<Props, State> {
             <BulletListIcon />
           </ButtonIcon>
         </td>
-        <td className="thin nowrap text-right">
+        <td className="thin nowrap text-right text-middle">
           <UserActions
             isCurrentUser={this.props.isCurrentUser}
             onUpdateUsers={onUpdateUsers}
index c1a17f834c778451e9b11184cb2ece0683daa72d..27543ac8b02cc2b88d12397d8903d41b99a61cba 100644 (file)
@@ -29,7 +29,7 @@ export interface Props {
 
 export default function UserListItemIdentity({ identityProvider, user }: Props) {
   return (
-    <td>
+    <td className="text-middle">
       <div>
         <strong className="js-user-name">{user.name}</strong>
         <span className="js-user-login note little-spacer-left">{user.login}</span>
index 8905a4b99af0f56fea2d261748780e023eb94331..e0649832c3ec35029c48060b9812f562d74b633e 100644 (file)
@@ -3,7 +3,7 @@
 exports[`should render correctly 1`] = `
 <tr>
   <td
-    className="thin nowrap"
+    className="thin nowrap text-middle"
   >
     <Connect(Avatar)
       name="One"
@@ -22,17 +22,23 @@ exports[`should render correctly 1`] = `
       }
     }
   />
-  <td>
+  <td
+    className="thin nowrap text-middle"
+  >
     <UserScmAccounts
       scmAccounts={Array []}
     />
   </td>
-  <td>
+  <td
+    className="thin nowrap text-middle"
+  >
     <DateFromNowHourPrecision
       date="2019-01-18T15:06:33+0100"
     />
   </td>
-  <td>
+  <td
+    className="thin nowrap text-middle"
+  >
     <UserGroups
       groups={Array []}
       onUpdateUsers={[MockFunction]}
@@ -48,7 +54,9 @@ exports[`should render correctly 1`] = `
       }
     />
   </td>
-  <td>
+  <td
+    className="thin nowrap text-middle"
+  >
     <ButtonIcon
       className="js-user-tokens spacer-left button-small"
       onClick={[Function]}
@@ -58,7 +66,7 @@ exports[`should render correctly 1`] = `
     </ButtonIcon>
   </td>
   <td
-    className="thin nowrap text-right"
+    className="thin nowrap text-right text-middle"
   >
     <UserActions
       isCurrentUser={false}
@@ -81,7 +89,7 @@ exports[`should render correctly 1`] = `
 exports[`should render correctly without last connection date 1`] = `
 <tr>
   <td
-    className="thin nowrap"
+    className="thin nowrap text-middle"
   >
     <Connect(Avatar)
       name="One"
@@ -100,17 +108,23 @@ exports[`should render correctly without last connection date 1`] = `
       }
     }
   />
-  <td>
+  <td
+    className="thin nowrap text-middle"
+  >
     <UserScmAccounts
       scmAccounts={Array []}
     />
   </td>
-  <td>
+  <td
+    className="thin nowrap text-middle"
+  >
     <DateFromNowHourPrecision
       date="2019-01-18T15:06:33+0100"
     />
   </td>
-  <td>
+  <td
+    className="thin nowrap text-middle"
+  >
     <UserGroups
       groups={Array []}
       onUpdateUsers={[MockFunction]}
@@ -126,7 +140,9 @@ exports[`should render correctly without last connection date 1`] = `
       }
     />
   </td>
-  <td>
+  <td
+    className="thin nowrap text-middle"
+  >
     <ButtonIcon
       className="js-user-tokens spacer-left button-small"
       onClick={[Function]}
@@ -136,7 +152,7 @@ exports[`should render correctly without last connection date 1`] = `
     </ButtonIcon>
   </td>
   <td
-    className="thin nowrap text-right"
+    className="thin nowrap text-right text-middle"
   >
     <UserActions
       isCurrentUser={false}
index c9d65154d56a2d8b1e6cfcb7cbe83c9608112413..c6b01bdea01adf3eafea8d07f2d03da61005e91c 100644 (file)
@@ -36,7 +36,9 @@ exports[`#ExternalProvider should render the user external provider and identity
 `;
 
 exports[`#UserListItemIdentity should render correctly 1`] = `
-<td>
+<td
+  className="text-middle"
+>
   <div>
     <strong
       className="js-user-name"