This repository was archived by the owner on Jul 9, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 374
chore: project tree flatten imports #6354
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
6f6d10a
flatten project tree in all up view
zhixzhan eb4d1e7
item active
zhixzhan a2da000
Merge branch 'main' into zhixzhan/projecttree-hierarchy
zhixzhan bc56506
update tests
zhixzhan 8d85a29
Merge branch 'main' into zhixzhan/projecttree-hierarchy
boydc2014 c225fd6
Merge branch 'main' into zhixzhan/projecttree-hierarchy
beyackle File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,6 +4,7 @@ | |
| import { BotIndexer } from '@bfc/indexers'; | ||
| import { BotAssets, checkForPVASchema, DialogInfo, FormDialogSchema, JsonSchemaFile } from '@bfc/shared'; | ||
| import isEmpty from 'lodash/isEmpty'; | ||
| import uniqBy from 'lodash/uniqBy'; | ||
| import { selector, selectorFamily } from 'recoil'; | ||
|
|
||
| import { LanguageFileImport } from '../../../../types/src'; | ||
|
|
@@ -48,6 +49,8 @@ export type TreeDataPerProject = { | |
| sortedDialogs: DialogInfo[]; | ||
| lgImports: Record<string, LanguageFileImport[]>; | ||
| luImports: Record<string, LanguageFileImport[]>; | ||
| lgImportsList: LanguageFileImport[]; // all imported file exclude form diloag | ||
| luImportsList: LanguageFileImport[]; | ||
| name: string; | ||
| isPvaSchema: boolean; | ||
| formDialogSchemas: FormDialogSchema[]; | ||
|
|
@@ -271,12 +274,9 @@ export const projectDialogsMapSelector = selector<{ [key: string]: DialogInfo[] | |
| }, | ||
| }); | ||
|
|
||
| export const projectTreeSelectorFamily = selectorFamily< | ||
| TreeDataPerProject[], | ||
| { showLgImports: boolean; showLuImports: boolean } | ||
| >({ | ||
| export const projectTreeSelectorFamily = selector<TreeDataPerProject[]>({ | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You should rename this now that it's no longer a family (just |
||
| key: 'projectTreeSelectorFamily', | ||
| get: (options) => ({ get }) => { | ||
| get: ({ get }) => { | ||
| const projectIds = get(botProjectIdsState); | ||
| return projectIds.map((projectId: string) => { | ||
| const { isRemote, isRootBot } = get(projectMetaDataState(projectId)); | ||
|
|
@@ -293,31 +293,45 @@ export const projectTreeSelectorFamily = selectorFamily< | |
|
|
||
| const botError = get(botErrorState(projectId)); | ||
| const name = get(botDisplayNameState(projectId)); | ||
| const dialogIds = get(dialogIdsState(projectId)); | ||
|
|
||
| const lgImports: Record<string, LanguageFileImport[]> = {}; | ||
| const luImports: Record<string, LanguageFileImport[]> = {}; | ||
|
|
||
| // flatten imported file list | ||
| let lgImportsList: LanguageFileImport[] = []; | ||
| let luImportsList: LanguageFileImport[] = []; | ||
|
|
||
| dialogs.forEach((d) => { | ||
| if (options.showLgImports) { | ||
| lgImports[d.id] = get(lgImportsSelectorFamily({ projectId, dialogId: d.id })) ?? []; | ||
| const currentLgImports = get(lgImportsSelectorFamily({ projectId, dialogId: d.id })) ?? []; | ||
| lgImports[d.id] = currentLgImports; | ||
| if (!d.isFormDialog) { | ||
| lgImportsList.push(...currentLgImports); | ||
| } | ||
|
|
||
| if (options.showLuImports) { | ||
| luImports[d.id] = get(luImportsSelectorFamily({ projectId, dialogId: d.id })) ?? []; | ||
| const currentLuImports = get(luImportsSelectorFamily({ projectId, dialogId: d.id })) ?? []; | ||
| luImports[d.id] = currentLuImports; | ||
| if (!d.isFormDialog) { | ||
| luImportsList.push(...currentLuImports); | ||
| } | ||
| }); | ||
|
|
||
| const schemas = get(schemasState(projectId)); | ||
| const isPvaSchema = schemas && checkForPVASchema(schemas.sdk); | ||
| const formDialogSchemas = get(formDialogSchemasSelectorFamily(projectId)); | ||
|
|
||
| lgImportsList = uniqBy(lgImportsList, 'id').filter((item) => !dialogIds.includes(item.displayName) && item.id); | ||
| luImportsList = uniqBy(luImportsList, 'id').filter((item) => !dialogIds.includes(item.displayName) && item.id); | ||
|
|
||
| return { | ||
| projectId, | ||
| isRemote, | ||
| isRootBot, | ||
| sortedDialogs, | ||
| luImports, | ||
| lgImports, | ||
| lgImportsList, | ||
| luImportsList, | ||
| name, | ||
| isPvaSchema, | ||
| formDialogSchemas, | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can keep this mostly as it is and just write
displayName: item.id.substring(0, item.id.indexOf('.'))as a field on the object (replacing theitem.descriptionpart).