-
Notifications
You must be signed in to change notification settings - Fork 374
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
refactor: centralize lg parsing logic to 'shared' lib #1663
Conversation
if (matches && matches.length === 2) return matches[1]; | ||
return ''; | ||
const lgTemplateRef = LgTemplateRef.parse(x); | ||
return lgTemplateRef ? lgTemplateRef.name : ''; |
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.
We can leverage the 'optional chaining' feature in ts 3.7. LgTemplateRef.parse(x)?.name
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.
const newLgName = lgMetadata.toLgTemplateName(); | ||
const newLgTemplateRefString = lgMetadata.toLgTemplateRefString(); | ||
|
||
await copyLgTemplate('common', lgTemplateRef.name, newLgName); |
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.
copyLgTemplate
will be defined as copyLgText
in my following PR. Targets to hide LG concepts from visual editor (and Form Editor), will inject a synthesized lg api from Shell level.
@@ -49,12 +49,10 @@ export const ObiEditor: FC<ObiEditorProps> = ({ | |||
); | |||
|
|||
const deleteLgTemplates = (lgTemplates: string[]) => { |
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.
deleteLgTemplates
will be defined as deleteLgText
. See my next comments on copyLgTemplate
Composer/packages/lib/shared/src/lgUtils/parsers/extractLgTemplateNames.ts
Outdated
Show resolved
Hide resolved
Composer/packages/lib/shared/__tests__/lgUtils/parsers/parseLgTemplateRef.test.ts
Show resolved
Hide resolved
LGTM, but let's wait a little bit until @cwhitten and @a-b-r-o-w-n can have a chance to look at. Also, if LSP is also good to go, let's merge LSP first. |
Description
Closes #1308.
Closes #1659.
Merges all LG related logic to one module in '@bfc/shared'. Prepares for the upcoming lg syntax update.
Where are we parsing lg strings?
In 'form -> TableField -> line 100', extract lg name out of string(should be coverd in another PR which focuses on shellApi refinement)How we understand LG strings
Task Item
Closes #1308
Type of change
Please delete options that are not relevant.
Checklist
Screenshots
Please include screenshots or gifs if your PR include UX changes.