Skip to content

Commit

Permalink
Merge pull request #18 from andrewdwallo/1.x-dev
Browse files Browse the repository at this point in the history
Update Ui
  • Loading branch information
andrewdwallo authored Jan 15, 2023
2 parents 0afb99a + e863a9b commit 76fc9f3
Show file tree
Hide file tree
Showing 7 changed files with 70 additions and 69 deletions.
4 changes: 4 additions & 0 deletions database/factories/UserFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@ public function definition(): array
'email' => $this->faker->unique()->safeEmail(),
'email_verified_at' => now(),
'password' => '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi', // password
'two_factor_secret' => null,
'two_factor_recovery_codes' => null,
'remember_token' => Str::random(10),
'profile_photo_path' => null,
'current_team_id' => null,
];
}

Expand Down
21 changes: 8 additions & 13 deletions resources/views/companies/company-employee-manager.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,8 @@ class="{{ $addCompanyEmployeeForm['role'] == $role->key ? 'font-semibold' : '' }
</div>

@if ($addCompanyEmployeeForm['role'] == $role->key)
<svg class="ml-2 h-5 w-5 text-primary-500" fill="none"
stroke-linecap="round" stroke-linejoin="round"
stroke-width="2" stroke="currentColor" viewBox="0 0 24 24">
<path d="M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z">
</path>
<svg class="ml-2 h-5 w-5 text-primary-500" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" d="M9 12.75L11.25 15 15 9.75M21 12a9 9 0 11-18 0 9 9 0 0118 0z" />
</svg>
@endif
</div>
Expand Down Expand Up @@ -213,10 +210,8 @@ class="{{ $currentRole == $role->key ? 'font-semibold' : '' }} text-sm text-gray
</div>

@if ($currentRole == $role->key)
<svg class="ml-2 h-5 w-5 text-green-400" fill="none" stroke-linecap="round"
stroke-linejoin="round" stroke-width="2" stroke="currentColor"
viewBox="0 0 24 24">
<path d="M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"></path>
<svg class="ml-2 h-5 w-5 text-primary-500" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" d="M9 12.75L11.25 15 15 9.75M21 12a9 9 0 11-18 0 9 9 0 0118 0z" />
</svg>
@endif
</div>
Expand Down Expand Up @@ -254,11 +249,11 @@ class="{{ $currentRole == $role->key ? 'font-semibold' : '' }} text-sm text-gray
</x-slot>

<x-slot name="footer">
<x-filament::button wire:click="$toggle('confirmingLeavingCompany')" wire:loading.attr="disabled">
<x-filament::button class="mr-3" color="gray" wire:click="$toggle('confirmingLeavingCompany')" wire:loading.attr="disabled">
{{ __('filament-companies::default.buttons.cancel') }}
</x-filament::button>

<x-filament::button class="ml-3" wire:click="leaveCompany" wire:loading.attr="disabled">
<x-filament::button class="ml-3" color="danger" class="ml-3" wire:click="leaveCompany" wire:loading.attr="disabled">
{{ __('filament-companies::default.buttons.leave') }}
</x-filament::button>
</x-slot>
Expand All @@ -275,11 +270,11 @@ class="{{ $currentRole == $role->key ? 'font-semibold' : '' }} text-sm text-gray
</x-slot>

<x-slot name="footer">
<x-filament::button wire:click="$toggle('confirmingCompanyEmployeeRemoval')" wire:loading.attr="disabled">
<x-filament::button color="gray" class="mr-3" wire:click="$toggle('confirmingCompanyEmployeeRemoval')" wire:loading.attr="disabled">
{{ __('filament-companies::default.buttons.cancel') }}
</x-filament::button>

<x-filament::button class="ml-3" wire:click="removeCompanyEmployee" wire:loading.attr="disabled">
<x-filament::button color="danger" class="ml-3" wire:click="removeCompanyEmployee" wire:loading.attr="disabled">
{{ __('filament-companies::default.buttons.remove') }}
</x-filament::button>
</x-slot>
Expand Down
64 changes: 41 additions & 23 deletions resources/views/components/dropdown/navigation-menu.blade.php
Original file line number Diff line number Diff line change
@@ -1,47 +1,65 @@
<div class="flex justify-end">
@if (Wallo\FilamentCompanies\FilamentCompanies::hasCompanyFeatures())
<x-filament::dropdown placement="bottom-end">
<x-slot name="trigger" class="ml-4">
<button @class([
'inline-flex items-center px-3 py-2 border border-transparent text-sm text-gray-800 hover:text-primary-500 leading-4 font-medium rounded-md bg-white hover:bg-gray-50 focus:outline-none focus:bg-gray-50 active:bg-gray-50 transition',
'dark:bg-gray-800 dark:hover:bg-gray-700 dark:border-white dark:hover:border-primary-400 dark:text-white dark:hover:text-primary-400' => config('filament.dark_mode'),
])>
{{ Auth::user()->currentCompany->name }}
<svg class="ml-2 -mr-0.5 h-4 w-4" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" d="M8.25 15L12 18.75 15.75 15m-7.5-6L12 5.25 15.75 9" />
</svg>
</button>
<x-filament::dropdown placement="bottom-start">
<x-slot name="trigger">
<span class ="inline-flex rounded-md">
<button @class([
'inline-flex items-center px-3 py-2 border border-transparent text-sm text-gray-800 leading-4 font-medium rounded-md bg-white hover:bg-gray-50 focus:outline-none focus:bg-gray-50 active:bg-gray-50 transition',
'dark:bg-gray-800 dark:hover:bg-gray-700 dark:border-white dark:hover:border-primary-400 dark:text-white dark:hover:text-primary-400' => config('filament.dark_mode'),
])>
{{ Auth::user()->currentCompany->name }}
<svg class="ml-2 -mr-0.5 h-4 w-4" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" d="M8.25 15L12 18.75 15.75 15m-7.5-6L12 5.25 15.75 9" />
</svg>
</button>
</span>
</x-slot>

<!-- Company Management -->
<x-filament::dropdown.header :icon="'heroicon-s-user-group'">
{{ __('filament-companies::default.navigation.headers.manage_company') }}
<x-filament::dropdown.header>
<div class="flex items-center">
<svg class="mr-2 h-5 w-5 rtl:ml2 rtl:mr-0 dark:text-primary-500" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" d="M18 18.72a9.094 9.094 0 003.741-.479 3 3 0 00-4.682-2.72m.94 3.198l.001.031c0 .225-.012.447-.037.666A11.944 11.944 0 0112 21c-2.17 0-4.207-.576-5.963-1.584A6.062 6.062 0 016 18.719m12 0a5.971 5.971 0 00-.941-3.197m0 0A5.995 5.995 0 0012 12.75a5.995 5.995 0 00-5.058 2.772m0 0a3 3 0 00-4.681 2.72 8.986 8.986 0 003.74.477m.94-3.197a5.971 5.971 0 00-.94 3.197M15 6.75a3 3 0 11-6 0 3 3 0 016 0zm6 3a2.25 2.25 0 11-4.5 0 2.25 2.25 0 014.5 0zm-13.5 0a2.25 2.25 0 11-4.5 0 2.25 2.25 0 014.5 0z"/>
</svg>
{{ __('filament-companies::default.navigation.headers.manage_company') }}
</div>
</x-filament::dropdown.header>

<!-- Company Settings -->
<x-filament::dropdown.list>
<x-filament::dropdown.list.item :icon="'heroicon-s-cog'">
<x-filament-companies::dropdown-link href="{{ url(\Wallo\FilamentCompanies\Pages\Companies\CompanySettings::getUrl()) }}">
<x-filament::dropdown.list.item href="{{ url(\Wallo\FilamentCompanies\Pages\Companies\CompanySettings::getUrl()) }}" tag="a">
<div class="flex items-center">
<svg class="mr-2 h-5 w-5 rtl:ml2 rtl:mr-0 group-hover:text-white group-focus:text-white dark:text-primary-500" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" d="M4.5 12a7.5 7.5 0 0015 0m-15 0a7.5 7.5 0 1115 0m-15 0H3m16.5 0H21m-1.5 0H12m-8.457 3.077l1.41-.513m14.095-5.13l1.41-.513M5.106 17.785l1.15-.964m11.49-9.642l1.149-.964M7.501 19.795l.75-1.3m7.5-12.99l.75-1.3m-6.063 16.658l.26-1.477m2.605-14.772l.26-1.477m0 17.726l-.26-1.477M10.698 4.614l-.26-1.477M16.5 19.794l-.75-1.299M7.5 4.205L12 12m6.894 5.785l-1.149-.964M6.256 7.178l-1.15-.964m15.352 8.864l-1.41-.513M4.954 9.435l-1.41-.514M12.002 12l-3.75 6.495"/>
</svg>
{{ __('filament-companies::default.navigation.links.company_settings') }}
</x-filament-companies::dropdown-link>
</div>
</x-filament::dropdown.list.item>

@can('create', Wallo\FilamentCompanies\FilamentCompanies::newCompanyModel())
<x-filament::dropdown.list.item :icon="'heroicon-s-plus-circle'">
<x-filament-companies::dropdown-link href="{{ url(\Wallo\FilamentCompanies\Pages\Companies\CreateCompany::getUrl()) }}">
<x-filament::dropdown.list.item href="{{ url(\Wallo\FilamentCompanies\Pages\Companies\CreateCompany::getUrl()) }}" tag="a">
<div class="flex items-center">
<svg class="mr-2 h-5 w-5 rtl:ml2 rtl:mr-0 group-hover:text-white group-focus:text-white dark:text-primary-500" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" d="M12 9v6m3-3H9m12 0a9 9 0 11-18 0 9 9 0 0118 0z"/>
</svg>
{{ __('filament-companies::default.navigation.links.new_company') }}
</x-filament-companies::dropdown-link>
</div>
</x-filament::dropdown.list.item>
@endcan

<div class="border-t border-gray-100"></div>
<x-filament::hr />

<!-- Company Switcher -->
<x-filament::dropdown.header :icon="'heroicon-s-adjustments'">
{{ __('filament-companies::default.navigation.headers.switch_companies') }}
<x-filament::dropdown.header>
<div class="flex items-center">
<svg class="mr-2 h-5 w-5 rtl:ml2 rtl:mr-0 dark:text-primary-500" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" d="M6 13.5V3.75m0 9.75a1.5 1.5 0 010 3m0-3a1.5 1.5 0 000 3m0 3.75V16.5m12-3V3.75m0 9.75a1.5 1.5 0 010 3m0-3a1.5 1.5 0 000 3m0 3.75V16.5m-6-9V3.75m0 3.75a1.5 1.5 0 010 3m0-3a1.5 1.5 0 000 3m0 9.75V10.5"/>
</svg>
{{ __('filament-companies::default.navigation.headers.switch_companies') }}
</div>
</x-filament::dropdown.header>

<div class="border-t border-gray-100"></div>
<x-filament::hr />

@foreach (Auth::user()->allCompanies() as $company)
<x-filament-companies::switchable-company :company="$company" />
Expand Down
4 changes: 3 additions & 1 deletion resources/views/components/switchable-company.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
<x-dynamic-component :component="$component" href="#" x-on:click.prevent="$root.submit();">
<div class="flex items-center">
@if (Auth::user()->isCurrentCompany($company))
<x-heroicon-s-check-circle wire:target class="mr-2 h-5 w-5 rtl:ml-2 rtl:mr-0 group-hover:text-white group-focus:text-white text-primary-500" />
<svg class="mr-2 h-5 w-5 rtl:ml-2 rtl:mr-0 group-hover:text-white group-focus:text-white dark:text-primary-500" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" d="M9 12.75L11.25 15 15 9.75M21 12a9 9 0 11-18 0 9 9 0 0118 0z" />
</svg>
@endif

<div class="truncate">{{ $company->name }}</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,13 @@
<div class="flex items-center">
<div>
@if ($session->agent->isDesktop())
<svg fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
viewBox="0 0 24 24" stroke="currentColor" class="h-8 w-8 text-gray-500">
<path
d="M9.75 17L9 20l-1 1h8l-1-1-.75-3M3 13h18M5 17h14a2 2 0 002-2V5a2 2 0 00-2-2H5a2 2 0 00-2 2v10a2 2 0 002 2z">
</path>
</svg>
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-8 h-8 text-gray-500">
<path stroke-linecap="round" stroke-linejoin="round" d="M9 17.25v1.007a3 3 0 01-.879 2.122L7.5 21h9l-.621-.621A3 3 0 0115 18.257V17.25m6-12V15a2.25 2.25 0 01-2.25 2.25H5.25A2.25 2.25 0 013 15V5.25m18 0A2.25 2.25 0 0018.75 3H5.25A2.25 2.25 0 003 5.25m18 0V12a2.25 2.25 0 01-2.25 2.25H5.25A2.25 2.25 0 013 12V5.25" />
</svg>
@else
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" stroke-width="2"
stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"
class="h-8 w-8 text-gray-500">
<path d="M0 0h24v24H0z" stroke="none"></path>
<rect x="7" y="4" width="10" height="16" rx="1">
</rect>
<path d="M11 5h2M12 17v.01"></path>
</svg>
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-8 h-8 text-gray-500">
<path stroke-linecap="round" stroke-linejoin="round" d="M10.5 1.5H8.25A2.25 2.25 0 006 3.75v16.5a2.25 2.25 0 002.25 2.25h7.5A2.25 2.25 0 0018 20.25V3.75a2.25 2.25 0 00-2.25-2.25H13.5m-3 0V3h3V1.5m-3 0h3m-3 18.75h3" />
</svg>
@endif
</div>

Expand Down
9 changes: 7 additions & 2 deletions tests/OrchestraTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Laravel\Fortify\FortifyServiceProvider;
use Wallo\FilamentCompanies\Features;
use Wallo\FilamentCompanies\FilamentCompaniesServiceProvider;
use Mockery;
use Orchestra\Testbench\TestCase;
use Livewire\LivewireServiceProvider;

Expand Down Expand Up @@ -33,8 +34,6 @@ protected function getPackageProviders($app)

protected function defineEnvironment($app)
{
$app['migrator']->path(__DIR__.'/../database/migrations');

$app['config']->set('database.default', 'testbench');

$app['config']->set('database.connections.testbench', [
Expand All @@ -44,6 +43,12 @@ protected function defineEnvironment($app)
]);
}

protected function defineDatabaseMigrations()
{
$this->loadMigrationsFrom(__DIR__.'/../database/migrations');
$this->loadMigrationsFrom(__DIR__.'/../vendor/laravel/fortify/database/migrations');
}

protected function defineHasCompanyEnvironment($app)
{
$features = $app->config->get('filament-companies.features', []);
Expand Down
17 changes: 1 addition & 16 deletions tests/UserProfileControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@

namespace Wallo\FilamentCompanies\Tests;

use Illuminate\Support\Facades\Schema;
use Laravel\Fortify\Actions\DisableTwoFactorAuthentication;
use Laravel\Fortify\Features;
use Wallo\FilamentCompanies\FilamentCompanies;
use Wallo\FilamentCompanies\Tests\Fixtures\User;

use Mockery as m;
class UserProfileControllerTest extends OrchestraTestCase
{
public function setUp(): void
Expand Down Expand Up @@ -39,8 +38,6 @@ public function test_empty_two_factor_state_is_noted()

public function test_two_factor_is_not_disabled_if_was_previously_empty_and_currently_confirming()
{
$this->migrate();

$disable = $this->mock(DisableTwoFactorAuthentication::class);
$disable->shouldReceive('__invoke')->never();

Expand All @@ -60,8 +57,6 @@ public function test_two_factor_is_not_disabled_if_was_previously_empty_and_curr

public function test_two_factor_is_disabled_if_was_previously_confirming_and_page_is_reloaded()
{
$this->migrate();

$disable = $this->mock(DisableTwoFactorAuthentication::class);
$disable->shouldReceive('__invoke')->once();

Expand All @@ -82,16 +77,6 @@ public function test_two_factor_is_disabled_if_was_previously_confirming_and_pag
$response->assertStatus(200);
}

protected function migrate()
{
$this->artisan('migrate', ['--database' => 'testbench'])->run();

Schema::table('users', function ($table) {
$table->string('two_factor_secret')->nullable();
$table->timestamp('two_factor_confirmed_at')->nullable();
});
}

protected function getEnvironmentSetUp($app)
{
parent::getEnvironmentSetUp($app);
Expand Down

0 comments on commit 76fc9f3

Please sign in to comment.