You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

NonAdminPagesContainer.tsx 2.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /*
  2. * SonarQube
  3. * Copyright (C) 2009-2021 SonarSource SA
  4. * mailto:info AT sonarsource DOT com
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU Lesser General Public
  8. * License as published by the Free Software Foundation; either
  9. * version 3 of the License, or (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * Lesser General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Lesser General Public License
  17. * along with this program; if not, write to the Free Software Foundation,
  18. * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  19. */
  20. import * as React from 'react';
  21. import { Alert } from '../../components/ui/Alert';
  22. import { translate } from '../../helpers/l10n';
  23. import { BranchLike } from '../../types/branch-like';
  24. import { isApplication } from '../../types/component';
  25. export interface NonAdminPagesContainerProps {
  26. children: JSX.Element;
  27. branchLike?: BranchLike;
  28. branchLikes: BranchLike[];
  29. component: T.Component;
  30. isInProgress?: boolean;
  31. isPending?: boolean;
  32. onBranchesChange: () => void;
  33. onComponentChange: (changes: {}) => void;
  34. }
  35. export default function NonAdminPagesContainer(props: NonAdminPagesContainerProps) {
  36. const { children, component } = props;
  37. /*
  38. * Catch Applications for which the user does not have access to all child projects
  39. * and prevent displaying whatever page was requested.
  40. * This doesn't apply to admin pages (those are not within this container)
  41. */
  42. if (isApplication(component.qualifier) && !component.canBrowseAllChildProjects) {
  43. return (
  44. <div className="page page-limited display-flex-justify-center">
  45. <Alert className="max-width-60 huge-spacer-top" display="block" variant="error">
  46. <p>{translate('application.cannot_access_all_child_projects1')}</p>
  47. <br />
  48. <p>{translate('application.cannot_access_all_child_projects2')}</p>
  49. </Alert>
  50. </div>
  51. );
  52. }
  53. return React.cloneElement(children, props);
  54. }