fix(striker-ui): remove unused network mapping flag

main
Tsu-ba-me 7 months ago
parent cdb2896984
commit fab0fdeb84
  1. 33
      striker-ui/components/NetworkInitForm.tsx
  2. 4
      striker-ui/components/PrepareNetworkForm.tsx
  3. 4
      striker-ui/components/StrikerInitForm.tsx
  4. 22
      striker-ui/lib/setMapNetwork.tsx

@ -49,7 +49,6 @@ import OutlinedInputWithLabel from './OutlinedInputWithLabel';
import { InnerPanel, InnerPanelHeader } from './Panels';
import periodicFetch from '../lib/fetchers/periodicFetch';
import SelectWithLabel from './SelectWithLabel';
import setMapNetwork from '../lib/setMapNetwork';
import Spinner from './Spinner';
import { createTestInputFunction, testNotBlank } from '../lib/test_input';
import { BodyText, MonoText, SmallText } from './Text';
@ -106,7 +105,6 @@ const CLASSES = {
ifaceNotApplied: `${CLASS_PREFIX}-network-interface-not-applied`,
};
const INITIAL_IFACES = [undefined, undefined];
const MSG_ID_API = 'api';
const MAX_INTERFACES_PER_NETWORK = 2;
const IT_IDS = {
@ -872,13 +870,6 @@ const NetworkInitForm = forwardRef<
[networkInputs],
);
const handleSetMapNetworkError = useCallback(
(msg: Message): void => {
setMessage(MSG_ID_API, msg);
},
[setMessage],
);
const inputTests: InputTestBatches = useMemo(() => {
const tests: InputTestBatches = {
[IT_IDS.dnsCSV]: {
@ -1375,30 +1366,6 @@ const NetworkInitForm = forwardRef<
testInputToToggleSubmitDisabled,
]);
useEffect(() => {
// Enable network mapping on component mount.
setMapNetwork(1, handleSetMapNetworkError);
if (window) {
window.addEventListener(
'beforeunload',
() => {
// Cannot use async request (i.e., axios) because they won't be guaranteed to complete.
const request = new XMLHttpRequest();
request.open('PUT', `${API_BASE_URL}/init/set-map-network`, false);
request.send(null);
},
{ once: true },
);
}
return () => {
// Disable network mapping on component unmount.
setMapNetwork(0, handleSetMapNetworkError);
};
}, [handleSetMapNetworkError]);
useImperativeHandle(
ref,
() => ({

@ -16,7 +16,6 @@ import NetworkInitForm, {
} from './NetworkInitForm';
import OutlinedInputWithLabel from './OutlinedInputWithLabel';
import { Panel, PanelHeader } from './Panels';
import setMapNetwork from '../lib/setMapNetwork';
import Spinner from './Spinner';
import { buildPeacefulStringTestBatch } from '../lib/test_input';
import { HeaderText } from './Text';
@ -210,9 +209,6 @@ const PrepareNetworkForm: FC<PrepareNetworkFormProps> = ({
<>Failed to prepare network. {parentMsg}</>
),
method: 'put',
onSuccess: () => {
setMapNetwork(0);
},
setMsg: netconfFormRef?.current?.setMessage,
successMsg: `Initiated prepare network on ${hostDetail?.shortHostName}`,
url: `/host/${hostUUID}?handler=subnode-network`,

@ -27,7 +27,6 @@ import NetworkInitForm, {
NetworkInitFormValues,
} from './NetworkInitForm';
import { Panel, PanelHeader } from './Panels';
import setMapNetwork from '../lib/setMapNetwork';
import Spinner from './Spinner';
import { BodyText, HeaderText, InlineMonoText, MonoText } from './Text';
@ -297,9 +296,6 @@ const StrikerInitForm: FC = () => {
api
.put('/init', requestBody)
.then(() => {
// Stop network mapping only on successful form submission.
setMapNetwork(0);
setIsSubmittingForm(false);
setSubmitMessage({
children: reconfig ? (

@ -1,22 +0,0 @@
import api from './api';
import handleAPIError from './handleAPIError';
const setMapNetwork = (
value: 0 | 1,
handleError?: (msg: Message) => void,
): void => {
api.put('/init/set-map-network', { value }).catch((error) => {
const emsg = handleAPIError(error);
emsg.children = (
<>
Failed to {value ? 'enable' : 'disable'} network mapping.{' '}
{emsg.children}
</>
);
handleError?.call(null, emsg);
});
};
export default setMapNetwork;
Loading…
Cancel
Save