import { Grid } from '@mui/material'; import Head from 'next/head'; import { FC, useState } from 'react'; import API_BASE_URL from '../../lib/consts/API_BASE_URL'; import ConfirmDialog from '../../components/ConfirmDialog'; import Header from '../../components/Header'; import periodicFetch from '../../lib/fetchers/periodicFetch'; import { ComplexOperationsPanel, SimpleOperationsPanel, } from '../../components/StrikerConfig'; // This page can't be reused, and default is set within the render function. // eslint-disable-next-line react/require-default-props const Config: FC<{ refreshInterval?: number }> = ({ refreshInterval = 60000, }) => { const [isOpenConfirmDialog, setIsOpenConfirmDialog] = useState(false); const [confirmDialogProps, setConfirmDialogProps] = useState({ actionProceedText: '', closeOnProceed: true, content: '', dialogProps: { open: isOpenConfirmDialog }, onCancelAppend: () => { setIsOpenConfirmDialog(false); }, onProceedAppend: () => { setIsOpenConfirmDialog(false); }, titleText: '', }); const [simpleOpsInstallTarget, setSimpleOpsInstallTarget] = useState< APIHostInstallTarget | undefined >(); const [simpleOpsPanelHeader, setSimpleOpsPanelHeader] = useState(''); const { data: hostDetail, isLoading: loadingHostDetail } = periodicFetch(`${API_BASE_URL}/host/local`, { onError: () => { setSimpleOpsPanelHeader('Unknown'); }, onSuccess: ({ installTarget, shortHostName }) => { setSimpleOpsInstallTarget(installTarget); setSimpleOpsPanelHeader(shortHostName); }, refreshInterval, }); return ( <> {loadingHostDetail ? 'Loading...' : `${hostDetail?.shortHostName} Config`}
{ setConfirmDialogProps((previous) => ({ ...previous, ...restConfirmDialogProps, onProceedAppend: (...args) => { onProceedAppend?.call(null, ...args); setIsOpenConfirmDialog(false); }, })); setIsOpenConfirmDialog(true); }} title={simpleOpsPanelHeader} /> ); }; export default Config;