Skip to content

Commit

Permalink
feat(SLB-318): add meta menu
Browse files Browse the repository at this point in the history
  • Loading branch information
Leksat committed May 28, 2024
1 parent 988875b commit 0b83734
Show file tree
Hide file tree
Showing 7 changed files with 281 additions and 0 deletions.
8 changes: 8 additions & 0 deletions apps/cms/config/sync/system.menu.meta.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
uuid: ed03f628-2d83-4f82-aeb8-6c59d150757d
langcode: en
status: true
dependencies: { }
id: meta
label: Meta
description: 'Meta links.'
locked: false
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
_meta:
version: '1.0'
entity_type: menu_link_content
uuid: 4aa4a86f-8e0f-441d-8fcb-ac95b15ed13c
bundle: menu_link_content
default_langcode: en
default:
enabled:
-
value: true
title:
-
value: 'Meta item 2'
menu_name:
-
value: meta
link:
-
uri: 'internal:/'
title: ''
options: { }
external:
-
value: false
rediscover:
-
value: true
weight:
-
value: -49
expanded:
-
value: false
content_translation_source:
-
value: und
content_translation_outdated:
-
value: false
content_translation_uid:
-
target_id: 1
content_translation_status:
-
value: true
content_translation_created:
-
value: 1716899458
translations:
de:
title:
-
value: 'Meta item 2 DE'
content_translation_source:
-
value: en
content_translation_outdated:
-
value: false
content_translation_uid:
-
target_id: 1
content_translation_status:
-
value: true
content_translation_created:
-
value: 1716900493
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
_meta:
version: '1.0'
entity_type: menu_link_content
uuid: 679de789-7c88-494e-866d-062c2abf8fbb
bundle: menu_link_content
default_langcode: en
default:
enabled:
-
value: true
title:
-
value: 'Meta item 1'
menu_name:
-
value: meta
link:
-
uri: 'internal:/'
title: ''
options: { }
external:
-
value: false
rediscover:
-
value: true
weight:
-
value: -50
expanded:
-
value: false
content_translation_source:
-
value: und
content_translation_outdated:
-
value: false
content_translation_uid:
-
target_id: 1
content_translation_status:
-
value: true
content_translation_created:
-
value: 1716899070
translations:
de:
title:
-
value: 'Meta item 1 DE'
content_translation_source:
-
value: en
content_translation_outdated:
-
value: false
content_translation_uid:
-
target_id: 1
content_translation_status:
-
value: true
content_translation_created:
-
value: 1716900444
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
_meta:
version: '1.0'
entity_type: menu_link_content
uuid: 72904161-a94f-4934-98aa-f4b67e2dc9d5
bundle: menu_link_content
default_langcode: en
depends:
679de789-7c88-494e-866d-062c2abf8fbb: menu_link_content
default:
enabled:
-
value: true
title:
-
value: 'Meta item child - should be ignored'
menu_name:
-
value: meta
link:
-
uri: 'internal:/'
title: ''
options: { }
external:
-
value: false
rediscover:
-
value: true
weight:
-
value: -50
expanded:
-
value: false
parent:
-
value: 'menu_link_content:679de789-7c88-494e-866d-062c2abf8fbb'
content_translation_source:
-
value: und
content_translation_outdated:
-
value: false
content_translation_uid:
-
target_id: 1
content_translation_status:
-
value: true
content_translation_created:
-
value: 1716899647
translations:
de:
title:
-
value: 'Meta item child - should be ignored DE'
content_translation_source:
-
value: en
content_translation_outdated:
-
value: false
content_translation_uid:
-
target_id: 1
content_translation_status:
-
value: true
content_translation_created:
-
value: 1716900507
3 changes: 3 additions & 0 deletions packages/schema/src/operations/Frame.gql
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ query Frame {
}
}
}
metaNavigation: metaNavigations {
...Navigation
}
mainNavigation: mainNavigations {
...Navigation
}
Expand Down
9 changes: 9 additions & 0 deletions packages/schema/src/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,11 @@ interface Navigation {
items: [NavigationItem]!
}

type MetaNavigation implements Navigation @menu(menu_id: "meta") {
locale: Locale! @resolveEntityLanguage
items: [NavigationItem]! @lang @resolveMenuItems(max_level: 1)
}

type MainNavigation implements Navigation @menu(menu_id: "main") {
locale: Locale! @resolveEntityLanguage
items: [NavigationItem]! @lang @resolveMenuItems
Expand Down Expand Up @@ -309,6 +314,10 @@ type Query {
previewDrupalPage(id: ID!, rid: ID, locale: String!): DrupalPage
@fetchEntity(type: "node", id: "$id", rid: "$rid", language: "$locale")

metaNavigations: [MetaNavigation]
@gatsbyNodes(type: "MetaNavigation")
@menuTranslations(menu_id: "meta")

mainNavigations: [MainNavigation]
@gatsbyNodes(type: "MainNavigation")
@menuTranslations(menu_id: "main")
Expand Down
52 changes: 52 additions & 0 deletions tests/schema/specs/menu.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import gql from 'noop-tag';
import { expect, test } from 'vitest';

import { fetch } from '../lib.js';

test('Meta', async () => {
const result = await fetch(gql`
{
metaNavigations {
locale
items {
title
target
}
}
}
`);
expect(result).toMatchInlineSnapshot(`
{
"data": {
"metaNavigations": [
{
"items": [
{
"target": "/en",
"title": "Meta item 1",
},
{
"target": "/en",
"title": "Meta item 2",
},
],
"locale": "en",
},
{
"items": [
{
"target": "/de",
"title": "Meta item 1 DE",
},
{
"target": "/de",
"title": "Meta item 2 DE",
},
],
"locale": "de",
},
],
},
}
`);
});

0 comments on commit 0b83734

Please sign in to comment.