diff --git a/licenses.yaml b/licenses.yaml index 54333670b43..009ab26c249 100644 --- a/licenses.yaml +++ b/licenses.yaml @@ -5813,7 +5813,7 @@ license_category: binary module: web-console license_name: MIT License copyright: Vadim Ogievetsky, Andrey Sidorov -version: 1.1.0 +version: 1.2.0 license_file_path: licenses/bin/json-bigint-native.MIT --- diff --git a/web-console/package-lock.json b/web-console/package-lock.json index 64232d0b745..1e016eed59a 100644 --- a/web-console/package-lock.json +++ b/web-console/package-lock.json @@ -14771,9 +14771,9 @@ "integrity": "sha512-OYu7XEzjkCQ3C5Ps3QIZsQfNpqoJyZZA99wd9aWd05NCtC5pWOkShK2mkL6HXQR6/Cy2lbNdPlZBpuQHXE63gA==" }, "json-bigint-native": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/json-bigint-native/-/json-bigint-native-1.1.0.tgz", - "integrity": "sha512-PPL9AlDP0ift5v8siEsR7oQsamOAIOLjn14GRaijZRUWDXsJC5rHXNlmtLPkPjK0k2i5yHK30VPqiFTZHolXaA==" + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/json-bigint-native/-/json-bigint-native-1.2.0.tgz", + "integrity": "sha512-qC9EtJsyULhbwC2KEYoR8sRsC+PH7VwwPdxU6+CZTZxMtM23zlxCfhIa+6Sn74FQ4VqDqWUaHaBeU0bMUTU9jQ==" }, "json-parse-better-errors": { "version": "1.0.2", diff --git a/web-console/package.json b/web-console/package.json index 7ff415ba1f2..62fb60241fd 100644 --- a/web-console/package.json +++ b/web-console/package.json @@ -85,7 +85,7 @@ "fontsource-open-sans": "^3.0.9", "has-own-prop": "^2.0.0", "hjson": "^3.2.1", - "json-bigint-native": "^1.1.0", + "json-bigint-native": "^1.2.0", "lodash.debounce": "^4.0.8", "lodash.escape": "^4.0.1", "memoize-one": "^5.1.1", diff --git a/web-console/src/components/auto-form/__snapshots__/auto-form.spec.tsx.snap b/web-console/src/components/auto-form/__snapshots__/auto-form.spec.tsx.snap index 0e28a10eba4..1a739957c5f 100644 --- a/web-console/src/components/auto-form/__snapshots__/auto-form.spec.tsx.snap +++ b/web-console/src/components/auto-form/__snapshots__/auto-form.spec.tsx.snap @@ -45,6 +45,7 @@ exports[`AutoForm matches snapshot 1`] = ` > + + + { { name: 'testSizeBytes', type: 'size-bytes' }, { name: 'testString', type: 'string' }, { name: 'testStringWithDefault', type: 'string', defaultValue: 'Hello World' }, + { + name: 'testStringWithMultiline', + type: 'string', + multiline: true, + defaultValue: 'Hello World', + }, { name: 'testBoolean', type: 'boolean' }, { name: 'testBooleanWithDefault', type: 'boolean', defaultValue: false }, { name: 'testStringArray', type: 'string-array' }, diff --git a/web-console/src/components/auto-form/auto-form.tsx b/web-console/src/components/auto-form/auto-form.tsx index 864ae1e8345..241dad03ec4 100644 --- a/web-console/src/components/auto-form/auto-form.tsx +++ b/web-console/src/components/auto-form/auto-form.tsx @@ -57,6 +57,7 @@ export interface Field { disabled?: Functor; defined?: Functor; required?: Functor; + multiline?: Functor; hide?: Functor; hideInMore?: Functor; valueAdjustment?: (value: any) => any; @@ -303,6 +304,7 @@ export class AutoForm> extends React.PureComponent large={large} disabled={AutoForm.evaluateFunctor(field.disabled, model, false)} intent={required && modelValue == null ? AutoForm.REQUIRED_INTENT : undefined} + multiline={AutoForm.evaluateFunctor(field.multiline, model, false)} /> ); } diff --git a/web-console/src/components/formatted-input/__snapshots__/formatted-input.spec.tsx.snap b/web-console/src/components/formatted-input/__snapshots__/formatted-input.spec.tsx.snap index 27b677dd0bf..20f74a65552 100644 --- a/web-console/src/components/formatted-input/__snapshots__/formatted-input.spec.tsx.snap +++ b/web-console/src/components/formatted-input/__snapshots__/formatted-input.spec.tsx.snap @@ -31,3 +31,15 @@ exports[`FormattedInput matches snapshot with escaped value 1`] = ` `; + +exports[`FormattedInput matches works with multiline 1`] = ` +
+ +
+`; diff --git a/web-console/src/components/formatted-input/formatted-input.scss b/web-console/src/components/formatted-input/formatted-input.scss index 4369df8b5b1..553ce0da3ce 100644 --- a/web-console/src/components/formatted-input/formatted-input.scss +++ b/web-console/src/components/formatted-input/formatted-input.scss @@ -26,4 +26,9 @@ top: 0; bottom: 0; } + + textarea { + width: 100%; + resize: vertical; + } } diff --git a/web-console/src/components/formatted-input/formatted-input.spec.tsx b/web-console/src/components/formatted-input/formatted-input.spec.tsx index da74ec71115..282c730d5c7 100644 --- a/web-console/src/components/formatted-input/formatted-input.spec.tsx +++ b/web-console/src/components/formatted-input/formatted-input.spec.tsx @@ -45,4 +45,18 @@ describe('FormattedInput', () => { const { container } = render(suggestibleInput); expect(container.firstChild).toMatchSnapshot(); }); + + it('matches works with multiline', () => { + const suggestibleInput = ( + {}} + formatter={JSON_STRING_FORMATTER} + multiline + /> + ); + + const { container } = render(suggestibleInput); + expect(container.firstChild).toMatchSnapshot(); + }); }); diff --git a/web-console/src/components/formatted-input/formatted-input.tsx b/web-console/src/components/formatted-input/formatted-input.tsx index fb3c0a7bd4a..aee9ddcea3a 100644 --- a/web-console/src/components/formatted-input/formatted-input.tsx +++ b/web-console/src/components/formatted-input/formatted-input.tsx @@ -16,7 +16,7 @@ * limitations under the License. */ -import { InputGroup, InputGroupProps2, Intent } from '@blueprintjs/core'; +import { InputGroup, InputGroupProps2, Intent, TextArea } from '@blueprintjs/core'; import { Tooltip2 } from '@blueprintjs/popover2'; import classNames from 'classnames'; import React, { useState } from 'react'; @@ -30,6 +30,7 @@ export interface FormattedInputProps extends InputGroupProps2 { onValueChange: (newValue: undefined | string) => void; sanitizer?: (rawValue: string) => string; issueWithValue?: (value: any) => string | undefined; + multiline?: boolean; } export const FormattedInput = React.memo(function FormattedInput(props: FormattedInputProps) { @@ -44,6 +45,8 @@ export const FormattedInput = React.memo(function FormattedInput(props: Formatte onFocus, onBlur, intent, + placeholder, + multiline, ...rest } = props; @@ -53,44 +56,67 @@ export const FormattedInput = React.memo(function FormattedInput(props: Formatte const issue: string | undefined = issueWithValue?.(value); const showIssue = Boolean(!isFocused && issue); + const myValue = + typeof intermediateValue !== 'undefined' + ? intermediateValue + : typeof value !== 'undefined' + ? formatter.stringify(value) + : undefined; + + const myDefaultValue = + typeof defaultValue !== 'undefined' ? formatter.stringify(defaultValue) : undefined; + + const myOnChange = (e: any) => { + let rawValue = e.target.value; + if (sanitizer) rawValue = sanitizer(rawValue); + setIntermediateValue(rawValue); + + let parsedValue: string | undefined; + try { + parsedValue = formatter.parse(rawValue); + } catch { + return; + } + onValueChange(parsedValue); + }; + + const myOnFocus = (e: any) => { + setIsFocused(true); + onFocus?.(e); + }; + + const myOnBlur = (e: any) => { + setIntermediateValue(undefined); + setIsFocused(false); + onBlur?.(e); + }; + + const myIntent = showIssue ? Intent.DANGER : intent; + return (
- { - let rawValue = e.target.value; - if (sanitizer) rawValue = sanitizer(rawValue); - setIntermediateValue(rawValue); - - let parsedValue: string | undefined; - try { - parsedValue = formatter.parse(rawValue); - } catch { - return; - } - onValueChange(parsedValue); - }} - onFocus={e => { - setIsFocused(true); - onFocus?.(e); - }} - onBlur={e => { - setIntermediateValue(undefined); - setIsFocused(false); - onBlur?.(e); - }} - intent={showIssue ? Intent.DANGER : intent} - {...rest} - /> + {multiline ? ( +