Use expandable section when description is longer than 512 characters to avoid making the wizard unusably long

This commit is contained in:
mabashian
2021-05-27 14:22:40 -04:00
parent dc64da6f72
commit af162b6897
2 changed files with 40 additions and 7 deletions

View File

@@ -1,5 +1,5 @@
import React from 'react';
import { Wizard } from '@patternfly/react-core';
import React, { useState } from 'react';
import { ExpandableSection, Wizard } from '@patternfly/react-core';
import { t } from '@lingui/macro';
import { Formik, useFormikContext } from 'formik';
import ContentError from '../ContentError';
@@ -19,6 +19,7 @@ function PromptModalForm({
resourceDefaultCredentials,
}) {
const { setFieldTouched, values } = useFormikContext();
const [showDescription, setShowDescription] = useState(false);
const {
steps,
@@ -102,7 +103,23 @@ function PromptModalForm({
}
}}
title={t`Launch | ${resource.name}`}
description={resource.description}
description={
resource.description.length > 512 ? (
<ExpandableSection
toggleText={
showDescription ? t`Hide description` : 'Show description'
}
onToggle={() => {
setShowDescription(!showDescription);
}}
isExpanded={showDescription}
>
{resource.description}
</ExpandableSection>
) : (
resource.description
)
}
steps={
isReady
? steps

View File

@@ -1,5 +1,5 @@
import React from 'react';
import { Wizard } from '@patternfly/react-core';
import React, { useState } from 'react';
import { ExpandableSection, Wizard } from '@patternfly/react-core';
import { t } from '@lingui/macro';
import { useFormikContext } from 'formik';
import AlertModal from '../../AlertModal';
@@ -39,7 +39,7 @@ function SchedulePromptableFields({
credentials,
resourceDefaultCredentials
);
const [showDescription, setShowDescription] = useState(false);
const { error, dismissError } = useDismissableError(contentError);
const cancelPromptableValues = async () => {
resetForm({
@@ -106,7 +106,23 @@ function SchedulePromptableFields({
}
}}
title={t`Prompt | ${resource.name}`}
description={resource.description}
description={
resource.description.length > 512 ? (
<ExpandableSection
toggleText={
showDescription ? t`Hide description` : t`Show description`
}
onToggle={() => {
setShowDescription(!showDescription);
}}
isExpanded={showDescription}
>
{resource.description}
</ExpandableSection>
) : (
resource.description
)
}
steps={
isReady
? steps