Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create Edit flow for Upload Jar Form #8458

Merged
merged 1 commit into from
Apr 8, 2021

Conversation

sahil143
Copy link
Contributor

@sahil143 sahil143 commented Mar 24, 2021

Fixes: https://issues.redhat.com/browse/ODC-5466

This PR adds the flow to edit resources created from UploadJarForm.

Screen shots / Gifs for design review:

edit-jar-form

Unit test coverage report:

Test setup:

Browser conformance:

  • Chrome
  • Firefox
  • Safari
  • Edge

@openshift-ci-robot openshift-ci-robot added component/dev-console Related to dev-console component/knative Related to knative-plugin component/topology Related to topology labels Mar 24, 2021
@openshift-ci-robot openshift-ci-robot added the kind/i18n Indicates issue or PR relates to internationalization or has content that needs to be translated label Mar 25, 2021
Comment on lines 41 to 48
const pageHeading = getPageHeading(
_.get(initialValues, 'build.strategy', ''),
_.get(initialValues, 'build.source.type', undefined),
);
const validationSchema = getValidationSchema(
_.get(initialValues, 'build.strategy', ''),
_.get(initialValues, 'build.source.type', undefined),
);
Copy link
Member

@invincibleJai invincibleJai Mar 26, 2021

Choose a reason for hiding this comment

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

nit: we can have strategy and source.type as const and use in getPageHeading, getValidationSchema

@@ -249,6 +249,7 @@ export const appResources: AppResources = {
annotations: {
'app.openshift.io/vcs-ref': 'master',
'app.openshift.io/vcs-uri': 'https://github.com/divyanshiGupta/nationalparks-py',
jarFileName: 'demo-app.jar',
Copy link
Member

Choose a reason for hiding this comment

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

all three of these annotations will be not be used together right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, jarFileName will be used to form Jar initial values and the other is for git import.

Comment on lines 122 to 125
expect(getFileUploadValues(editAppResource.data, buildConfig.data)).toEqual({
fileUpload: { name: 'demo-app.jar', value: '', javaArgs: undefined },
runtimeIcon: 'python',
});
Copy link
Member

Choose a reason for hiding this comment

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

will it make sense to update buildConfig mock data to have java as runtime as Upload Jar will always have that

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is just mock data. I don't see any difference using java or python here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is just mock data. I don't see any difference using java or python here.

import { BuildConfigModel, BuildModel } from '@console/internal/models';
import { K8sResourceKind } from '@console/internal/module/k8s';
import { history, resourcePathFromModel } from '@console/internal/components/utils';
import { useTranslation } from 'react-i18next';
Copy link
Member

Choose a reason for hiding this comment

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

nit: sort imports

Comment on lines 147 to 148
const renderForm = (formikProps: FormikProps<any>) => {
return (
Copy link
Member

Choose a reason for hiding this comment

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

nit: can use implicit return

const isFromJarUpload = (type: string): boolean => type === BuildSourceType.Binary;

const getBuildSourceType = (buildConfig: K8sResourceKind): string =>
buildConfig?.spec?.source?.type ?? undefined;
Copy link
Member

Choose a reason for hiding this comment

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

if any value is not there in buildConfig?.spec?.source?.type then it'll return undefined only so does it make sense to return undefined explicitly as well?

const fileName = buildConfig.metadata?.annotations?.jarFileName ?? '';
const javaArgs: string = resource.spec?.template?.spec?.containers
?.find((container) => container.name === resourceName)
?.env?.find((args) => args.name === 'JAVA_ARGS').value;
Copy link
Member

Choose a reason for hiding this comment

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

I think this will fail for a scenario where Env var name is not 'JAVA_ARGS' and will would acc values. Observed this when i added env say TEST: testwhile edit flow

image

@openshift-ci-robot openshift-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Mar 29, 2021
@openshift-ci-robot openshift-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Mar 30, 2021
@invincibleJai
Copy link
Member

on edit flow, if I remove Optional Java commands i.e jai then as well the value is persisted

image

@invincibleJai
Copy link
Member

/retest


export enum BuildSourceType {
Git = 'Git',
Binary = 'Binary',
Copy link
Contributor

Choose a reason for hiding this comment

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

how about if we move these to edit-application-types.ts

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Other enums are also in this file. Not sure if it matters to move these to edit-application-types.ts.

@debsmita1
Copy link
Contributor

@sahil143 a test case is failing

verified the changes, it works fine

@debsmita1
Copy link
Contributor

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Mar 31, 2021
@invincibleJai
Copy link
Member

Verified works as expected for D/KSVC but for DC jar file name is not auto-populated on edit

image

@openshift-ci-robot openshift-ci-robot removed the lgtm Indicates that a PR is ready to be merged. label Apr 1, 2021
@invincibleJai
Copy link
Member

/retest

@invincibleJai
Copy link
Member

/approve

Verified the changes, works as expected.

@openshift-ci-robot openshift-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Apr 5, 2021
@sahil143
Copy link
Contributor Author

sahil143 commented Apr 5, 2021

/retest

Copy link
Contributor

@rottencandy rottencandy left a comment

Choose a reason for hiding this comment

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

Tested locally, works as expected.
/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Apr 7, 2021
@openshift-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: debsmita1, invincibleJai, rottencandy, sahil143

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-merge-robot openshift-merge-robot merged commit 67f4303 into openshift:master Apr 8, 2021
@spadgett spadgett added this to the v4.8 milestone Apr 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. component/dev-console Related to dev-console component/knative Related to knative-plugin component/topology Related to topology kind/i18n Indicates issue or PR relates to internationalization or has content that needs to be translated lgtm Indicates that a PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants