Skip to content

Commit

Permalink
add UPGRADE.md
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewdwallo committed Mar 19, 2024
1 parent c601fb0 commit 5570699
Show file tree
Hide file tree
Showing 13 changed files with 116 additions and 30 deletions.
93 changes: 93 additions & 0 deletions UPGRADE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
# Upgrade Guide

## Upgrading from FilamentCompanies 3.x to 4.x

This major release introduces significant changes designed to streamline the usage of FilamentCompanies. Here’s how to migrate your project from 3.x to 4.x.

### Breaking Changes

1. Removal of Classes:
- `Wallo\FilamentCompanies\Features`
- `Wallo\FilamentCompanies\Providers`
- `Wallo\FilamentCompanies\Socialite`

2. Introduction of Enums:
- Functionality previously available through the `Providers` class has been replaced by the `Wallo\FilamentCompanies\Enums\Provider` enum.
- Some functionality previously available through the `Socialite` class has been replaced by the `Wallo\FilamentCompanies\Enums\Feature` enum.

3. Removal of the `MakeUserCommand` command.
- It isn't necessary and was removed to simplify the package.

### Migration Steps

For Socialite providers, replace the usage of the `Wallo\FilamentCompanies\Providers` class with the `Wallo\FilamentCompanies\Enums\Provider` enum.

Before:

```php

use Wallo\FilamentCompanies\Providers;

// Enable the following Socialite providers.
Providers::github(),
// And so on for the other providers...

// Determine if the following Socialite providers are enabled.
Providers::hasGithub(),
// And so on for the other providers...
```

After:

```php

use Wallo\FilamentCompanies\Enums\Provider;

// Enable the following Socialite providers.
Provider::Github,
// And so on for the other providers...

// Determine if the following Socialite providers are enabled.
Provider::Github->isEnabled(),
// And so on for the other providers...

```

For Socialite features, replace the usage of the `Wallo\FilamentCompanies\Socialite` class with the `Wallo\FilamentCompanies\Enums\Feature` enum.

Before:

```php

use Wallo\FilamentCompanies\Socialite;

// Enable the following features.
Socialite::rememberSession(),
// And so on for the other features...

// Determine if the following features are enabled.
Socialite::hasRememberSessionFeature(),
// And so on for the other features...

```

After:

```php

use Wallo\FilamentCompanies\Enums\Feature;

// Enable the following features.
Feature::RememberSession,
// And so on for the other features...

// Determine if the following features are enabled.
Feature::RememberSession->isEnabled(),
// And so on for the other features...
```

### Important Notes
> The rest of the methods previously available in the `Socialite` and `Features` classes are still available and were moved to the main `Wallo\FilamentCompanies\FilamentCompanies` class.
### Further Assistance
Should you encounter any issues during the upgrade process, please don’t hesitate to reach out Discord or by creating a new Discussion on GitHub.
2 changes: 1 addition & 1 deletion resources/views/components/connected-account.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
$providerEnum = \Wallo\FilamentCompanies\Enums\Provider::tryFrom($provider);
@endphp

@if($providerEnum?->hasSupport())
@if($providerEnum?->isEnabled())
<div class="filament-companies-connected-account">
<div class="filament-companies-connected-account-container flex items-center justify-between">
<div class="filament-companies-connected-account-details flex items-center gap-x-2">
Expand Down
2 changes: 1 addition & 1 deletion resources/views/components/socialite.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

<div class="filament-companies-socialite-button-container mt-6 flex flex-wrap items-center justify-center gap-6">
@foreach (\Wallo\FilamentCompanies\Enums\Provider::cases() as $provider)
@if ($provider->hasSupport())
@if ($provider->isEnabled())
<a href="{{ \Wallo\FilamentCompanies\FilamentCompanies::generateOAuthRedirectUrl($provider->value) }}"
class="filament-companies-socialite-buttons inline-flex rounded-md border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-700 dark:focus:border-primary-500 py-2 px-4 shadow-sm hover:bg-gray-50 dark:hover:bg-gray-600">
<span class="sr-only">{{ $provider->getLabel() }}</span>
Expand Down
2 changes: 1 addition & 1 deletion src/Concerns/Base/HasRoutes.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public static function route(string $name, mixed $parameters = [], bool $absolut

public static function generateRouteName(string $name): string
{
return "filament." . static::getCompanyPanel() . ".{$name}";
return 'filament.' . static::getCompanyPanel() . ".{$name}";
}

public static function generateOAuthRedirectUrl(string $provider): string
Expand Down
3 changes: 2 additions & 1 deletion src/Concerns/Socialite/HasProviderFeatures.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,11 @@ public function setFeatures(?array $features = null): static
/**
* Check if the given feature is enabled.
*/
public static function isFeatureEnabled(Feature|string $feature): bool
public static function isFeatureEnabled(Feature | string $feature): bool
{
try {
$featureEnum = $feature instanceof Feature ? $feature : Feature::from($feature);

return in_array($featureEnum, static::$enabledFeatures, true);
} catch (ValueError) {
return false;
Expand Down
3 changes: 2 additions & 1 deletion src/Concerns/Socialite/HasProviders.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,11 @@ public function setProviders(?array $providers = null): static
/**
* Check if the given provider is enabled.
*/
public static function isProviderEnabled(Provider|string $provider): bool
public static function isProviderEnabled(Provider | string $provider): bool
{
try {
$providerEnum = $provider instanceof Provider ? $provider : Provider::from($provider);

return in_array($providerEnum, static::$enabledProviders, true);
} catch (ValueError) {
return false;
Expand Down
1 change: 0 additions & 1 deletion src/Concerns/Socialite/HasSocialiteProfileFeatures.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,4 @@ public static function canManageConnectedAccounts(): bool
{
return static::$canManageConnectedAccounts;
}

}
2 changes: 1 addition & 1 deletion src/Enums/Provider.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function getLabel(): string
};
}

public function hasSupport(): bool
public function isEnabled(): bool
{
return FilamentCompanies::isProviderEnabled($this);
}
Expand Down
8 changes: 0 additions & 8 deletions src/Features.php

This file was deleted.

20 changes: 10 additions & 10 deletions src/FilamentCompanies.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,26 +19,26 @@

class FilamentCompanies implements Plugin
{
use Concerns\ManagesProfileComponents;
use Concerns\Base\HasAddedProfileComponents;
use Concerns\Base\HasBaseActionBindings;
use Concerns\Base\HasBaseModels;
use Concerns\Base\HasPermissions;
use Concerns\Base\HasPanels;
use Concerns\Base\HasRoutes;
use Concerns\Base\HasBaseProfileComponents;
use Concerns\Base\HasBaseProfileFeatures;
use Concerns\Base\HasCompanyFeatures;
use Concerns\Base\HasModals;
use Concerns\Base\HasNotifications;
use Concerns\Base\HasPanels;
use Concerns\Base\HasPermissions;
use Concerns\Base\HasRoutes;
use Concerns\Base\HasTermsAndPrivacyPolicy;
use Concerns\Base\HasModals;
use Concerns\Base\HasAddedProfileComponents;
use Concerns\Socialite\HasProviders;
use Concerns\Socialite\HasProviderFeatures;
use Concerns\ManagesProfileComponents;
use Concerns\Socialite\CanEnableSocialite;
use Concerns\Socialite\HasConnectedAccountModel;
use Concerns\Socialite\HasProviderFeatures;
use Concerns\Socialite\HasProviders;
use Concerns\Socialite\HasSocialiteActionBindings;
use Concerns\Socialite\HasSocialiteComponents;
use Concerns\Socialite\HasSocialiteProfileFeatures;
use Concerns\Socialite\HasSocialiteActionBindings;
use Concerns\Socialite\CanEnableSocialite;

public function getId(): string
{
Expand Down
2 changes: 1 addition & 1 deletion src/Mail/CompanyInvitation.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,6 @@ public function build(): static
$acceptUrl = FilamentCompanies::generateAcceptInvitationUrl($this->invitation);

return $this->markdown('filament-companies::mail.company-invitation', compact('acceptUrl'))
->subject(__('Company Invitation'));
->subject(__('Company Invitation'));
}
}
4 changes: 2 additions & 2 deletions src/Pages/Auth/PrivacyPolicy.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ protected function getViewData(): array
];
}

public function getHeading(): string|Htmlable
public function getHeading(): string | Htmlable
{
return '';
}

public function getMaxWidth(): MaxWidth|string|null
public function getMaxWidth(): MaxWidth | string | null
{
return MaxWidth::TwoExtraLarge;
}
Expand Down
4 changes: 2 additions & 2 deletions src/Pages/Auth/Terms.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ protected function getViewData(): array
];
}

public function getHeading(): string|Htmlable
public function getHeading(): string | Htmlable
{
return '';
}

public function getMaxWidth(): MaxWidth|string|null
public function getMaxWidth(): MaxWidth | string | null
{
return MaxWidth::TwoExtraLarge;
}
Expand Down

0 comments on commit 5570699

Please sign in to comment.