diff --git a/packages/breadcrumb/src/components/DruxtBreadcrumb.vue b/packages/breadcrumb/src/components/DruxtBreadcrumb.vue index 92e83f2d9..264c5d297 100644 --- a/packages/breadcrumb/src/components/DruxtBreadcrumb.vue +++ b/packages/breadcrumb/src/components/DruxtBreadcrumb.vue @@ -75,8 +75,8 @@ export default { crumbs: ({ model }) => model, ...mapState({ - route: state => state.druxtRouter.route, - routes: state => state.druxtRouter.routes + route: state => state.druxtRouter?.route, + routes: state => state.druxtRouter?.routes }) }, @@ -103,9 +103,9 @@ export default { * Fetch Crumbs */ async fetchCrumbs() { - const path = this.path || this.$route.path + const path = this.path || this.$route?.path let route = this.route - if (path && path !== route.path) { + if (path && path !== route?.path) { route = await this.getRoute(path) } diff --git a/packages/druxt/src/components/DruxtModule.vue b/packages/druxt/src/components/DruxtModule.vue index 93c6f20ea..091b82b58 100644 --- a/packages/druxt/src/components/DruxtModule.vue +++ b/packages/druxt/src/components/DruxtModule.vue @@ -444,7 +444,7 @@ export default { // Return only wrapper if fetch state is still pending and Druxt hasn't set // the available component options. - if (this.$fetchState.pending && !this.component.options?.length) { + if (this.$fetchState.pending && !this.component?.options?.length) { return h(this.wrapper?.component || 'div', wrapperData) } diff --git a/packages/menu/src/components/DruxtMenu.vue b/packages/menu/src/components/DruxtMenu.vue index 4aaecb12a..dd5b51bb4 100644 --- a/packages/menu/src/components/DruxtMenu.vue +++ b/packages/menu/src/components/DruxtMenu.vue @@ -205,7 +205,7 @@ export default { }), ...mapState({ - entities: state => state.druxtMenu.entities + entities: state => state.druxtMenu?.entities }) }, diff --git a/packages/router/src/components/DruxtRouter.vue b/packages/router/src/components/DruxtRouter.vue index 035469460..29f896885 100644 --- a/packages/router/src/components/DruxtRouter.vue +++ b/packages/router/src/components/DruxtRouter.vue @@ -199,7 +199,7 @@ export default { */ componentOptions: ({ module, route }) => [ // @TODO - Add Path options. - [module || 'error', route.isHomePath ? 'front' : 'not-front'], + [module || 'error', route?.isHomePath ? 'front' : 'not-front'], ['default'] ], @@ -259,7 +259,7 @@ export default { const scopedSlots = {} // Provide defualt error message. - if (this.model.error) { + if (this.model?.error) { scopedSlots.default = () => h('div', [ h('h1', [`Error ${this.model.error.statusCode}`]), h('p', [this.model.error.message]), diff --git a/packages/site/src/components/DruxtSite.vue b/packages/site/src/components/DruxtSite.vue index 13727916a..90dd13619 100644 --- a/packages/site/src/components/DruxtSite.vue +++ b/packages/site/src/components/DruxtSite.vue @@ -68,7 +68,7 @@ export default { }, data: ({ $druxt }) => ({ - defaultTheme: ($druxt.settings.site || {}).theme, + defaultTheme: $druxt?.settings?.site?.theme, }), /** */ @@ -129,7 +129,7 @@ export default { .addFields(type, ['theme']) .addFilter('plugin', 'system_main_block') .addPageLimit(1) - }).then((resources) => resources.data[0].attributes.theme) + })?.then((resources) => resources.data[0].attributes.theme) } // Fetch all available regions. @@ -139,7 +139,7 @@ export default { query: new DrupalJsonApiParams() .addFilter('theme', this.theme || this.defaultTheme) .addFields(type, ['region']), - }).then((resources) => resources.data.map((resource) => resource.attributes.region).filter((v, i, s) => s.indexOf(v) === i)) + })?.then((resources) => resources.data.map((resource) => resource.attributes.region).filter((v, i, s) => s.indexOf(v) === i)) } }, diff --git a/packages/views/src/components/DruxtView.vue b/packages/views/src/components/DruxtView.vue index 0653445b8..c98bc4c61 100644 --- a/packages/views/src/components/DruxtView.vue +++ b/packages/views/src/components/DruxtView.vue @@ -160,7 +160,7 @@ export default { * @type {string[]} */ attachments_after() { - if (!((((this.view || {}).data || {}).attributes || {}).display)) return false + if (!this.view?.data?.attributes?.display) return false const displays = this.view.data.attributes.display return Object.keys(displays).filter(key => { @@ -176,7 +176,7 @@ export default { * @type {string[]} */ attachments_before() { - if (!((((this.view || {}).data || {}).attributes || {}).display)) return false + if (!this.view?.data?.attributes?.display) return false const displays = this.view.data.attributes.display return Object.keys(displays).filter(key => { @@ -201,7 +201,7 @@ export default { * @type {object} */ display() { - if (!(((this.view || {}).data || {}).attributes || {}).display) return {} + if (!this.view?.data?.attributes?.display) return {} if (this.display_id === 'default') return this.view.data.attributes.display[this.display_id] @@ -259,7 +259,7 @@ export default { * @type {object[]} */ results() { - return (this.resource || {}).data || [] + return this.resource?.data || [] }, /** @@ -432,8 +432,8 @@ export default { * @returns {ComponentOptions} */ componentOptions: ({ displayId, uuid, view, viewId }) => ([ - [viewId || ((view.data || {}).attributes || {}).drupal_internal__id, displayId], - [uuid || (view.data || {}).id, displayId], + [viewId || view?.data?.attributes?.drupal_internal__id, displayId], + [uuid || view?.data?.id, displayId], [displayId] ]), @@ -454,7 +454,7 @@ export default { type: this.type, query: new DrupalJsonApiParams().addFilter('drupal_internal__id', this.viewId) }) - this.view = { data: collection.data[0] } + this.view = { data: collection?.data?.[0] } } } }, @@ -463,7 +463,7 @@ export default { * Fetch JSON:API Views results. */ async fetchData(settings) { - const viewId = this.viewId || (((this.view || {}).data || {}).attributes || {}).drupal_internal__id + const viewId = this.viewId || this.view?.data?.attributes?.drupal_internal__id if (viewId) { // Check if we need to bypass cache. let bypassCache = false