-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Feature] new Community Manager role (#8094)
* Add community manager to rolepermission seeder * Give community managers ability to assign any team role this will work better long term, AND be easier to implement * create assignUserToTeam mutation * Update mutation to affect only single user and single team * Use User query with reduced scope, and don't for it to render table Instead of Users query, get UserPublicProfiles, a safer query available to more user roles, and sufficient since we only need names. Also, don't wait for the potentially long-running user query to render the table, since its only required for adding new users to team. * Abuse useMemo to avoid infinite re-rendering * Show loading message on disabled Select until users are loaded * Test community-manager role permissions * Add PHPUnit tests for new mutation * Check in Role enum * Allow Community Manager to access some admin pages * Seed comunity manager * Reveal relevant links to Community Mngrs, on Admin * Seed PlatformAdmin with all roles * ensure authorizedToView scope doesn't block viewing of basic info * Allow Community Managers to view all pools * Use new mutation when editing roles on Team Members page * Add french translation * Remove unused variables * Reverse change to user scopeAuthorizedToView * Fix form input id * Combine mutation arguments * Add authorizedToView scope so Community Manager can view Pool pages (when not allowed to view candidates) * Allow Community Managers to publish pools * ACTUALLY allow Community Managers to publish pools * Run PHP linter --------- Co-authored-by: tristan-orourke <tristan.orourke@gmail.com>
- Loading branch information
1 parent
524e8cd
commit 90bfd94
Showing
27 changed files
with
713 additions
and
118 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?php | ||
|
||
namespace App\Enums; | ||
|
||
enum Role: string | ||
{ | ||
case BASE_USER = 'base_user'; | ||
case APPLICANT = 'applicant'; | ||
case POOL_OPERATOR = 'pool_operator'; | ||
case REQUEST_RESPONDER = 'request_responder'; | ||
case COMMUNITY_MANAGER = 'community_manager'; | ||
case PLATFORM_ADMIN = 'platform_admin'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
|
||
namespace App\GraphQL\Mutations; | ||
|
||
use App\Models\Team; | ||
use App\Models\User; | ||
|
||
final class UpdateUserTeamRoles | ||
{ | ||
/** | ||
* Duplicates a pool | ||
* | ||
* @param array{} $args | ||
*/ | ||
public function __invoke($_, array $args) | ||
{ | ||
$team = Team::find($args['teamId']); // Even if we don't use the whole team object, ensure it exists. | ||
$user = User::find($args['userId']); | ||
|
||
// Assemble a roleAssignments object which makes sense to User->setRoleAssignmentsInputAttribute | ||
// Do this by inserting the team id into each attach/detach/sync key of role assignments | ||
$roleAssignments = $args['roleAssignments']; | ||
foreach ($roleAssignments as $key => $value) { | ||
$roleAssignments[$key]['team'] = $team->id; | ||
} | ||
$user->setRoleAssignmentsInputAttribute($roleAssignments); | ||
|
||
return $team->fresh(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
|
||
namespace App\GraphQL\Validators; | ||
|
||
use Illuminate\Validation\Rule; | ||
use Nuwave\Lighthouse\Validation\Validator; | ||
|
||
final class TeamRolesInputValidator extends Validator | ||
{ | ||
public function __construct() | ||
{ | ||
} | ||
|
||
/** | ||
* Return the validation rules. | ||
* | ||
* @return array<string, array<mixed>> | ||
*/ | ||
public function rules(): array | ||
{ | ||
return [ | ||
'roles.*' => [ | ||
'distinct', | ||
Rule::exists('roles', 'id')->where(function ($query) { | ||
return $query->where('is_team_based', true); | ||
}), | ||
], | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.