From: Stas Vilchik Date: Mon, 11 Dec 2017 16:59:17 +0000 (+0100) Subject: SONAR-10186 Switch between organizations from the header X-Git-Tag: 7.0-RC1~82 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=0d3c531f4a6ef72a1f0982808543273760ea05ba;p=sonarqube.git SONAR-10186 Switch between organizations from the header --- diff --git a/server/sonar-web/src/main/js/apps/organizations/navigation/OrganizationNavigation.css b/server/sonar-web/src/main/js/apps/organizations/navigation/OrganizationNavigation.css new file mode 100644 index 00000000000..f61bbd33bd2 --- /dev/null +++ b/server/sonar-web/src/main/js/apps/organizations/navigation/OrganizationNavigation.css @@ -0,0 +1,57 @@ +/* + * SonarQube + * Copyright (C) 2009-2017 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. + */ +.organization-switch { + display: inline-block; +} + +.organization-switch .dropdown-toggle { + display: block; + height: calc(4 * var(--gridSize)); + line-height: calc(4 * var(--gridSize) - 2px); + padding: 0 var(--gridSize); + border: 1px solid transparent; + border-radius: 2px; + box-sizing: border-box; + color: var(--baseFontColor) !important; + transition: all 0.3s ease; +} + +.organization-switch .dropdown-toggle:hover, +.organization-switch.open .dropdown-toggle { + border-color: var(--barBorderColor); + background-color: #fff; + box-shadow: var(--defaultShadow); +} + +.organization-switch.open .dropdown-toggle { + border-bottom-color: transparent; + border-bottom-left-radius: 0; + border-bottom-right-radius: 0; +} + +.organization-switch .dropdown-menu { + min-width: 100%; + margin-left: -1px; +} + +.organization-switch .dropdown-menu > li > a { + padding-left: var(--gridSize); + padding-right: var(--gridSize); +} diff --git a/server/sonar-web/src/main/js/apps/organizations/navigation/OrganizationNavigation.tsx b/server/sonar-web/src/main/js/apps/organizations/navigation/OrganizationNavigation.tsx index 4cffcc47d80..b57d9840517 100644 --- a/server/sonar-web/src/main/js/apps/organizations/navigation/OrganizationNavigation.tsx +++ b/server/sonar-web/src/main/js/apps/organizations/navigation/OrganizationNavigation.tsx @@ -18,222 +18,25 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import * as React from 'react'; -import * as classNames from 'classnames'; -import { Link } from 'react-router'; +import OrganizationNavigationHeaderContainer from './OrganizationNavigationHeaderContainer'; +import OrganizationNavigationMeta from './OrganizationNavigationMeta'; +import OrganizationNavigationMenu from './OrganizationNavigationMenu'; import * as theme from '../../../app/theme'; -import { translate } from '../../../helpers/l10n'; import ContextNavBar from '../../../components/nav/ContextNavBar'; -import NavBarTabs from '../../../components/nav/NavBarTabs'; -import OrganizationAvatar from '../../../components/common/OrganizationAvatar'; -import { getQualityGatesUrl } from '../../../helpers/urls'; -import { Extension, Organization } from '../../../app/types'; - -const ADMIN_PATHS = [ - 'edit', - 'groups', - 'delete', - 'permissions', - 'permission_templates', - 'projects_management' -]; +import { Organization } from '../../../app/types'; +import './OrganizationNavigation.css'; interface Props { location: { pathname: string }; organization: Organization; } -export default class OrganizationNavigation extends React.PureComponent { - renderAdministration(adminActive: boolean) { - const { organization } = this.props; - - return ( -
  • - - {translate('layout.settings')}  - -
      - {this.renderAdminExtensions()} -
    • - - {translate('user_groups.page')} - -
    • -
    • - - {translate('permissions.page')} - -
    • -
    • - - {translate('permission_templates')} - -
    • -
    • - - {translate('projects_management')} - -
    • -
    • - - {translate('edit')} - -
    • - {organization.canDelete && ( -
    • - - {translate('delete')} - -
    • - )} -
    -
  • - ); - } - - renderAdminExtensions() { - const extensions = this.props.organization.adminPages || []; - return extensions.map(this.renderExtension); - } - - renderExtension = (extension: Extension) => { - const { organization } = this.props; - const pathname = `/organizations/${organization.key}/extension/${extension.key}`; - return ( -
  • - - {extension.name} - -
  • - ); - }; - - renderExtensions(moreActive: boolean) { - const extensions = this.props.organization.pages || []; - if (extensions.length > 0) { - return ( -
  • - - {translate('more')}  - -
      {extensions.map(this.renderExtension)}
    -
  • - ); - } else { - return null; - } - } - - render() { - const { organization, location } = this.props; - - const isHomeActive = - location.pathname === `organizations/${organization.key}/projects` || - location.pathname === `organizations/${organization.key}/projects/favorite`; - - const adminPathsWithExtensions = (organization.adminPages || []) - .map(e => `extension/${e.key}`) - .concat(ADMIN_PATHS); - - const adminActive = adminPathsWithExtensions.some(path => - location.pathname.endsWith(`organizations/${organization.key}/${path}`) - ); - const moreActive = !adminActive && location.pathname.includes('/extension/'); - - return ( - -
    -

    - - - {organization.name} - -

    - {organization.description != null && ( -
    -

    - {organization.description} -

    -
    - )} -
    - -
    -
    - {translate('organization.key')}: {organization.key} -
    - {organization.url != null && ( - - )} -
    - - -
  • - - {translate('projects.page')} - -
  • -
  • - - {translate('issues.page')} - -
  • -
  • - - {translate('quality_profiles.page')} - -
  • -
  • - - {translate('coding_rules.page')} - -
  • -
  • - - {translate('quality_gates.page')} - -
  • -
  • - - {translate('organization.members.page')} - -
  • - {this.renderExtensions(moreActive)} - {organization.canAdmin && this.renderAdministration(adminActive)} -
    -
    - ); - } +export default function OrganizationNavigation({ organization, location }: Props) { + return ( + + + + + + ); } diff --git a/server/sonar-web/src/main/js/apps/organizations/navigation/OrganizationNavigationAdministration.tsx b/server/sonar-web/src/main/js/apps/organizations/navigation/OrganizationNavigationAdministration.tsx new file mode 100644 index 00000000000..98d50b19d61 --- /dev/null +++ b/server/sonar-web/src/main/js/apps/organizations/navigation/OrganizationNavigationAdministration.tsx @@ -0,0 +1,112 @@ +/* + * SonarQube + * Copyright (C) 2009-2017 SonarSource SA + * mailto:contact 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 * as React from 'react'; +import { Link } from 'react-router'; +import * as classNames from 'classnames'; +import { Organization } from '../../../app/types'; +import { translate } from '../../../helpers/l10n'; +import Dropdown from '../../../components/controls/Dropdown'; +import DropdownIcon from '../../../components/icons-components/DropdownIcon'; + +interface Props { + location: { pathname: string }; + organization: Organization; +} + +const ADMIN_PATHS = [ + 'edit', + 'groups', + 'delete', + 'permissions', + 'permission_templates', + 'projects_management' +]; + +export default function OrganizationNavigationAdministration({ location, organization }: Props) { + const extensions = organization.adminPages || []; + const adminPathsWithExtensions = extensions.map(e => `extension/${e.key}`).concat(ADMIN_PATHS); + const adminActive = adminPathsWithExtensions.some(path => + location.pathname.endsWith(`organizations/${organization.key}/${path}`) + ); + + return ( + + {({ onToggleClick, open }) => ( +
  • + + {translate('layout.settings')} + + +
      + {extensions.map(extension => ( +
    • + + {extension.name} + +
    • + ))} +
    • + + {translate('user_groups.page')} + +
    • +
    • + + {translate('permissions.page')} + +
    • +
    • + + {translate('permission_templates')} + +
    • +
    • + + {translate('projects_management')} + +
    • +
    • + + {translate('edit')} + +
    • + {organization.canDelete && ( +
    • + + {translate('delete')} + +
    • + )} +
    +
  • + )} +
    + ); +} diff --git a/server/sonar-web/src/main/js/apps/organizations/navigation/OrganizationNavigationExtensions.tsx b/server/sonar-web/src/main/js/apps/organizations/navigation/OrganizationNavigationExtensions.tsx new file mode 100644 index 00000000000..097fcba9bc0 --- /dev/null +++ b/server/sonar-web/src/main/js/apps/organizations/navigation/OrganizationNavigationExtensions.tsx @@ -0,0 +1,70 @@ +/* + * SonarQube + * Copyright (C) 2009-2017 SonarSource SA + * mailto:contact 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 * as React from 'react'; +import { Link } from 'react-router'; +import * as classNames from 'classnames'; +import { Organization } from '../../../app/types'; +import { translate } from '../../../helpers/l10n'; +import Dropdown from '../../../components/controls/Dropdown'; + +interface Props { + location: { pathname: string }; + organization: Organization; +} + +export default function OrganizationNavigationExtensions({ location, organization }: Props) { + const extensions = organization.pages || []; + if (extensions.length === 0) { + return null; + } + const active = extensions.some( + extension => + location.pathname === `/organizations/${organization.key}/extension/${extension.key}` + ); + + return ( + + {({ onToggleClick, open }) => ( +
  • + + {translate('more')} + + + +
      + {extensions.map(extension => ( +
    • + + {extension.name} + +
    • + ))} +
    +
  • + )} +
    + ); +} diff --git a/server/sonar-web/src/main/js/apps/organizations/navigation/OrganizationNavigationHeader.tsx b/server/sonar-web/src/main/js/apps/organizations/navigation/OrganizationNavigationHeader.tsx new file mode 100644 index 00000000000..afa4332544c --- /dev/null +++ b/server/sonar-web/src/main/js/apps/organizations/navigation/OrganizationNavigationHeader.tsx @@ -0,0 +1,81 @@ +/* + * SonarQube + * Copyright (C) 2009-2017 SonarSource SA + * mailto:contact 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 * as React from 'react'; +import * as classNames from 'classnames'; +import { sortBy } from 'lodash'; +import { Organization } from '../../../app/types'; +import OrganizationAvatar from '../../../components/common/OrganizationAvatar'; +import Dropdown from '../../../components/controls/Dropdown'; +import DropdownIcon from '../../../components/icons-components/DropdownIcon'; +import OrganizationLink from '../../../components/ui/OrganizationLink'; +import { translate } from '../../../helpers/l10n'; + +interface Props { + organization: Organization; + organizations: Organization[]; +} + +export default function OrganizationNavigationHeader({ organization, organizations }: Props) { + const other = organizations.filter(o => o.key !== organization.key); + + return ( +
    +

    + + {other.length ? ( + + {({ onToggleClick, open }) => ( +
    + + {organization.name} + + +
      + {sortBy(other, org => org.name.toLowerCase()).map(organization => ( +
    • + +
      + + {organization.name} +
      + {organization.isAdmin && ( + {translate('admin')} + )} +
      +
    • + ))} +
    +
    + )} +
    + ) : ( + {organization.name} + )} +

    + {organization.description != null && ( +
    +

    + {organization.description} +

    +
    + )} +
    + ); +} diff --git a/server/sonar-web/src/main/js/apps/organizations/navigation/OrganizationNavigationHeaderContainer.tsx b/server/sonar-web/src/main/js/apps/organizations/navigation/OrganizationNavigationHeaderContainer.tsx new file mode 100644 index 00000000000..c94996e6a76 --- /dev/null +++ b/server/sonar-web/src/main/js/apps/organizations/navigation/OrganizationNavigationHeaderContainer.tsx @@ -0,0 +1,33 @@ +/* + * SonarQube + * Copyright (C) 2009-2017 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 { connect } from 'react-redux'; +import OrganizationNavigationHeader from './OrganizationNavigationHeader'; +import { Organization } from '../../../app/types'; +import { getMyOrganizations } from '../../../store/rootReducer'; + +interface StateProps { + organizations: Organization[]; +} + +const mapStateToProps = (state: any): StateProps => ({ + organizations: getMyOrganizations(state) +}); + +export default connect(mapStateToProps)(OrganizationNavigationHeader); diff --git a/server/sonar-web/src/main/js/apps/organizations/navigation/OrganizationNavigationMenu.tsx b/server/sonar-web/src/main/js/apps/organizations/navigation/OrganizationNavigationMenu.tsx new file mode 100644 index 00000000000..048c9f3b750 --- /dev/null +++ b/server/sonar-web/src/main/js/apps/organizations/navigation/OrganizationNavigationMenu.tsx @@ -0,0 +1,78 @@ +/* + * SonarQube + * Copyright (C) 2009-2017 SonarSource SA + * mailto:contact 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 * as React from 'react'; +import { Link } from 'react-router'; +import { Organization } from '../../../app/types'; +import NavBarTabs from '../../../components/nav/NavBarTabs'; +import { translate } from '../../../helpers/l10n'; +import { getQualityGatesUrl } from '../../../helpers/urls'; +import OrganizationNavigationExtensions from './OrganizationNavigationExtensions'; +import OrganizationNavigationAdministration from './OrganizationNavigationAdministration'; + +interface Props { + location: { pathname: string }; + organization: Organization; +} + +export default function OrganizationNavigationMenu({ location, organization }: Props) { + return ( + +
  • + + {translate('projects.page')} + +
  • +
  • + + {translate('issues.page')} + +
  • +
  • + + {translate('quality_profiles.page')} + +
  • +
  • + + {translate('coding_rules.page')} + +
  • +
  • + + {translate('quality_gates.page')} + +
  • +
  • + + {translate('organization.members.page')} + +
  • + + {organization.canAdmin && ( + + )} +
    + ); +} diff --git a/server/sonar-web/src/main/js/apps/organizations/navigation/OrganizationNavigationMeta.tsx b/server/sonar-web/src/main/js/apps/organizations/navigation/OrganizationNavigationMeta.tsx new file mode 100644 index 00000000000..b720223abe1 --- /dev/null +++ b/server/sonar-web/src/main/js/apps/organizations/navigation/OrganizationNavigationMeta.tsx @@ -0,0 +1,49 @@ +/* + * SonarQube + * Copyright (C) 2009-2017 SonarSource SA + * mailto:contact 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 * as React from 'react'; +import { Organization } from '../../../app/types'; +import { translate } from '../../../helpers/l10n'; + +interface Props { + organization: Organization; +} + +export default function OrganizationNavigationMeta({ organization }: Props) { + return ( +
    +
    + {translate('organization.key')}: {organization.key} +
    + {organization.url != null && ( + + )} +
    + ); +} diff --git a/server/sonar-web/src/main/js/apps/organizations/navigation/__tests__/OrganizationNavigation-test.tsx b/server/sonar-web/src/main/js/apps/organizations/navigation/__tests__/OrganizationNavigation-test.tsx index e4884f83545..41fea385334 100644 --- a/server/sonar-web/src/main/js/apps/organizations/navigation/__tests__/OrganizationNavigation-test.tsx +++ b/server/sonar-web/src/main/js/apps/organizations/navigation/__tests__/OrganizationNavigation-test.tsx @@ -22,40 +22,17 @@ import { shallow } from 'enzyme'; import OrganizationNavigation from '../OrganizationNavigation'; import { Visibility } from '../../../../app/types'; -jest.mock('../../../issues/utils', () => ({ - isMySet: () => false -})); - -const organization = { - key: 'foo', - name: 'Foo', - canAdmin: false, - canDelete: false, - projectVisibility: Visibility.Public -}; - -it('regular user', () => { - expect(getWrapper()).toMatchSnapshot(); -}); - -it('admin', () => { +it('render', () => { expect( - getWrapper({ organization: { ...organization, canAdmin: true, canDelete: true } }) + shallow( + + ) ).toMatchSnapshot(); }); - -it('undeletable org', () => { - expect( - getWrapper({ organization: { ...organization, canAdmin: true, canDelete: false } }) - ).toMatchSnapshot(); -}); - -function getWrapper(props = {}) { - return shallow( - - ); -} diff --git a/server/sonar-web/src/main/js/apps/organizations/navigation/__tests__/OrganizationNavigationAdministration-test.tsx b/server/sonar-web/src/main/js/apps/organizations/navigation/__tests__/OrganizationNavigationAdministration-test.tsx new file mode 100644 index 00000000000..4bebf6b977e --- /dev/null +++ b/server/sonar-web/src/main/js/apps/organizations/navigation/__tests__/OrganizationNavigationAdministration-test.tsx @@ -0,0 +1,37 @@ +/* + * SonarQube + * Copyright (C) 2009-2017 SonarSource SA + * mailto:contact 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 * as React from 'react'; +import { shallow } from 'enzyme'; +import OrganizationNavigationAdministration from '../OrganizationNavigationAdministration'; +import { Visibility } from '../../../../app/types'; + +it('renders', () => { + const wrapper = shallow( + + ); + expect(wrapper.find('Dropdown').dive()).toMatchSnapshot(); +}); diff --git a/server/sonar-web/src/main/js/apps/organizations/navigation/__tests__/OrganizationNavigationHeader-test.tsx b/server/sonar-web/src/main/js/apps/organizations/navigation/__tests__/OrganizationNavigationHeader-test.tsx new file mode 100644 index 00000000000..bb9bd18b521 --- /dev/null +++ b/server/sonar-web/src/main/js/apps/organizations/navigation/__tests__/OrganizationNavigationHeader-test.tsx @@ -0,0 +1,56 @@ +/* + * SonarQube + * Copyright (C) 2009-2017 SonarSource SA + * mailto:contact 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 * as React from 'react'; +import { shallow } from 'enzyme'; +import OrganizationNavigationHeader from '../OrganizationNavigationHeader'; +import { Visibility } from '../../../../app/types'; + +it('renders', () => { + expect( + shallow( + + ) + ).toMatchSnapshot(); +}); + +it('renders dropdown', () => { + const organizations = [ + { isAdmin: true, key: 'org1', name: 'org1', projectVisibility: Visibility.Public }, + { isAdmin: false, key: 'org2', name: 'org2', projectVisibility: Visibility.Public } + ]; + const wrapper = shallow( + + ); + expect(wrapper.find('Dropdown').dive()).toMatchSnapshot(); +}); diff --git a/server/sonar-web/src/main/js/apps/organizations/navigation/__tests__/OrganizationNavigationMenu-test.tsx b/server/sonar-web/src/main/js/apps/organizations/navigation/__tests__/OrganizationNavigationMenu-test.tsx new file mode 100644 index 00000000000..a5b266bcc2a --- /dev/null +++ b/server/sonar-web/src/main/js/apps/organizations/navigation/__tests__/OrganizationNavigationMenu-test.tsx @@ -0,0 +1,54 @@ +/* + * SonarQube + * Copyright (C) 2009-2017 SonarSource SA + * mailto:contact 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 * as React from 'react'; +import { shallow } from 'enzyme'; +import OrganizationNavigationMenu from '../OrganizationNavigationMenu'; +import { Visibility } from '../../../../app/types'; + +it('renders', () => { + expect( + shallow( + + ) + ).toMatchSnapshot(); +}); + +it('renders for admin', () => { + expect( + shallow( + + ) + ).toMatchSnapshot(); +}); diff --git a/server/sonar-web/src/main/js/apps/organizations/navigation/__tests__/OrganizationNavigationMeta-test.tsx b/server/sonar-web/src/main/js/apps/organizations/navigation/__tests__/OrganizationNavigationMeta-test.tsx new file mode 100644 index 00000000000..5b69f2c4853 --- /dev/null +++ b/server/sonar-web/src/main/js/apps/organizations/navigation/__tests__/OrganizationNavigationMeta-test.tsx @@ -0,0 +1,37 @@ +/* + * SonarQube + * Copyright (C) 2009-2017 SonarSource SA + * mailto:contact 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 * as React from 'react'; +import { shallow } from 'enzyme'; +import OrganizationNavigationMeta from '../OrganizationNavigationMeta'; +import { Visibility } from '../../../../app/types'; + +it('renders', () => { + expect( + shallow( + + ) + ).toMatchSnapshot(); +}); diff --git a/server/sonar-web/src/main/js/apps/organizations/navigation/__tests__/__snapshots__/OrganizationNavigation-test.tsx.snap b/server/sonar-web/src/main/js/apps/organizations/navigation/__tests__/__snapshots__/OrganizationNavigation-test.tsx.snap index b9efc8fe2e3..eb04cc431fe 100644 --- a/server/sonar-web/src/main/js/apps/organizations/navigation/__tests__/__snapshots__/OrganizationNavigation-test.tsx.snap +++ b/server/sonar-web/src/main/js/apps/organizations/navigation/__tests__/__snapshots__/OrganizationNavigation-test.tsx.snap @@ -1,523 +1,41 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`admin 1`] = ` +exports[`render 1`] = ` -
    -

    - - - Foo - -

    -
    -
    -
    - - organization.key - : - - - foo -
    -
    - -
  • - - projects.page - -
  • -
  • - - issues.page - -
  • -
  • - - quality_profiles.page - -
  • -
  • - - coding_rules.page - -
  • -
  • - - quality_gates.page - -
  • -
  • - - organization.members.page - -
  • -
  • - - layout.settings -   - - -
      -
    • - - user_groups.page - -
    • -
    • - - permissions.page - -
    • -
    • - - permission_templates - -
    • -
    • - - projects_management - -
    • -
    • - - edit - -
    • -
    • - - delete - -
    • -
    -
  • -
    -
    -`; - -exports[`regular user 1`] = ` - -
    -

    - - - Foo - -

    -
    -
    -
    - - organization.key - : - - - foo -
    -
    - -
  • - - projects.page - -
  • -
  • - - issues.page - -
  • -
  • - - quality_profiles.page - -
  • -
  • - - coding_rules.page - -
  • -
  • - - quality_gates.page - -
  • -
  • - - organization.members.page - -
  • -
    -
    -`; - -exports[`undeletable org 1`] = ` - -
    -

    - - - Foo - -

    -
    -
    -
    - - organization.key - : - - - foo -
    -
    - -
  • - - projects.page - -
  • -
  • - - issues.page - -
  • -
  • - - quality_profiles.page - -
  • -
  • - - coding_rules.page - -
  • -
  • - - quality_gates.page - -
  • -
  • - - organization.members.page - -
  • -
  • - - layout.settings -   - - -
      -
    • - - user_groups.page - -
    • -
    • - - permissions.page - -
    • -
    • - - permission_templates - -
    • -
    • - - projects_management - -
    • -
    • - - edit - -
    • -
    -
  • -
    + + +
    `; diff --git a/server/sonar-web/src/main/js/apps/organizations/navigation/__tests__/__snapshots__/OrganizationNavigationAdministration-test.tsx.snap b/server/sonar-web/src/main/js/apps/organizations/navigation/__tests__/__snapshots__/OrganizationNavigationAdministration-test.tsx.snap new file mode 100644 index 00000000000..61f766d7cf7 --- /dev/null +++ b/server/sonar-web/src/main/js/apps/organizations/navigation/__tests__/__snapshots__/OrganizationNavigationAdministration-test.tsx.snap @@ -0,0 +1,71 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`renders 1`] = ` +
  • + + layout.settings + + +
      +
    • + + user_groups.page + +
    • +
    • + + permissions.page + +
    • +
    • + + permission_templates + +
    • +
    • + + projects_management + +
    • +
    • + + edit + +
    • +
    +
  • +`; diff --git a/server/sonar-web/src/main/js/apps/organizations/navigation/__tests__/__snapshots__/OrganizationNavigationHeader-test.tsx.snap b/server/sonar-web/src/main/js/apps/organizations/navigation/__tests__/__snapshots__/OrganizationNavigationHeader-test.tsx.snap new file mode 100644 index 00000000000..32683a0f5be --- /dev/null +++ b/server/sonar-web/src/main/js/apps/organizations/navigation/__tests__/__snapshots__/OrganizationNavigationHeader-test.tsx.snap @@ -0,0 +1,120 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`renders 1`] = ` +
    +

    + + + Foo + +

    +
    +`; + +exports[`renders dropdown 1`] = ` +
    + + Foo + + +
      +
    • + +
      + + + org1 + +
      + + admin + +
      +
    • +
    • + +
      + + + org2 + +
      +
      +
    • +
    +
    +`; diff --git a/server/sonar-web/src/main/js/apps/organizations/navigation/__tests__/__snapshots__/OrganizationNavigationMenu-test.tsx.snap b/server/sonar-web/src/main/js/apps/organizations/navigation/__tests__/__snapshots__/OrganizationNavigationMenu-test.tsx.snap new file mode 100644 index 00000000000..1177b7604b7 --- /dev/null +++ b/server/sonar-web/src/main/js/apps/organizations/navigation/__tests__/__snapshots__/OrganizationNavigationMenu-test.tsx.snap @@ -0,0 +1,201 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`renders 1`] = ` + +
  • + + projects.page + +
  • +
  • + + issues.page + +
  • +
  • + + quality_profiles.page + +
  • +
  • + + coding_rules.page + +
  • +
  • + + quality_gates.page + +
  • +
  • + + organization.members.page + +
  • + +
    +`; + +exports[`renders for admin 1`] = ` + +
  • + + projects.page + +
  • +
  • + + issues.page + +
  • +
  • + + quality_profiles.page + +
  • +
  • + + coding_rules.page + +
  • +
  • + + quality_gates.page + +
  • +
  • + + organization.members.page + +
  • + + +
    +`; diff --git a/server/sonar-web/src/main/js/apps/organizations/navigation/__tests__/__snapshots__/OrganizationNavigationMeta-test.tsx.snap b/server/sonar-web/src/main/js/apps/organizations/navigation/__tests__/__snapshots__/OrganizationNavigationMeta-test.tsx.snap new file mode 100644 index 00000000000..3da71c25930 --- /dev/null +++ b/server/sonar-web/src/main/js/apps/organizations/navigation/__tests__/__snapshots__/OrganizationNavigationMeta-test.tsx.snap @@ -0,0 +1,18 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`renders 1`] = ` +
    +
    + + organization.key + : + + + foo +
    +
    +`; diff --git a/server/sonar-web/src/main/js/components/icons-components/DropdownIcon.tsx b/server/sonar-web/src/main/js/components/icons-components/DropdownIcon.tsx new file mode 100644 index 00000000000..20bc9629f31 --- /dev/null +++ b/server/sonar-web/src/main/js/components/icons-components/DropdownIcon.tsx @@ -0,0 +1,41 @@ +/* + * SonarQube + * Copyright (C) 2009-2017 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 * as React from 'react'; +import { IconProps } from './types'; + +export default function DropdownIcon({ className, fill = 'currentColor', size = 16 }: IconProps) { + return ( + + + + + + ); +}