diff --git a/modules/Fileshare/Components/Form.php b/modules/Fileshare/Components/Form.php
new file mode 100644
index 00000000..948abd69
--- /dev/null
+++ b/modules/Fileshare/Components/Form.php
@@ -0,0 +1,107 @@
+ 'required|string|max:255',
+ 'type' => 'array',
+ ];
+ }
+
+ public function validationAttributes(): array
+ {
+ return [
+ 'type' => 'Typ',
+ 'name' => 'Bezeichnung',
+ ];
+ }
+
+ public function mount(?string $id = null): void
+ {
+ $this->types = ConnectionType::forSelect();
+
+ // if ($id) {
+ // $this->model = Mailgateway::find($id);
+ // $this->name = $this->model->name;
+ // $this->type = $this->model->type;
+ // $this->typeClass = get_class($this->model->type);
+ // }
+ }
+
+ public function fields(): array
+ {
+ return $this->type ? $this->typeClass::fields() : [];
+ }
+
+ public function updatedTypeClass(?string $type): void
+ {
+ if (!$type) {
+ return;
+ }
+
+ $this->type = $type::defaults();
+ }
+
+ #[On('onStoreFromModal')]
+ public function onSave(): void
+ {
+ $type = $this->typeClass::from($this->type);
+
+ if (!$type->check()) {
+ throw ValidationException::withMessages(['typeClass' => 'Verbindung fehlgeschlagen']);
+ }
+
+ Fileshare::create([
+ ...$this->validate(),
+ 'type' => $type,
+ ]);
+
+ $this->dispatch('closeModal');
+ $this->dispatch('refresh-page');
+ $this->dispatch('success', 'Verbindung erstellt.');
+ }
+
+ public function render()
+ {
+ return <<<'HTML'
+
+
+
+ HTML;
+ }
+}
diff --git a/modules/Fileshare/Components/FormTest.php b/modules/Fileshare/Components/FormTest.php
new file mode 100644
index 00000000..3995f8a2
--- /dev/null
+++ b/modules/Fileshare/Components/FormTest.php
@@ -0,0 +1,56 @@
+withoutExceptionHandling()->login()->loginNami();
+
+ Livewire::test(Form::class)
+ ->assertSet('name', '')
+ ->assertSee('Bezeichnung')
+ ->assertSee('Owncloud')
+ ->assertSee('Nextcloud')
+ ->assertSet('type', []);
+});
+
+it('it displays owncloud connection values', function () {
+ test()->withoutExceptionHandling()->login()->loginNami();
+
+ Livewire::test(Form::class)
+ ->set('typeClass', OwncloudConnection::class)
+ ->assertSet('typeClass', OwncloudConnection::class)
+ ->assertSee('Benutzer')
+ ->assertSee('URL')
+ ->assertSet('type.user', '')
+ ->assertSet('type.base_url', '')
+ ->assertSet('type.password', '');
+});
+
+it('it saves owncloud connection', function () {
+ test()->login()->loginNami()->withUser('badenpowell', 'secret');
+
+ Livewire::test(Form::class)
+ ->set('name', 'lala')
+ ->set('typeClass', OwncloudConnection::class)
+ ->set('type.user', 'badenpowell')
+ ->set('type.password', 'secret')
+ ->set('type.base_url', env('TEST_OWNCLOUD_DOMAIN'))
+ ->call('onSave')
+ ->assertDispatched('success', 'Verbindung erstellt.')
+ ->assertDispatched('refresh-page');
+
+ $connection = Fileshare::firstOrFail();
+ $this->assertEquals('badenpowell', $connection->type->user);
+ $this->assertEquals('secret', $connection->type->password);
+ $this->assertEquals(env('TEST_OWNCLOUD_DOMAIN'), $connection->type->baseUrl);
+ $this->assertEquals('lala', $connection->name);
+});
diff --git a/tests/Fileshare/FileshareStoreActionTest.php b/tests/Fileshare/FileshareStoreActionTest.php
index 01980ff1..d5ddb9f2 100644
--- a/tests/Fileshare/FileshareStoreActionTest.php
+++ b/tests/Fileshare/FileshareStoreActionTest.php
@@ -9,27 +9,6 @@ use Tests\FileshareTestCase;
class FileshareStoreActionTest extends FileshareTestCase
{
- public function testItStoresAConnection(): void
- {
- $this->withoutExceptionHandling()->login()->loginNami()->withUser('badenpowell', 'secret');
-
- $this->post(route('fileshare.store'), [
- 'name' => 'Lala',
- 'type' => OwncloudConnection::class,
- 'config' => [
- 'user' => 'badenpowell',
- 'password' => 'secret',
- 'base_url' => env('TEST_OWNCLOUD_DOMAIN'),
- ]
- ])->assertOk();
-
- $connection = Fileshare::firstOrFail();
- $this->assertEquals('badenpowell', $connection->type->user);
- $this->assertEquals('secret', $connection->type->password);
- $this->assertEquals(env('TEST_OWNCLOUD_DOMAIN'), $connection->type->baseUrl);
- $this->assertEquals('Lala', $connection->name);
- }
-
public function testItChecksConnection(): void
{
$this->withExceptionHandling()->login()->loginNami();