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: Filter property names, not trigger #4540

Merged
merged 3 commits into from
Oct 27, 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
12 changes: 5 additions & 7 deletions Composer/packages/lib/indexers/src/groupTriggers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const getPropertyReferences = (content: any) => {
return uniq(foundProperties);
};

const getTriggerPropertyReferences = (trigger: ITrigger) => {
const getTriggerPropertyReferences = (trigger: ITrigger, isValidProperty: (name: string) => boolean) => {
const content = trigger.content;

// inspect trigger
Expand All @@ -52,7 +52,7 @@ const getTriggerPropertyReferences = (trigger: ITrigger) => {
}
}

const result = uniq(foundProperties);
const result = uniq(foundProperties).filter(isValidProperty);

if (result.length === 0) {
return [NoGroupingTriggerGroupName];
Expand All @@ -76,18 +76,16 @@ export const groupTriggersByPropertyReference = (
): Record<string, ITrigger[]> => {
const result = {} as Record<string, ITrigger[]>;

const validProperties = options?.validProperties;
const isValidProperty = validProperties
? (x: string | undefined) => x && (x === NoGroupingTriggerGroupName || validProperties.includes(x))
: () => true;
const isValidProperty = (name: string) =>
!options?.validProperties || name === NoGroupingTriggerGroupName || options?.validProperties.includes(name);

const addResult = (property: string, trigger: ITrigger) => {
result[property] ? result[property].push(trigger) : (result[property] = [trigger]);
};

if (dialog?.triggers) {
dialog.triggers.forEach((t) => {
const properties = getTriggerPropertyReferences(t).filter(isValidProperty);
const properties = getTriggerPropertyReferences(t, isValidProperty);
if (properties.length > 1 && options?.allowMultiParent) {
properties.forEach((p) => {
addResult(p, t);
Expand Down
2 changes: 1 addition & 1 deletion Composer/packages/server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
"@bfc/lu-languageserver": "*",
"@bfc/shared": "*",
"@microsoft/bf-dispatcher": "^4.11.0-beta.20201016.393c6b2",
"@microsoft/bf-generate-library": "^4.10.0-daily.20201015.174962",
"@microsoft/bf-generate-library": "^4.10.0-daily.20201026.178528",
"@microsoft/bf-lu": "^4.11.0-dev.20201013.7ccb128",
"@microsoft/bf-orchestrator": "4.11.0-beta.20201013.20d7917",
"archiver": "^5.0.2",
Expand Down
8 changes: 4 additions & 4 deletions Composer/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3006,10 +3006,10 @@
ts-md5 "^1.2.6"
tslib "^1.10.0"

"@microsoft/bf-generate-library@^4.10.0-daily.20201015.174962":
version "4.10.0-daily.20201015.174962"
resolved "https://botbuilder.myget.org/F/botframework-cli/npm/@microsoft/bf-generate-library/-/@microsoft/bf-generate-library-4.10.0-daily.20201015.174962.tgz#42838aa5a44649a9de7bc3a7c987fe91b7ab65e3"
integrity sha1-QoOKpaRGSanee8OnyYf+kberZeM=
"@microsoft/bf-generate-library@^4.10.0-daily.20201026.178528":
version "4.10.0-daily.20201026.178528"
resolved "https://botbuilder.myget.org/F/botframework-cli/npm/@microsoft/bf-generate-library/-/@microsoft/bf-generate-library-4.10.0-daily.20201026.178528.tgz#9dd8acd3e5140776b515b9089f1238ff034352d0"
integrity sha1-ndis0+UUB3a1FbkInxI4/wNDUtA=
dependencies:
"@microsoft/bf-lu" "^4.11.0-dev.20201015.a41c691"
adaptive-expressions "^4.11.0-dev.20201015.e56fdb7"
Expand Down