-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
chore: add widget id prefix #35221
chore: add widget id prefix #35221
Conversation
WalkthroughThe recent changes enhance the widget ID generation in the application by introducing structured prefixes for different widget types. This improves the organization and identification of widgets, making it easier to manage them. Specifically, zones are prefixed with "zone-" and sections with "section-", allowing for greater clarity and uniqueness in the widget management process. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant WidgetCard
participant SectionUtils
participant ZoneUtils
User->>WidgetCard: Drag widget
WidgetCard->>generateReactKey: Generate widgetId with type prefix
alt Zone Widget
generateReactKey-->>WidgetCard: Returns zone widgetId
WidgetCard->>SectionUtils: Add zone widget with zone widgetId
else Other Widget
generateReactKey-->>WidgetCard: Returns component widgetId
WidgetCard->>SectionUtils: Add component widget with component widgetId
end
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configuration File (
|
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.
Actionable comments posted: 0
Outside diff range, codebase verification and nitpick comments (2)
app/client/src/layoutSystems/anvil/utils/sectionOperationUtils.ts (1)
170-170
: Attention Needed: UpdategenerateReactKey
Function CallsThe code changes in
addNewZonesToSection
are approved. However, several instances ofgenerateReactKey
in the codebase do not follow the new signature, which includes an optional object parameter with aprefix
key.Please update the following instances to ensure consistency:
app/client/test/factories/Widgets/DividerFactory.ts
app/client/test/factories/Widgets/DatepickerFactory.ts
app/client/test/factories/Widgets/RadiogroupFactory.ts
app/client/test/factories/Widgets/VideoFactory.ts
app/client/test/factories/Widgets/TabsFactory.ts
app/client/test/factories/Widgets/DropdownFactory.ts
app/client/test/factories/Widgets/RichTextFactory.ts
app/client/test/factories/Widgets/ModalFactory.ts
app/client/test/factories/Widgets/MapFactory.ts
app/client/test/factories/Widgets/InputFactory.ts
app/client/test/factories/Widgets/ImageFactory.ts
app/client/test/factories/Widgets/IconFactory.ts
app/client/test/factories/Widgets/FormButtonFactory.ts
app/client/test/factories/Widgets/FilepickerFactory.ts
app/client/test/factories/Widgets/TextFactory.ts
app/client/test/factories/Widgets/SwitchFactory.ts
app/client/test/factories/Widgets/ChartFactory.ts
app/client/test/factories/Widgets/CanvasFactory.ts
app/client/test/factories/Widgets/SkeletonFactory.ts
app/client/test/factories/Widgets/FormFactory.ts
app/client/test/factories/Widgets/ContainerFactory.ts
app/client/test/factories/Widgets/TableFactory.ts
app/client/test/factories/Widgets/ListFactory.ts
app/client/test/factories/Widgets/CheckboxFactory.ts
app/client/test/factories/Widgets/ButtonFactory.ts
app/client/src/widgets/wds/WDSTableWidget/component/Constants.ts
app/client/src/widgets/TabsMigrator/widget/index.tsx
app/client/src/widgets/TableWidgetV2/component/Constants.ts
app/client/src/widgets/TableWidgetV2/component/header/actions/filter/FilterPaneContent.tsx
app/client/src/widgets/ListWidgetV2/MetaWidgetGenerator.ts
app/client/src/widgets/JSONFormWidget/fields/ArrayField.tsx
app/client/src/widgets/ContainerWidget/widget/index.test.tsx
app/client/src/widgets/ChartWidget/widget/index.tsx
app/client/src/utils/editor/browserTabsTracking.ts
app/client/src/sagas/WidgetBlueprintSagas.ts
app/client/src/sagas/WidgetOperationUtils.ts
app/client/src/sagas/WidgetOperationSagas.tsx
app/client/src/sagas/WidgetAdditionSagas.ts
app/client/src/sagas/ModalSagas.ts
app/client/src/sagas/BuildingBlockSagas/BuildingBlockAdditionSagas.ts
app/client/src/mocks/widgetProps/button.ts
app/client/src/layoutSystems/anvil/layoutComponents/presets/DefaultLayoutPreset.tsx
app/client/src/layoutSystems/anvil/layoutComponents/presets/sectionPreset.tsx
app/client/src/mocks/widgetProps/container.ts
app/client/src/layoutSystems/anvil/layoutComponents/presets/ModalPreset.tsx
app/client/src/layoutSystems/anvil/layoutComponents/presets/FormPreset.tsx
app/client/src/layoutSystems/anvil/layoutComponents/presets/StatboxPreset.tsx
app/client/src/layoutSystems/anvil/layoutComponents/presets/zonePreset.tsx
app/client/src/mocks/widgetProps/input.ts
app/client/src/mocks/widgetProps/canvas.ts
app/client/src/layoutSystems/anvil/utils/AnvilDSLTransformer.ts
app/client/src/layoutSystems/anvil/utils/paste/utils.ts
app/client/src/layoutSystems/anvil/utils/layouts/update/additionUtils.ts
app/client/src/layoutSystems/anvil/utils/layouts/update/sectionUtils.ts
app/client/src/layoutSystems/autolayout/layoutComponents/presets/ModalPreset.ts
app/client/src/layoutSystems/anvil/utils/layouts/update/zoneUtils.ts
app/client/src/layoutSystems/anvil/integrations/sagas/anvilDraggingSagas/anvilDraggingSagas.test.ts
app/client/src/layoutSystems/anvil/integrations/sagas/pasteSagas/pasteSagas.test.ts
app/client/src/mocks/layoutComponents/layoutComponentMock.ts
app/client/src/layoutSystems/fixedlayout/editor/FixedLayoutCanvasArenas/CanvasSelectionArena.test.tsx
app/client/src/pages/Editor/widgetSidebar/WidgetCard.tsx
app/client/src/pages/Editor/QueryEditor/BindDataButton.tsx
app/client/src/pages/Editor/Popper.tsx
app/client/src/pages/Editor/IDE/AppsmithIDE.test.tsx
app/client/src/pages/Editor/Explorer/Actions/helpers.tsx
app/client/src/components/propertyControls/ToolbarButtonListControl.tsx
app/client/src/components/propertyControls/MenuItemsControl.tsx
app/client/src/components/propertyControls/KeyValueComponent.tsx
app/client/src/components/propertyControls/IconSelectControlV2.tsx
app/client/src/components/propertyControls/IconSelectControl.tsx
app/client/src/components/propertyControls/ColumnActionSelectorControl.tsx
app/client/src/components/editorComponents/ActionCreator/index.tsx
app/client/src/components/editorComponents/ActionCreator/viewComponents/TextView/index.tsx
app/client/src/components/propertyControls/ChartDataControl.tsx
app/client/src/components/propertyControls/ButtonListControl.tsx
app/client/src/WidgetProvider/factory/index.tsx
app/client/src/WidgetProvider/factory/helpers.ts
app/client/packages/dsl/src/migrate/utils.ts
app/client/packages/dsl/src/migrate/tests/ChartDataFromArrayFromArrayToObject.test.ts
app/client/packages/dsl/src/migrate/migrations/012-migrate-incorrect-dynamic-binding-path-lists.ts
app/client/packages/dsl/src/migrate/migrations/016-migrate-chart-data-from-array-to-object.ts
app/client/packages/dsl/src/migrate/migrations/001-update-containers.ts
Please ensure all these instances are updated to use the new signature of
generateReactKey
.Analysis chain
LGTM! But verify the function usage in the codebase.
The code changes are approved. The addition of a prefix to the widget ID generation will help in debugging and managing widgets.
However, ensure that all function calls to
generateReactKey
match the new signature.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify all function calls to `generateReactKey` match the new signature. # Test: Search for the function usage. Expect: Only occurrences of the new signature. rg --type ts -A 5 $'generateReactKey'Length of output: 114083
app/client/src/layoutSystems/anvil/utils/layouts/update/sectionUtils.ts (1)
Line range hint
89-144
:
Reminder: Address the maxChildLimit issue.The TODO comment indicates a potential issue with the maxChildLimit of 4 for sections. This needs to be addressed to prevent adding too many zones to a section.
Do you want me to help address this issue or open a GitHub issue to track this task?
Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Files selected for processing (4)
- app/client/src/layoutSystems/anvil/utils/layouts/update/sectionUtils.ts (1 hunks)
- app/client/src/layoutSystems/anvil/utils/layouts/update/zoneUtils.ts (1 hunks)
- app/client/src/layoutSystems/anvil/utils/sectionOperationUtils.ts (1 hunks)
- app/client/src/pages/Editor/widgetSidebar/WidgetCard.tsx (1 hunks)
Additional comments not posted (6)
app/client/src/pages/Editor/widgetSidebar/WidgetCard.tsx (1)
131-137
: LGTM! But verify the function usage in the codebase.The code changes are approved. The addition of a prefix to the widget ID generation will help in debugging and managing widgets.
However, ensure that all function calls to
generateReactKey
match the new signature.app/client/src/layoutSystems/anvil/utils/layouts/update/zoneUtils.ts (1)
40-40
: LGTM! But verify the function usage in the codebase.The code changes are approved. The addition of a prefix to the widget ID generation will help in debugging and managing widgets.
However, ensure that all function calls to
generateReactKey
match the new signature.app/client/src/layoutSystems/anvil/utils/layouts/update/sectionUtils.ts (4)
Line range hint
41-52
:
FunctionsplitWidgets
is well-implemented.The function correctly splits widgets into zones and non-zones.
Line range hint
54-87
:
FunctionaddZoneToSection
is well-implemented.The function correctly handles adding zones to sections, both for new and existing widgets.
Line range hint
146-168
:
FunctionmoveWidgetsToSection
is well-implemented.The function correctly handles moving widgets to a section and updating their relationships.
31-33
: LGTM! But verify the function usage in the codebase.The change to prefix
widgetId
with "section-" is a good practice for better identification and debugging. Ensure that all function calls tocreateSectionAndAddWidget
handle the newwidgetId
format correctly.Verification successful
Let's verify how the
widgetId
is handled in themainCanvasLayoutUtils.ts
file after calling thecreateSectionAndAddWidget
function to ensure the new format is correctly managed.
Function usage verified successfully!
The
widgetId
generated with the "section-" prefix is being correctly handled in themainCanvasLayoutUtils.ts
file. After callingcreateSectionAndAddWidget
, thewidgetId
is accessed and added tomainCanvasWidget.children
as expected.
mainCanvasLayoutUtils.ts
: Proper handling ofwidgetId
after callingcreateSectionAndAddWidget
.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify all function calls to `createSectionAndAddWidget` handle the new widgetId format correctly. # Test: Search for the function usage. Expect: Proper handling of the new widgetId format. rg --type ts -A 5 $'createSectionAndAddWidget'Length of output: 2068
Script:
#!/bin/bash # Description: Verify how `widgetId` is used in `mainCanvasLayoutUtils.ts` after calling `createSectionAndAddWidget`. # Test: Search for the usage of `widgetId` in `mainCanvasLayoutUtils.ts`. Expect: Proper handling of the new widgetId format. rg --type ts -A 10 'createSectionAndAddWidget' app/client/src/layoutSystems/anvil/utils/layouts/update/mainCanvasLayoutUtils.tsLength of output: 863
@@ -37,7 +37,7 @@ export function* createZoneAndAddWidgets( | |||
/** | |||
* Create Zone widget. | |||
*/ | |||
const widgetId: string = generateReactKey(); | |||
const widgetId: string = generateReactKey({ prefix: "zone-" }); |
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.
Do we need this for the rest of the widgets? 🤔 cc @riodeuno
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.
@KelvinOm could you clarify what you mean? We now have prefixes for zones, sections and component widgets. Are there other widgets I missed?
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.
I'm talking about other types of widgets, inputs, switches, checkboxes, and so on.
fb1cbe8
to
053f81f
Compare
This reverts commit 1668b04.
## Description This pull request fixes an issue where the error count was not being properly checked when a list widget was dropped. * Reverts a previous commit(#35221). * Include changes to the test file and the widget creation functions to ensure that the error count is correctly checked when a list widget is dragged and dropped. Fixes #35578 _or_ Fixes `Issue URL` > [!WARNING] > _If no issue exists, please create an issue first, and check with the maintainers if the issue is valid._ ## Automation /ok-to-test tags="@tag.All" ### 🔍 Cypress test results <!-- This is an auto-generated comment: Cypress test results --> > [!TIP] > 🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉 > Workflow run: <https://github.com/appsmithorg/appsmith/actions/runs/10350318730> > Commit: 07f3abc > <a href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=10350318730&attempt=1" target="_blank">Cypress dashboard</a>. > Tags: `@tag.All` > Spec: > <hr>Mon, 12 Aug 2024 11:35:20 UTC <!-- end of auto-generated comment: Cypress test results --> ## Communication Should the DevRel and Marketing teams inform users about this change? - [ ] Yes - [x] No <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Improved drag-and-drop functionality for list widgets. - **Bug Fixes** - Enhanced clarity and organization of test cases for better logical flow. - **Chores** - Simplified widget ID generation across several components, improving consistency in the application. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
Description
Add widget type to id in order to simplify debugging. For example
3jgf4p6owp
=>section-3jgf4p6owp
Automation
/ok-to-test tags="@tag.All"
🔍 Cypress test results
Tip
🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉
Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/10158529399
Commit: 053f81f
Cypress dashboard.
Tags:
@tag.All
Spec:
Tue, 30 Jul 2024 08:58:49 UTC
Communication
Should the DevRel and Marketing teams inform users about this change?
Summary by CodeRabbit
New Features
widgetId
generation, allowing for better identification of section and zone widgets.widgetId
prefixes.Bug Fixes