-
Notifications
You must be signed in to change notification settings - Fork 710
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
New deployment forms: add json-schema-based table #5412
Changes from all commits
c2b71e8
41b2ab9
bf0fd45
c23a1d6
e73bffd
73e9fff
47866f2
37e3a6f
d63b338
d46d171
d58e282
7bfb69d
2f5029d
ed6552a
bde921a
cd21b80
9655a5f
98d7fce
486cc47
ebf442c
57dfb67
7b12f70
b698179
c6462b8
035172a
07bfec2
f919322
a5fb3b2
f48ec48
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,7 +27,7 @@ import { | |
import { getPluginsSupportingRollback } from "shared/utils"; | ||
import { ActionType, deprecated } from "typesafe-actions"; | ||
import { InstalledPackage } from "../shared/InstalledPackage"; | ||
import { validate } from "../shared/schema"; | ||
import { validateSchema, validateValuesSchema } from "../shared/schema"; | ||
import { handleErrorAction } from "./auth"; | ||
|
||
const { createAction } = deprecated; | ||
|
@@ -234,11 +234,20 @@ export function installPackage( | |
dispatch(requestInstallPackage()); | ||
try { | ||
if (values && schema) { | ||
const validation = validate(values, schema); | ||
const schemaValidation = validateSchema(schema); | ||
if (!schemaValidation.valid) { | ||
const errorText = schemaValidation?.errors | ||
?.map(e => ` - ${e.instancePath}: ${e.message}`) | ||
.join("\n"); | ||
throw new UnprocessableEntityError( | ||
`The schema for this package is not valid. Please contact the package author. The following errors were found:\n${errorText}`, | ||
); | ||
} | ||
Comment on lines
+237
to
+245
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Validating the schema before actually creating the InstalledPackage. I have considered adding a "force button", however, Helm is also failing if a wrong schema is added (as it is validating against the Currently, for us, the problem is mainly just bitnami/readme-generator-for-helm#34. |
||
const validation = validateValuesSchema(values, schema); | ||
if (!validation.valid) { | ||
const errorText = | ||
validation.errors && | ||
validation.errors.map(e => ` - ${e.instancePath}: ${e.message}`).join("\n"); | ||
const errorText = validation?.errors | ||
?.map(e => ` - ${e.instancePath}: ${e.message}`) | ||
.join("\n"); | ||
throw new UnprocessableEntityError( | ||
`The given values don't match the required format. The following errors were found:\n${errorText}`, | ||
); | ||
|
@@ -283,11 +292,20 @@ export function updateInstalledPackage( | |
dispatch(requestUpdateInstalledPackage()); | ||
try { | ||
if (values && schema) { | ||
const validation = validate(values, schema); | ||
const schemaValidation = validateSchema(schema); | ||
if (!schemaValidation.valid) { | ||
const errorText = schemaValidation?.errors | ||
?.map(e => ` - ${e.instancePath}: ${e.message}`) | ||
.join("\n"); | ||
throw new UnprocessableEntityError( | ||
`The schema for this package is not valid. Please contact the package author. The following errors were found:\n${errorText}`, | ||
); | ||
} | ||
const validation = validateValuesSchema(values, schema); | ||
if (!validation.valid) { | ||
const errorText = | ||
validation.errors && | ||
validation.errors.map(e => ` - ${e.instancePath}: ${e.message}`).join("\n"); | ||
const errorText = validation?.errors | ||
?.map(e => ` - ${e.instancePath}: ${e.message}`) | ||
.join("\n"); | ||
throw new UnprocessableEntityError( | ||
`The given values don't match the required format. The following errors were found:\n${errorText}`, | ||
); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,25 +10,24 @@ import AvailablePackageDetailExcerpt from "components/Catalog/AvailablePackageDe | |
import Alert from "components/js/Alert"; | ||
import Column from "components/js/Column"; | ||
import Row from "components/js/Row"; | ||
import LoadingWrapper from "components/LoadingWrapper"; | ||
import PackageHeader from "components/PackageHeader/PackageHeader"; | ||
import { push } from "connected-react-router"; | ||
import { | ||
AvailablePackageReference, | ||
ReconciliationOptions, | ||
} from "gen/kubeappsapis/core/packages/v1alpha1/packages"; | ||
import { Plugin } from "gen/kubeappsapis/core/plugins/v1alpha1/plugins"; | ||
import { useEffect, useState } from "react"; | ||
import { useEffect, useRef, useState } from "react"; | ||
import { useDispatch, useSelector } from "react-redux"; | ||
import * as ReactRouter from "react-router-dom"; | ||
import "react-tabs/style/react-tabs.css"; | ||
import { Action } from "redux"; | ||
import { ThunkDispatch } from "redux-thunk"; | ||
import { Kube } from "shared/Kube"; | ||
import { FetchError, IStoreState } from "shared/types"; | ||
import * as url from "shared/url"; | ||
import { getPluginsRequiringSA, k8sObjectNameRegex } from "shared/utils"; | ||
import DeploymentFormBody from "../DeploymentFormBody/DeploymentFormBody"; | ||
import LoadingWrapper from "../LoadingWrapper/LoadingWrapper"; | ||
import DeploymentFormBody from "./DeploymentFormBody"; | ||
interface IRouteParams { | ||
cluster: string; | ||
namespace: string; | ||
|
@@ -63,6 +62,7 @@ export default function DeploymentForm() { | |
const [valuesModified, setValuesModified] = useState(false); | ||
const [serviceAccountList, setServiceAccountList] = useState([] as string[]); | ||
const [reconciliationOptions, setReconciliationOptions] = useState({} as ReconciliationOptions); | ||
const formRef = useRef<HTMLFormElement>(null); | ||
|
||
const error = apps.error || selectedPackage.error; | ||
|
||
|
@@ -209,7 +209,7 @@ export default function DeploymentForm() { | |
</Column> | ||
<Column span={9}> | ||
{error && <Alert theme="danger">An error occurred: {error.message}</Alert>} | ||
<form onSubmit={handleDeploy}> | ||
<form onSubmit={handleDeploy} ref={formRef}> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a hacky way to pass information from the children to the parent container in React. We need to manually control the form submission downstream. |
||
<CdsFormGroup | ||
validate={true} | ||
className="deployment-form" | ||
|
@@ -267,6 +267,7 @@ export default function DeploymentForm() { | |
setValues={handleValuesChange} | ||
appValues={appValues} | ||
setValuesModified={setValuesModifiedTrue} | ||
formRef={formRef} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It seems that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It was introduced in one of my previous attempts when working on this. The idea is to trigger a plain normal HTML form "submit" event from a child, this way we leverage the built-in HTML validations (like Anyway, just to double-check, I'm trying locally to replace the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
/> | ||
</form> | ||
</Column> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved to dev-deps as they are not required in the production build