EnvVarsTable.tsx 787 B

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