Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ export const toAPIApplication = (app: AppForm): ApplicationProviderSpec => {

return {
name: app.name,
appType: AppType.AppTypeCompose,
appType: app.appType || AppType.AppTypeCompose,
inline: app.files.map(
(file): InlineApplicationFileFixed => ({
path: file.path,
Expand Down Expand Up @@ -396,6 +396,7 @@ export const getApplicationValues = (deviceSpec?: DeviceSpec): AppForm[] => {
if (isImageAppProvider(app)) {
return {
specType: AppSpecType.OCI_IMAGE,
appType: app.appType,
name: app.name || '',
image: app.image,
variables: getAppFormVariables(app),
Expand All @@ -405,6 +406,7 @@ export const getApplicationValues = (deviceSpec?: DeviceSpec): AppForm[] => {
// TODO EDM-2451: Add support for artifact applications
return {
specType: AppSpecType.INLINE,
appType: app.appType,
name: app.name || '',
files: (app as InlineApplicationProviderSpec).inline.map((file) => ({
path: file.path || '',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import * as React from 'react';

import { Button, FormGroup, FormSection, Grid, Split, SplitItem } from '@patternfly/react-core';
import { Button } from '@patternfly/react-core/dist/esm/components/Button';
import { FormGroup, FormSection } from '@patternfly/react-core/dist/esm/components/Form';
import { Grid } from '@patternfly/react-core/dist/esm/layouts/Grid';
import { Split, SplitItem } from '@patternfly/react-core/dist/esm/layouts/Split';
import { FieldArray, useField, useFormikContext } from 'formik';
import { MinusCircleIcon } from '@patternfly/react-icons/dist/js/icons/minus-circle-icon';
import { PlusCircleIcon } from '@patternfly/react-icons/dist/js/icons/plus-circle-icon';
Expand Down Expand Up @@ -45,6 +48,7 @@ const ApplicationSection = ({ index, isReadOnly }: { index: number; isReadOnly?:
setValue(
{
specType: AppSpecType.INLINE,
appType: (app.appType || ('compose' as unknown as AppForm['appType'])),

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like it would work without the casting

Suggested change
appType: (app.appType || ('compose' as unknown as AppForm['appType'])),
appType: app.appType,

name: app.name || '',
files: [{ path: '', content: '' }],
variables: [],
Expand All @@ -55,14 +59,15 @@ const ApplicationSection = ({ index, isReadOnly }: { index: number; isReadOnly?:
setValue(
{
specType: AppSpecType.OCI_IMAGE,
appType: app.appType,
name: app.name || '',
image: '',
variables: [],
},
false,
);
}
}, [isImageIncomplete, isInlineIncomplete, app.name, setValue]);
}, [isImageIncomplete, isInlineIncomplete, app.name, app.appType, setValue]);

return (
<ExpandableFormSection
Expand Down Expand Up @@ -92,6 +97,20 @@ const ApplicationSection = ({ index, isReadOnly }: { index: number; isReadOnly?:
<TextField aria-label={t('Application name')} name={`${appFieldName}.name`} isDisabled={isReadOnly} />
</FormGroupWithHelperText>

{isInlineAppForm(app) && (
<FormGroup label={t('Application format')} isRequired>
<FormSelect
items={{
compose: t('Compose'),
quadlet: t('Quadlet'),
}}
name={`${appFieldName}.appType`}
placeholderText={t('Select a format')}
isDisabled={isReadOnly}
/>
</FormGroup>
)}

{isImageAppForm(app) && <ApplicationImageForm app={app} index={index} isReadOnly={isReadOnly} />}
{isInlineAppForm(app) && <ApplicationInlineForm app={app} index={index} isReadOnly={isReadOnly} />}

Expand Down
3 changes: 2 additions & 1 deletion libs/ui-components/src/types/deviceSpec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {
AppType,
ArtifactApplicationProviderSpec,
ConfigProviderSpec,
DisruptionBudget,
Expand Down Expand Up @@ -46,7 +47,7 @@ type InlineContent = {

type AppBase = {
specType: AppSpecType;
// appType: AppType - commented out for now, since it only accepts one value ("compose")
appType?: AppType;
name?: string;
variables: { name: string; value: string }[];
volumes?: {
Expand Down
Loading