EnvVarsTable.tsx 801 B

1234567891011121314151617181920212223242526272829303132333435
  1. import type React from 'react';
  2. import type { JSX } from 'react';
  3. import { LoadingSpinner } from '@growi/ui/dist/components';
  4. type EnvVarsTableProps = {
  5. envVars?: Record<string, string | number | boolean>;
  6. };
  7. export const EnvVarsTable: React.FC<EnvVarsTableProps> = (
  8. props: EnvVarsTableProps,
  9. ) => {
  10. const { envVars } = props;
  11. if (envVars == null) {
  12. return <LoadingSpinner />;
  13. }
  14. const envVarRows: JSX.Element[] = [];
  15. for (const [key, value] of Object.entries(envVars ?? {})) {
  16. if (value != null) {
  17. envVarRows.push(
  18. <tr key={key}>
  19. <th className="col-sm-4">{key}</th>
  20. <td>{value.toString()}</td>
  21. </tr>,
  22. );
  23. }
  24. }
  25. return (
  26. <table className="table table-bordered">
  27. <tbody>{envVarRows}</tbody>
  28. </table>
  29. );
  30. };