@triptease/tt-navbar 0.0.39 → 0.0.41

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,5 +1,5 @@
1
1
  /**
2
- * @triptease/tt-navbar v0.0.39
2
+ * @triptease/tt-navbar v0.0.41
3
3
  */
4
4
 
5
5
  // src/urlMappings.ts
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.39",
6
+ "version": "0.0.41",
7
7
  "type": "module",
8
8
  "main": "dist/src/index.js",
9
9
  "module": "dist/src/index.js",
@@ -5,6 +5,8 @@ export class NavbarController implements ReactiveController {
5
5
 
6
6
  private _isOpen = true;
7
7
 
8
+ private _hasInitialized = false;
9
+
8
10
  constructor(host: ReactiveControllerHost) {
9
11
  (this.host = host).addController(this);
10
12
  }
@@ -13,21 +15,21 @@ export class NavbarController implements ReactiveController {
13
15
  return this._isOpen;
14
16
  }
15
17
 
16
- hostConnected() {
17
- if (window.Clerk) {
18
+ hostUpdate() {
19
+ if (!this._hasInitialized && window.Clerk) {
18
20
  const userSetting =
19
21
  window.Clerk.user?.unsafeMetadata?.preferences?.ui?.navigationOpen;
20
22
 
21
23
  if (userSetting !== undefined) {
22
24
  this._isOpen = userSetting;
25
+ this._hasInitialized = true;
23
26
  this.host.requestUpdate();
24
27
  }
25
28
  }
26
29
  }
27
30
 
28
31
  async toggle() {
29
- const newState = !this._isOpen;
30
- this._isOpen = newState;
32
+ this._isOpen = !this._isOpen;
31
33
 
32
34
  if (window.Clerk) {
33
35
  await window.Clerk.user?.update({
@@ -37,7 +39,7 @@ export class NavbarController implements ReactiveController {
37
39
  ...window.Clerk.user?.unsafeMetadata?.preferences,
38
40
  ui: {
39
41
  ...window.Clerk.user?.unsafeMetadata?.preferences?.ui,
40
- navigationOpen: newState,
42
+ navigationOpen: this.isOpen,
41
43
  },
42
44
  },
43
45
  },
package/src/TtNavbar.ts CHANGED
@@ -12,7 +12,7 @@ import {
12
12
  logout,
13
13
  sidebarCollapsed,
14
14
  user,
15
- wallet
15
+ wallet,
16
16
  } from '@triptease/icons';
17
17
  import '@triptease/tt-combobox';
18
18
  import { styles } from './styles.js';
@@ -121,10 +121,11 @@ export class TtNavbar extends LitElement {
121
121
  const parsedPath = currentPath.replace(this.clientKey, '$CLIENT_KEY');
122
122
  const mappedUrl = urlMappings[parsedPath];
123
123
  if (mappedUrl) {
124
- const clientSpecificUrl = mappedUrl.includes('$CLIENT_KEY') ? mappedUrl.replace('$CLIENT_KEY', this.clientKey) : mappedUrl;
124
+ const clientSpecificUrl = mappedUrl.includes('$CLIENT_KEY')
125
+ ? mappedUrl.replace('$CLIENT_KEY', this.clientKey)
126
+ : mappedUrl;
125
127
  const links = Object.values(this.allNavLinks);
126
128
  bestMatch = links.find(link => link.href.includes(clientSpecificUrl));
127
- console.log({ mappedUrl, clientSpecificUrl, bestMatch });
128
129
  }
129
130
  }
130
131
 
@@ -234,18 +235,21 @@ export class TtNavbar extends LitElement {
234
235
  class="nav-item"
235
236
  href=${this.buildUrl('/')}
236
237
  @click=${this.onAnchorClick}
238
+ data-intercom-target="dashboard"
237
239
  >${unsafeSVG(home)}<span>Dashboard</span></a
238
240
  >
239
241
  <a id="${Routes.CampaignManager}" class="nav-item" href=${this.campaignManagerUrl}
242
+ data-intercom-target="campaigns"
240
243
  >${unsafeSVG(campaigns)}<span>Campaigns</span></a
241
244
  >
242
245
  <a
243
246
  class="nav-item"
244
247
  href=${this.buildUrl('/$CLIENT_KEY/channels')}
245
248
  @click=${this.onAnchorClick}
249
+ data-intercom-target="channels"
246
250
  >${unsafeSVG(channels)}<span>Channels</span></a
247
251
  >
248
- <details id="market-insights" @toggle=${this.handleToggle}>
252
+ <details id="market-insights" @toggle=${this.handleToggle} data-intercom-target="market-insights">
249
253
  <summary>
250
254
  ${unsafeSVG(graph)}
251
255
  <span>Market Insights</span>
@@ -256,17 +260,19 @@ export class TtNavbar extends LitElement {
256
260
  class="sub-nav-item"
257
261
  href=${this.buildUrl('/parity/$CLIENT_KEY')}
258
262
  @click=${this.onAnchorClick}
263
+ data-intercom-target="parity-monitoring"
259
264
  >Parity monitoring</a
260
265
  >
261
266
  <a
262
267
  class="sub-nav-item"
263
268
  href=${this.buildUrl('/guest-insights/$CLIENT_KEY')}
264
269
  @click=${this.onAnchorClick}
270
+ data-intercom-target="guest-insights"
265
271
  >Guest insights</a
266
272
  >
267
273
  </div>
268
274
  </details>
269
- <details id="settings" @toggle=${this.handleToggle}>
275
+ <details id="settings" @toggle=${this.handleToggle} data-intercom-target="settings">
270
276
  <summary>
271
277
  ${unsafeSVG(gear)}
272
278
  <span>Settings</span>
@@ -277,30 +283,34 @@ export class TtNavbar extends LitElement {
277
283
  class="sub-nav-item"
278
284
  href=${this.buildUrl('/$CLIENT_KEY/guest-behavioural-data')}
279
285
  @click=${this.onAnchorClick}
286
+ data-intercom-target="email-setup"
280
287
  >Email setup</a
281
288
  >
282
289
  <a
283
290
  class="sub-nav-item"
284
291
  href=${this.buildUrl('/$CLIENT_KEY/crm-config')}
285
292
  @click=${this.onAnchorClick}
293
+ data-intercom-target="crm-connectivity"
286
294
  >CRM connectivity</a
287
295
  >
288
296
  <a
289
297
  class="sub-nav-item"
290
298
  href=${this.buildUrl('/settings/$CLIENT_KEY/guides')}
291
299
  @click=${this.onAnchorClick}
300
+ data-intercom-target="group-settings"
292
301
  >Group settings</a
293
302
  >
294
303
  <a
295
304
  class="sub-nav-item"
296
305
  href=${this.buildUrl('/settings/$CLIENT_KEY/hotels')}
297
306
  @click=${this.onAnchorClick}
307
+ data-intercom-target="property-settings"
298
308
  >Property settings</a
299
309
  >
300
310
  </div>
301
311
  </details>
302
312
  <hr />
303
- <details id="account" @toggle=${this.handleToggle}>
313
+ <details id="account" @toggle=${this.handleToggle} data-intercom-target="account">
304
314
  <summary>
305
315
  ${unsafeSVG(user)}
306
316
  <span>Account</span>
@@ -311,17 +321,19 @@ export class TtNavbar extends LitElement {
311
321
  class="sub-nav-item"
312
322
  href=${this.buildUrl('/account')}
313
323
  @click=${this.onAnchorClick}
324
+ data-intercom-target="user-settings"
314
325
  >User settings</a
315
326
  >
316
327
  <a
317
328
  class="sub-nav-item"
318
329
  href=${this.buildUrl('/account/team/$CLIENT_KEY')}
319
330
  @click=${this.onAnchorClick}
331
+ data-intercom-target="team-permissions"
320
332
  >Team and permissions</a
321
333
  >
322
334
  </div>
323
335
  </details>
324
- <details id="billing-routes" @toggle=${this.handleToggle}>
336
+ <details id="billing-routes" @toggle=${this.handleToggle} data-intercom-target="billing">
325
337
  <summary>
326
338
  ${unsafeSVG(wallet)}
327
339
  <span>Billing</span>
@@ -332,12 +344,14 @@ export class TtNavbar extends LitElement {
332
344
  class="sub-nav-item"
333
345
  href=${this.buildUrl('/account/billing-management/$CLIENT_KEY')}
334
346
  @click=${this.onAnchorClick}
347
+ data-intercom-target="booking-reconciliation"
335
348
  >Booking reconciliation</a
336
349
  >
337
350
  <a
338
351
  class="sub-nav-item"
339
352
  href=${this.buildUrl('/subscriptions/$CLIENT_KEY')}
340
353
  @click=${this.onAnchorClick}
354
+ data-intercom-target="subscriptions"
341
355
  >Subscriptions</a
342
356
  >
343
357
  </div>
@@ -379,26 +393,26 @@ export class TtNavbar extends LitElement {
379
393
  ${
380
394
  this.clients.length > 1
381
395
  ? html`
382
- <tt-combobox
383
- .openUpward=${true}
384
- .value=${this.clientKey ? [this.clientKey] : []}
385
- @change=${this.handleClientChange}
386
- >
387
- ${this.clients.map(
388
- client => html`
389
- <option slot="option" value=${client.clientKey}>
390
- ${client.displayName}
391
- </option>
392
- `
393
- )}
394
- </tt-combobox>
395
- `
396
+ <tt-combobox
397
+ .openUpward=${true}
398
+ .value=${this.clientKey ? [this.clientKey] : []}
399
+ @change=${this.handleClientChange}
400
+ >
401
+ ${this.clients.map(
402
+ client => html`
403
+ <option slot="option" value=${client.clientKey}>
404
+ ${client.displayName}
405
+ </option>
406
+ `,
407
+ )}
408
+ </tt-combobox>
409
+ `
396
410
  : html`
397
- <div class="single-client-name">
398
- ${this.clients.find(m => m.clientKey === this.clientKey)
399
- ?.displayName}
400
- </div>
401
- `
411
+ <div class="single-client-name">
412
+ ${this.clients.find(m => m.clientKey === this.clientKey)
413
+ ?.displayName}
414
+ </div>
415
+ `
402
416
  }
403
417
  </div>
404
418
  <a
@@ -406,6 +420,7 @@ export class TtNavbar extends LitElement {
406
420
  class="nav-item"
407
421
  href=${this.buildUrl('/logout')}
408
422
  @click=${this.onAnchorClick}
423
+ data-intercom-target="logout"
409
424
  >${unsafeSVG(logout)}<span>Logout</span></a>
410
425
  </div>
411
426
  </nav>
@@ -461,6 +461,7 @@ describe('TtNavbar', () => {
461
461
  ) as HTMLButtonElement;
462
462
 
463
463
  navbarToggleBtn.click();
464
+ await elementUpdated(navbar);
464
465
 
465
466
  await expect(timesCalled).to.equal(1);
466
467
  expect(calledWith).to.deep.equal({