diff --git a/app/base/routing.js b/app/base/routing.js index 6763fe1162f8aa2045f749f141f4a4955b0c4cc0..3b68a6b5d06ee9b71193a7f6b15f19f4810a5636 100644 --- a/app/base/routing.js +++ b/app/base/routing.js @@ -8,8 +8,8 @@ export default class BaseRoute extends Route { @service currentUser; async beforeModel(transition) { - this.session.requireAuthentication(transition, 'login'); + await this.currentUser.loadCurrentUser(); if (this.currentUser.user) { @@ -17,14 +17,16 @@ export default class BaseRoute extends Route { } } - setupController() { + async setupController() { super.setupController(...arguments); + let app_controller = this.controllerFor('authenticated'), + home_folder, + inbox_folder; - let app_controller = this.controllerFor('authenticated'); - - this.currentUser.user.getHomeFolder().then((home_folder) => { - app_controller.set('home_folder', home_folder); - }); + home_folder = await this.currentUser.user.getHomeFolder(); + inbox_folder = await this.currentUser.user.getInboxFolder(); + app_controller.set('home_folder', home_folder); + app_controller.set('inbox_folder', inbox_folder); } } diff --git a/app/components/breadcrumb/index.hbs b/app/components/breadcrumb/index.hbs index cc88a5f6fca79c2ace74de7ba7e268cbca785142..badd252879d56536132480962799b354138f6e99 100644 --- a/app/components/breadcrumb/index.hbs +++ b/app/components/breadcrumb/index.hbs @@ -6,7 +6,15 @@ @node={{node}} @extranode={{@extranode}} @extradoc={{@extradoc}} - @hint={{@hint}} /> + @hint={{@hint}}> + {{#if (is_equal node.title ".inbox")}} + <i class="bi-inbox-fill me-2"></i>Inbox + {{else if (is_equal node.title ".home")}} + <i class="fa fa-home me-2"></i>Home + {{else}} + {{node.title}} + {{/if}} + </DualLinkTo> </li> {{/each}} </ol> diff --git a/app/components/dual_link_to/index.hbs b/app/components/dual_link_to/index.hbs index 735bce8b3cf97c137a87effe670c942b3f8084c9..c60f688992c2c609068bfdc984bf828018110883 100644 --- a/app/components/dual_link_to/index.hbs +++ b/app/components/dual_link_to/index.hbs @@ -3,5 +3,9 @@ @model={{this.model.id}} @query={{this.query}} ...attributes > - {{this.title}} + {{#if (has-block)}} + {{yield}} + {{else}} + {{this.title}} + {{/if}} </LinkTo> diff --git a/app/components/nav/sidebar.hbs b/app/components/nav/sidebar.hbs index 39e73bb2562b93357cfe6c3a120b267616b714e6..b382bf48bd4452e57f4b7eb4c84d368945e843f3 100644 --- a/app/components/nav/sidebar.hbs +++ b/app/components/nav/sidebar.hbs @@ -12,20 +12,22 @@ </LinkTo> <hr> <ul class="nav nav-pills flex-column mb-auto"> - <li class="nav-item"> + <li> <LinkTo @route="authenticated.nodes" @model="{{@home_folder.id}}" - class="nav-link text-white {{this.active}}" aria-current="page"> + class="nav-link text-white" aria-current="page"> <i class="fa fa-home me-2"></i>Home </LinkTo> </li> <li> - <LinkTo @route="authenticated.inbox" class="nav-link text-white"> + <LinkTo + @route="authenticated.nodes" + @model="{{@inbox_folder.id}}" + class="nav-link text-white" aria-current="page"> <i class="bi-inbox me-2"></i>Inbox </LinkTo> </li> - <li> <LinkTo @route="authenticated.automates" class="nav-link text-white"> <i class="fas fa-robot me-2"></i>Automates @@ -71,13 +73,14 @@ @route="authenticated.nodes" @model="{{@home_folder.id}}" {{tooltip title="Home"}} - class="nav-link text-white {{this.active}}" aria-current="page"> + class="nav-link text-white"> <i class="fa fa-home me-2"></i> </LinkTo> </li> <li> <LinkTo - @route="authenticated.inbox" + @route="authenticated.nodes" + @model="{{@inbox_folder.id}}" {{tooltip title="Inbox"}} class="nav-link text-white" > <i class="bi-inbox me-2"></i> diff --git a/app/components/nav/sidebar.js b/app/components/nav/sidebar.js deleted file mode 100644 index 909b31eb9262dec038b72ba50a14619eb0cf84c5..0000000000000000000000000000000000000000 --- a/app/components/nav/sidebar.js +++ /dev/null @@ -1,31 +0,0 @@ -import Component from '@glimmer/component'; -import { inject as service } from '@ember/service'; - - -export default class SidebarComponent extends Component { - @service router; - - get active() { - /* - Returns 'active' if current route name is one of following: - - * authenticated.nodes - * authenticated.document - - 'active' is used as css class name in component's template. - */ - let route_name, active_routes; - - active_routes = [ - 'authenticated.nodes', - 'authenticated.document', - ] - route_name = this.router.currentRoute.name; - - if (active_routes.includes(route_name)) { - return 'active'; - } - - return ''; - } -} diff --git a/app/controllers/authenticated.js b/app/controllers/authenticated.js index ca5061a1a3d07b8ce5c47827a04f18e3771d091f..516dc6f073a6c444c35efb1b047de9f59e0b5ec5 100644 --- a/app/controllers/authenticated.js +++ b/app/controllers/authenticated.js @@ -9,6 +9,5 @@ export default class AuthenticatedController extends Controller { @action onSidebarToggle() { this.expanded = !this.expanded; - console.log(`this.expanded=${this.expanded}`); } } \ No newline at end of file diff --git a/app/models/user.js b/app/models/user.js index 38cc8c2b04fce99e1229e9b096033df2dee0375a..48beb36ce96ebf4b5fea01d45e0d8f9d17311ce4 100644 --- a/app/models/user.js +++ b/app/models/user.js @@ -31,6 +31,15 @@ class UserModel extends Model { return adapter.getFolder(home_id); } + + async getInboxFolder() { + let inbox_id, adapter; + + adapter = this.store.adapterFor('node'); + inbox_id = this.inbox_folder.get('id'); + + return adapter.getFolder(inbox_id); + } } export default UserModel; diff --git a/app/router.js b/app/router.js index c9e0b990e067058f50e3472dd5390adf017c7a7f..3c6432e4616459214393ed8d0e7b29564f71396f 100644 --- a/app/router.js +++ b/app/router.js @@ -9,7 +9,6 @@ export default class Router extends EmberRouter { Router.map(function () { this.route('authenticated', { path: '' }, function () { this.route('documents'); - this.route('inbox'); this.route('document', { path: '/document/:document_id' }); this.route('nodes', { path: '/nodes/:node_id' }); diff --git a/app/routes/application.js b/app/routes/application.js index 67af593e21d379983382796c234aa2ead34dfe30..a23748b3fa7c0d5651cc8b763edd139a82f71d22 100644 --- a/app/routes/application.js +++ b/app/routes/application.js @@ -1,17 +1,6 @@ import BaseRoute from 'papermerge/base/routing'; -import { service } from '@ember/service'; export default class ApplicationRoute extends BaseRoute { - @service currentUser; - async model() { - if (this.currentUser.isAuthenticated) { - return this.currentUser.user.getHomeFolder(); - } - } - - setupController(controller, model) { - controller.set('home_folder', model); - } } diff --git a/app/routes/authenticated/nodes.js b/app/routes/authenticated/nodes.js index 8ac69788ca80faa8b6154f224d87b46ef4c38bab..a4c022e6768953a93ea9ddbc6c195c6f716be934 100644 --- a/app/routes/authenticated/nodes.js +++ b/app/routes/authenticated/nodes.js @@ -4,7 +4,7 @@ import { inject as service } from '@ember/service'; import { getPanelInfo } from './utils'; -export default class FolderRoute extends Route { +export default class NodesRoute extends Route { @service store; @service currentUser; @@ -53,6 +53,8 @@ export default class FolderRoute extends Route { 'pages': extra_pages_with_url, } context['home_folder'] = this.currentUser.user.home_folder; + context['inbox_folder'] = this.currentUser.user.inbox_folder; + return context; } @@ -66,6 +68,7 @@ export default class FolderRoute extends Route { } context['home_folder'] = await this.currentUser.user.getHomeFolder(); + context['inbox_folder'] = await this.currentUser.user.getInboxFolder(); return context; } @@ -75,6 +78,7 @@ export default class FolderRoute extends Route { let _auth_controller = this.controllerFor('authenticated'); _auth_controller.set('home_folder', model.home_folder); + _auth_controller.set('inbox_folder', model.inbox_folder); } } diff --git a/app/templates/authenticated.hbs b/app/templates/authenticated.hbs index 9e784daf2bf59335168c380003a4a7195c8f5130..6f5d721b0c8ee52c4d9129cc4435e14648e9cb38 100644 --- a/app/templates/authenticated.hbs +++ b/app/templates/authenticated.hbs @@ -1,8 +1,8 @@ <main> <Nav::Sidebar @home_folder={{this.home_folder}} - @expanded={{this.expanded}} - /> + @inbox_folder={{this.inbox_folder}} + @expanded={{this.expanded}} /> <div class="w-100 central-bar"> <Nav::Topbar @onSidebarToggle={{this.onSidebarToggle}} /> diff --git a/app/templates/authenticated/inbox.hbs b/app/templates/authenticated/inbox.hbs deleted file mode 100644 index 1ac28e958d2ca9dc6dff76cccbb583957f1b76fa..0000000000000000000000000000000000000000 --- a/app/templates/authenticated/inbox.hbs +++ /dev/null @@ -1 +0,0 @@ -<h1>Inbox</h1> \ No newline at end of file