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

Implemented basic component authorization & ability to sort components #205

Merged
merged 5 commits into from
Aug 24, 2023

Conversation

boris-glumpler
Copy link
Contributor

I've added a basic static method MyProfileComponent::canView(). This is then being checked in BreezyCore::getRegisteredMyProfileComponents(). I've implemented this mainly for Sanctum tokens, but it might come in handy for other custom sections as well. It could then be used like so:

use Jeffgreco13\FilamentBreezy\Livewire\SanctumTokens;

class Sanctum extends SanctumTokens
{
    public static function canView(): bool
    {
        return current_member()->canUseFeature(API::class);
    }
}

@boris-glumpler boris-glumpler changed the title Implemented basic profile component authorization Implemented basic component authorization & ability to sort components Aug 11, 2023
@boris-glumpler
Copy link
Contributor Author

I have just pushed some additional changes that let you sort profile components. For this I hijacked the existing $sort property. As far as I could tell it wasn't being used, so I made it static, added some helper methods and gave the package components some sensible defaults.

To change the order of a package component you can now do something like this in a service provider:

TwoFactorAuthentication::setSort(4);

I've spaced the default order out a bit, so mostly this won't be necessary.

return true;
}

public static function sort(): int
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think this should be getSort

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@boris-glumpler I agree with this, could you update to getSort to match Filament?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

@jeffgreco13 jeffgreco13 merged commit 4e4841c into jeffgreco13:2.x Aug 24, 2023
@boris-glumpler boris-glumpler deleted the component-authorization branch August 24, 2023 22:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants