Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…oser into sorgh/splash_screen
  • Loading branch information
sorgh committed Sep 15, 2020
2 parents 4fb3248 + 834f8df commit 7327e25
Show file tree
Hide file tree
Showing 19 changed files with 313 additions and 2,208 deletions.
7 changes: 6 additions & 1 deletion Composer/.dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,16 @@
**/package-lock.json
**/dist
**/build
**/es
**/server/data.json
**/server/tmp.zip
# not ignore all lib folder because packages/lib, so probably we should rename that to libs
packages/lib/*/lib

Dockerfile
.dockerignore

# ignore local bots
plugins/localPublish/hostedBots/*

# ignore test
coverage
9 changes: 6 additions & 3 deletions Composer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,20 @@

FROM node:12-alpine as build

ARG YARN_ARGS

WORKDIR /src/Composer
COPY . .
# run yarn install as a distinct layer
RUN yarn install --frozen-lock-file --verbose
RUN yarn install --frozen-lock-file $YARN_ARGS
ENV NODE_OPTIONS "--max-old-space-size=4096"
ENV NODE_ENV "production"
RUN yarn build:prod --verbose
RUN yarn build:prod $YARN_ARGS



FROM node:12-alpine as composerbasic
ARG YARN_ARGS

WORKDIR /app/Composer
COPY --from=build /src/Composer/yarn.lock .
Expand All @@ -37,7 +40,7 @@ COPY --from=build /src/Composer/packages/ui-plugins ./packages/ui-plugins
COPY --from=build /src/Composer/plugins ./plugins

ENV NODE_ENV "production"
RUN yarn --production --frozen-lockfile --force --verbose && yarn cache clean
RUN yarn --production --frozen-lockfile --force $YARN_ARGS && yarn cache clean
WORKDIR /app/Composer

FROM composerbasic
Expand Down
2 changes: 1 addition & 1 deletion Composer/cypress/integration/NotificationPage.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ context('Notification Page', () => {
cy.withinEditor('PropertyEditor', () => {
cy.findByText('Condition').should('exist');
cy.findByTestId('expression-type-dropdown-Condition').focus().should('contain.text', 'expression');
cy.get('#root\\.condition').click().type('foo = bar', { delay: 200 });
cy.get('#root\\.condition').click().type('=foo = bar', { delay: 200 });
cy.findByTestId('FieldErrorMessage').should('exist');
});

Expand Down
2 changes: 1 addition & 1 deletion Composer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"elliptic": "^6.5.3",
"@babel/parser": "^7.11.3",
"bl": "^2.2.1",
"node-forge": "^0.10.0"
"node-forge": "0.9.0"
},
"engines": {
"node": ">=12"
Expand Down
2 changes: 1 addition & 1 deletion Composer/packages/electron-server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"test:watch": "jest --watch"
},
"devDependencies": {
"@types/archiver": "^3.0.0",
"@types/archiver": "^3.1.0",
"@types/body-parser": "^1.17.0",
"@types/compression": "^1.0.1",
"@types/cookie-parser": "^1.4.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@
// Licensed under the MIT License.

import React from 'react';

import { useLanguageServer } from '../hooks/useLanguageServer';
import { checkIsOutside } from '../utils/uiUtils';

import { CompletionList } from './CompletionList';

export const IntellisenseTextField = React.memo(
Expand Down Expand Up @@ -42,7 +40,7 @@ export const IntellisenseTextField = React.memo(
if (value !== undefined && value !== textFieldValue) {
setTextFieldValue(value);
}
}, [value]);
}, [value, textFieldValue]);

// Show the completion list again every time the results are different (unless something was just selected from the list)
React.useEffect(() => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import { LgFile } from '@bfc/shared';
import { ReturnType } from 'adaptive-expressions';

import { validate } from '../../src/validations/expressionValidation/validation';

Expand Down Expand Up @@ -29,36 +30,42 @@ describe('search lg custom function', () => {

describe('validate expression', () => {
it('if string expression do nothing', () => {
const expression = { value: 'hello', required: false, path: 'test', types: ['string'] };
const expression = { value: 'hello', required: false, path: 'test', types: [ReturnType.String] };
const result = validate(expression, []);
expect(result).toBeNull();
});

it('if start with =, but type is not match', () => {
const expression = { value: '=13', required: false, path: 'test', types: ['string'] };
const expression = { value: '=13', required: false, path: 'test', types: [ReturnType.String] };
const result = validate(expression, []);
expect(result?.message).toBe('the expression type is not match');
expect(result?.message).toBe('the return type does not match');
});

it('if start with =, and type is match', () => {
const expression = { value: '=13', required: false, path: 'test', types: ['integer'] };
const expression = { value: '=13', required: false, path: 'test', types: [ReturnType.Number] };
const result = validate(expression, []);
expect(result).toBeNull();
expression.value = '=true';
expression.types[0] = 'boolean';
expression.types[0] = 1;
const result1 = validate(expression, []);
expect(result1).toBeNull();
});

it('use custom functions, but lg file does not export', () => {
const expression = { value: '=foo.bar()', required: false, path: 'test', types: ['boolean'] };
it('use custom functions will not throw error', () => {
const expression = { value: '=foo.bar()', required: false, path: 'test', types: [ReturnType.Boolean] };
const result = validate(expression, []);
expect(result).not.toBeNull();
expect(result).toBeNull();
});

it('use custom functions, and lg file does export', () => {
const expression = { value: '=foo.bar()', required: false, path: 'test', types: ['boolean'] };
const expression = { value: '=foo.bar()', required: false, path: 'test', types: [ReturnType.Boolean] };
const result = validate(expression, ['foo.bar']);
expect(result).toBeNull();
});

it('built-in function return type', () => {
const expression = { value: "=concat('test', '1')", required: false, path: 'test', types: [ReturnType.String] };
const result = validate(expression, []);
expect(result).toBeNull();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@
// Licensed under the MIT License.

import { Diagnostic, LgFile, LuFile } from '@bfc/shared';
import { ReturnType } from 'adaptive-expressions';

export enum ExpressionType {
number = 'number',
integer = 'integer',
boolean = 'boolean',
string = 'string',
array = 'array',
}
export const StringMapExpressionType = {
number: ReturnType.Number,
string: ReturnType.String,
boolean: ReturnType.Boolean,
object: ReturnType.Object,
array: ReturnType.Array,
integer: ReturnType.Number,
};

export type ValidateFunc = (
path: string,
Expand All @@ -21,8 +23,8 @@ export type ValidateFunc = (
) => Diagnostic[] | null; // error msg

export type ExpressionProperty = {
value: string | boolean | number;
value: any;
required: boolean; //=true, the value is required in dialog
path: string; //the json path of the value
types: string[]; //supported expression type of the value
types: number[]; //supported expression type of the value
};
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import values from 'lodash/values';
import { FieldNames } from '@bfc/shared';

import { ExpressionType } from './types';
import { StringMapExpressionType } from './types';

export const createPath = (path: string, type: string): string => {
let list = path.split('.');
Expand Down Expand Up @@ -41,18 +41,23 @@ export function findRequiredProperties(schema: any): { [key: string]: boolean }
return required;
}

export function findTypes(schema: any): string[] {
export function findTypes(schema: any): number[] {
if (!schema) return [];
let types: string[] = [];
let types: number[] = [];
if (schema.type) {
if (Array.isArray(schema.type)) {
types = [...types, ...schema.type];
types = schema.type.map((item: string) => StringMapExpressionType[item]);
} else {
types.push(schema.type);
types.push(StringMapExpressionType[schema.type]);
}
} else {
types = schema.oneOf?.filter((item) => !!ExpressionType[item.type]).map((item) => item.type);
} else if (schema.oneOf) {
types = schema.oneOf.reduce((result: string[], item) => {
if (StringMapExpressionType[item.type]) {
result.push(StringMapExpressionType[item.type]);
}
return result;
}, []);
}

return Array.from(new Set<string>(types));
return Array.from(new Set<number>(types));
}
Loading

0 comments on commit 7327e25

Please sign in to comment.