-
Notifications
You must be signed in to change notification settings - Fork 305
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Re-organize a bit controllers * Added the featureflagcontroller * Implement feature flags in the front-end * Clean env files * Clean console.log messages * Fix feature flag test
- Loading branch information
Showing
40 changed files
with
304 additions
and
147 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
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
41 changes: 41 additions & 0 deletions
41
api/app/Http/Controllers/Content/FeatureFlagsController.php
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,41 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers\Content; | ||
|
||
use App\Http\Controllers\Controller; | ||
|
||
class FeatureFlagsController extends Controller | ||
{ | ||
public function index() | ||
{ | ||
$featureFlags = \Cache::remember('feature_flags', 3600, function () { | ||
return [ | ||
'self_hosted' => config('app.self_hosted', true), | ||
'custom_domains' => config('custom_domains.enabled', false), | ||
'ai_features' => !empty(config('services.openai.api_key')), | ||
|
||
'billing' => [ | ||
'enabled' => !empty(config('cashier.key')) && !empty(config('cashier.secret')), | ||
'appsumo' => !empty(config('services.appsumo.api_key')) && !empty(config('services.appsumo.api_secret')), | ||
], | ||
'storage' => [ | ||
'local' => config('filesystems.default') === 'local', | ||
's3' => config('filesystems.default') !== 'local', | ||
], | ||
'services' => [ | ||
'unsplash' => !empty(config('services.unsplash.access_key')), | ||
'google' => [ | ||
'fonts' => !empty(config('services.google.fonts_api_key')), | ||
'auth' => !empty(config('services.google.client_id')) && !empty(config('services.google.client_secret')), | ||
], | ||
], | ||
'integrations' => [ | ||
'zapier' => config('services.zapier.enabled'), | ||
'google_sheets' => !empty(config('services.google.client_id')) && !empty(config('services.google.client_secret')), | ||
], | ||
]; | ||
}); | ||
|
||
return response()->json($featureFlags); | ||
} | ||
} |
7 changes: 6 additions & 1 deletion
7
api/app/Http/Controllers/FontsController.php → ...p/Controllers/Content/FontsController.php
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
<?php | ||
|
||
use App\Http\Controllers\Content\FeatureFlagsController; | ||
use Illuminate\Support\Facades\Cache; | ||
use Illuminate\Support\Facades\Config; | ||
|
||
it('returns feature flags', function () { | ||
// Arrange | ||
Config::set('app.self_hosted', false); | ||
Config::set('custom_domains.enabled', true); | ||
Config::set('cashier.key', 'stripe_key'); | ||
Config::set('cashier.secret', 'stripe_secret'); | ||
Config::set('services.appsumo.api_key', 'appsumo_key'); | ||
Config::set('services.appsumo.api_secret', 'appsumo_secret'); | ||
Config::set('filesystems.default', 's3'); | ||
Config::set('services.openai.api_key', 'openai_key'); | ||
Config::set('services.unsplash.access_key', 'unsplash_key'); | ||
Config::set('services.google.fonts_api_key', 'google_fonts_key'); | ||
Config::set('services.google.client_id', 'google_client_id'); | ||
Config::set('services.google.client_secret', 'google_client_secret'); | ||
Config::set('services.zapier.enabled', true); | ||
|
||
// Act | ||
$response = $this->getJson(route('content.feature-flags')); | ||
|
||
// Assert | ||
$response->assertStatus(200) | ||
->assertJson([ | ||
'self_hosted' => false, | ||
'custom_domains' => true, | ||
'ai_features' => true, | ||
'billing' => [ | ||
'enabled' => true, | ||
'appsumo' => true, | ||
], | ||
'storage' => [ | ||
'local' => false, | ||
's3' => true, | ||
], | ||
'services' => [ | ||
'unsplash' => true, | ||
'google' => [ | ||
'fonts' => true, | ||
'auth' => true, | ||
], | ||
], | ||
'integrations' => [ | ||
'zapier' => true, | ||
'google_sheets' => true, | ||
], | ||
]); | ||
}); | ||
|
||
it('caches feature flags', function () { | ||
// Arrange | ||
Cache::shouldReceive('remember') | ||
->once() | ||
->withArgs(function ($key, $ttl, $callback) { | ||
return $key === 'feature_flags' && $ttl === 3600 && is_callable($callback); | ||
}) | ||
->andReturn(['some' => 'data']); | ||
|
||
// Act | ||
$controller = new FeatureFlagsController(); | ||
$response = $controller->index(); | ||
|
||
// Assert | ||
$this->assertEquals(['some' => 'data'], $response->getData(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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,4 @@ | ||
NUXT_PUBLIC_APP_URL=/ | ||
NUXT_PUBLIC_API_BASE=/api | ||
NUXT_PRIVATE_API_BASE=http://ingress/api | ||
NUXT_PUBLIC_AI_FEATURES_ENABLED=false | ||
NUXT_PUBLIC_ENV=dev | ||
NUXT_PUBLIC_GOOGLE_ANALYTICS_CODE= | ||
NUXT_PUBLIC_H_CAPTCHA_SITE_KEY= | ||
NUXT_PUBLIC_S3_ENABLED=false | ||
NUXT_PUBLIC_ENV=dev |
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 |
---|---|---|
@@ -1,13 +1,9 @@ | ||
NUXT_LOG_LEVEL= | ||
NUXT_PUBLIC_APP_URL= | ||
NUXT_PUBLIC_API_BASE= | ||
NUXT_PUBLIC_AI_FEATURES_ENABLED= | ||
NUXT_PUBLIC_AMPLITUDE_CODE= | ||
NUXT_PUBLIC_CRISP_WEBSITE_ID= | ||
NUXT_PUBLIC_CUSTOM_DOMAINS_ENABLED= | ||
NUXT_PUBLIC_ENV= | ||
NUXT_PUBLIC_GOOGLE_ANALYTICS_CODE= | ||
NUXT_PUBLIC_H_CAPTCHA_SITE_KEY= | ||
NUXT_PUBLIC_PAID_PLANS_ENABLED= | ||
NUXT_PUBLIC_S3_ENABLED= | ||
NUXT_API_SECRET=secret |
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.