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

fix: Dialog validate throw error when delete an action #3537

Merged
merged 6 commits into from
Jul 2, 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ describe('search lg custom function', () => {
expect(result.length).toEqual(2);
expect(result[0]).toEqual('foo.bar');
expect(result[1]).toEqual('foo.cool');
const lgFilesWithoutOptions = [{ id: 'test.en-us' }];
const result1 = searchLgCustomFunction(lgFilesWithoutOptions as LgFile[]);
expect(result1.length).toEqual(0);
});

it('should return custom functions with namespace', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,17 @@ const ExportsKey = '@exports';
export const searchLgCustomFunction = (lgFiles: LgFile[]): string[] => {
const customFunctions = lgFiles.reduce((result: string[], lgFile) => {
const { options } = lgFile;
const exports = extractOptionByKey(ExportsKey, options);
let namespace = extractOptionByKey(NamespaceKey, options);
if (!namespace) namespace = lgFile.id; //if namespace doesn't exist, use file name
const funcList = exports.split(',');
funcList.forEach((func) => {
if (func) {
result.push(`${namespace}.${func.trim()}`);
}
});

if (options?.length) {
const exports = extractOptionByKey(ExportsKey, options);
let namespace = extractOptionByKey(NamespaceKey, options);
if (!namespace) namespace = lgFile.id; //if namespace doesn't exist, use file name
const funcList = exports.split(',');
funcList.forEach((func) => {
if (func) {
result.push(`${namespace}.${func.trim()}`);
}
});
}
return result;
}, []);
return customFunctions;
Expand Down
2 changes: 1 addition & 1 deletion Composer/packages/lib/shared/src/types/indexers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ export interface LgFile {
content: string;
diagnostics: Diagnostic[];
templates: LgTemplate[];
options: string[];
options?: string[];
}

export interface Skill {
Expand Down