-
Notifications
You must be signed in to change notification settings - Fork 0
Unify access-control service API with resource-based methods #138
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
Conversation
Co-authored-by: TheRealSeber <111927572+TheRealSeber@users.noreply.github.com>
Co-authored-by: TheRealSeber <111927572+TheRealSeber@users.noreply.github.com>
TheRealSeber
left a comment
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.
@copilot please adjust
src/routes/dashboard/teacher/contests/[contestId]/collaborators/collaborators.remote.ts
Show resolved
Hide resolved
- Removed getAssignableUsers from remote functions (not used, getAllUsers with frontend filtering is used instead) - Removed all deprecated methods from AccessControlService - Updated all usages to use new unified methods (getCollaborators, addCollaborator, updateCollaborator, deleteCollaborator) - Removed unused Valibot schemas (CollaboratorSchema, AddCollaboratorRequestSchema, etc.) - Updated layout.server.ts files to use ResourceType enum Co-authored-by: TheRealSeber <111927572+TheRealSeber@users.noreply.github.com>
All feedback addressed in commit 103614a:
Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
|
@copilot please adjust src\routes\dashboard\teacher\tasks[taskId]\collaborators+page.svelte and src\routes\dashboard\teacher\contests[contestId]\collaborators+page.svelte. we shouldn't be using user query there, instead we should use assignable user (thus we won;t have to pre-filter students etc. on frontend anymore as backend handles it) |
- Added getAssignableUsers query to both task and contest collaborators remote files - Updated Svelte pages to call getAssignableUsers with taskId/contestId - Backend now handles filtering of students and existing collaborators - Removed client-side filtering logic from AddCollaboratorButton components - Removed existingCollaborators prop (no longer needed) - Removed UserService import from remote files Co-authored-by: TheRealSeber <111927572+TheRealSeber@users.noreply.github.com>
Updated both pages to use Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
3a69109 to
8689d05
Compare
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.
Pull request overview
This PR unifies the access-control service API by replacing resource-specific methods with generic resource-based methods that accept a ResourceType parameter. The changes align the frontend with backend API consolidation and introduce backend-filtered user assignment.
Key changes:
- Introduced
ResourceTypeenum and unified service methods (getCollaborators,addCollaborator, etc.) replacing separate task/contest-specific methods - Implemented backend
/assignableendpoint to retrieve assignable users, eliminating client-side filtering logic - Added task visibility toggle feature with confirmation dialog and i18n support
Reviewed changes
Copilot reviewed 22 out of 22 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| src/lib/dto/accessControl.ts | Added ResourceType enum and request interfaces for type-safe API calls |
| src/lib/services/AccessControlService.ts | Replaced 6 resource-specific methods with 4 unified methods accepting resourceType parameter |
| src/routes/dashboard/teacher/tasks/[taskId]/collaborators/collaborators.remote.ts | Updated to use unified API methods and getAssignableUsers endpoint |
| src/routes/dashboard/teacher/contests/[contestId]/collaborators/collaborators.remote.ts | Updated to use unified API methods and getAssignableUsers endpoint |
| src/routes/dashboard/teacher/tasks/[taskId]/+layout.server.ts | Updated getTaskCollaborators call to unified getCollaborators method |
| src/routes/dashboard/teacher/contests/[contestId]/+layout.server.ts | Updated getContestCollaborators call to unified getCollaborators method |
| src/routes/dashboard/user/contests/[contestId]/results/+layout.server.ts | Updated getContestCollaborators call to unified getCollaborators method |
| src/lib/components/dashboard/admin/tasks/AddCollaboratorButton.svelte | Removed existingCollaborators prop and client-side filtering logic |
| src/lib/components/dashboard/admin/contests/AddContestCollaboratorButton.svelte | Removed existingCollaborators prop and client-side filtering logic |
| src/routes/dashboard/teacher/tasks/[taskId]/collaborators/+page.svelte | Replaced getAllUsers with getAssignableUsers query |
| src/routes/dashboard/teacher/contests/[contestId]/collaborators/+page.svelte | Replaced getAllUsers with getAssignableUsers query |
| src/routes/dashboard/teacher/tasks/tasks.remote.ts | Added toggleTaskVisibility command for visibility management |
| src/lib/services/TasksManagementService.ts | Added toggleTaskVisibility service method |
| src/lib/dto/task.ts | Added isVisible field to Task and UploadTaskDto interfaces |
| src/lib/components/dashboard/admin/tasks/TaskVisibilityToggle.svelte | New component for toggling task visibility with confirmation |
| src/lib/components/dashboard/tasks/AdminTaskCard.svelte | Integrated TaskVisibilityToggle component |
| src/lib/components/dashboard/admin/tasks/TasksUploadDialog.svelte | Added visibility checkbox to upload form |
| src/lib/components/dashboard/admin/contests/EditContestDialog.svelte | Removed explicit id attributes from checkboxes |
| src/routes/dashboard/teacher/tasks/upload.remote.ts | Added isVisible field to upload schema and payload |
| src/routes/dashboard/teacher/contests/contests.remote.ts | Added debug console.log statement |
| messages/en.json | Added i18n strings for visibility toggle feature |
| messages/pl.json | Added Polish translations for visibility toggle feature |
Comments suppressed due to low confidence (1)
src/lib/components/dashboard/admin/contests/EditContestDialog.svelte:280
- The id attributes were removed from the Checkbox components, but the corresponding Label components still reference them via the for attribute (e.g., for="isRegistrationOpen", for="isSubmissionOpen", for="isVisible"). This breaks the label-checkbox association. Either keep the id attributes on the checkboxes or remove the for attributes from the labels.
<div class="flex items-center gap-3">
<Checkbox
{...updateContest.fields.isRegistrationOpen.as('checkbox')}
checked={contest.isRegistrationOpen}
/>
<Label for="isRegistrationOpen" class="cursor-pointer text-sm font-normal">
{m.admin_contests_form_registration_open()}
</Label>
</div>
<div class="flex items-center gap-3">
<Checkbox
{...updateContest.fields.isSubmissionOpen.as('checkbox')}
checked={contest.isSubmissionOpen}
/>
<Label for="isSubmissionOpen" class="cursor-pointer text-sm font-normal">
{m.admin_contests_form_submission_open()}
</Label>
</div>
<div class="flex items-center gap-3">
<Checkbox
{...updateContest.fields.isVisible.as('checkbox')}
checked={contest.isVisible}
/>
<Label for="isVisible" class="cursor-pointer text-sm font-normal">
{m.admin_contests_form_visible()}
</Label>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…ake task visibility editable (#138)
Backend API consolidated task/contest collaborator endpoints into generic resource-based paths (
/access-control/resources/{resource_type}/{resource_id}/...). Frontend had separate methods per resource type.Changes
ResourceTypeenum for type-safe resource typesresourceTypeparameter:getAssignableUsersendpoint to retrieve assignable users filtered by backendBackend Filtering Implementation
Replaced client-side user filtering with backend
/assignableendpoint:Before:
getAllUsers()existingCollaboratorsprop to componentsAfter:
getAssignableUsers(resourceId)endpointExample
All backend collaborator endpoints now covered with a clean, unified, type-safe implementation. Backend handles user filtering for better performance and separation of concerns.
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.