@triptease/tt-navbar 0.0.53 → 0.0.55

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,26 +1,17 @@
1
1
  /**
2
- * @triptease/tt-navbar v0.0.53
2
+ * @triptease/tt-navbar v0.0.55
3
3
  */
4
4
 
5
5
  // src/urlMappings.ts
6
6
  var urlMappings = {
7
- "/paidsearch/$CLIENT_KEY/performance": "/channels",
8
- "/meta/$CLIENT_KEY/performance": "/channels",
9
- "/retargeting/$CLIENT_KEY/performance": "/channels",
10
- "/retargeting/$CLIENT_KEY/ad-config": "/channels",
11
- "/messages/$CLIENT_KEY/messages": "/channels",
12
- "/messages/$CLIENT_KEY/messages/wizard": "/channels",
13
- "/messages/$CLIENT_KEY/messages/type": "/channels",
14
- "/messages/$CLIENT_KEY/messages/notifications": "/channels",
15
- "/messages/$CLIENT_KEY/messages/templates/nudge": "/channels",
16
- "/$CLIENT_KEY/email": "/channels",
17
- "/pricematch/$CLIENT_KEY/performance": "/channels",
18
- "/chat/insights/$CLIENT_KEY": "/channels",
19
- "/settings/$CLIENT_KEY/branding": "/settings/$CLIENT_KEY/guides",
20
- "/settings/$CLIENT_KEY/price-check": "/settings/$CLIENT_KEY/guides",
21
- "/settings/$CLIENT_KEY/price-config": "/settings/$CLIENT_KEY/guides",
22
- "/settings/$CLIENT_KEY/hotel-details-finder": "/settings/$CLIENT_KEY/guides",
23
- "/settings/$CLIENT_KEY/deactivation-center": "/settings/$CLIENT_KEY/guides"
7
+ "/paidsearch/:clientKey/*": "/channels",
8
+ "/meta/:clientKey/*": "/channels",
9
+ "/retargeting/:clientKey/*": "/channels",
10
+ "/messages/:clientKey/*": "/channels",
11
+ "/:clientKey/email": "/channels",
12
+ "/pricematch/:clientKey/*": "/channels",
13
+ "/chat/insights/:clientKey": "/channels",
14
+ "/settings/:clientKey/*": "/settings/$CLIENT_KEY/guides"
24
15
  };
25
16
  export {
26
17
  urlMappings
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/urlMappings.ts"],
4
- "sourcesContent": ["type UrlMapping = Record<string, string>;\n\nconst urlMappings: UrlMapping = {\n '/paidsearch/$CLIENT_KEY/performance': '/channels',\n '/meta/$CLIENT_KEY/performance': '/channels',\n '/retargeting/$CLIENT_KEY/performance': '/channels',\n '/retargeting/$CLIENT_KEY/ad-config': '/channels',\n '/messages/$CLIENT_KEY/messages': '/channels',\n '/messages/$CLIENT_KEY/messages/wizard': '/channels',\n '/messages/$CLIENT_KEY/messages/type': '/channels',\n '/messages/$CLIENT_KEY/messages/notifications': '/channels',\n '/messages/$CLIENT_KEY/messages/templates/nudge': '/channels',\n '/$CLIENT_KEY/email': '/channels',\n '/pricematch/$CLIENT_KEY/performance': '/channels',\n '/chat/insights/$CLIENT_KEY': '/channels',\n '/settings/$CLIENT_KEY/branding': '/settings/$CLIENT_KEY/guides',\n '/settings/$CLIENT_KEY/price-check': '/settings/$CLIENT_KEY/guides',\n '/settings/$CLIENT_KEY/price-config': '/settings/$CLIENT_KEY/guides',\n '/settings/$CLIENT_KEY/hotel-details-finder': '/settings/$CLIENT_KEY/guides',\n '/settings/$CLIENT_KEY/deactivation-center': '/settings/$CLIENT_KEY/guides',\n};\n\nexport { urlMappings };\n"],
5
- "mappings": ";;;;;AAEA,IAAM,cAA0B;AAAA,EAC9B,uCAAuC;AAAA,EACvC,iCAAiC;AAAA,EACjC,wCAAwC;AAAA,EACxC,sCAAsC;AAAA,EACtC,kCAAkC;AAAA,EAClC,yCAAyC;AAAA,EACzC,uCAAuC;AAAA,EACvC,gDAAgD;AAAA,EAChD,kDAAkD;AAAA,EAClD,sBAAsB;AAAA,EACtB,uCAAuC;AAAA,EACvC,8BAA8B;AAAA,EAC9B,kCAAkC;AAAA,EAClC,qCAAqC;AAAA,EACrC,sCAAsC;AAAA,EACtC,8CAA8C;AAAA,EAC9C,6CAA6C;AAC/C;",
4
+ "sourcesContent": ["type UrlMapping = Record<string, string>;\n\nconst urlMappings: UrlMapping = {\n '/paidsearch/:clientKey/*': '/channels',\n '/meta/:clientKey/*': '/channels',\n '/retargeting/:clientKey/*': '/channels',\n '/messages/:clientKey/*': '/channels',\n '/:clientKey/email': '/channels',\n '/pricematch/:clientKey/*': '/channels',\n '/chat/insights/:clientKey': '/channels',\n '/settings/:clientKey/*': '/settings/$CLIENT_KEY/guides',\n};\n\nexport { urlMappings };\n"],
5
+ "mappings": ";;;;;AAEA,IAAM,cAA0B;AAAA,EAC9B,4BAA4B;AAAA,EAC5B,sBAAsB;AAAA,EACtB,6BAA6B;AAAA,EAC7B,0BAA0B;AAAA,EAC1B,qBAAqB;AAAA,EACrB,4BAA4B;AAAA,EAC5B,6BAA6B;AAAA,EAC7B,0BAA0B;AAC5B;",
6
6
  "names": []
7
7
  }
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "Webcomponent tt-navbar following open-wc recommendations",
4
4
  "license": "MIT",
5
5
  "author": "tt-navbar",
6
- "version": "0.0.53",
6
+ "version": "0.0.55",
7
7
  "type": "module",
8
8
  "main": "dist/src/index.js",
9
9
  "module": "dist/src/index.js",
package/src/TtNavbar.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { html, LitElement } from 'lit';
2
- import { property, queryAll, state } from 'lit/decorators.js';
2
+ import { property, query, queryAll, state } from 'lit/decorators.js';
3
3
  import { unsafeSVG } from 'lit/directives/unsafe-svg.js';
4
4
  import {
5
5
  campaigns,
@@ -66,6 +66,9 @@ export class TtNavbar extends LitElement {
66
66
  @queryAll('a')
67
67
  protected allNavLinks!: Array<HTMLAnchorElement>;
68
68
 
69
+ @query(`a#${Routes.CampaignManager}`)
70
+ private campaignManagerLink!: HTMLAnchorElement;
71
+
69
72
  protected firstUpdated() {
70
73
  this.setActiveState();
71
74
  }
@@ -91,6 +94,12 @@ export class TtNavbar extends LitElement {
91
94
  super.disconnectedCallback();
92
95
  }
93
96
 
97
+ // eslint-disable-next-line no-undef
98
+ private get mappedUrlPatterns(): URLPattern[] {
99
+ // eslint-disable-next-line no-undef
100
+ return Object.keys(urlMappings).map(pattern => new URLPattern({ pathname: pattern, baseURL: window.location.origin }));
101
+ }
102
+
94
103
  /*
95
104
  * Set the active state for the current page.
96
105
  *
@@ -119,16 +128,20 @@ export class TtNavbar extends LitElement {
119
128
 
120
129
  // Check special cases first, as everything will always match on / and return Dashboard
121
130
  if (this.activeRoute === Routes.CampaignManager) {
122
- const links = Object.values(this.allNavLinks);
123
- bestMatch = links.find(link => link.id === Routes.CampaignManager);
131
+ bestMatch = this.campaignManagerLink;
124
132
  }
125
133
  if (!bestMatch && this.clientKey) {
126
134
  const parsedPath = currentPath.replace(this.clientKey, '$CLIENT_KEY');
127
- const mappedUrl = urlMappings[parsedPath];
135
+ let mappedUrl: string | undefined = urlMappings[parsedPath];
136
+
137
+ const matchedPattern = this.mappedUrlPatterns.find(pattern => pattern.test(currentPath, window.location.origin))?.pathname;
138
+
139
+ if (matchedPattern) {
140
+ mappedUrl = urlMappings[matchedPattern];
141
+ }
142
+
128
143
  if (mappedUrl) {
129
- const clientSpecificUrl = mappedUrl.includes('$CLIENT_KEY')
130
- ? mappedUrl.replace('$CLIENT_KEY', this.clientKey)
131
- : mappedUrl;
144
+ const clientSpecificUrl= mappedUrl.replace('$CLIENT_KEY', this.clientKey);
132
145
  const links = Object.values(this.allNavLinks);
133
146
  bestMatch = links.find(link => link.href.includes(clientSpecificUrl));
134
147
  }
package/src/styles.ts CHANGED
@@ -295,6 +295,7 @@ export const styles = css`
295
295
  display: flex;
296
296
  align-items: center;
297
297
  padding: var(--space-scale-1) 0;
298
+ margin-bottom: var(--space-scale-2);
298
299
  }
299
300
 
300
301
  #client-selector tt-combobox {
@@ -1,23 +1,14 @@
1
1
  type UrlMapping = Record<string, string>;
2
2
 
3
3
  const urlMappings: UrlMapping = {
4
- '/paidsearch/$CLIENT_KEY/performance': '/channels',
5
- '/meta/$CLIENT_KEY/performance': '/channels',
6
- '/retargeting/$CLIENT_KEY/performance': '/channels',
7
- '/retargeting/$CLIENT_KEY/ad-config': '/channels',
8
- '/messages/$CLIENT_KEY/messages': '/channels',
9
- '/messages/$CLIENT_KEY/messages/wizard': '/channels',
10
- '/messages/$CLIENT_KEY/messages/type': '/channels',
11
- '/messages/$CLIENT_KEY/messages/notifications': '/channels',
12
- '/messages/$CLIENT_KEY/messages/templates/nudge': '/channels',
13
- '/$CLIENT_KEY/email': '/channels',
14
- '/pricematch/$CLIENT_KEY/performance': '/channels',
15
- '/chat/insights/$CLIENT_KEY': '/channels',
16
- '/settings/$CLIENT_KEY/branding': '/settings/$CLIENT_KEY/guides',
17
- '/settings/$CLIENT_KEY/price-check': '/settings/$CLIENT_KEY/guides',
18
- '/settings/$CLIENT_KEY/price-config': '/settings/$CLIENT_KEY/guides',
19
- '/settings/$CLIENT_KEY/hotel-details-finder': '/settings/$CLIENT_KEY/guides',
20
- '/settings/$CLIENT_KEY/deactivation-center': '/settings/$CLIENT_KEY/guides',
4
+ '/paidsearch/:clientKey/*': '/channels',
5
+ '/meta/:clientKey/*': '/channels',
6
+ '/retargeting/:clientKey/*': '/channels',
7
+ '/messages/:clientKey/*': '/channels',
8
+ '/:clientKey/email': '/channels',
9
+ '/pricematch/:clientKey/*': '/channels',
10
+ '/chat/insights/:clientKey': '/channels',
11
+ '/settings/:clientKey/*': '/settings/$CLIENT_KEY/guides',
21
12
  };
22
13
 
23
14
  export { urlMappings };
@@ -296,6 +296,7 @@ describe('TtNavbar', () => {
296
296
  [`/${CLIENT_KEY}/email`, 'Channels'],
297
297
  [`/pricematch/${CLIENT_KEY}/performance`, 'Channels'],
298
298
  [`/chat/insights/${CLIENT_KEY}`, 'Channels'],
299
+ [`/messages/${CLIENT_KEY}/messages/new/save-the-search`, 'Channels'],
299
300
 
300
301
  // Settings routes
301
302
  [`/settings/${CLIENT_KEY}/branding`, 'Group settings'],