Skip to content

fix(web): remove orphaned hasPermission inline body in roles-manager#1433

Merged
MODSetter merged 1 commit into
MODSetter:devfrom
suryo12:fix/roles-manager-orphaned-hasPermission
May 25, 2026
Merged

fix(web): remove orphaned hasPermission inline body in roles-manager#1433
MODSetter merged 1 commit into
MODSetter:devfrom
suryo12:fix/roles-manager-orphaned-hasPermission

Conversation

@suryo12
Copy link
Copy Markdown
Contributor

@suryo12 suryo12 commented May 24, 2026

Removes orphaned arrow-function code left behind in roles-manager.tsx after PR #1428 (for issue #1366) extracted hasPermission into the shared canPerform helper. The leftover lines produce a parse error that breaks pnpm build and currently fails the E2E job on every PR targeting dev.

Description

components/settings/roles-manager.tsx ends up with two function bodies stacked on top of each other after the merge — the new useCallback(canPerform(...)) block closes correctly, then a second arrow function, its dependency array, and a trailing ) follow with no enclosing call. This patch deletes those orphan lines.

Before:

const hasPermission = useCallback(
    (permission: string) => canPerform(access, permission),
    [access]
);
    (permission: string) => {
        if (!access) return false;
        if (access.is_owner) return true;
        return access.permissions?.includes(permission) ?? false;
    },
    [access]
);

After:

const hasPermission = useCallback(
    (permission: string) => canPerform(access, permission),
    [access]
);

The remaining useCallback already supplies the same predicate the duplicated body computed (canPerform was extracted from that exact body in #1428), so behavior is unchanged.

Motivation and Context

Currently any PR opened against dev fails the Journey E2E job because Playwright's webServer runs pnpm build && pnpm start in CI — and pnpm build exits 1 with Expression expected on roles-manager.tsx:269. Confirmed locally on a clean dev checkout. After this patch pnpm build completes successfully.

Sister file app/dashboard/[search_space_id]/team/team-content.tsx (the other file #1428 touched) was migrated cleanly and is not affected.

Screenshots

N/A — bug fix, no UI change.

API Changes

  • This PR includes API changes

Change Type

  • Bug fix

Testing Performed

  • Reproduced the failure on a clean dev checkout: pnpm build exits 1 with Expression expected at roles-manager.tsx:269.

  • After the patch: pnpm build completes successfully, pnpm exec biome check ./components/settings/roles-manager.tsx passes.

  • No behavior to QA — the deleted lines were never reachable code.

  • Tested locally

  • Manual/QA verification

Checklist

  • Follows project coding standards and conventions
  • Documentation updated as needed
  • Dependencies updated as needed
  • No lint/build errors or new warnings
  • All relevant tests are passing

High-level PR Summary

This PR fixes a build-breaking syntax error in roles-manager.tsx by removing orphaned code leftover from a previous refactoring. After PR #1428 extracted the hasPermission logic into a shared canPerform helper, duplicate function body lines were inadvertently left behind, causing parse errors that broke pnpm build and failed E2E tests. The fix also reorders the import statement for consistency.

⏱️ Estimated Review Time: 5-15 minutes

💡 Review Order Suggestion
Order File Path
1 surfsense_web/components/settings/roles-manager.tsx

Need help? Join our Discord

PR MODSetter#1428 (issue MODSetter#1366) extracted the inline `hasPermission` callback into
a shared `canPerform` helper but left the original arrow-function body,
its dependency array, and trailing `)` behind after the new
`useCallback` block. The result was a syntactically invalid statement
that broke `pnpm build` on the `dev` branch and is now blocking every
E2E job in the PR queue.

Delete the orphaned lines so the file parses again. No behavior change —
the working `useCallback(canPerform(access, permission))` already
supplies the same predicate the duplicated body did.
Copilot AI review requested due to automatic review settings May 24, 2026 10:29
@vercel
Copy link
Copy Markdown

vercel Bot commented May 24, 2026

@suryo12 is attempting to deploy a commit to the Rohan Verma's projects Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 24, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 8c11e39b-2f50-49b5-9e3c-b5486968dee8

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Refactors roles permission checking in the settings UI to reuse a shared canPerform helper instead of inlining permission logic.

Changes:

  • Reordered imports to include canPerform alongside myAccessAtom.
  • Removed the inline permission-checking implementation and delegated checks to the shared canPerform(access, permission) helper.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 260 to 262
(permission: string) => canPerform(access, permission),
[access]
);
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The local callback here is hasPermission, not canPerform, so there's no shadow — canPerform resolves to the imported helper on line 29. The sister file team-content.tsx (touched in the same originating PR #1428) ships the identical pattern, so this patch only restores parity. No rename needed.

@MODSetter MODSetter merged commit 18c6640 into MODSetter:dev May 25, 2026
5 of 9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants