Skip to content

Commit

Permalink
Merge branch 'master' into edit-package-file
Browse files Browse the repository at this point in the history
  • Loading branch information
fiskus authored Sep 12, 2022
2 parents cc967d9 + e7b5eeb commit 79be411
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 14 deletions.
25 changes: 13 additions & 12 deletions catalog/app/components/JsonEditor/State.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import * as dateFns from 'date-fns'
import * as FP from 'fp-ts'
import * as R from 'ramda'
import * as React from 'react'

import * as jsonSchemaUtils from 'utils/json-schema/json-schema'

import { COLUMN_IDS, EMPTY_VALUE } from './constants'

const serializeAddress = (addressPath) => `/${addressPath.join('/')}`
Expand Down Expand Up @@ -109,17 +110,17 @@ function calcReactId(valuePath, value) {
}

function getDefaultValue(jsonDictItem) {
if (!jsonDictItem || !jsonDictItem.valueSchema) return EMPTY_VALUE

const schema = jsonDictItem.valueSchema
try {
if (schema.format === 'date' && schema.dateformat)
return dateFns.format(new Date(), schema.dateformat)
} catch (error) {
// eslint-disable-next-line no-console
console.error(error)
}
if (schema.default !== undefined) return schema.default
if (!jsonDictItem?.valueSchema) return EMPTY_VALUE

const defaultFromSchema = jsonSchemaUtils.getDefaultValue(jsonDictItem?.valueSchema)
if (defaultFromSchema !== undefined) return defaultFromSchema

// TODO:
// get defaults from nested objects
// const setDefaults = jsonSchemaUtils.makeSchemaDefaultsSetter(jsonDictItem?.valueSchema)
// const nestedDefaultFromSchema = setDefaults()
// if (nestedDefaultFromSchema !== undefined) return nestedDefaultFromSchema

return EMPTY_VALUE
}

Expand Down
9 changes: 7 additions & 2 deletions catalog/app/containers/Bucket/PackageDialog/PackageDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@ import * as APIConnector from 'utils/APIConnector'
import * as AWS from 'utils/AWS'
import * as Sentry from 'utils/Sentry'
import { mkFormError } from 'utils/formTools'
import { JsonSchema, makeSchemaValidator } from 'utils/json-schema'
import {
JsonSchema,
makeSchemaDefaultsSetter,
makeSchemaValidator,
} from 'utils/json-schema'
import * as packageHandleUtils from 'utils/packageHandle'
import * as s3paths from 'utils/s3paths'
import * as workflows from 'utils/workflows'
Expand Down Expand Up @@ -169,7 +173,8 @@ export function mkMetaValidator(schema?: JsonSchema) {
}

if (schema) {
const errors = schemaValidator(value || {})
const setDefaults = makeSchemaDefaultsSetter(schema)
const errors = schemaValidator(setDefaults(value || {}))
if (errors.length) return errors
}

Expand Down
1 change: 1 addition & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
* [Added] Edit button for text files in packages ([#3070](https://github.com/quiltdata/quilt/pull/3070))
* [Fixed] Fix package creation in S3 buckets with SSE-KMS enabled ([#2754](https://github.com/quiltdata/quilt/pull/2754))
* [Fixed] Fix creation of packages with large (4+ GiB) files ([#2933](https://github.com/quiltdata/quilt/pull/2933))
* [Fixed] Fix pre-popullation of default dates when using "dateformat" + {"format": "date"} ([3082](https://github.com/quiltdata/quilt/pull/3082))
* [Changed] Clean up home page ([#2780](https://github.com/quiltdata/quilt/pull/2780)).
* [Changed] Make `pkgpush` lambda directly invocable, adjust handling of parameters and errors ([#2776](https://github.com/quiltdata/quilt/pull/2776))
* [Changed] Push packages via GraphQL ([#2768](https://github.com/quiltdata/quilt/pull/2768))
Expand Down

0 comments on commit 79be411

Please sign in to comment.