2019-10-27 14:03:39 -07:00
|
|
|
import React, { FC } from 'react';
|
|
|
|
import { RouteComponentProps } from '@reach/router';
|
2019-11-12 05:35:47 -08:00
|
|
|
import { Table } from 'reactstrap';
|
|
|
|
import { withStatusIndicator } from '../withStatusIndicator';
|
2019-11-02 02:27:36 -07:00
|
|
|
import { useFetch } from '../utils/useFetch';
|
2019-11-04 00:17:50 -08:00
|
|
|
import PathPrefixProps from '../PathPrefixProps';
|
2019-10-27 14:03:39 -07:00
|
|
|
|
2019-11-12 05:35:47 -08:00
|
|
|
interface FlagMap {
|
2019-11-02 02:27:36 -07:00
|
|
|
[key: string]: string;
|
|
|
|
}
|
|
|
|
|
2019-11-12 05:35:47 -08:00
|
|
|
interface FlagsProps {
|
|
|
|
data?: FlagMap;
|
|
|
|
}
|
2019-11-02 02:27:36 -07:00
|
|
|
|
2019-11-12 05:35:47 -08:00
|
|
|
export const FlagsContent: FC<FlagsProps> = ({ data = {} }) => {
|
2019-11-02 02:27:36 -07:00
|
|
|
return (
|
|
|
|
<>
|
|
|
|
<h2>Command-Line Flags</h2>
|
2019-11-12 05:35:47 -08:00
|
|
|
<Table bordered size="sm" striped>
|
|
|
|
<tbody>
|
|
|
|
{Object.keys(data).map(key => (
|
|
|
|
<tr key={key}>
|
|
|
|
<th>{key}</th>
|
|
|
|
<td>{data[key]}</td>
|
|
|
|
</tr>
|
|
|
|
))}
|
|
|
|
</tbody>
|
|
|
|
</Table>
|
2019-11-02 02:27:36 -07:00
|
|
|
</>
|
|
|
|
);
|
|
|
|
};
|
2019-11-12 05:35:47 -08:00
|
|
|
const FlagsWithStatusIndicator = withStatusIndicator(FlagsContent);
|
|
|
|
|
|
|
|
FlagsContent.displayName = 'Flags';
|
|
|
|
|
|
|
|
const Flags: FC<RouteComponentProps & PathPrefixProps> = ({ pathPrefix = '' }) => {
|
|
|
|
const { response, error, isLoading } = useFetch<FlagMap>(`${pathPrefix}/api/v1/status/flags`);
|
|
|
|
return <FlagsWithStatusIndicator data={response.data} error={error} isLoading={isLoading} />;
|
|
|
|
};
|
2019-10-27 14:03:39 -07:00
|
|
|
|
|
|
|
export default Flags;
|