feat(surveys): add permission check on committee Create Survey CTA click#1000
feat(surveys): add permission check on committee Create Survey CTA click#1000MRashad26 wants to merge 1 commit into
Conversation
Replace routerLink on both Create Survey buttons (table-actions slot and empty-state) with an onCreateSurvey() click handler that fetches fresh committee permissions via getCommittee() before navigating. If the member's role was downgraded from Manager to Member since the page loaded, the stale canEdit() signal would still show the button; the click handler catches this and redirects to the lens-appropriate overview (/foundation/overview or /project/overview) with _notice=surveys so AppComponent shows the "Access Denied" toast — consistent with the writerGuard denial flow. Signed-off-by: Rashad <mrashad@contractor.linuxfoundation.org>
WalkthroughBoth "Create Survey" buttons in ChangesPermission-gated Create Survey navigation
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
ESLint install failed. For unrecoverable errors, disable the tool in CodeRabbit configuration. Comment |
There was a problem hiding this comment.
Pull request overview
Adds a “fresh permission” check to the Committee Surveys tab’s Create Survey CTA so that stale, page-load-time canEdit() state can’t incorrectly allow navigation when committee write access has been revoked mid-session. This aligns the UX with the existing writerGuard denial flow by redirecting with _notice=surveys for the Access Denied toast, and makes the redirect lens-aware (foundation vs project).
Changes:
- Introduces
onCreateSurvey()that re-fetches committee permissions viaCommitteeService.getCommittee()before routing to/surveys/create. - On denied/errored permission refresh, redirects to
/foundation/overviewor/project/overviewwith_notice=surveys(andprojectwhen available) to trigger the standard Access Denied toast. - Replaces
[routerLink]navigation on both Create Survey buttons with the new click handler.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| apps/lfx-one/src/app/modules/committees/components/committee-surveys/committee-surveys.component.ts | Adds fresh committee permission check on CTA click and lens-aware denial redirect before navigating to survey creation. |
| apps/lfx-one/src/app/modules/committees/components/committee-surveys/committee-surveys.component.html | Routes Create Survey CTAs through (click)="onCreateSurvey()" instead of direct routerLink navigation. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
🧹 Nitpick comments (1)
apps/lfx-one/src/app/modules/committees/components/committee-surveys/committee-surveys.component.ts (1)
47-70: Button double-click during permission check — consistent with meetings component pattern.The
onCreateSurvey()method implements the same permission check pattern as theonScheduleMeeting()method in the meetings component, and both lack loading state protection. While multiple API calls won't cause functional issues (Angular Router handles duplicate navigations gracefully), consider adding a loading signal to disable the button during the check for better UX consistency.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@apps/lfx-one/src/app/modules/committees/components/committee-surveys/committee-surveys.component.ts` around lines 47 - 70, The onCreateSurvey method lacks loading state protection, allowing users to trigger multiple API calls by double-clicking the button during the permission check. Add a loading signal (similar to the meetings component's onScheduleMeeting pattern) that is set to true before initiating the getCommittee call and set to false in both the next and error callback handlers. Bind this loading signal to disable the create survey button to prevent duplicate submissions during the permission verification.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In
`@apps/lfx-one/src/app/modules/committees/components/committee-surveys/committee-surveys.component.ts`:
- Around line 47-70: The onCreateSurvey method lacks loading state protection,
allowing users to trigger multiple API calls by double-clicking the button
during the permission check. Add a loading signal (similar to the meetings
component's onScheduleMeeting pattern) that is set to true before initiating the
getCommittee call and set to false in both the next and error callback handlers.
Bind this loading signal to disable the create survey button to prevent
duplicate submissions during the permission verification.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 29baa182-25ea-4fbb-84d3-b3921f65a3a1
📒 Files selected for processing (2)
apps/lfx-one/src/app/modules/committees/components/committee-surveys/committee-surveys.component.htmlapps/lfx-one/src/app/modules/committees/components/committee-surveys/committee-surveys.component.ts
🚀 Deployment StatusYour branch has been deployed to: https://ui-pr-1000.dev.v2.cluster.linuxfound.info Deployment Details:
The deployment will be automatically removed when this PR is closed. |
Summary
canEdit()— derived fromcommittee.writerat page-load time. If the member's role is downgraded from Manager to Member after the page loads, the stale signal still shows the button.onCreateSurvey(), which fetches fresh committee permissions viagetCommittee()before navigating. On denial, redirects to the lens-appropriate overview (/foundation/overviewor/project/overview) with_notice=surveyssoAppComponent.initAccessDeniedToast()shows the "Access Denied" toast — consistent with thewriterGuarddenial flow and lens-aware (unlike the equivalent fix in feat(meetings): add access-denied toast and fix meeting coordinator permissions #992 for meetings).writerGuardon/surveys/createremains as the final safety net for direct URL access.Changed files
committee-surveys.component.tsCommitteeService,LensService,Router; addonCreateSurvey()click handler with fresh permission check and lens-aware deny redirectcommittee-surveys.component.html[routerLink]+[queryParams]on both Create Survey buttons with(click)="onCreateSurvey()"References
committee-votes(PR feat(votes): add permission check on committee Create Vote CTA click #997) andcommittee-meetings(PR feat(meetings): add access-denied toast and fix meeting coordinator permissions #992)Test plan
/surveys/createwithcommittee_uidandprojectquery paramscanEdit()) but clicking it redirects to the project overview with an "Access Denied" toast/foundation/overview, not/project/overview/surveys/create?committee_uid=...—writerGuardblocks and shows the toast