chore: added a validate function for storepath

This commit is contained in:
blam
2021-01-14 18:51:03 +01:00
parent 5224a49a26
commit 2249b22e3e
3 changed files with 28 additions and 9 deletions
+1
View File
@@ -40,6 +40,7 @@
"@rjsf/core": "^2.4.0",
"@rjsf/material-ui": "^2.4.0",
"classnames": "^2.2.6",
"git-url-parse": "^11.4.3",
"moment": "^2.26.0",
"react": "^16.13.1",
"react-dom": "^16.13.1",
@@ -39,6 +39,7 @@ import { rootRoute } from '../../routes';
import { JobStatusModal } from '../JobStatusModal';
import { MultistepJsonForm } from '../MultistepJsonForm';
import { useJobPolling } from '../hooks/useJobPolling';
import gitParse from 'git-url-parse';
const useTemplate = (
templateName: string,
@@ -183,6 +184,18 @@ export const TemplatePage = () => {
label: 'Choose owner and repo',
schema: OWNER_REPO_SCHEMA,
customFormats: REPO_FORMAT,
validate: (formData, errors) => {
const { storePath } = formData;
const parsedUrl = gitParse(storePath);
if (!parsedUrl.resource) {
errors.storePath.addError(
'There needs to be a hostname in the storePath',
);
}
return errors;
},
},
]}
/>
+14 -9
View File
@@ -1644,9 +1644,11 @@
to-fast-properties "^2.0.0"
"@backstage/catalog-model@^0.2.0":
version "0.6.0"
version "0.2.0"
resolved "https://registry.npmjs.org/@backstage/catalog-model/-/catalog-model-0.2.0.tgz#e3fe2a4ddeb6a9b6ec480c80cb2b9c39cb245576"
integrity sha512-Y1ocdRpBlxK/VrJQjHlQd0bgADECd1B2NRjwd8ss46ibT5hwLvMOfD80+Fa7oPLu0ktJrH4lq0pNIIJIml48zA==
dependencies:
"@backstage/config" "^0.1.2"
"@backstage/config" "^0.1.1"
"@types/json-schema" "^7.0.5"
"@types/yup" "^0.29.8"
json-schema "^0.2.5"
@@ -1655,9 +1657,11 @@
yup "^0.29.3"
"@backstage/catalog-model@^0.3.0":
version "0.6.0"
version "0.3.1"
resolved "https://registry.npmjs.org/@backstage/catalog-model/-/catalog-model-0.3.1.tgz#45d08e2f333c9c566b2bf2629fd707fe989bb404"
integrity sha512-9XhV7c4rmVW+Yzj2PiwTQ7DsegWGB3C4ELsDRExuEVZONdqNcC02cyJtrt3fT5F31ZS3tHkB9bMUymFOBLqUSA==
dependencies:
"@backstage/config" "^0.1.2"
"@backstage/config" "^0.1.1"
"@types/json-schema" "^7.0.5"
"@types/yup" "^0.29.8"
json-schema "^0.2.5"
@@ -1666,16 +1670,17 @@
yup "^0.29.3"
"@backstage/core@^0.3.0":
version "0.4.3"
version "0.3.2"
resolved "https://registry.npmjs.org/@backstage/core/-/core-0.3.2.tgz#a8209126d5076cf4a8b9bd632fe4e5e2edb62916"
integrity sha512-i5d+Wh8js4qEWoAsPY5L7HVSWpumr1OhfF2dUCGYdyW6AMqVJPca6+n6zp1Rg2CO+J9norp44XAVVCbyhtUpig==
dependencies:
"@backstage/config" "^0.1.2"
"@backstage/core-api" "^0.2.8"
"@backstage/theme" "^0.2.2"
"@backstage/config" "^0.1.1"
"@backstage/core-api" "^0.2.1"
"@backstage/theme" "^0.2.1"
"@material-ui/core" "^4.11.0"
"@material-ui/icons" "^4.9.1"
"@material-ui/lab" "4.0.0-alpha.45"
"@types/dagre" "^0.7.44"
"@types/prop-types" "^15.7.3"
"@types/react" "^16.9"
"@types/react-sparklines" "^1.7.0"
classnames "^2.2.6"