зеркало из
1
0
Форкнуть 0

github bug fix and user feedback (#342)

This commit is contained in:
YingXue 2020-08-05 16:32:04 -07:00 коммит произвёл GitHub
Родитель 4c0af3975e
Коммит 396d011afa
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
5 изменённых файлов: 12 добавлений и 11 удалений

Просмотреть файл

@ -24,7 +24,7 @@ export const REMOVE = 'Delete';
export const RETURN = 'ReturnKey';
export const SAVE = 'Save';
export const START = 'Play';
export const STOP = 'Stop';
export const STOP = 'StopSolid';
export const SUBMIT = 'CloudUpload';
export const SYNCH = 'SyncOccurence';
export const WARNING = 'Warning';

Просмотреть файл

@ -10,7 +10,6 @@ import { Overlay } from 'office-ui-fabric-react/lib/components/Overlay';
import { ActionButton } from 'office-ui-fabric-react/lib/components/Button';
import { ResourceKeys } from '../../../../../localization/resourceKeys';
import { getLocalizedData } from '../../../../api/dataTransforms/modelDefinitionTransform';
import { isValueDefined } from '../../../shared/components/dataForm';
import { RenderSimplyTypeValue } from '../../../shared/components/simpleReportedSection';
import { ComplexReportedFormPanel } from '../../../shared/components/complexReportedFormPanel';
import { SemanticUnit } from '../../../../shared/units/components/semanticUnit';
@ -84,8 +83,8 @@ export const DevicePropertiesPerInterface: React.FC<DevicePropertiesDataProps> =
const ariaLabel = t(ResourceKeys.deviceProperties.columns.value);
return (
<div aria-label={ariaLabel}>
{isValueDefined(item.reportedTwin) ?
(isSchemaSimpleType(item) ?
{
isSchemaSimpleType(item) ?
RenderSimplyTypeValue(
item.reportedTwin,
item.propertySchema,
@ -97,7 +96,6 @@ export const DevicePropertiesPerInterface: React.FC<DevicePropertiesDataProps> =
>
{t(ResourceKeys.deviceProperties.command.openReportedValuePanel)}
</ActionButton>
) : <Label>--</Label>
}
</div>
);

Просмотреть файл

@ -22,7 +22,7 @@ describe('deviceSettingsPerInterfacePerSetting', () => {
const displayName = 'Device State';
const handleCollapseToggle = jest.fn();
let schema = 'boolean';
let twinValue: any = true; // tslint:disable-line:no-any
let twinValue: any = false; // tslint:disable-line:no-any
const propertyModelDefinition: PropertyContent = {
'@type': 'Property',
@ -76,7 +76,7 @@ describe('deviceSettingsPerInterfacePerSetting', () => {
expect(schemaLabel.props().children).toEqual(schema);
const valueLabel = wrapper.find(Label).at(3); // tslint:disable-line:no-magic-numbers
expect(valueLabel.props().children).toEqual('true');
expect(valueLabel.props().children).toEqual('false');
});
it('renders when there is a writable property of complex type with sync status', () => {

Просмотреть файл

@ -120,8 +120,8 @@ export const DeviceSettingsPerInterfacePerSetting: React.FC<DeviceSettingDataPro
const { reportedTwin } = props;
return (
<>
{isValueDefined(reportedTwin) ?
(isSchemaSimpleType() ?
{
isSchemaSimpleType() ?
<ErrorBoundary error={t(ResourceKeys.errorBoundary.text)}>
{RenderSimplyTypeValue(
reportedTwin,
@ -135,7 +135,6 @@ export const DeviceSettingsPerInterfacePerSetting: React.FC<DeviceSettingDataPro
>
{t(ResourceKeys.deviceSettings.command.openReportedValuePanel)}
</ActionButton>
) : <Label>--</Label>
}
</>
);

Просмотреть файл

@ -6,6 +6,7 @@ import * as React from 'react';
import { Validator, ValidationError } from 'jsonschema';
import { Label } from 'office-ui-fabric-react/lib/components/Label';
import { ParsedJsonSchema } from '../../../api/models/interfaceJsonParserOutput';
import { isValueDefined } from './dataForm';
// tslint:disable-next-line: cyclomatic-complexity
export const RenderSimplyTypeValue = (twin: any, schema: ParsedJsonSchema, errorLabel: string) => { // tslint:disable-line:no-any
@ -13,7 +14,10 @@ export const RenderSimplyTypeValue = (twin: any, schema: ParsedJsonSchema, error
const result = validator.validate(twin, schema);
return (
<>
{twin && typeof(twin) === 'object' ? <Label>{JSON.stringify(twin)}</Label> : <Label>{twin && twin.toString()}</Label>}
{isValueDefined(twin) ?
(typeof(twin) === 'object' ? <Label>{JSON.stringify(twin)}</Label> : <Label>{twin.toString()}</Label>) :
<Label>--</Label>
}
{result && result.errors && result.errors.length !== 0 && renderSchemaErrors(result.errors, errorLabel)}
</>
);