Skip to content

Commit

Permalink
Fix styling
Browse files Browse the repository at this point in the history
  • Loading branch information
stephenjude authored and github-actions[bot] committed Feb 22, 2024
1 parent 25a52cd commit 5da220d
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 18 deletions.
12 changes: 6 additions & 6 deletions src/Models/FeatureSegment.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ public function resolve(mixed $scope): bool
* This check is TRUE if the segment is activated and the scope meets the criteria. Additionally,
* it returns TRUE if the segment is deactivated and doesn't meet the criteria.
*/
if (($this->active && $meetsSegmentCriteria) || (!$this->active && !$meetsSegmentCriteria)) {
if (($this->active && $meetsSegmentCriteria) || (! $this->active && ! $meetsSegmentCriteria)) {
return true;
}

/*
* This check is FALSE if the segment is activated and the scope doesn't meet the criteria.
* Additionally, it returns FALSE if the segment is deactivated and meet's the criteria.
*/
if (($this->active && !$meetsSegmentCriteria) || (!$this->active && $meetsSegmentCriteria)) {
if (($this->active && ! $meetsSegmentCriteria) || (! $this->active && $meetsSegmentCriteria)) {
return false;
}

Expand All @@ -50,12 +50,12 @@ public function resolve(mixed $scope): bool

public function title(): Attribute
{
return Attribute::get(fn() => class_exists($this->feature) ? $this->feature::title() : '(Feature Deleted)');
return Attribute::get(fn () => class_exists($this->feature) ? $this->feature::title() : '(Feature Deleted)');
}

public function description(): Attribute
{
return Attribute::get(fn() => sprintf(
return Attribute::get(fn () => sprintf(
'%s %s for customers who have any of these %s — %s.',
$this->title,
$this->active ? 'activated' : 'deactivated',
Expand All @@ -67,7 +67,7 @@ public function description(): Attribute
public static function allFeatures(): array
{
return collect(Feature::all())
->map(fn($value, $key) => [
->map(fn ($value, $key) => [
'id' => $key,
'name' => $name = str(class_basename($key))->snake()->replace('_', ' ')->title()->toString(),
'state' => $value,
Expand All @@ -86,7 +86,7 @@ public static function segmentOptionsList(): array
{
return collect(config('filament-feature-flags.segments'))
->pluck('column')
->mapWithKeys(fn($segment) => [$segment => str($segment)->plural()->title()->toString()])
->mapWithKeys(fn ($segment) => [$segment => str($segment)->plural()->title()->toString()])
->toArray();
}
}
18 changes: 9 additions & 9 deletions src/Resources/FeatureSegmentResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public static function form(Form $form): Form

Select::make('scope')
->live()
->afterStateUpdated(fn(Set $set) => $set('values', null))
->afterStateUpdated(fn (Set $set) => $set('values', null))
->required()
->columnSpanFull()
->options(FeatureSegment::segmentOptionsList()),
Expand All @@ -64,7 +64,7 @@ public static function form(Form $form): Form
->options([true => 'Activate', false => 'Deactivate'])
->unique(
ignoreRecord: true,
modifyRuleUsing: fn(Unique $rule, Get $get) => $rule
modifyRuleUsing: fn (Unique $rule, Get $get) => $rule
->where('feature', $get('feature'))
->where('scope', $get('scope'))
->where('active', $get('active'))
Expand All @@ -90,7 +90,7 @@ public static function table(Table $table): Table
->badge(),
Tables\Columns\TextColumn::make('status')
->badge()
->color(fn(string $state): string => match ($state) {
->color(fn (string $state): string => match ($state) {
'ACTIVATED' => 'success',
'DEACTIVATED' => 'danger',
})
Expand All @@ -110,20 +110,20 @@ public static function table(Table $table): Table
Tables\Actions\EditAction::make()
->label('Modify')
->modalHeading('Modify Feature Segment')
->after(fn(FeatureSegment $record) => FeatureSegmentModified::dispatch(
->after(fn (FeatureSegment $record) => FeatureSegmentModified::dispatch(
$record,
Filament::auth()->user()
)),

Tables\Actions\DeleteAction::make()
->modalHeading('Removing this feature segment cannot be undone!')
->modalDescription(fn(FeatureSegment $record) => $record->description)
->modalDescription(fn (FeatureSegment $record) => $record->description)
->label('Remove')
->before(fn(FeatureSegment $record) => RemovingFeatureSegment::dispatch(
->before(fn (FeatureSegment $record) => RemovingFeatureSegment::dispatch(
$record,
Filament::auth()->user()
))
->after(fn() => FeatureSegmentRemoved::dispatch(Filament::auth()->user())),
->after(fn () => FeatureSegmentRemoved::dispatch(Filament::auth()->user())),
]);
}

Expand All @@ -146,13 +146,13 @@ function ($segment) {

return Select::make('values')
->label(str($column)->plural()->title())
->hidden(fn(Get $get) => $get('scope') !== $column)
->hidden(fn (Get $get) => $get('scope') !== $column)
->required()
->multiple()
->searchable()
->columnSpanFull()
->getSearchResultsUsing(
fn(string $search): array => $model::where($value, 'like', "%{$search}%")
fn (string $search): array => $model::where($value, 'like', "%{$search}%")
->limit(50)->pluck($value, $key)->toArray()
);
}
Expand Down
6 changes: 3 additions & 3 deletions src/Traits/WithFeatureResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ trait WithFeatureResolver
*/
public function resolve(mixed $scope): bool
{
if (!is_a($scope, config('filament-feature-flags.scope'))) {
if (! is_a($scope, config('filament-feature-flags.scope'))) {
return config('filament-feature-flags.default');
}

Expand All @@ -24,8 +24,8 @@ public function resolve(mixed $scope): bool
return FeatureSegment::where('feature', get_class($this))
->get()
->whenEmpty(
fn() => config('filament-feature-flags.default'),
fn($segments) => $segments->map(fn(FeatureSegment $segment) => $segment->resolve($scope))
fn () => config('filament-feature-flags.default'),
fn ($segments) => $segments->map(fn (FeatureSegment $segment) => $segment->resolve($scope))
->doesntContain(
false
) // Makes sure that multiple segmentations are all true, if not resolve as false.
Expand Down

0 comments on commit 5da220d

Please sign in to comment.