1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- import React from 'react';
- import { ClusterId, TopicName, TopicConfig } from 'redux/interfaces';
- interface Props {
- clusterId: ClusterId;
- topicName: TopicName;
- config?: TopicConfig[];
- isFetched: boolean;
- fetchTopicConfig: (clusterId: ClusterId, topicName: TopicName) => void;
- }
- const ConfigListItem: React.FC<TopicConfig> = ({
- name,
- value,
- defaultValue,
- }) => {
- const hasCustomValue = value !== defaultValue;
- return (
- <tr>
- <td className={hasCustomValue ? 'has-text-weight-bold' : ''}>
- {name}
- </td>
- <td className={hasCustomValue ? 'has-text-weight-bold' : ''}>
- {value}
- </td>
- <td
- className="has-text-grey"
- title="Default Value"
- >
- {hasCustomValue && defaultValue}
- </td>
- </tr>
- )
- }
- const Sertings: React.FC<Props> = ({
- clusterId,
- topicName,
- isFetched,
- fetchTopicConfig,
- config,
- }) => {
- React.useEffect(
- () => { fetchTopicConfig(clusterId, topicName); },
- [fetchTopicConfig, clusterId, topicName],
- );
- if (!isFetched || !config) {
- return (null);
- }
- return (
- <div className="box">
- <table className="table is-striped is-fullwidth">
- <thead>
- <tr>
- <th>Key</th>
- <th>Value</th>
- <th>Default Value</th>
- </tr>
- </thead>
- <tbody>
- {config.map((item, index) => <ConfigListItem key={`config-list-item-key-${index}`} {...item} />)}
- </tbody>
- </table>
- </div>
- );
- }
- export default Sertings;
|