refactor(striker-ui): group manage fence related components

main
Tsu-ba-me 2 years ago committed by digimer
parent ac7ce0dcb6
commit ccd977e39d
  1. 8
      striker-ui/components/ManageFence/AddFenceInputGroup.tsx
  2. 18
      striker-ui/components/ManageFence/CommonFenceInputGroup.tsx
  3. 2
      striker-ui/components/ManageFence/EditFenceInputGroup.tsx
  4. 30
      striker-ui/components/ManageFence/ManageFencePanel.tsx
  5. 3
      striker-ui/components/ManageFence/index.tsx
  6. 26
      striker-ui/pages/manage-element/index.tsx

@ -1,11 +1,11 @@
import { Box } from '@mui/material'; import { Box } from '@mui/material';
import { FC, useMemo, useState } from 'react'; import { FC, useMemo, useState } from 'react';
import Autocomplete from './Autocomplete'; import Autocomplete from '../Autocomplete';
import CommonFenceInputGroup from './CommonFenceInputGroup'; import CommonFenceInputGroup from './CommonFenceInputGroup';
import FlexBox from './FlexBox'; import FlexBox from '../FlexBox';
import Spinner from './Spinner'; import Spinner from '../Spinner';
import { BodyText } from './Text'; import { BodyText } from '../Text';
const AddFenceInputGroup: FC<AddFenceInputGroupProps> = ({ const AddFenceInputGroup: FC<AddFenceInputGroupProps> = ({
fenceTemplate: externalFenceTemplate, fenceTemplate: externalFenceTemplate,

@ -1,15 +1,15 @@
import { Box, styled, Tooltip } from '@mui/material'; import { Box, styled, Tooltip } from '@mui/material';
import { FC, ReactElement, ReactNode, useMemo } from 'react'; import { FC, ReactElement, ReactNode, useMemo } from 'react';
import INPUT_TYPES from '../lib/consts/INPUT_TYPES'; import INPUT_TYPES from '../../lib/consts/INPUT_TYPES';
import FlexBox from './FlexBox'; import FlexBox from '../FlexBox';
import InputWithRef from './InputWithRef'; import InputWithRef from '../InputWithRef';
import OutlinedInputWithLabel from './OutlinedInputWithLabel'; import OutlinedInputWithLabel from '../OutlinedInputWithLabel';
import { ExpandablePanel } from './Panels'; import { ExpandablePanel } from '../Panels';
import SelectWithLabel from './SelectWithLabel'; import SelectWithLabel from '../SelectWithLabel';
import SwitchWithLabel from './SwitchWithLabel'; import SwitchWithLabel from '../SwitchWithLabel';
import { BodyText } from './Text'; import { BodyText } from '../Text';
const CHECKED_STATES: Array<string | undefined> = ['1', 'on']; const CHECKED_STATES: Array<string | undefined> = ['1', 'on'];
const ID_SEPARATOR = '-'; const ID_SEPARATOR = '-';

@ -1,7 +1,7 @@
import { FC, useMemo } from 'react'; import { FC, useMemo } from 'react';
import CommonFenceInputGroup from './CommonFenceInputGroup'; import CommonFenceInputGroup from './CommonFenceInputGroup';
import Spinner from './Spinner'; import Spinner from '../Spinner';
const EditFenceInputGroup: FC<EditFenceInputGroupProps> = ({ const EditFenceInputGroup: FC<EditFenceInputGroupProps> = ({
fenceId, fenceId,

@ -8,29 +8,29 @@ import {
useState, useState,
} from 'react'; } from 'react';
import API_BASE_URL from '../lib/consts/API_BASE_URL'; import API_BASE_URL from '../../lib/consts/API_BASE_URL';
import AddFenceInputGroup from './AddFenceInputGroup'; import AddFenceInputGroup from './AddFenceInputGroup';
import api from '../lib/api'; import api from '../../lib/api';
import { ID_SEPARATOR } from './CommonFenceInputGroup'; import { ID_SEPARATOR } from './CommonFenceInputGroup';
import ConfirmDialog from './ConfirmDialog'; import ConfirmDialog from '../ConfirmDialog';
import EditFenceInputGroup from './EditFenceInputGroup'; import EditFenceInputGroup from './EditFenceInputGroup';
import FlexBox from './FlexBox'; import FlexBox from '../FlexBox';
import handleAPIError from '../lib/handleAPIError'; import handleAPIError from '../../lib/handleAPIError';
import List from './List'; import List from '../List';
import { Panel, PanelHeader } from './Panels'; import { Panel, PanelHeader } from '../Panels';
import periodicFetch from '../lib/fetchers/periodicFetch'; import periodicFetch from '../../lib/fetchers/periodicFetch';
import Spinner from './Spinner'; import Spinner from '../Spinner';
import { import {
BodyText, BodyText,
HeaderText, HeaderText,
InlineMonoText, InlineMonoText,
MonoText, MonoText,
SensitiveText,
SmallText, SmallText,
} from './Text'; } from '../Text';
import useIsFirstRender from '../hooks/useIsFirstRender'; import useIsFirstRender from '../../hooks/useIsFirstRender';
import useProtectedState from '../hooks/useProtectedState'; import useProtectedState from '../../hooks/useProtectedState';
import SensitiveText from './Text/SensitiveText';
type FormFenceParameterData = { type FormFenceParameterData = {
fenceAgent: string; fenceAgent: string;
@ -143,7 +143,7 @@ const buildConfirmFenceParameters = (
/> />
); );
const ManageFencesPanel: FC = () => { const ManageFencePanel: FC = () => {
const isFirstRender = useIsFirstRender(); const isFirstRender = useIsFirstRender();
const confirmDialogRef = useRef<ConfirmDialogForwardedRefContent>({}); const confirmDialogRef = useRef<ConfirmDialogForwardedRefContent>({});
@ -333,4 +333,4 @@ const ManageFencesPanel: FC = () => {
); );
}; };
export default ManageFencesPanel; export default ManageFencePanel;

@ -0,0 +1,3 @@
import ManageFencePanel from './ManageFencePanel';
export default ManageFencePanel;

@ -7,6 +7,7 @@ import getQueryParam from '../../lib/getQueryParam';
import Grid from '../../components/Grid'; import Grid from '../../components/Grid';
import handleAPIError from '../../lib/handleAPIError'; import handleAPIError from '../../lib/handleAPIError';
import Header from '../../components/Header'; import Header from '../../components/Header';
import ManageFencePanel from '../../components/ManageFence';
import { Panel } from '../../components/Panels'; import { Panel } from '../../components/Panels';
import PrepareHostForm from '../../components/PrepareHostForm'; import PrepareHostForm from '../../components/PrepareHostForm';
import PrepareNetworkForm from '../../components/PrepareNetworkForm'; import PrepareNetworkForm from '../../components/PrepareNetworkForm';
@ -21,9 +22,9 @@ import useProtectedState from '../../hooks/useProtectedState';
const MAP_TO_PAGE_TITLE: Record<string, string> = { const MAP_TO_PAGE_TITLE: Record<string, string> = {
'prepare-host': 'Prepare Host', 'prepare-host': 'Prepare Host',
'prepare-network': 'Prepare Network', 'prepare-network': 'Prepare Network',
'manage-fence-devices': 'Manage Fence Devices', 'manage-fence': 'Manage Fence Devices',
'manage-upses': 'Manage UPSes', 'manage-ups': 'Manage UPSes',
'manage-manifests': 'Manage Manifests', 'manage-manifest': 'Manage Manifests',
}; };
const PAGE_TITLE_LOADING = 'Loading'; const PAGE_TITLE_LOADING = 'Loading';
const STEP_CONTENT_GRID_COLUMNS = { md: 8, sm: 6, xs: 1 }; const STEP_CONTENT_GRID_COLUMNS = { md: 8, sm: 6, xs: 1 };
@ -116,6 +117,19 @@ const PrepareNetworkTabContent: FC = () => {
); );
}; };
const ManageFenceTabContent: FC = () => (
<Grid
columns={STEP_CONTENT_GRID_COLUMNS}
layout={{
'managefence-left-column': {},
'managefence-center-column': {
children: <ManageFencePanel />,
...STEP_CONTENT_GRID_CENTER_COLUMN,
},
}}
/>
);
const ManageElement: FC = () => { const ManageElement: FC = () => {
const { const {
isReady, isReady,
@ -162,7 +176,7 @@ const ManageElement: FC = () => {
> >
<Tab label="Prepare host" value="prepare-host" /> <Tab label="Prepare host" value="prepare-host" />
<Tab label="Prepare network" value="prepare-network" /> <Tab label="Prepare network" value="prepare-network" />
<Tab label="Manage fence devices" value="manage-fence-devices" /> <Tab label="Manage fence devices" value="manage-fence" />
</Tabs> </Tabs>
</Panel> </Panel>
<TabContent changingTabId={pageTabId} tabId="prepare-host"> <TabContent changingTabId={pageTabId} tabId="prepare-host">
@ -171,8 +185,8 @@ const ManageElement: FC = () => {
<TabContent changingTabId={pageTabId} tabId="prepare-network"> <TabContent changingTabId={pageTabId} tabId="prepare-network">
<PrepareNetworkTabContent /> <PrepareNetworkTabContent />
</TabContent> </TabContent>
<TabContent changingTabId={pageTabId} tabId="manage-fence-devices"> <TabContent changingTabId={pageTabId} tabId="manage-fence">
{} <ManageFenceTabContent />
</TabContent> </TabContent>
</> </>
); );

Loading…
Cancel
Save