Skip to content

Commit 7e3e096

Browse files
sjd78sshveta
authored andcommitted
🐛 New application form has basic and source sections expanded by default (konveyor#2585)
Resolves: https://issues.redhat.com/browse/MTA-6003 The new application form should have the basic details and the source code sections expanded by default. The other sections should be collapsed by default. When editing an existing application, the sections that have data should be expanded by default. UI tests PR: 1660 Signed-off-by: Scott J Dickerson <[email protected]>
1 parent 05a7eca commit 7e3e096

File tree

3 files changed

+18
-9
lines changed

3 files changed

+18
-9
lines changed

client/src/app/pages/applications/application-form/application-form-modal.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ export const ApplicationFormModal: React.FC<ApplicationFormModalProps> = ({
6565
</Button>,
6666
]}
6767
>
68-
<ApplicationForm form={form} data={data} />
68+
<ApplicationForm application={application} form={form} data={data} />
6969
</Modal>
7070
);
7171
};

client/src/app/pages/applications/application-form/application-form.tsx

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,12 @@ import { QuestionCircleIcon } from "@patternfly/react-icons";
2222
import { SchemaDefinedField } from "@app/components/schema-defined-fields/SchemaDefinedFields";
2323
import { useApplicationForm } from "./useApplicationForm";
2424
import { useApplicationFormData } from "./useApplicationFormData";
25+
import { Application } from "@app/api/models";
2526

2627
export const ApplicationForm: React.FC<{
2728
form: ReturnType<typeof useApplicationForm>["form"];
2829
data: ReturnType<typeof useApplicationFormData>;
30+
application: Application | null;
2931
}> = ({
3032
form: { control, trigger, getValues },
3133
data: {
@@ -36,6 +38,7 @@ export const ApplicationForm: React.FC<{
3638
businessServiceOptions,
3739
sourcePlatformOptions,
3840
},
41+
application,
3942
}) => {
4043
const { t } = useTranslation();
4144
const watchKind = useWatch({ control, name: "kind" });
@@ -45,19 +48,24 @@ export const ApplicationForm: React.FC<{
4548
const [isBasicExpanded, setBasicExpanded] = React.useState(true);
4649

4750
const [isSourceCodeExpanded, setSourceCodeExpanded] = React.useState(
48-
!!values.kind && !!values.sourceRepository
51+
application === null || (!!values.kind && !!values.sourceRepository)
4952
);
5053

5154
const [isBinaryExpanded, setBinaryExpanded] = React.useState(
52-
!!values.group && !!values.artifact && !!values.version
55+
application !== null &&
56+
!!values.group &&
57+
!!values.artifact &&
58+
!!values.version
5359
);
5460

5561
const [isSourcePlatformExpanded, setSourcePlatformExpanded] = React.useState(
56-
values.id === undefined || !!values.sourcePlatform
62+
application !== null && !!values.sourcePlatform
5763
);
5864

5965
const [isAssetRepositoryExpanded, setAssetRepositoryExpanded] =
60-
React.useState(!!values.assetKind && !!values.assetRepository);
66+
React.useState(
67+
application !== null && !!values.assetKind && !!values.assetRepository
68+
);
6169

6270
return (
6371
<Form>

client/src/app/pages/applications/application-form/useApplicationForm.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import { jsonSchemaToYupSchema } from "@app/components/schema-defined-fields/uti
1717
import { useFetchPlatformCoordinatesSchema } from "@app/queries/schemas";
1818
import { useApplicationFormData } from "./useApplicationFormData";
1919

20+
type RepositoryKind = "git" | "subversion" | "";
2021
export interface FormValues {
2122
id?: number;
2223
name: string;
@@ -26,15 +27,15 @@ export interface FormValues {
2627
tags: TagItemType[];
2728
owner: string | null;
2829
contributors: string[];
29-
kind: string;
30+
kind: RepositoryKind;
3031
sourceRepository: string;
3132
branch: string;
3233
rootPath: string;
3334
group: string;
3435
artifact: string;
3536
version: string;
3637
packaging: string;
37-
assetKind: string;
38+
assetKind: RepositoryKind;
3839
assetRepository: string;
3940
assetBranch: string;
4041
assetRootPath: string;
@@ -230,7 +231,7 @@ export const useApplicationForm = ({
230231
contributors:
231232
application?.contributors?.map((contributor) => contributor.name) || [],
232233

233-
kind: application?.repository?.kind || "",
234+
kind: (application?.repository?.kind ?? "") as RepositoryKind,
234235
sourceRepository: application?.repository?.url || "",
235236
branch: application?.repository?.branch || "",
236237
rootPath: application?.repository?.path || "",
@@ -239,7 +240,7 @@ export const useApplicationForm = ({
239240
version: getBinaryInitialValue(application, "version"),
240241
packaging: getBinaryInitialValue(application, "packaging"),
241242

242-
assetKind: application?.assets?.kind || "",
243+
assetKind: (application?.assets?.kind ?? "") as RepositoryKind,
243244
assetRepository: application?.assets?.url || "",
244245
assetBranch: application?.assets?.branch || "",
245246
assetRootPath: application?.assets?.path || "",

0 commit comments

Comments
 (0)