fix(striker-ui): allow string header in ExpandablePanel

main
Tsu-ba-me 2 years ago committed by digimer
parent 8502f546ce
commit 964dcf231f
  1. 7
      striker-ui/components/Panels/ExpandablePanel.tsx
  2. 5
      striker-ui/components/StrikerConfig/ConfigPeersForm.tsx
  3. 5
      striker-ui/components/StrikerConfig/ManageChangedSSHKeysForm.tsx
  4. 5
      striker-ui/components/StrikerConfig/ManageUsersForm.tsx

@ -12,6 +12,7 @@ import InnerPanel from './InnerPanel';
import InnerPanelBody from './InnerPanelBody'; import InnerPanelBody from './InnerPanelBody';
import InnerPanelHeader from './InnerPanelHeader'; import InnerPanelHeader from './InnerPanelHeader';
import Spinner from '../Spinner'; import Spinner from '../Spinner';
import { BodyText } from '../Text';
type ExpandablePanelOptionalProps = { type ExpandablePanelOptionalProps = {
expandInitially?: boolean; expandInitially?: boolean;
@ -46,6 +47,10 @@ const ExpandablePanel: FC<ExpandablePanelProps> = ({
[isExpand], [isExpand],
); );
const contentHeight = useMemo(() => (isExpand ? 'auto' : '.2em'), [isExpand]); const contentHeight = useMemo(() => (isExpand ? 'auto' : '.2em'), [isExpand]);
const headerElement = useMemo(
() => (typeof header === 'string' ? <BodyText>{header}</BodyText> : header),
[header],
);
const headerSpinner = useMemo( const headerSpinner = useMemo(
() => () =>
isShowHeaderSpinner && !isExpand && isLoading ? ( isShowHeaderSpinner && !isExpand && isLoading ? (
@ -74,7 +79,7 @@ const ExpandablePanel: FC<ExpandablePanelProps> = ({
<InnerPanel> <InnerPanel>
<InnerPanelHeader> <InnerPanelHeader>
<FlexBox row> <FlexBox row>
{header} {headerElement}
{headerSpinner} {headerSpinner}
</FlexBox> </FlexBox>
<IconButton <IconButton

@ -127,10 +127,7 @@ const ConfigPeersForm: FC<ConfigPeerFormProps> = ({
return ( return (
<> <>
<ExpandablePanel <ExpandablePanel header="Configure striker peers" loading={isLoading}>
header={<BodyText>Configure striker peers</BodyText>}
loading={isLoading}
>
<Grid columns={{ xs: 1, sm: 2 }} container spacing="1em"> <Grid columns={{ xs: 1, sm: 2 }} container spacing="1em">
<Grid item xs={1}> <Grid item xs={1}>
<List <List

@ -85,10 +85,7 @@ const ManageChangedSSHKeysForm: FC<ManageChangedSSHKeysFormProps> = ({
return ( return (
<> <>
<ExpandablePanel <ExpandablePanel header="Manage changed SSH keys" loading={isLoading}>
header={<BodyText>Manage changed SSH keys</BodyText>}
loading={isLoading}
>
<FlexBox spacing=".2em"> <FlexBox spacing=".2em">
<BodyText> <BodyText>
The identity of the following targets have unexpectedly changed. The identity of the following targets have unexpectedly changed.

@ -36,10 +36,7 @@ const ManageUsersForm: FC = () => {
}, [setListMessage, setUsers, users]); }, [setListMessage, setUsers, users]);
return ( return (
<ExpandablePanel <ExpandablePanel header="Manage users" loading={!users}>
header={<BodyText>Manage users</BodyText>}
loading={!users}
>
<List <List
allowEdit={false} allowEdit={false}
listEmpty={<MessageBox {...listMessage} />} listEmpty={<MessageBox {...listMessage} />}

Loading…
Cancel
Save