-
Notifications
You must be signed in to change notification settings - Fork 592
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3931 from divyanshiGupta/edit-app
Add edit application feature for apps created using deploy image flow
- Loading branch information
Showing
31 changed files
with
1,427 additions
and
403 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 24 additions & 17 deletions
41
frontend/packages/dev-console/src/components/edit-application/EditApplicationForm.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,50 +1,57 @@ | ||
import * as React from 'react'; | ||
import * as _ from 'lodash'; | ||
import { FormikProps, FormikValues } from 'formik'; | ||
import { ModalTitle, ModalBody, ModalSubmitFooter } from '@console/internal/components/factory'; | ||
import { BuildStrategyType } from '@console/internal/components/build'; | ||
import { Form } from '@patternfly/react-core'; | ||
import { PageHeading } from '@console/internal/components/utils'; | ||
import { FormFooter } from '@console/shared'; | ||
import GitSection from '../import/git/GitSection'; | ||
import BuilderSection from '../import/builder/BuilderSection'; | ||
import DockerSection from '../import/git/DockerSection'; | ||
import AdvancedSection from '../import/advanced/AdvancedSection'; | ||
import AppSection from '../import/app/AppSection'; | ||
import { NormalizedBuilderImages } from '../../utils/imagestream-utils'; | ||
import ImageSearchSection from '../import/image-search/ImageSearchSection'; | ||
import { CreateApplicationFlow } from './edit-application-utils'; | ||
|
||
export interface EditApplicationFormProps { | ||
createFlowType: string; | ||
builderImages?: NormalizedBuilderImages; | ||
} | ||
|
||
const EditApplicationForm: React.FC<FormikProps<FormikValues> & EditApplicationFormProps> = ({ | ||
handleSubmit, | ||
handleReset, | ||
values, | ||
createFlowType, | ||
builderImages, | ||
dirty, | ||
errors, | ||
status, | ||
isSubmitting, | ||
}) => ( | ||
<form className="modal-content" onSubmit={handleSubmit}> | ||
<ModalTitle>Edit Application</ModalTitle> | ||
<ModalBody> | ||
{!_.isEmpty(values.build.strategy) && <GitSection />} | ||
{values.build.strategy === BuildStrategyType.Source && ( | ||
<> | ||
<PageHeading title={createFlowType} style={{ padding: '0px' }} /> | ||
<Form onSubmit={handleSubmit}> | ||
{createFlowType !== CreateApplicationFlow.Container && <GitSection />} | ||
{createFlowType === CreateApplicationFlow.Git && ( | ||
<BuilderSection image={values.image} builderImages={builderImages} /> | ||
)} | ||
{values.build.strategy === BuildStrategyType.Docker && ( | ||
{createFlowType === CreateApplicationFlow.Dockerfile && ( | ||
<DockerSection buildStrategy={values.build.strategy} /> | ||
)} | ||
{createFlowType === CreateApplicationFlow.Container && <ImageSearchSection />} | ||
<AppSection project={values.project} /> | ||
<AdvancedSection values={values} /> | ||
</ModalBody> | ||
<ModalSubmitFooter | ||
submitText="Save" | ||
submitDisabled={!dirty || !_.isEmpty(errors)} | ||
cancel={handleReset} | ||
inProgress={isSubmitting} | ||
errorMessage={status && status.submitError} | ||
/> | ||
</form> | ||
<FormFooter | ||
handleReset={handleReset} | ||
errorMessage={status && status.submitError} | ||
isSubmitting={isSubmitting} | ||
submitLabel="Save" | ||
disableSubmit={!dirty || !_.isEmpty(errors)} | ||
resetLabel="Cancel" | ||
/> | ||
</Form> | ||
</> | ||
); | ||
|
||
export default EditApplicationForm; |
89 changes: 89 additions & 0 deletions
89
frontend/packages/dev-console/src/components/edit-application/EditApplicationPage.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
import * as React from 'react'; | ||
import { Firehose, FirehoseResource, LoadingBox } from '@console/internal/components/utils'; | ||
import { ImageStreamModel } from '@console/internal/models'; | ||
import { RouteComponentProps } from 'react-router-dom'; | ||
import { Helmet } from 'react-helmet'; | ||
import { ServiceModel } from '@console/knative-plugin'; | ||
import { referenceForModel } from '@console/internal/module/k8s'; | ||
import NamespacedPage, { NamespacedPageVariants } from '../NamespacedPage'; | ||
import EditApplication from './EditApplication'; | ||
import { EditApplicationProps } from './edit-application-types'; | ||
|
||
const EditApplicationComponentLoader: React.FunctionComponent<EditApplicationProps> = ( | ||
props: EditApplicationProps, | ||
) => { | ||
const { loaded } = props; | ||
return loaded ? <EditApplication {...props} /> : <LoadingBox />; | ||
}; | ||
|
||
export type ImportPageProps = RouteComponentProps<{ ns?: string }>; | ||
|
||
const EditApplicationPage: React.FunctionComponent<ImportPageProps> = ({ match, location }) => { | ||
const namespace = match.params.ns; | ||
const queryParams = new URLSearchParams(location.search); | ||
const editAppResourceKind = queryParams.get('kind'); | ||
const appName = queryParams.get('name'); | ||
const appResources: FirehoseResource[] = [ | ||
{ | ||
kind: 'Service', | ||
prop: 'service', | ||
name: appName, | ||
namespace, | ||
optional: true, | ||
}, | ||
{ | ||
kind: 'BuildConfig', | ||
prop: 'buildConfig', | ||
name: appName, | ||
namespace, | ||
optional: true, | ||
}, | ||
{ | ||
kind: 'Route', | ||
prop: 'route', | ||
name: appName, | ||
namespace, | ||
optional: true, | ||
}, | ||
{ | ||
kind: 'ImageStream', | ||
prop: 'imageStream', | ||
name: appName, | ||
namespace, | ||
optional: true, | ||
}, | ||
{ | ||
kind: ImageStreamModel.kind, | ||
prop: 'imageStreams', | ||
isList: true, | ||
namespace: 'openshift', | ||
optional: true, | ||
}, | ||
]; | ||
let kind = editAppResourceKind; | ||
if (kind === ServiceModel.kind) { | ||
kind = referenceForModel(ServiceModel); | ||
} | ||
appResources.push({ | ||
kind, | ||
prop: 'editAppResource', | ||
name: appName, | ||
namespace, | ||
optional: true, | ||
}); | ||
|
||
return ( | ||
<NamespacedPage disabled variant={NamespacedPageVariants.light}> | ||
<Helmet> | ||
<title>Edit</title> | ||
</Helmet> | ||
<div className="co-m-pane__body"> | ||
<Firehose resources={appResources}> | ||
<EditApplicationComponentLoader namespace={namespace} appName={appName} /> | ||
</Firehose> | ||
</div> | ||
</NamespacedPage> | ||
); | ||
}; | ||
|
||
export default EditApplicationPage; |
Oops, something went wrong.