Details.tsx 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. import React from 'react';
  2. import { SchemaSubject } from 'generated-sources';
  3. import { ClusterName, SchemaName } from 'redux/interfaces';
  4. import { clusterSchemasPath } from 'lib/paths';
  5. import ClusterContext from 'components/contexts/ClusterContext';
  6. import Breadcrumb from '../../common/Breadcrumb/Breadcrumb';
  7. import SchemaVersion from './SchemaVersion';
  8. import LatestVersionItem from './LatestVersionItem';
  9. import PageLoader from '../../common/PageLoader/PageLoader';
  10. export interface DetailsProps {
  11. subject: SchemaName;
  12. schema: SchemaSubject;
  13. clusterName: ClusterName;
  14. versions: SchemaSubject[];
  15. isFetched: boolean;
  16. fetchSchemaVersions: (
  17. clusterName: ClusterName,
  18. schemaName: SchemaName
  19. ) => void;
  20. }
  21. const Details: React.FC<DetailsProps> = ({
  22. subject,
  23. schema,
  24. clusterName,
  25. fetchSchemaVersions,
  26. versions,
  27. isFetched,
  28. }) => {
  29. const { isReadOnly } = React.useContext(ClusterContext);
  30. React.useEffect(() => {
  31. fetchSchemaVersions(clusterName, subject);
  32. }, [fetchSchemaVersions, clusterName]);
  33. return (
  34. <div className="section">
  35. <div className="level">
  36. <Breadcrumb
  37. links={[
  38. {
  39. href: clusterSchemasPath(clusterName),
  40. label: 'Schema Registry',
  41. },
  42. ]}
  43. >
  44. {subject}
  45. </Breadcrumb>
  46. </div>
  47. {isFetched ? (
  48. <>
  49. <div className="box">
  50. <div className="level">
  51. <div className="level-left">
  52. <div className="level-item">
  53. <div className="mr-1">
  54. <b>Latest Version</b>
  55. </div>
  56. <div className="tag is-info is-light" title="Version">
  57. #{schema.version}
  58. </div>
  59. </div>
  60. </div>
  61. {!isReadOnly && (
  62. <div className="level-right">
  63. <button
  64. className="button is-warning is-small level-item"
  65. type="button"
  66. title="in development"
  67. disabled
  68. >
  69. Update Schema
  70. </button>
  71. <button
  72. className="button is-danger is-small level-item"
  73. type="button"
  74. title="in development"
  75. disabled
  76. >
  77. Delete
  78. </button>
  79. </div>
  80. )}
  81. </div>
  82. <LatestVersionItem schema={schema} />
  83. </div>
  84. <div className="box">
  85. <div className="table-container">
  86. <table className="table is-striped is-fullwidth">
  87. <thead>
  88. <tr>
  89. <th>Version</th>
  90. <th>ID</th>
  91. <th>Schema</th>
  92. </tr>
  93. </thead>
  94. <tbody>
  95. {versions.map((version) => (
  96. <SchemaVersion key={version.id} version={version} />
  97. ))}
  98. </tbody>
  99. </table>
  100. </div>
  101. </div>
  102. </>
  103. ) : (
  104. <PageLoader />
  105. )}
  106. </div>
  107. );
  108. };
  109. export default Details;