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

chore: Adding create permission check for the plus button on tabs list #39672

Open
wants to merge 15 commits into
base: release
Choose a base branch
from

Conversation

ankitakinger
Copy link
Contributor

@ankitakinger ankitakinger commented Mar 11, 2025

Description

  • Adding create permission check for the plus button on tabs list to fix a bad UX on EE.
  • Removing an unused classname.
  • Updating filenames.
  • Updating storybook for Entity item.
  • Refactoring focus retention strategy function definition for getEntityParentUrl and updating handleRemoveFocusHistory in focus retention saga

Fixes #39673

Automation

/ok-to-test tags="@tag.All"

🔍 Cypress test results

Caution

🔴 🔴 🔴 Some tests have failed.
Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/13806079072
Commit: f26e5f4
Cypress dashboard.
Tags: @tag.All
Spec:
The following are new failures, please fix them before merging the PR:

  1. cypress/e2e/Regression/ClientSide/IDE/Canvas_Context_Property_Pane_1_spec.js
  2. cypress/e2e/Regression/ClientSide/IDE/Canvas_Context_Property_Pane_2_spec.js
  3. cypress/e2e/Regression/ClientSide/IDE/Canvas_Context_Selected_Widgets_spec.js
  4. cypress/e2e/Regression/ClientSide/IDE/Editor_Segment_Context_Switching_spec.ts
List of identified flaky tests.
Wed, 12 Mar 2025 09:14:58 UTC

Communication

Should the DevRel and Marketing teams inform users about this change?

  • Yes
  • No

Summary by CodeRabbit

  • New Features

    • Updated IDE tab behavior: The “Add” tab now displays more consistently with refined visibility conditions.
    • Enhanced Git workflows: Branch context is seamlessly incorporated during deletion and tab closure operations.
    • Improved Entity Explorer: Additional action controls now appear on hover for a smoother interactive experience.
    • Introduced new focus strategy types and interfaces for better navigation handling.
  • Style

    • Streamlined error notifications: Push failure warnings now present a cleaner and more consistent visual appearance.

@ankitakinger ankitakinger requested a review from a team as a code owner March 11, 2025 14:16
Copy link
Contributor

coderabbitai bot commented Mar 11, 2025

Walkthrough

This pull request updates the logic for rendering the "Add" tab in the IDE by refining permission checks and modifying the control flow. It also reorganizes focus-related type imports and declarations, moving them to a centralized module. New files and exports are introduced to facilitate this modularization, while unused exports are removed. Additionally, several saga functions have been updated to incorporate the current Git branch when handling focus history, and a minor DOM class removal and a storybook property addition have been made for styling and UI enhancements.

Changes

File(s) Change Summary
app/.../EditorTabs/index.tsx Updated logic to determine hideAdd by including canCreateActions in the condition and simplified conditional rendering for the AddTab.
app/.../FocusElements/AppIDE.ts, app/.../sagas/FocusRetentionSaga.ts, app/.../FocusStrategy/AppIDEFocusStrategy.ts, app/.../FocusStrategy/types.ts, app/.../ee/navigation/FocusStrategy/types.ts, app/.../FocusStrategy/NoIDEFocusStrategy.ts Replaced imports of focus-related types from "sagas/FocusRetentionSaga" with "ee/navigation/FocusStrategy/types", updated method signatures (using generator functions for getEntityParentUrl), and removed redundant type declarations.
app/.../AppIDEFocusSetters.ts New file: Re-exports all entities from "ce/navigation/AppIDEFocusSetters".
app/.../FocusSetters.ts Removed export statement for "ce/navigation/FocusSetters".
app/.../PushFailedWarning.tsx Removed the "ankita" class from the Container component for styling adjustments.
app/.../EntityItem/EntityItem.stories.tsx Added new property rightControlVisibility: "hover" to the EntityItem component's props in the story.
app/.../DatasourcesSagas.ts, app/.../JSActionSagas.ts, app/.../ActionSagas.ts, app/.../WidgetDeletionSagas.ts Added new imports and logic to select the current Git branch (selectGitApplicationCurrentBranch) and append it to URLs in calls to FocusRetention.handleRemoveFocusHistory, updating the branch context in saga operations.

Possibly related PRs

  • appsmithorg/appsmith#39470: The changes in the main PR, which modify the logic for displaying the "Add" tab based on user permissions, are related to the retrieved PR that removes the useCreateActionsPermissions hook, as both involve handling permissions for creating actions within the application.
  • appsmithorg/appsmith#38799: The changes in the main PR regarding the EditorTabs component's logic for displaying the "Add" tab are related to the modifications in the retrieved PR, which also involves the management of IDE tabs as part of the focus retention state.
  • appsmithorg/appsmith#37757: The changes in the main PR regarding the visibility and rendering logic of the "Add" tab in the EditorTabs component are related to the removal of the global add feature in the segmented header from the retrieved PR, as both involve modifications to the add functionality within the editor context.

Suggested labels

Enhancement, Bug

Suggested reviewers

  • ApekshaBhosale
  • hetunandu

Poem

In lines of code so neat and bright,
Tabs and types now dance in light.
Branches blend with saga flair,
Permissions, exports, all laid bare.
A code symphony of change and cheer,
Bringing fresh logic year to year!


📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro (Legacy)

📥 Commits

Reviewing files that changed from the base of the PR and between d0df6c6 and f26e5f4.

📒 Files selected for processing (1)
  • app/client/src/ce/sagas/JSActionSagas.ts (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • app/client/src/ce/sagas/JSActionSagas.ts
⏰ Context from checks skipped due to timeout of 90000ms (8)
  • GitHub Check: client-prettier / prettier-check
  • GitHub Check: client-lint / client-lint
  • GitHub Check: client-check-cyclic-deps / check-cyclic-dependencies
  • GitHub Check: client-unit-tests / client-unit-tests
  • GitHub Check: client-build / client-build
  • GitHub Check: storybook-tests
  • GitHub Check: chromatic-deployment
  • GitHub Check: chromatic-deployment

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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 using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions github-actions bot added the skip-changelog Adding this label to a PR prevents it from being listed in the changelog label Mar 11, 2025
@ankitakinger ankitakinger added the ok-to-test Required label for CI label Mar 11, 2025
@ankitakinger ankitakinger removed the request for review from a team March 11, 2025 14:33
@github-actions github-actions bot added IDE Pod Issues that new developers face while exploring the IDE IDE Product Issues related to the IDE Product Task A simple Todo labels Mar 11, 2025
@ankitakinger ankitakinger requested a review from hetunandu March 11, 2025 14:33
@ankitakinger ankitakinger requested a review from a team as a code owner March 11, 2025 17:00
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Inline review comments failed to post. This is likely due to GitHub's limits when posting large numbers of comments. If you are seeing this consistently it is likely a permissions issue. Please check "Moderation" -> "Code review limits" under your organization settings.

Actionable comments posted: 1

🔭 Outside diff range comments (1)
app/client/cypress/e2e/Regression/ServerSide/GenerateCRUD/Postgres2_Spec.ts (1)

1-731: 🛠️ Refactor suggestion

Replace Sleep and Wait calls with proper Cypress waiting mechanisms.

The test uses numerous instances of agHelper.Sleep() and cy.wait() which violate the coding guidelines and can lead to flaky tests. These fixed time delays should be replaced with Cypress's built-in waiting mechanisms.

Example patterns to use instead:

- agHelper.Sleep(2000);
+ cy.get('.selector').should('be.visible');
- cy.wait('@postExecute');
+ cy.wait('@postExecute').its('response.statusCode').should('eq', 200);
🧹 Nitpick comments (4)
app/server/appsmith-server/src/main/java/com/appsmith/server/datasourcestorages/base/DatasourceStorageServiceCEImpl.java (1)

280-293: Good implementation of metadata setting.

The method correctly retrieves and sets organization and instance IDs in the metadata map.

Consider adding error handling for cases where either Mono might fail, as this could affect the datasource storage flow.

 private Mono<DatasourceStorage> setAdditionalMetadataInDatasourceStorage(DatasourceStorage datasourceStorage) {
     Mono<String> organizationIdMono = organizationService.getCurrentUserOrganizationId();
     Mono<String> instanceIdMono = configService.getInstanceId();
 
     Map<String, Object> metadata = new HashMap<>();
 
-    return organizationIdMono.zipWith(instanceIdMono).map(tuple -> {
+    return organizationIdMono.zipWith(instanceIdMono)
+            .onErrorResume(error -> {
+                log.error("Error retrieving metadata for datasource storage: {}", error.getMessage());
+                return Mono.just(Tuples.of("", ""));
+            })
+            .map(tuple -> {
         // Change this to ORGANIZATION_ID once we have the organizationId field in the datasource storage
         metadata.put(ORGANIZATION_ID, tuple.getT1());
         metadata.put(INSTANCE_ID, tuple.getT2());
         datasourceStorage.setMetadata(metadata);
         return datasourceStorage;
-    });
+    });
 }
app/client/src/ce/navigation/FocusStrategy/types.ts (3)

22-24: Address eslint-disabled type issues now

Consider fixing the any types now rather than postponing. Using more specific types would improve type safety and make future maintenance easier.

-  // TODO: Fix this the next time the file is edited
-  // eslint-disable-next-line @typescript-eslint/no-explicit-any
-  ) => Generator<any, Array<FocusPath>, any>;
+  ) => Generator<unknown, Array<FocusPath>, unknown>;

29-31: Address eslint-disabled type issues now

Same issue here - consider addressing these type issues now rather than later.

-  // TODO: Fix this the next time the file is edited
-  // eslint-disable-next-line @typescript-eslint/no-explicit-any
-  ) => Generator<any, Array<FocusPath>, any>;
+  ) => Generator<unknown, Array<FocusPath>, unknown>;

41-43: Address eslint-disabled type issues now

And here as well - consider addressing these type issues now rather than later.

-  // TODO: Fix this the next time the file is edited
-  // eslint-disable-next-line @typescript-eslint/no-explicit-any
-  ) => Generator<any, void, any>;
+  ) => Generator<unknown, void, unknown>;
🛑 Comments failed to post (1)
app/client/src/ce/sagas/moduleInterfaceSagas.ts (1)

17-21: ⚠️ Potential issue

Generator function isn't using yield

The function is declared as a generator with the function* syntax, but it doesn't contain any yield statements. If this function doesn't need to yield control during execution, consider using a regular function instead.

-export function* handleModuleWidgetCreationSaga(
-  props: HandleModuleWidgetCreationSagaPayload,
-) {
-  return props.widgets;
-}
+export function handleModuleWidgetCreationSaga(
+  props: HandleModuleWidgetCreationSagaPayload,
+) {
+  return props.widgets;
+}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

export function handleModuleWidgetCreationSaga(
  props: HandleModuleWidgetCreationSagaPayload,
) {
  return props.widgets;
}
🧰 Tools
🪛 Biome (1.9.4)

[error] 17-21: This generator function doesn't contain yield.

(lint/correctness/useYield)

KelvinOm
KelvinOm previously approved these changes Mar 11, 2025
Copy link
Member

@hetunandu hetunandu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR has a lot of miscellaneous changes. Can we separate it out?

@@ -139,7 +103,11 @@ class FocusRetention {
parentElement,
);

removeKeys.push(`${parentPath}#${branch}`);
if (focusEntityInfo.params.basePageId) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This adds a implicit configuration which does something separately for AppIDE vs other IDEs. Since other IDEs could also have git, we should find a better way to identify this.

I this the focusStategy should define this instead of us doing this in this Saga

@ankitakinger ankitakinger requested a review from a team as a code owner March 12, 2025 06:10
@ankitakinger ankitakinger added ok-to-test Required label for CI and removed ok-to-test Required label for CI labels Mar 12, 2025
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro (Legacy)

📥 Commits

Reviewing files that changed from the base of the PR and between 6d8086b and eab2050.

📒 Files selected for processing (8)
  • app/client/src/ce/navigation/FocusStrategy/AppIDEFocusStrategy.ts (3 hunks)
  • app/client/src/ce/navigation/FocusStrategy/NoIDEFocusStrategy.ts (2 hunks)
  • app/client/src/ce/navigation/FocusStrategy/types.ts (1 hunks)
  • app/client/src/ce/sagas/DatasourcesSagas.ts (3 hunks)
  • app/client/src/ce/sagas/JSActionSagas.ts (3 hunks)
  • app/client/src/sagas/ActionSagas.ts (4 hunks)
  • app/client/src/sagas/FocusRetentionSaga.ts (2 hunks)
  • app/client/src/sagas/WidgetDeletionSagas.ts (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
  • app/client/src/sagas/FocusRetentionSaga.ts
  • app/client/src/ce/navigation/FocusStrategy/AppIDEFocusStrategy.ts
  • app/client/src/ce/navigation/FocusStrategy/types.ts
🧰 Additional context used
🪛 Biome (1.9.4)
app/client/src/ce/navigation/FocusStrategy/NoIDEFocusStrategy.ts

[error] 11-13: This generator function doesn't contain yield.

(lint/correctness/useYield)

⏰ Context from checks skipped due to timeout of 90000ms (9)
  • GitHub Check: perform-test / ci-test-result
  • GitHub Check: client-check-cyclic-deps / check-cyclic-dependencies
  • GitHub Check: client-unit-tests / client-unit-tests
  • GitHub Check: client-lint / client-lint
  • GitHub Check: client-prettier / prettier-check
  • GitHub Check: client-build / client-build
  • GitHub Check: chromatic-deployment
  • GitHub Check: storybook-tests
  • GitHub Check: chromatic-deployment
🔇 Additional comments (12)
app/client/src/ce/navigation/FocusStrategy/NoIDEFocusStrategy.ts (1)

1-1: Update to import source for FocusStrategy type looks good.

The import statement has been updated to use the centralized type definition from the EE module, which aligns with the architectural changes mentioned in the PR objectives.

app/client/src/ce/sagas/DatasourcesSagas.ts (3)

187-187: Import added for Git branch selection

The import for selectGitApplicationCurrentBranch from selectors/gitModSelectors supports the focus history enhancement.


445-447: Branch selection for focus history tracking

Good addition of branch context for focus history management.


457-460: Enhanced URL with branch information

The URL now includes the branch information as a fragment, improving focus history tracking across branches.

app/client/src/sagas/WidgetDeletionSagas.ts (3)

61-61: Import added for Git branch selection

The import for Git branch selector is consistent with other sagas.


342-349: Branch-aware focus history in widget deletion

Properly integrates branch context into focus history management for widget deletion.


495-503: Branch context added to bulk widget deletion

Correctly handles branch context for focus history in the bulk deletion saga.

app/client/src/ce/sagas/JSActionSagas.ts (2)

80-80: Import added for Git branch selection

The import for Git branch selector maintains consistency with other sagas.


337-349: Branch context added for JS collection deletion

Good integration of branch information in focus history for JS collection deletion.

app/client/src/sagas/ActionSagas.ts (3)

147-147: Import added for Git branch selection

Consistent with other sagas, the selector import enhances focus history functionality.


581-633: Branch context added to action deletion

Proper integration of branch information in focus history for action deletion.


1269-1276: Branch context added to action tab closure

The implementation correctly includes branch information for focus history tracking.

@KelvinOm KelvinOm requested review from KelvinOm and removed request for a team and KelvinOm March 12, 2025 08:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
IDE Pod Issues that new developers face while exploring the IDE IDE Product Issues related to the IDE Product ok-to-test Required label for CI skip-changelog Adding this label to a PR prevents it from being listed in the changelog Task A simple Todo
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Task]: Add permission check for the plus button in tabs list
3 participants