diff --git a/app/Fileshare/Actions/FileshareApiIndexAction.php b/app/Fileshare/Actions/FileshareApiIndexAction.php deleted file mode 100644 index 4ee530e1..00000000 --- a/app/Fileshare/Actions/FileshareApiIndexAction.php +++ /dev/null @@ -1,21 +0,0 @@ -put('menu', 'setting'); - session()->put('title', 'Datei-Verbindungen'); - - return FileshareResource::collection(Fileshare::paginate(15)); - } -} diff --git a/app/Fileshare/FileshareSettings.php b/app/Fileshare/FileshareSettings.php index 8cc634b6..97ff21b6 100644 --- a/app/Fileshare/FileshareSettings.php +++ b/app/Fileshare/FileshareSettings.php @@ -21,10 +21,8 @@ class FileshareSettings extends LocalSettings /** * @inheritdoc */ - public function viewData(): array + public function data() { - return [ - 'data' => FileshareResource::collection(Fileshare::paginate(15)) - ]; + return FileshareResource::collection(Fileshare::paginate(15)); } } diff --git a/app/Http/Resources/UserResource.php b/app/Http/Resources/UserResource.php index 898441d9..41df3e8c 100644 --- a/app/Http/Resources/UserResource.php +++ b/app/Http/Resources/UserResource.php @@ -38,6 +38,10 @@ class UserResource extends JsonResource public static function meta(): array { return [ + 'default' => [ + 'firstname' => '', + 'lastname' => '', + ], 'links' => [] ]; } diff --git a/app/Mailgateway/MailgatewaySettings.php b/app/Mailgateway/MailgatewaySettings.php index 5e959d66..2cff7c1b 100644 --- a/app/Mailgateway/MailgatewaySettings.php +++ b/app/Mailgateway/MailgatewaySettings.php @@ -18,14 +18,6 @@ class MailgatewaySettings extends LocalSettings return 'E-Mail-Verbindungen'; } - /** - * @inheritdoc - */ - public function meta(): array - { - return MailgatewayResource::meta(); - } - /** * @inheritdoc */ diff --git a/app/Module/ModuleSettings.php b/app/Module/ModuleSettings.php index 0ee41cc5..4494a0e3 100644 --- a/app/Module/ModuleSettings.php +++ b/app/Module/ModuleSettings.php @@ -41,11 +41,14 @@ class ModuleSettings extends LocalSettings implements Storeable /** * @inheritdoc */ - public function meta(): array + public function data(): array { return [ - ...parent::meta(), - 'modules' => Module::forSelect() + ...parent::data(), + 'meta' => [ + ...parent::data()['meta'], + 'modules' => Module::forSelect(), + ] ]; } } diff --git a/app/Setting/Actions/ViewAction.php b/app/Setting/Actions/ViewAction.php index a1c7a5e1..41eb46de 100644 --- a/app/Setting/Actions/ViewAction.php +++ b/app/Setting/Actions/ViewAction.php @@ -20,7 +20,6 @@ class ViewAction return Inertia::render('setting/' . ucfirst($settingGroup::group()), [ 'data' => $settingGroup->data(), 'settingMenu' => app(SettingFactory::class)->getShare(), - 'meta' => $settingGroup->meta(), ]); } } diff --git a/app/Setting/LocalSettings.php b/app/Setting/LocalSettings.php index 3bb9e232..f7ecd8d9 100644 --- a/app/Setting/LocalSettings.php +++ b/app/Setting/LocalSettings.php @@ -19,21 +19,19 @@ abstract class LocalSettings extends Settings return $this->url(); } - public function meta(): array - { - return [ - 'links' => [ - 'store' => $this->storeUrl(), - ] - ]; - } - /** * @return mixed */ public function data() { - return $this->toArray(); + return [ + 'data' => $this->toArray(), + 'meta' => [ + 'links' => [ + 'store' => $this->storeUrl(), + ] + ] + ]; } public function beforeSave(ActionRequest $request): void diff --git a/app/Setting/NamiSettings.php b/app/Setting/NamiSettings.php index e64cf032..91298a36 100644 --- a/app/Setting/NamiSettings.php +++ b/app/Setting/NamiSettings.php @@ -66,9 +66,12 @@ class NamiSettings extends LocalSettings implements Storeable public function data(): array { return [ - 'mglnr' => $this->mglnr, - 'password' => '', - 'default_group_id' => $this->default_group_id, + ...parent::data(), + 'data' => [ + 'mglnr' => $this->mglnr, + 'password' => '', + 'default_group_id' => $this->default_group_id, + ], ]; } } diff --git a/app/User/Actions/IndexAction.php b/app/User/Actions/IndexAction.php deleted file mode 100644 index d6461057..00000000 --- a/app/User/Actions/IndexAction.php +++ /dev/null @@ -1,18 +0,0 @@ -get()); - } -} diff --git a/app/User/UserSettings.php b/app/User/UserSettings.php index 1bea49f5..b69dbd15 100644 --- a/app/User/UserSettings.php +++ b/app/User/UserSettings.php @@ -18,19 +18,11 @@ class UserSettings extends LocalSettings return 'Benutzer'; } - /** - * @inheritdoc - */ - public function meta(): array - { - return UserResource::meta(); - } - /** * @inheritdoc */ public function data() { - return UserResource::collection(User::orderByRaw('lastname, firstname')->get())->toArray(request()); + return UserResource::collection(User::orderByRaw('lastname, firstname')->get()); } } diff --git a/resources/js/views/setting/Fileshare.vue b/resources/js/views/setting/Fileshare.vue index 89340fd4..39757ba3 100644 --- a/resources/js/views/setting/Fileshare.vue +++ b/resources/js/views/setting/Fileshare.vue @@ -76,10 +76,12 @@ diff --git a/resources/js/views/setting/User.vue b/resources/js/views/setting/User.vue index f7a60176..5eec75d2 100644 --- a/resources/js/views/setting/User.vue +++ b/resources/js/views/setting/User.vue @@ -5,6 +5,10 @@
+
+ + +
Speichern Abbrechen @@ -41,21 +45,9 @@ diff --git a/resources/js/views/setting/useSettings.js b/resources/js/views/setting/useSettings.js index ebdd5d70..3844f5e9 100644 --- a/resources/js/views/setting/useSettings.js +++ b/resources/js/views/setting/useSettings.js @@ -2,7 +2,7 @@ import {useIndex} from '../../composables/useInertiaApiIndex.js'; import SettingLayout from './Layout.vue'; export function useSettings(props) { - const {data, meta, router} = useIndex(props); + const {data, meta, router} = useIndex(props.data); function submit() { router.post(meta.value.links.store, {...data.value}); @@ -19,19 +19,10 @@ export function useSettings(props) { const props = { data: { - type: Object, - required: true, - }, - settingMenu: { - type: Object, - required: true, - }, - meta: { - type: Object, - required: false, default: () => { - return {}; + return {data: [], meta: {}}; }, + type: Object, }, }; diff --git a/routes/api.php b/routes/api.php index 2f417d6e..70730f99 100644 --- a/routes/api.php +++ b/routes/api.php @@ -4,10 +4,8 @@ use App\Contribution\Actions\GenerateApiAction as ContributionGenerateApiAction; use App\Form\Actions\FormApiListAction; use App\Form\Actions\RegisterAction; use App\Group\Actions\GroupApiIndexAction; -use App\User\Actions\IndexAction as UserIndexAction; Route::post('/contribution-generate', ContributionGenerateApiAction::class)->name('api.contribution.generate')->middleware('client:contribution-generate'); Route::post('/form/{form}/register', RegisterAction::class)->name('form.register'); Route::get('/group/{group?}', GroupApiIndexAction::class)->name('api.group'); Route::get('/form', FormApiListAction::class)->name('api.form.index'); -Route::get('/user', UserIndexAction::class)->name('api.user.index'); diff --git a/routes/web.php b/routes/web.php index 7996811b..7f3aae8f 100644 --- a/routes/web.php +++ b/routes/web.php @@ -19,7 +19,6 @@ use App\Invoice\Actions\InvoiceStoreAction; use App\Course\Actions\CourseUpdateAction; use App\Dashboard\Actions\IndexAction as DashboardIndexAction; use App\Efz\ShowEfzDocumentAction; -use App\Fileshare\Actions\FileshareApiIndexAction; use App\Fileshare\Actions\FileshareStoreAction; use App\Fileshare\Actions\FileshareUpdateAction; use App\Fileshare\Actions\ListFilesAction; @@ -182,6 +181,5 @@ Route::group(['middleware' => 'auth:web'], function (): void { // ------------------------------------ fileshare ----------------------------------- Route::post('/fileshare', FileshareStoreAction::class)->name('fileshare.store'); Route::patch('/fileshare/{fileshare}', FileshareUpdateAction::class)->name('fileshare.update'); - Route::get('/api/fileshare', FileshareApiIndexAction::class)->name('api.fileshare.index'); Route::post('/api/fileshare/{fileshare}/files', ListFilesAction::class)->name('api.fileshare.files'); }); diff --git a/tests/Feature/Permission/UserIndexTest.php b/tests/Feature/Permission/UserIndexTest.php index 0ceb1364..2ea904fc 100644 --- a/tests/Feature/Permission/UserIndexTest.php +++ b/tests/Feature/Permission/UserIndexTest.php @@ -12,24 +12,19 @@ class UserIndexTest extends TestCase use DatabaseTransactions; public function testItOpensSettingsPage(): void - { - $this->login()->loginNami(); - $this->get(route('setting.view', ['settingGroup' => 'user'])) - ->assertOk() - ->assertComponent('setting/User'); - } - - public function testItListsUsers(): void { $this->login()->loginNami(); auth()->user()->update(['firstname' => 'Jane', 'lastname' => 'Doe']); User::factory()->create(['firstname' => 'John', 'lastname' => 'Doe']); $anna = User::factory()->create(['firstname' => 'Anna', 'lastname' => 'Doe']); - $this->get(route('api.user.index')) - ->assertJsonPath('data.0.firstname', 'Anna') - ->assertJsonPath('data.0.lastname', 'Doe') - ->assertJsonPath('data.0.id', $anna->id) - ->assertJsonPath('data.1.firstname', 'Jane') - ->assertJsonPath('data.2.firstname', 'John'); + $this->get(route('setting.view', ['settingGroup' => 'user'])) + ->assertOk() + ->assertComponent('setting/User') + ->assertInertiaPath('data.data.0.firstname', 'Anna') + ->assertInertiaPath('data.data.0.lastname', 'Doe') + ->assertInertiaPath('data.data.0.id', $anna->id) + ->assertInertiaPath('data.data.1.firstname', 'Jane') + ->assertInertiaPath('data.data.2.firstname', 'John') + ->assertInertiaPath('data.meta.default.firstname', ''); } } diff --git a/tests/Fileshare/FileshareIndexActionTest.php b/tests/Fileshare/FileshareIndexActionTest.php index a398d74a..7ca75b5a 100644 --- a/tests/Fileshare/FileshareIndexActionTest.php +++ b/tests/Fileshare/FileshareIndexActionTest.php @@ -17,31 +17,25 @@ class FileshareIndexActionTest extends FileshareTestCase ->name('lokaler Server') ->create(); - $this->get('/api/fileshare') - ->assertJsonPath('data.0.name', 'lokaler Server') - ->assertJsonPath('data.0.type', OwncloudConnection::class) - ->assertJsonPath('data.0.config.user', 'badenpowell') - ->assertJsonPath('data.0.config.password', 'secret') - ->assertJsonPath('data.0.config.base_url', env('TEST_OWNCLOUD_DOMAIN')) - ->assertJsonPath('data.0.id', $connection->id) - ->assertJsonPath('data.0.is_active', true) - ->assertJsonPath('data.0.type_human', 'Owncloud') - ->assertJsonPath('data.0.links.update', route('fileshare.update', ['fileshare' => $connection])) - ->assertJsonPath('meta.default.name', '') - ->assertJsonPath('meta.links.store', route('fileshare.store')) - ->assertJsonPath('meta.types.0.id', NextcloudConnection::class) - ->assertJsonPath('meta.types.0.name', 'Nextcloud') - ->assertJsonPath('meta.types.0.defaults.base_url', '') - ->assertJsonPath('meta.types.1.id', OwncloudConnection::class) - ->assertJsonPath('meta.types.1.name', 'Owncloud') - ->assertJsonPath('meta.types.1.defaults.base_url', '') - ->assertJsonPath('meta.types.0.fields.1', ['label' => 'Benutzer', 'key' => 'user', 'type' => 'text']); - } - - public function testItRendersComponent(): void - { - $this->withoutExceptionHandling()->login()->loginNami(); - - $this->get('/setting/fileshare')->assertComponent('setting/Fileshare'); + $this->get(route('setting.view', ['settingGroup' => 'fileshare'])) + ->assertComponent('setting/Fileshare') + ->assertInertiaPath('data.data.0.name', 'lokaler Server') + ->assertInertiaPath('data.data.0.type', OwncloudConnection::class) + ->assertInertiaPath('data.data.0.config.user', 'badenpowell') + ->assertInertiaPath('data.data.0.config.password', 'secret') + ->assertInertiaPath('data.data.0.config.base_url', env('TEST_OWNCLOUD_DOMAIN')) + ->assertInertiaPath('data.data.0.id', $connection->id) + ->assertInertiaPath('data.data.0.is_active', true) + ->assertInertiaPath('data.data.0.type_human', 'Owncloud') + ->assertInertiaPath('data.data.0.links.update', route('fileshare.update', ['fileshare' => $connection])) + ->assertInertiaPath('data.meta.default.name', '') + ->assertInertiaPath('data.meta.links.store', route('fileshare.store')) + ->assertInertiaPath('data.meta.types.0.id', NextcloudConnection::class) + ->assertInertiaPath('data.meta.types.0.name', 'Nextcloud') + ->assertInertiaPath('data.meta.types.0.defaults.base_url', '') + ->assertInertiaPath('data.meta.types.1.id', OwncloudConnection::class) + ->assertInertiaPath('data.meta.types.1.name', 'Owncloud') + ->assertInertiaPath('data.meta.types.1.defaults.base_url', '') + ->assertInertiaPath('data.meta.types.0.fields.1', ['label' => 'Benutzer', 'key' => 'user', 'type' => 'text']); } }