Repository navigation
feat: let organization admins choose its color #1303
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,15 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace App\Actions; | ||
|
|
||
| use App\Models\Profile; | ||
|
|
||
| final readonly class UpdateOrganizationLane | ||
| { | ||
| public function handle(Profile $organization, ?int $lane, ?string $color): void | ||
| { | ||
| $organization->update(['preferred_lane' => $lane, 'lane_color' => $color]); | ||
| } | ||
| } |
This file contains hidden or 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 hidden or 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,26 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace App\Http\Controllers; | ||
|
|
||
| use App\Actions\UpdateOrganizationLane; | ||
| use App\Http\Requests\UpdateOrganizationLaneRequest; | ||
| use App\Models\Profile; | ||
| use Illuminate\Http\RedirectResponse; | ||
| use Inertia\Inertia; | ||
|
|
||
| final readonly class OrganizationLaneController | ||
| { | ||
| public function update(UpdateOrganizationLaneRequest $request, Profile $organization, UpdateOrganizationLane $action): RedirectResponse | ||
| { | ||
| $action->handle($organization, $request->lane(), $request->color()); | ||
|
|
||
| Inertia::flash('toast', [ | ||
| 'type' => 'success', | ||
| 'message' => 'Color saved.', | ||
| ]); | ||
|
|
||
| return back(); | ||
| } | ||
| } |
This file contains hidden or 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,49 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace App\Http\Requests; | ||
|
|
||
| use App\Models\Profile; | ||
| use App\Models\User; | ||
| use Illuminate\Auth\Access\Response; | ||
| use Illuminate\Foundation\Http\FormRequest; | ||
|
|
||
| final class UpdateOrganizationLaneRequest extends FormRequest | ||
| { | ||
| /** | ||
| * Only the organization's admins choose its color. Users' profiles have no admins, so they look like they do not | ||
| * exist. | ||
| */ | ||
| public function authorize(): Response | ||
| { | ||
| $user = $this->user(); | ||
| assert($user instanceof User); | ||
|
|
||
| $organization = $this->route('organization'); | ||
| assert($organization instanceof Profile); | ||
|
|
||
| return $organization->admins()->whereKey($user->id)->exists() ? Response::allow() : Response::denyAsNotFound(); | ||
| } | ||
|
|
||
| /** | ||
| * @return array<string, array<int, string>> | ||
| */ | ||
| public function rules(): array | ||
| { | ||
| return [ | ||
| 'lane' => ['present', 'nullable', 'integer', 'between:0,5'], | ||
| 'color' => ['nullable', 'string', 'regex:/^#[0-9a-f]{6}$/', 'prohibits:lane'], | ||
| ]; | ||
| } | ||
|
|
||
| public function lane(): ?int | ||
| { | ||
| return $this->filled('lane') ? $this->integer('lane') : null; | ||
| } | ||
|
|
||
| public function color(): ?string | ||
| { | ||
| return $this->filled('color') ? $this->string('color')->toString() : null; | ||
| } | ||
| } | ||
This file contains hidden or 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 hidden or 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
23 changes: 23 additions & 0 deletions
23
database/migrations/2026_10_29_120000_add_lane_to_profiles_table.php
This file contains hidden or 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,23 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| use Illuminate\Database\Migrations\Migration; | ||
| use Illuminate\Database\Schema\Blueprint; | ||
| use Illuminate\Support\Facades\Schema; | ||
|
|
||
| return new class extends Migration | ||
| { | ||
| /** | ||
| * The color an organization's admins chose for its lane, like users': one from the palette or a custom one. Both | ||
| * empty is /dev/null's blue, which every organization has until its admins choose. | ||
| * Everyone sees it on the organization's page. It goes with the organization when GitHub no longer has it. | ||
| */ | ||
| public function up(): void | ||
| { | ||
| Schema::table('profiles', function (Blueprint $table): void { | ||
| $table->unsignedTinyInteger('preferred_lane')->nullable(); | ||
| $table->string('lane_color', 7)->nullable(); | ||
|
Comment on lines
+19
to
+20
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's weird to have 2 fields, but we're staying consistent with how it's implemented for users. Ideally later we refactor to store only the color, and merge both columns into one. but here we stay consistent with users. |
||
| }); | ||
| } | ||
|
coderabbitai[bot] marked this conversation as resolved.
Resolved
|
||
| }; | ||
This file contains hidden or 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 hidden or 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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Here we're hardcoding the permission check, that's because we're working on permissions in a separate PR, this should be refactored later to use a gate or policy.