Hide details when adaptor config is download-only (#938)

This commit is contained in:
Jon Koops 2021-08-04 14:24:55 +02:00 committed by GitHub
parent b99c57d43b
commit be0506653d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -12,7 +12,7 @@ import {
TextArea, TextArea,
} from "@patternfly/react-core"; } from "@patternfly/react-core";
import FileSaver from "file-saver"; import FileSaver from "file-saver";
import React, { useState } from "react"; import React, { useMemo, useState } from "react";
import { useTranslation } from "react-i18next"; import { useTranslation } from "react-i18next";
import { useAdminClient, useFetch } from "../../context/auth/AdminClient"; import { useAdminClient, useFetch } from "../../context/auth/AdminClient";
import { useServerInfo } from "../../context/server-info/ServerInfoProvider"; import { useServerInfo } from "../../context/server-info/ServerInfoProvider";
@ -45,6 +45,11 @@ export const DownloadDialog = ({
const [snippet, setSnippet] = useState(""); const [snippet, setSnippet] = useState("");
const [openType, setOpenType] = useState(false); const [openType, setOpenType] = useState(false);
const selectedConfig = useMemo(
() => configFormats?.find((config) => config.id === selected) ?? null,
[selected]
);
useFetch( useFetch(
async () => { async () => {
const snippet = await adminClient.clients.getInstallationProviders({ const snippet = await adminClient.clients.getInstallationProviders({
@ -115,7 +120,7 @@ export const DownloadDialog = ({
value={selected} value={selected}
selections={selected} selections={selected}
onSelect={(_, value) => { onSelect={(_, value) => {
setSelected(value as string); setSelected(value.toString());
setOpenType(false); setOpenType(false);
}} }}
aria-label="Select Input" aria-label="Select Input"
@ -132,28 +137,30 @@ export const DownloadDialog = ({
</Select> </Select>
</FormGroup> </FormGroup>
</StackItem> </StackItem>
<StackItem isFilled> {!selectedConfig?.downloadOnly && (
<FormGroup <StackItem isFilled>
fieldId="details" <FormGroup
label={t("clients:details")} fieldId="details"
labelIcon={ label={t("clients:details")}
<HelpItem labelIcon={
helpText={t("clients-help:details")} <HelpItem
forLabel={t("clients:details")} helpText={t("clients-help:details")}
forID="details" forLabel={t("clients:details")}
forID="details"
/>
}
>
<TextArea
id="details"
readOnly
rows={12}
resizeOrientation="vertical"
value={snippet}
aria-label="text area example"
/> />
} </FormGroup>
> </StackItem>
<TextArea )}
id="details"
readOnly
rows={12}
resizeOrientation="vertical"
value={snippet}
aria-label="text area example"
/>
</FormGroup>
</StackItem>
</Stack> </Stack>
</Form> </Form>
</ConfirmDialogModal> </ConfirmDialogModal>