2019-10-27 14:03:39 -07:00
|
|
|
import React, { FC } from 'react';
|
|
|
|
import { RouteComponentProps } from '@reach/router';
|
2019-11-02 02:27:36 -07:00
|
|
|
import { Alert, Table } from 'reactstrap';
|
|
|
|
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
|
|
|
import { faSpinner } from '@fortawesome/free-solid-svg-icons';
|
|
|
|
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-02 02:27:36 -07:00
|
|
|
export interface FlagMap {
|
|
|
|
[key: string]: string;
|
|
|
|
}
|
|
|
|
|
2019-11-04 00:17:50 -08:00
|
|
|
const Flags: FC<RouteComponentProps & PathPrefixProps> = ({ pathPrefix }) => {
|
|
|
|
const { response, error } = useFetch(`${pathPrefix}/api/v1/status/flags`);
|
2019-11-02 02:27:36 -07:00
|
|
|
|
|
|
|
const body = () => {
|
|
|
|
const flags: FlagMap = response && response.data;
|
|
|
|
if (error) {
|
|
|
|
return (
|
|
|
|
<Alert color="danger">
|
|
|
|
<strong>Error:</strong> Error fetching flags: {error.message}
|
|
|
|
</Alert>
|
|
|
|
);
|
|
|
|
} else if (flags) {
|
|
|
|
return (
|
|
|
|
<Table bordered={true} size="sm" striped={true}>
|
|
|
|
<tbody>
|
|
|
|
{Object.keys(flags).map(key => {
|
|
|
|
return (
|
|
|
|
<tr key={key}>
|
|
|
|
<th>{key}</th>
|
|
|
|
<td>{flags[key]}</td>
|
|
|
|
</tr>
|
|
|
|
);
|
|
|
|
})}
|
|
|
|
</tbody>
|
|
|
|
</Table>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
return <FontAwesomeIcon icon={faSpinner} spin />;
|
|
|
|
};
|
|
|
|
|
|
|
|
return (
|
|
|
|
<>
|
|
|
|
<h2>Command-Line Flags</h2>
|
|
|
|
{body()}
|
|
|
|
</>
|
|
|
|
);
|
|
|
|
};
|
2019-10-27 14:03:39 -07:00
|
|
|
|
|
|
|
export default Flags;
|