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

Bug 1843239: Fix number widget detection in operand form #5665

Merged
merged 1 commit into from
Jun 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { JSONSchema6TypeName } from 'json-schema';

export const K8S_UI_SCHEMA = {
apiVersion: {
'ui:widget': 'hidden',
Expand Down Expand Up @@ -27,4 +25,5 @@ export const K8S_UI_SCHEMA = {
'ui:order': ['metadata', 'spec', '*'],
};

export const JSON_SCHEMA_GROUP_TYPES: JSONSchema6TypeName[] = ['object', 'array'];
export const JSON_SCHEMA_GROUP_TYPES: string[] = ['object', 'array'];
export const JSON_SCHEMA_NUMBER_TYPES: string[] = ['number', 'integer'];
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import * as _ from 'lodash';
import * as classnames from 'classnames';
import * as React from 'react';
import { JSONSchema6TypeName } from 'json-schema';
import {
ArrayFieldTemplateProps,
FieldTemplateProps,
Expand Down Expand Up @@ -140,7 +139,7 @@ export const FieldTemplate: React.FC<FieldTemplateProps> = (props) => {
if (hidden || !dependencyMet) {
return null;
}
const isGroup = JSON_SCHEMA_GROUP_TYPES.includes(type as JSONSchema6TypeName);
const isGroup = JSON_SCHEMA_GROUP_TYPES.includes(type);
return isGroup ? children : <AtomicFieldTemplate {...props} />;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,25 @@ import { WidgetProps } from 'react-jsonschema-form';
import { NumberSpinner, ListDropdown, Dropdown } from '@console/internal/components/utils';
import { K8sKind, GroupVersionKind, ImagePullPolicy } from '@console/internal/module/k8s';
import { RadioGroup } from '@console/internal/components/radio';
import { JSON_SCHEMA_NUMBER_TYPES } from './const';
import { getSchemaType } from 'react-jsonschema-form/lib/utils';

export const TextWidget: React.FC<WidgetProps> = ({
disabled = false,
id,
onBlur,
onChange,
onFocus,
readonly = false,
required = false,
value = '',
}) => {
return (
export const TextWidget: React.FC<WidgetProps> = (props) => {
const {
disabled = false,
id,
onBlur,
onChange,
onFocus,
readonly = false,
required = false,
schema = {},
value = '',
} = props;
const schemaType = getSchemaType(schema);
return JSON_SCHEMA_NUMBER_TYPES.includes(schemaType) ? (
<NumberWidget {...props} />
) : (
<input
className="pf-c-form-control"
disabled={disabled}
Expand Down