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.

PageHeader.tsx 3.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /*
  2. * SonarQube
  3. * Copyright (C) 2009-2024 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 { Spinner } from '@sonarsource/echoes-react';
  21. import { Card, ClipboardButton, FlagMessage, Title } from 'design-system';
  22. import * as React from 'react';
  23. import withAppStateContext from '../../../app/components/app-state/withAppStateContext';
  24. import AppVersionStatus from '../../../components/shared/AppVersionStatus';
  25. import { toShortISO8601String } from '../../../helpers/dates';
  26. import { translate } from '../../../helpers/l10n';
  27. import { AppState } from '../../../types/appstate';
  28. import PageActions from './PageActions';
  29. export interface Props {
  30. isCluster: boolean;
  31. loading: boolean;
  32. logLevel: string;
  33. onLogLevelChange: () => void;
  34. appState: AppState;
  35. serverId?: string;
  36. version?: string;
  37. }
  38. function PageHeader(props: Readonly<Props>) {
  39. const { isCluster, loading, logLevel, serverId, version, appState } = props;
  40. return (
  41. <header className="sw-mt-8">
  42. <div className="sw-flex sw-items-start sw-justify-between">
  43. <Title>{translate('system_info.page')}</Title>
  44. <div className="sw-flex sw-items-center">
  45. <Spinner className="sw-mr-4 sw-mt-1" isLoading={loading} />
  46. <PageActions
  47. canDownloadLogs={!isCluster}
  48. cluster={isCluster}
  49. logLevel={logLevel}
  50. onLogLevelChange={props.onLogLevelChange}
  51. serverId={serverId}
  52. />
  53. </div>
  54. </div>
  55. {serverId && version && (
  56. <Card className="sw-max-w-1/2 sw-mb-8">
  57. {!appState.productionDatabase && (
  58. <FlagMessage className="sw-mb-2" variant="warning">
  59. {translate('system.not_production_database_warning')}
  60. </FlagMessage>
  61. )}
  62. <div className="sw-flex sw-items-center sw-justify-between">
  63. <div>
  64. <div className="sw-flex sw-items-center">
  65. <strong className="sw-w-32">{translate('system.server_id')}</strong>
  66. <span className="sw-code">{serverId}</span>
  67. </div>
  68. <div className="sw-flex sw-items-center">
  69. <strong className="sw-w-32">{translate('system.version')}</strong>
  70. <span>
  71. <AppVersionStatus />
  72. </span>
  73. </div>
  74. </div>
  75. <ClipboardButton
  76. className="sw-ml-4"
  77. copyValue={`SonarQube ID information
  78. Server ID: ${serverId}
  79. Version: ${version}
  80. Date: ${toShortISO8601String(Date.now())}
  81. `}
  82. >
  83. <span className="sw-ml-1 sw-whitespace-nowrap">
  84. {translate('system.copy_id_info')}
  85. </span>
  86. </ClipboardButton>
  87. </div>
  88. </Card>
  89. )}
  90. </header>
  91. );
  92. }
  93. export default withAppStateContext(PageHeader);