feat: add Account Settings view
This is not interacting with Vervis at this point in time. I clarified that changes should be persisted on moving away from a view. I'm going to implement that once I have all views in place. On top of that, persisting changes to Vervis requires me to study the now documented Vervis API in more detail. I'm going to postpone this for now but will revisit it in a few weeks. Signed-off-by: André Jaenisch <andre.jaenisch@posteo.de>
This commit is contained in:
parent
be727a6d9c
commit
03c8334338
13 changed files with 245 additions and 17 deletions
8
package-lock.json
generated
8
package-lock.json
generated
|
@ -1,12 +1,12 @@
|
||||||
{
|
{
|
||||||
"name": "anvil",
|
"name": "anvil",
|
||||||
"version": "0.0.10",
|
"version": "0.0.11",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "anvil",
|
"name": "anvil",
|
||||||
"version": "0.0.10",
|
"version": "0.0.11",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@floating-ui/dom": "1.6.8",
|
"@floating-ui/dom": "1.6.8",
|
||||||
"axios": "1.7.2",
|
"axios": "1.7.2",
|
||||||
|
@ -20,13 +20,13 @@
|
||||||
"@storybook/addon-a11y": "8.2.6",
|
"@storybook/addon-a11y": "8.2.6",
|
||||||
"@storybook/addon-coverage": "1.0.4",
|
"@storybook/addon-coverage": "1.0.4",
|
||||||
"@storybook/addon-essentials": "8.2.6",
|
"@storybook/addon-essentials": "8.2.6",
|
||||||
"@storybook/addon-interactions": "^8.2.6",
|
"@storybook/addon-interactions": "8.2.6",
|
||||||
"@storybook/addon-links": "8.2.6",
|
"@storybook/addon-links": "8.2.6",
|
||||||
"@storybook/blocks": "8.2.6",
|
"@storybook/blocks": "8.2.6",
|
||||||
"@storybook/builder-vite": "8.2.6",
|
"@storybook/builder-vite": "8.2.6",
|
||||||
"@storybook/svelte": "8.2.6",
|
"@storybook/svelte": "8.2.6",
|
||||||
"@storybook/sveltekit": "8.2.6",
|
"@storybook/sveltekit": "8.2.6",
|
||||||
"@storybook/test": "^8.2.6",
|
"@storybook/test": "8.2.6",
|
||||||
"@sveltejs/adapter-node": "5.2.0",
|
"@sveltejs/adapter-node": "5.2.0",
|
||||||
"@sveltejs/kit": "2.5.18",
|
"@sveltejs/kit": "2.5.18",
|
||||||
"@sveltejs/vite-plugin-svelte": "3.1.1",
|
"@sveltejs/vite-plugin-svelte": "3.1.1",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "anvil",
|
"name": "anvil",
|
||||||
"version": "0.0.10",
|
"version": "0.0.11",
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "vite dev",
|
"dev": "vite dev",
|
||||||
|
|
|
@ -37,7 +37,7 @@ You should have received a copy of the GNU Affero General Public License along w
|
||||||
name="profile"
|
name="profile"
|
||||||
value="profile"
|
value="profile"
|
||||||
on:change={onTileChanged}
|
on:change={onTileChanged}
|
||||||
regionLabel="float-start ps-2 py-1 text-surface-500"
|
regionLabel="float-start ps-2 py-1 font-normal text-surface-500 !text-xl"
|
||||||
regionLead="float-start ps-8 text-surface-500"
|
regionLead="float-start ps-8 text-surface-500"
|
||||||
title={$_('settings.profile.label')}
|
title={$_('settings.profile.label')}
|
||||||
>
|
>
|
||||||
|
@ -51,7 +51,7 @@ You should have received a copy of the GNU Affero General Public License along w
|
||||||
name="account"
|
name="account"
|
||||||
value="account"
|
value="account"
|
||||||
on:change={onTileChanged}
|
on:change={onTileChanged}
|
||||||
regionLabel="float-start ps-2 py-1 text-surface-500"
|
regionLabel="float-start ps-2 py-1 font-normal text-surface-500 !text-xl"
|
||||||
regionLead="float-start ps-8 text-surface-500"
|
regionLead="float-start ps-8 text-surface-500"
|
||||||
title={$_('settings.account.label')}
|
title={$_('settings.account.label')}
|
||||||
>
|
>
|
||||||
|
@ -65,7 +65,7 @@ You should have received a copy of the GNU Affero General Public License along w
|
||||||
name="ssh_gpg_keys"
|
name="ssh_gpg_keys"
|
||||||
value="ssh_gpg_keys"
|
value="ssh_gpg_keys"
|
||||||
on:change={onTileChanged}
|
on:change={onTileChanged}
|
||||||
regionLabel="float-start ps-2 py-1 text-surface-500"
|
regionLabel="float-start ps-2 py-1 font-normal text-surface-500 !text-xl"
|
||||||
regionLead="float-start ps-8 text-surface-500"
|
regionLead="float-start ps-8 text-surface-500"
|
||||||
title={$_('settings.ssh_gpg_keys.label')}
|
title={$_('settings.ssh_gpg_keys.label')}
|
||||||
>
|
>
|
||||||
|
@ -79,7 +79,7 @@ You should have received a copy of the GNU Affero General Public License along w
|
||||||
name="appearance"
|
name="appearance"
|
||||||
value="appearance"
|
value="appearance"
|
||||||
on:change={onTileChanged}
|
on:change={onTileChanged}
|
||||||
regionLabel="float-start ps-2 py-1 text-surface-500"
|
regionLabel="float-start ps-2 py-1 font-normal text-surface-500 !text-xl"
|
||||||
regionLead="float-start ps-8 text-surface-500"
|
regionLead="float-start ps-8 text-surface-500"
|
||||||
title={$_('settings.appearance.label')}
|
title={$_('settings.appearance.label')}
|
||||||
>
|
>
|
||||||
|
@ -93,7 +93,7 @@ You should have received a copy of the GNU Affero General Public License along w
|
||||||
name="notifications"
|
name="notifications"
|
||||||
value="notifications"
|
value="notifications"
|
||||||
on:change={onTileChanged}
|
on:change={onTileChanged}
|
||||||
regionLabel="float-start ps-2 py-1 text-surface-500"
|
regionLabel="float-start ps-2 py-1 font-normal text-surface-500 !text-xl"
|
||||||
regionLead="float-start ps-8 text-surface-500"
|
regionLead="float-start ps-8 text-surface-500"
|
||||||
title={$_('settings.notifications.label')}
|
title={$_('settings.notifications.label')}
|
||||||
>
|
>
|
||||||
|
|
|
@ -12,6 +12,7 @@ You should have received a copy of the GNU Affero General Public License along w
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import SettingsAccount from './SettingsAccount.svelte';
|
||||||
import SettingsSidebar from '../atoms/SettingsSidebar.svelte';
|
import SettingsSidebar from '../atoms/SettingsSidebar.svelte';
|
||||||
import SettingsProfile from './SettingsProfile.svelte';
|
import SettingsProfile from './SettingsProfile.svelte';
|
||||||
|
|
||||||
|
@ -22,10 +23,12 @@ You should have received a copy of the GNU Affero General Public License along w
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="flex bg-surface-50">
|
<div class="flex bg-surface-50 min-h-[900px]">
|
||||||
<SettingsSidebar on:switch-settings={onTileChanged} />
|
<SettingsSidebar on:switch-settings={onTileChanged} />
|
||||||
|
|
||||||
{#if activeSetting === 'profile'}
|
{#if activeSetting === 'profile'}
|
||||||
<SettingsProfile />
|
<SettingsProfile />
|
||||||
|
{:else if activeSetting === 'account'}
|
||||||
|
<SettingsAccount />
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
|
|
43
src/lib/components/molecules/SettingsAccount.svelte
Normal file
43
src/lib/components/molecules/SettingsAccount.svelte
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
<!--
|
||||||
|
SettingsAccount molecule.
|
||||||
|
Copyright (C) 2024 André Jaenisch
|
||||||
|
SPDX-FileCopyrightText: 2024 André Jaenisch
|
||||||
|
SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import { _ } from 'svelte-i18n';
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<div class="flex flex-col flex-1 gap-4 pe-8 pb-8 ps-8 pt-20 bg-surface-100">
|
||||||
|
<div class="flex text-surface-500 text-xl font-semibold">{$_('settings.account.headline')}</div>
|
||||||
|
<div class="flex flex-col gap-6">
|
||||||
|
<div>
|
||||||
|
<span class="text-surface-500 font-semibold">{$_('settings.account.f2.label')}</span>
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
placeholder={$_('settings.account.f2.placeholder')}
|
||||||
|
class="input bg-white placeholder:text-surface-300"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div class="flex flex-col gap-1">
|
||||||
|
<span class="text-surface-500 font-semibold">{$_('settings.account.password.label')}</span>
|
||||||
|
<input type="password" class="input bg-white" />
|
||||||
|
<a>{$_('settings.account.password.reset')}</a>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<span class="text-surface-500 font-semibold">{$_('settings.account.verification.label')}</span
|
||||||
|
>
|
||||||
|
<input type="text" class="input bg-white" />
|
||||||
|
</div>
|
||||||
|
<div class="flex justify-end">
|
||||||
|
<button class="btn variant-filled-warning">{$_('settings.account.delete')}</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
|
@ -16,7 +16,7 @@ You should have received a copy of the GNU Affero General Public License along w
|
||||||
import { Person24, Upload16, XCircleFill12 } from 'svelte-octicons';
|
import { Person24, Upload16, XCircleFill12 } from 'svelte-octicons';
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="flex flex-col flex-1 gap-4 pe-8 pb-8 pt-20 bg-surface-100">
|
<div class="flex flex-col flex-1 gap-4 pe-8 pb-8 ps-8 pt-20 bg-surface-100">
|
||||||
<div class="flex text-surface-500 text-xl font-semibold">{$_('settings.profile.headline')}</div>
|
<div class="flex text-surface-500 text-xl font-semibold">{$_('settings.profile.headline')}</div>
|
||||||
<div class="flex flex-col gap-6">
|
<div class="flex flex-col gap-6">
|
||||||
<div class="text-surface-500 font-semibold">{$_('settings.profile.avatar.headline')}</div>
|
<div class="text-surface-500 font-semibold">{$_('settings.profile.avatar.headline')}</div>
|
||||||
|
|
|
@ -176,7 +176,20 @@
|
||||||
"settings": {
|
"settings": {
|
||||||
"headline": "",
|
"headline": "",
|
||||||
"account": {
|
"account": {
|
||||||
|
"delete": "",
|
||||||
|
"f2": {
|
||||||
|
"label": "",
|
||||||
|
"placeholder": ""
|
||||||
|
},
|
||||||
|
"headline": "",
|
||||||
|
"label": "",
|
||||||
|
"password": {
|
||||||
|
"label": "",
|
||||||
|
"reset": ""
|
||||||
|
},
|
||||||
|
"verification": {
|
||||||
"label": ""
|
"label": ""
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"appearance": {
|
"appearance": {
|
||||||
"label": ""
|
"label": ""
|
||||||
|
|
|
@ -176,7 +176,20 @@
|
||||||
"settings": {
|
"settings": {
|
||||||
"headline": "",
|
"headline": "",
|
||||||
"account": {
|
"account": {
|
||||||
|
"delete": "",
|
||||||
|
"f2": {
|
||||||
|
"label": "",
|
||||||
|
"placeholder": ""
|
||||||
|
},
|
||||||
|
"headline": "",
|
||||||
|
"label": "",
|
||||||
|
"password": {
|
||||||
|
"label": "",
|
||||||
|
"reset": ""
|
||||||
|
},
|
||||||
|
"verification": {
|
||||||
"label": ""
|
"label": ""
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"appearance": {
|
"appearance": {
|
||||||
"label": ""
|
"label": ""
|
||||||
|
|
|
@ -176,7 +176,20 @@
|
||||||
"settings": {
|
"settings": {
|
||||||
"headline": "Settings",
|
"headline": "Settings",
|
||||||
"account": {
|
"account": {
|
||||||
"label": "Account"
|
"delete": "Delete account",
|
||||||
|
"f2": {
|
||||||
|
"label": "F2 Account",
|
||||||
|
"placeholder": "@user@server.com"
|
||||||
|
},
|
||||||
|
"headline": "Account",
|
||||||
|
"label": "Account",
|
||||||
|
"password": {
|
||||||
|
"label": "Password",
|
||||||
|
"reset": "Reset password"
|
||||||
|
},
|
||||||
|
"verification": {
|
||||||
|
"label": "Verification mail"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"appearance": {
|
"appearance": {
|
||||||
"label": "Appearance"
|
"label": "Appearance"
|
||||||
|
|
|
@ -176,7 +176,20 @@
|
||||||
"settings": {
|
"settings": {
|
||||||
"headline": "",
|
"headline": "",
|
||||||
"account": {
|
"account": {
|
||||||
|
"delete": "",
|
||||||
|
"f2": {
|
||||||
|
"label": "",
|
||||||
|
"placeholder": ""
|
||||||
|
},
|
||||||
|
"headline": "",
|
||||||
|
"label": "",
|
||||||
|
"password": {
|
||||||
|
"label": "",
|
||||||
|
"reset": ""
|
||||||
|
},
|
||||||
|
"verification": {
|
||||||
"label": ""
|
"label": ""
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"appearance": {
|
"appearance": {
|
||||||
"label": ""
|
"label": ""
|
||||||
|
|
|
@ -176,7 +176,20 @@
|
||||||
"settings": {
|
"settings": {
|
||||||
"headline": "",
|
"headline": "",
|
||||||
"account": {
|
"account": {
|
||||||
|
"delete": "",
|
||||||
|
"f2": {
|
||||||
|
"label": "",
|
||||||
|
"placeholder": ""
|
||||||
|
},
|
||||||
|
"headline": "",
|
||||||
|
"label": "",
|
||||||
|
"password": {
|
||||||
|
"label": "",
|
||||||
|
"reset": ""
|
||||||
|
},
|
||||||
|
"verification": {
|
||||||
"label": ""
|
"label": ""
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"appearance": {
|
"appearance": {
|
||||||
"label": ""
|
"label": ""
|
||||||
|
|
26
stories/molecules/SettingsAccount.stories.ts
Normal file
26
stories/molecules/SettingsAccount.stories.ts
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
/* Stories for SettingsAccount molecule.
|
||||||
|
* Copyright (C) 2024 André Jaenisch
|
||||||
|
* SPDX-FileCopyrightText: 2024 André Jaenisch
|
||||||
|
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import type { Meta, StoryObj } from '@storybook/svelte';
|
||||||
|
|
||||||
|
import SettingsAccount from '$lib/components/molecules/SettingsAccount.svelte';
|
||||||
|
|
||||||
|
const meta = {
|
||||||
|
title: 'Molecules/SettingsAccount',
|
||||||
|
component: SettingsAccount,
|
||||||
|
tags: ['autodocs']
|
||||||
|
} satisfies Meta<SettingsAccount>;
|
||||||
|
|
||||||
|
export default meta;
|
||||||
|
type Story = StoryObj<typeof meta>;
|
||||||
|
|
||||||
|
export const Plain: Story = {};
|
91
tests/components/molecules/SettingsAccount.test.ts
Normal file
91
tests/components/molecules/SettingsAccount.test.ts
Normal file
|
@ -0,0 +1,91 @@
|
||||||
|
/* Component test for SettingsAccount molecule.
|
||||||
|
* Copyright (C) 2024 André Jaenisch
|
||||||
|
* SPDX-FileCopyrightText: 2024 André Jaenisch
|
||||||
|
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import '@testing-library/jest-dom';
|
||||||
|
import { render, screen } from '@testing-library/svelte';
|
||||||
|
import { init, locale, register } from 'svelte-i18n';
|
||||||
|
|
||||||
|
import SettingsAccount from '../../../src/lib/components/molecules/SettingsAccount.svelte';
|
||||||
|
import enMessages from '../../../src/lib/i18n/locales/en.json';
|
||||||
|
|
||||||
|
describe('SettingsAccount.svelte', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
register('en', () => import('../../../src/lib/i18n/locales/en.json'));
|
||||||
|
init({ fallbackLocale: 'en', initialLocale: 'en' });
|
||||||
|
locale.set('en');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should mount', () => {
|
||||||
|
// Arrange
|
||||||
|
// Nothing to prepare
|
||||||
|
|
||||||
|
// Act
|
||||||
|
const { container } = render(SettingsAccount);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(container).toBeTruthy();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should have an account input', () => {
|
||||||
|
// Arrange
|
||||||
|
// Nothing to prepare
|
||||||
|
|
||||||
|
// Act
|
||||||
|
render(SettingsAccount);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(
|
||||||
|
screen.getByPlaceholderText(enMessages.settings.account.f2.placeholder)
|
||||||
|
).toBeInTheDocument();
|
||||||
|
});
|
||||||
|
|
||||||
|
// TODO: Mark up proper label and input
|
||||||
|
it.skip('should have a password input', () => {
|
||||||
|
// Arrange
|
||||||
|
// Nothing to prepare
|
||||||
|
|
||||||
|
// Act
|
||||||
|
render(SettingsAccount);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(
|
||||||
|
screen.getByPlaceholderText(enMessages.settings.account.password.label)
|
||||||
|
).toBeInTheDocument();
|
||||||
|
});
|
||||||
|
|
||||||
|
// TODO: Mark up proper label and input
|
||||||
|
it.skip('should have a verification mail input', () => {
|
||||||
|
// Arrange
|
||||||
|
// Nothing to prepare
|
||||||
|
|
||||||
|
// Act
|
||||||
|
render(SettingsAccount);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(
|
||||||
|
screen.getByPlaceholderText(enMessages.settings.account.verification.label)
|
||||||
|
).toBeInTheDocument();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should have a delete account button', () => {
|
||||||
|
// Arrange
|
||||||
|
// Nothing to prepare
|
||||||
|
|
||||||
|
// Act
|
||||||
|
render(SettingsAccount);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(
|
||||||
|
screen.getByRole('button', { name: enMessages.settings.account.delete })
|
||||||
|
).toBeInTheDocument();
|
||||||
|
});
|
||||||
|
});
|
Loading…
Reference in a new issue