Skip to content
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

feat: add support for feature flags #1811

Merged
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ MAIL_PASSWORD="${DB_USERNAME}"
MAIL_FROM_ADDRESS=noreply@retroachievements.org
MAIL_FROM_NAME="${APP_NAME}"

# Feature Flags

FEATURE_BEAT=true

# Providers

CLAMAV_SKIP_VALIDATION=true
Expand Down
5 changes: 5 additions & 0 deletions app/Site/AppServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\Relation;
use Illuminate\Support\Facades\Blade;
use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Str;

Expand Down Expand Up @@ -55,6 +56,10 @@ public function boot(): void
$schedule->command(DeleteOverdueUserAccounts::class)->daily();
});

Blade::if('hasfeature', function ($feature) {
luchaos marked this conversation as resolved.
Show resolved Hide resolved
return config("feature.$feature", false);
});

/*
* https://josephsilber.com/posts/2018/07/02/eloquent-polymorphic-relations-morph-map
*/
Expand Down
2 changes: 2 additions & 0 deletions config/envy.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@
'REDIS_DB',
'REDIS_CACHE_DB',
'MYSQL_ATTR_SSL_CA',
// config/feature.php
'FEATURE_BEAT',
// config/filesystem.php
'AWS_ENDPOINT',
'AWS_URL',
Expand Down
10 changes: 10 additions & 0 deletions config/feature.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

return [

/*
* If true, player-facing beaten games UI/UX is enabled.
*/
'beat' => env('FEATURE_BEAT', false),

];
13 changes: 13 additions & 0 deletions resources/views/demo.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,19 @@
<code>{{ '<br>' }}</code>s are meant for single line breaks.
</p>
</x-section>

<x-section>
<h3>Feature Flags</h3>
<div class="flex justify-between">
<p>Beaten Games Player-facing UX</p>
@hasfeature("beat")
Enabled
@else
Disabled
@endhasfeature
</div>
</x-section>
luchaos marked this conversation as resolved.
Show resolved Hide resolved

<div>
This is not in a {{ '<section>' }}.
</div>
Expand Down
Loading