From b448da234ec8cb60d413f2b33fe511907f297884 Mon Sep 17 00:00:00 2001 From: Maicol Battistini Date: Fri, 8 Dec 2023 17:31:27 +0100 Subject: [PATCH] fix: Visualizzazione menu utente MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Il componente UserInfoActionDialog è stato creato per mostrare le informazioni dell'utente con opzioni per il profilo utente e il logout. Allo stesso tempo, il codice relativo alle azioni dell'utente è stato rimosso da UserInfoAction.tsx e sostituito con il nuovo componente. Ho inoltre apportato una modifica a app.blade.php per correggere il caricamento dell'utente. --- .../Dialogs/UserInfoActionDialog.tsx | 47 +++++++++++++++++++ .../topappbar_actions/UserInfoAction.tsx | 38 ++------------- resources/ts/WebComponents/NavDrawer.ts | 3 -- resources/views/app.blade.php | 2 +- 4 files changed, 51 insertions(+), 39 deletions(-) create mode 100644 resources/ts/Components/Dialogs/UserInfoActionDialog.tsx diff --git a/resources/ts/Components/Dialogs/UserInfoActionDialog.tsx b/resources/ts/Components/Dialogs/UserInfoActionDialog.tsx new file mode 100644 index 000000000..b6639158a --- /dev/null +++ b/resources/ts/Components/Dialogs/UserInfoActionDialog.tsx @@ -0,0 +1,47 @@ +import '@material/web/button/text-button.js'; + +import {router} from '@maicol07/inertia-mithril'; +import {mdiAccountOutline, mdiLogoutVariant} from '@mdi/js'; +import Dialog, {DialogAttributes} from '@osm/Components/Dialogs/Dialog'; +import MdIcon from '@osm/Components/MdIcon'; +import {VnodeCollection} from '@osm/typings/jsx'; +import collect from 'collect.js'; +import Mithril from 'mithril'; +import {Request} from 'mithril-utilities'; + +export default class UserInfoActionDialog extends Dialog { + icon(): Mithril.Children { + return app.user?.picture ? ( + {app.user.username}/ + ) : ; + } + + headline(): Mithril.Children { + return {app.user?.username}; + } + + contents(vnode: Mithril.Vnode): Mithril.Children { + return ( + {app.user?.email} + ); + } + + actions(vnode: Mithril.Vnode): VnodeCollection { + return collect({ + profile: ( + {__('Il tuo profilo')} + ), + logout: ( + + {__('Esci')} + + + ) + }); + } + + async logout() { + await Request.post(route('logout')); + router.visit(route('login')); + } +} diff --git a/resources/ts/Components/layout/topappbar_actions/UserInfoAction.tsx b/resources/ts/Components/layout/topappbar_actions/UserInfoAction.tsx index f93d481ad..41ccb99ee 100644 --- a/resources/ts/Components/layout/topappbar_actions/UserInfoAction.tsx +++ b/resources/ts/Components/layout/topappbar_actions/UserInfoAction.tsx @@ -1,17 +1,7 @@ -import '@material/web/button/outlined-button.js'; -import '@material/web/button/text-button.js'; - -import {router} from '@maicol07/inertia-mithril'; -import { - mdiAccountCircleOutline, - mdiAccountOutline, - mdiLogoutVariant -} from '@mdi/js'; -import Dialog from '@osm/Components/Dialogs/Dialog'; -import MdIcon from '@osm/Components/MdIcon'; +import {mdiAccountOutline} from '@mdi/js'; +import UserInfoActionDialog from '@osm/Components/Dialogs/UserInfoActionDialog'; import {Vnode} from 'mithril'; import Stream from 'mithril/stream'; -import {Request} from 'mithril-utilities'; import TopAppBarAction from './TopAppBarAction'; @@ -22,27 +12,10 @@ export default class UserInfoAction extends TopAppBarAction { dialogState = Stream(false); view(vnode: Vnode) { - // TODO: Redo with flex columns and gap return [ super.view(vnode), // eslint-disable-next-line mithril/jsx-key - -
- {app.user?.picture ? ( - {app.user.username}/ - ) : } - {app.user?.username} - {app.user?.email} -
- - {this.ariaLabel} - - - - {__('Esci')} - - -
+ ]; } @@ -50,11 +23,6 @@ export default class UserInfoAction extends TopAppBarAction { this.dialogState(true); } - async logout() { - await Request.post(route('logout')); - router.visit(route('login')); - } - getIconElement(): JSX.Element { return app.user && app.user.picture ? {app.user.username} : super.getIconElement(); } diff --git a/resources/ts/WebComponents/NavDrawer.ts b/resources/ts/WebComponents/NavDrawer.ts index 415c96c4b..29ee7542d 100644 --- a/resources/ts/WebComponents/NavDrawer.ts +++ b/resources/ts/WebComponents/NavDrawer.ts @@ -183,9 +183,6 @@ export default class NavDrawer extends LitElement { --_pane-margin-inline-start: var(--nav-drawer-pane-spacing-start, 28px); } } - .body:not(.open) .scroll-wrapper { - overflow-x: hidden; - } .pane { box-sizing: border-box; diff --git a/resources/views/app.blade.php b/resources/views/app.blade.php index 883e44039..a758adb10 100644 --- a/resources/views/app.blade.php +++ b/resources/views/app.blade.php @@ -32,7 +32,7 @@ app = @js([ 'locale' => app()->getLocale(), 'modules' => $modules, - 'user' => Route::currentRouteName() !== 'setup.index' && auth()->user(), + 'user' => Route::currentRouteName() !== 'setup.index' ? auth()->user() : null, 'VERSION' => trim(file_get_contents(base_path('VERSION'))), 'REVISION' => trim(file_get_contents(base_path('REVISION'))), 'settings' => !str_starts_with(Route::getCurrentRoute()?->getName() ?? '', 'setup.') ? [