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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. /*
  2. * SonarQube
  3. * Copyright (C) 2009-2022 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 withAppStateContext from '../../../app/components/app-state/withAppStateContext';
  22. import { ClipboardButton } from '../../../components/controls/clipboard';
  23. import { Alert } from '../../../components/ui/Alert';
  24. import { toShortNotSoISOString } from '../../../helpers/dates';
  25. import { translate } from '../../../helpers/l10n';
  26. import { AppState } from '../../../types/appstate';
  27. import PageActions from './PageActions';
  28. export interface Props {
  29. isCluster: boolean;
  30. loading: boolean;
  31. logLevel: string;
  32. onLogLevelChange: () => void;
  33. appState: AppState;
  34. serverId?: string;
  35. showActions: boolean;
  36. version?: string;
  37. }
  38. export function PageHeader(props: Props) {
  39. const { isCluster, loading, logLevel, serverId, showActions, version, appState } = props;
  40. return (
  41. <header className="page-header">
  42. <h1 className="page-title">{translate('system_info.page')}</h1>
  43. {showActions && (
  44. <PageActions
  45. canDownloadLogs={!isCluster}
  46. canRestart={!isCluster}
  47. cluster={isCluster}
  48. logLevel={logLevel}
  49. onLogLevelChange={props.onLogLevelChange}
  50. serverId={serverId}
  51. />
  52. )}
  53. {loading && (
  54. <div className="page-actions">
  55. <i className="spinner" />
  56. </div>
  57. )}
  58. {serverId && version && (
  59. <div className="system-info-copy-paste-id-info boxed-group ">
  60. {!appState.productionDatabase && (
  61. <Alert className="width-100" variant="warning">
  62. {translate('system.not_production_database_warning')}
  63. </Alert>
  64. )}
  65. <div className="display-flex-center">
  66. <div className="flex-1">
  67. <table className="width-100">
  68. <tbody>
  69. <tr>
  70. <th>
  71. <strong>{translate('system.server_id')}</strong>
  72. </th>
  73. <td>
  74. <code>{serverId}</code>
  75. </td>
  76. </tr>
  77. <tr>
  78. <th>
  79. <strong>{translate('system.version')}</strong>
  80. </th>
  81. <td>{version}</td>
  82. </tr>
  83. </tbody>
  84. </table>
  85. </div>
  86. <ClipboardButton
  87. className="flex-0"
  88. copyValue={`SonarQube ID information
  89. Server ID: ${serverId}
  90. Version: ${version}
  91. Date: ${toShortNotSoISOString(Date.now())}
  92. `}>
  93. {translate('system.copy_id_info')}
  94. </ClipboardButton>
  95. </div>
  96. </div>
  97. )}
  98. </header>
  99. );
  100. }
  101. export default withAppStateContext(PageHeader);