@castlabs/ui 7.9.3 → 7.10.0

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,4 +1,4 @@
1
- /* @castlabs/ui v7.9.3 */
1
+ /* @castlabs/ui v7.10.0 */
2
2
 
3
3
  /*!
4
4
  * Bootstrap v5.3.8 (https://getbootstrap.com/)
@@ -337,6 +337,521 @@ const CONST = {
337
337
  }
338
338
  }
339
339
 
340
+ // helpers that handle CS data
341
+
342
+ const ENV = {
343
+ DEV: 'DEV',
344
+ TEST: 'TEST',
345
+ STAG: 'STAG',
346
+ PROD: 'PROD'
347
+ }
348
+
349
+ const SERVICE = {
350
+ CP: 'Content Platform',
351
+ CP_TAGLINE: 'Access the Content Platform, manage, encode and watermark assets',
352
+ CP_URN: 'urn:janus:service:76b6e8558263431d9d766779987d6410',
353
+ CS: 'Castlabs hub',
354
+ CS_TAGLINE: 'Manage organizations, plans, downloads',
355
+ CS_URN: 'urn:janus:service:OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO',
356
+ DT: 'DRMtoday',
357
+ DT_TAGLINE: 'Cloud DRM & CAS licensing',
358
+ DT_URN: 'urn:janus:service:79a1092a0be44b1c95a4557b8d3ee2b7',
359
+ DTO: 'DRMtoday Onboard',
360
+ DTO_TAGLINE: 'DRMtoday Onboard',
361
+ DTO_URN: 'urn:janus:service:442f84ee6cc942188cb24486d7208289',
362
+ DTS: 'DRMtoday Staging',
363
+ DTS_TAGLINE: 'Cloud DRM & CAS licensing',
364
+ DTS_URN: 'urn:janus:service:17edeac267d84703ab0ddd7a33d85706',
365
+ PP: 'PRESTOplay',
366
+ PP_TAGLINE: 'Cross-platform video players (via Castlabs hub)',
367
+ PP_URN: 'urn:janus:service:a0682fd65f234a6793c526dc33131bab',
368
+ PP_URN_ANDROID: 'urn:janus:service:95841e63952149408c71c650c9659fb7',
369
+ PP_URN_BROWSER: 'urn:janus:service:852e1377df314c1a80003a9f67b98dfe',
370
+ PP_URN_GSTREAMER: 'urn:janus:service:76b6e8558263431d9d766779987d64c1',
371
+ PP_URN_IOS: 'urn:janus:service:2187beecaae44a01ac7eb353f5095f0f',
372
+ PP_URN_REACTNATIVE: 'urn:janus:service:6efecac3ac04477e9b36d3d14e0ae257',
373
+ PP_URN_WEBRTC: 'urn:janus:service:250402eb2e2d47118422ba4f2334ee54',
374
+ VTK: 'Video Toolkit',
375
+ VTK_TAGLINE: 'Cloud encoding, packaging, watermarking',
376
+ VTK_URN: 'urn:janus:service:a50e21d6a5e246809b636854abfbd34d',
377
+ WM: 'STARDUSTmark',
378
+ WM_TAGLINE: 'Video & image forensic watermarking',
379
+ WM_URN: 'urn:janus:service:76b6e8558263431d9d766779987d64c4'
380
+ }
381
+
382
+ const ROLE = {
383
+ CS_READONLY: 'Read-Only',
384
+ CS_READONLY_URN: 'urn:janus:role:b9d0931a01034fa095aa1a18ec303bac',
385
+
386
+ CS_ADMIN: 'Admin',
387
+ CS_ADMIN_URN: 'urn:janus:role:ab0cc31ad04a4090b41b0e552f7a3742',
388
+ CS_BILLING: 'Billing',
389
+ CS_BILLING_URN: 'urn:janus:role:2f4a76d16c9a47609255a253d873135c',
390
+ CS_REPORTS: 'Reports',
391
+ CS_REPORTS_URN: 'urn:janus:role:076e6514fe1f4d5abf307dc9fee7bbeb',
392
+
393
+ PP_ADMIN: 'PRESTOplay admin',
394
+ PP_ADMIN_URN: 'urn:janus:role:b79b1a10741f43b2bc0d1302d61b5865',
395
+ PP_USER: 'PRESTOplay user',
396
+ PP_USER_URN: 'urn:janus:role:7f2c7c7ee74d46e8936461d57180a1d3',
397
+
398
+ DT_MEMBERS: 'Members',
399
+ DT_MEMBERS_URN: 'urn:janus:role:2e5cfd4579d1485ca7e5f8cc97bdfe32',
400
+ DT_SUBORGS: 'Sub-organizations',
401
+ DT_SUBORGS_URN: 'urn:janus:role:2042447e1ae944c5a2bb75c9dd7077f3',
402
+ DT_CONFIGURATION: 'Configuration',
403
+ DT_CONFIGURATION_URN: 'urn:janus:role:07ac6d78216e41528d1b04a0ad737bc6',
404
+ DT_KEYS_DELETE: 'Key delete',
405
+ DT_KEYS_DELETE_URN: 'urn:janus:role:a79f863667944cca89588f69ea9d61dc',
406
+ DT_KEYS_INGEST: 'Key ingest',
407
+ DT_KEYS_INGEST_URN: 'urn:janus:role:08b9f5a98f084dd59d766be7039b504d',
408
+ DT_ASSETS: 'Assets',
409
+ DT_ASSETS_URN: 'urn:janus:role:4a2551570d644c08abb2795ccb8474cc',
410
+ DT_DELIVERIES: 'Deliveries',
411
+ DT_DELIVERIES_URN: 'urn:janus:role:7e23400fa5b84a38bbeca2ee515e5c9d',
412
+
413
+ DTO_DEVICES: 'Devices',
414
+ DTO_DEVICES_URN: 'urn:janus:role:c4e5556c769f4b23af3e502f9c589511',
415
+ DTO_KEYBOX: 'Keyboxes',
416
+ DTO_KEYBOX_URN: 'urn:janus:role:0658721525624ccc8fa612add5152d03',
417
+ DTO_DOWNLOAD: 'Downloads',
418
+ DTO_DOWNLOAD_URN: 'urn:janus:role:50905ceedf494b5e8d4379c0edce4b00',
419
+ DTO_REPORTS: 'Reports',
420
+ DTO_REPORTS_URN: 'urn:janus:role:50905ceedf494b5e8d4379c0edce4b01',
421
+ DTO_CONFIGURATION: 'Configuration',
422
+ DTO_CONFIGURATION_URN: 'urn:janus:role:50905ceedf494b5e8d4379c0edce4b02',
423
+
424
+ DTS_MEMBERS: 'Members',
425
+ DTS_MEMBERS_URN: 'urn:janus:role:36f4f90309294ceaa4f94e56953c1726',
426
+ DTS_SUBORGS: 'Sub-organizations',
427
+ DTS_SUBORGS_URN: 'urn:janus:role:471fe9be7e5d46feb6d84dd52e308b71',
428
+ DTS_CONFIGURATION: 'Configuration',
429
+ DTS_CONFIGURATION_URN: 'urn:janus:role:ff16e9fd5acc48e8a9acc078d2b72e7d',
430
+ DTS_KEYS_DELETE: 'Key delete',
431
+ DTS_KEYS_DELETE_URN: 'urn:janus:role:3f8dc55d3dbb4a4e893ba33ced829642',
432
+ DTS_KEYS_INGEST: 'Key ingest',
433
+ DTS_KEYS_INGEST_URN: 'urn:janus:role:471c6826d37f4d3aaa43cb3a3fda63ae',
434
+ DTS_ASSETS: 'Assets',
435
+ DTS_ASSETS_URN: 'urn:janus:role:f7c9335c70f14e4bb15d3f30761b8626',
436
+ DTS_DELIVERIES: 'Deliveries',
437
+ DTS_DELIVERIES_URN: 'urn:janus:role:e79a8f99a96a45238283b3c049e7374b',
438
+
439
+ VTK_ADMIN: 'Video Toolkit admin',
440
+ VTK_ADMIN_URN: 'urn:janus:role:8ff40a162b834e96a36f7ddbfda475ef',
441
+ VTK_USER: 'Video Toolkit user',
442
+ VTK_USER_URN: 'urn:janus:role:33c9c2001ca14dde9c3b310d0748b8b4',
443
+
444
+ CP_USER: 'Content Platform user',
445
+ CP_USER_URN: 'urn:janus:role:33c9c2001ca14dde9c3b310d0748b871',
446
+
447
+ WM_DEMO: 'Demo',
448
+ WM_DEMO_URN: 'urn:janus:role:33c9c2001ca14dde9c3b310d0748b850',
449
+ WM_EXTRACTION: 'Extraction',
450
+ WM_EXTRACTION_URN: 'urn:janus:role:33c9c2001ca14dde9c3b310d0748b851'
451
+ }
452
+
453
+ const STATE = {
454
+ UNKNOWN: null,
455
+ ACTIVE: 0,
456
+ PENDING: 1,
457
+ DELETED: 2,
458
+ SUSPENDED: 3
459
+ }
460
+
461
+ const LICENSE_STATE = {
462
+ ...STATE,
463
+ APPROVAL_REQUIRED: 4,
464
+ APPROVAL_DENIED: 5,
465
+ APPROVAL_REVOKED: 6
466
+ }
467
+
468
+ const PLAN = {
469
+ UNKNOWN: null,
470
+ TRIAL: 0,
471
+ STARTER: 1,
472
+ ENTERPRISE: 2,
473
+ CUSTOM: 3
474
+ }
475
+
476
+ const CS = {
477
+ SERVICE,
478
+ ROLE,
479
+ STATE,
480
+ LICENSE_STATE,
481
+ PLAN
482
+ }
483
+
484
+ // ----------------------------------------------------------------------------------------
485
+
486
+ function urlCS (env, oid, path) {
487
+ return getDevTestUrl(
488
+ env,
489
+ `https://account.test.cs.castlabs.com/o/${oid ?? ''}${path ?? ''}`,
490
+ `https://account.castlabs.com/o/${oid ?? ''}${path ?? ''}`
491
+ )
492
+ }
493
+
494
+ const NAV = {
495
+ CP: {
496
+ id: 'CP',
497
+ subtitle: SERVICE.CP_TAGLINE,
498
+ title: SERVICE.CP,
499
+ services: [CS.SERVICE.CP_URN],
500
+ roles: [ROLE.CP_USER_URN],
501
+ urlManage: (env, oid) =>
502
+ getEnvUrl(
503
+ env,
504
+ `https://platform.content.castlabs.com/#/o/${oid ?? ''}`,
505
+ `https://platform.content-stag.castlabs.com/#/o/${oid ?? ''}`
506
+ ),
507
+ urlPlan: (env, oid) => urlCS(env, oid),
508
+ sidenav: false
509
+ },
510
+
511
+ CS: {
512
+ id: 'CS',
513
+ subtitle: SERVICE.CS_TAGLINE,
514
+ title: SERVICE.CS,
515
+ services: [CS.SERVICE.CS_URN],
516
+ roles: [],
517
+ urlManage: (env, oid) => urlCS(env, oid),
518
+ urlPlan: (env, oid) => urlCS(env, oid),
519
+ sidenav: true
520
+ },
521
+
522
+ DT: {
523
+ id: 'DT',
524
+ subtitle: SERVICE.DT_TAGLINE,
525
+ title: SERVICE.DT,
526
+ services: [CS.SERVICE.DT_URN],
527
+ roles: [
528
+ ROLE.DT_MEMBERS_URN,
529
+ ROLE.DT_SUBORGS_URN,
530
+ ROLE.DT_CONFIGURATION_URN,
531
+ ROLE.DT_KEYS_DELETE_URN,
532
+ ROLE.DT_KEYS_INGEST_URN,
533
+ ROLE.DT_ASSETS_URN,
534
+ ROLE.DT_DELIVERIES_URN
535
+ ],
536
+ urlManage: (env, oid) =>
537
+ getDevTestUrl(
538
+ env,
539
+ `https://fe.test.drmtoday.com/dashboard/${oid ? `${oid}/` : ''}index`,
540
+ `https://fe.drmtoday.com/dashboard/${oid ? `${oid}/` : ''}index`
541
+ ),
542
+ urlPlan: (env, oid) => urlCS(env, oid, '/plans/drmtoday'),
543
+ sidenav: true
544
+ },
545
+
546
+ DTO: {
547
+ id: 'DTO',
548
+ subtitle: SERVICE.DTO_TAGLINE,
549
+ title: SERVICE.DTO,
550
+ services: [CS.SERVICE.DTO_URN],
551
+ roles: [
552
+ ROLE.DTO_DEVICES_URN,
553
+ ROLE.DTO_KEYBOX_URN,
554
+ ROLE.DTO_DOWNLOAD_URN,
555
+ ROLE.DTO_CONFIGURATION_URN,
556
+ ROLE.DTO_REPORTS_URN
557
+ ],
558
+ urlManage: (env, oid) => `https://onboard.castlabs.com/o/${oid ?? ''}/devices`,
559
+ urlPlan: (env, oid) => urlCS(env, oid),
560
+ sidenav: false
561
+ },
562
+
563
+ DTS: {
564
+ id: 'DTS',
565
+ subtitle: SERVICE.DTS_TAGLINE,
566
+ title: SERVICE.DTS,
567
+ services: [CS.SERVICE.DTS_URN],
568
+ roles: [
569
+ ROLE.DTS_MEMBERS_URN,
570
+ ROLE.DTS_SUBORGS_URN,
571
+ ROLE.DTS_CONFIGURATION_URN,
572
+ ROLE.DTS_KEYS_DELETE_URN,
573
+ ROLE.DTS_KEYS_INGEST_URN,
574
+ ROLE.DTS_ASSETS_URN,
575
+ ROLE.DTS_DELIVERIES_URN
576
+ ],
577
+ urlManage: (env, oid) =>
578
+ getDevTestUrl(
579
+ env,
580
+ `https://fe.test.drmtoday.com/dashboard/${oid ? `${oid}/` : ''}index`,
581
+ `https://fe.staging.drmtoday.com/dashboard/${oid ? `${oid}/` : ''}index`
582
+ ),
583
+ urlPlan: (env, oid) => urlCS(env, oid, '/plans/drmtoday'),
584
+ sidenav: false
585
+ },
586
+
587
+ PP: {
588
+ id: 'PP',
589
+ subtitle: SERVICE.PP_TAGLINE,
590
+ title: SERVICE.PP,
591
+ services: [
592
+ CS.SERVICE.PP_URN,
593
+ CS.SERVICE.PP_URN_ANDROID,
594
+ CS.SERVICE.PP_URN_BROWSER,
595
+ CS.SERVICE.PP_URN_GSTREAMER,
596
+ CS.SERVICE.PP_URN_IOS,
597
+ CS.SERVICE.PP_URN_REACTNATIVE,
598
+ CS.SERVICE.PP_URN_WEBRTC
599
+ ],
600
+ roles: [ROLE.PP_USER_URN, ROLE.PP_ADMIN_URN],
601
+ urlManage: (env, oid) =>
602
+ getEnvUrl(
603
+ env,
604
+ `https://account.castlabs.com/o/${oid}/prestoplay`,
605
+ `https://account.test.cs.castlabs.com/o/${oid}/prestoplay`
606
+ ),
607
+ urlPlan: (env, oid) => urlCS(env, oid, '/plans/prestoplay'),
608
+ sidenav: true
609
+ },
610
+ WM: {
611
+ id: 'WM',
612
+ subtitle: SERVICE.WM_TAGLINE,
613
+ title: SERVICE.WM,
614
+ services: [CS.SERVICE.WM_URN],
615
+ roles: [ROLE.WM_DEMO_URN, ROLE.WM_EXTRACTION_URN],
616
+ urlManage: (env, oid) =>
617
+ getEnvUrl(
618
+ env,
619
+ `https://watermark.castlabs.com/#/o/${oid}`,
620
+ `https://demo-stag.fwm.castlabs.com/#/o/${oid}`
621
+ ),
622
+ urlPlan: (env, oid) => urlCS(env, oid, '/plans/wm'),
623
+ sidenav: true
624
+ },
625
+
626
+ VTK: {
627
+ id: 'VTK',
628
+ subtitle: SERVICE.VTK_TAGLINE,
629
+ services: [CS.SERVICE.VTK_URN],
630
+ roles: [ROLE.VTK_USER_URN, ROLE.VTK_ADMIN_URN],
631
+ title: SERVICE.VTK,
632
+ urlManage: (env, oid) =>
633
+ getEnvUrl(env, `https://vtk.castlabs.com/${oid}`, `https://vtks.castlabs.com/${oid}`),
634
+ urlPlan: (env, oid) => urlCS(env, oid, '/plans/vtk'),
635
+ sidenav: true
636
+ }
637
+ }
638
+
639
+ function getDevTestUrl (env, urlDevTest, urlOther) {
640
+ return getEnvUrl(env, urlDevTest, urlOther, [ENV.DEV, ENV.TEST])
641
+ }
642
+
643
+ function getEnvUrl (env, urlEnv, urlOther, envs = [ENV.PROD]) {
644
+ return envs.includes(env) ? urlEnv : urlOther
645
+ }
646
+
647
+ // ----------------------------------------------------------------------------------------
648
+
649
+ function csGetBestOrgLicense (membership, sids) {
650
+ // sometimes multiple licenes apply to a service (e.g. PP-android, PP-ios, ...)
651
+ // in that case we choose the license with the highest service level to be used
652
+ // for sidenav link calulation
653
+ let best = null
654
+ for (const sid of sids) {
655
+ const license = csGetOrgLicense(membership, sid)
656
+ if (!license) continue
657
+ if (
658
+ best === null ||
659
+ (best.status === CS.LICENSE_STATE.APPROVAL_REQUIRED &&
660
+ license.status === CS.LICENSE_STATE.ACTIVE) ||
661
+ (best.plan === CS.PLAN.TRIAL && license.plan !== CS.PLAN.TRIAL)
662
+ ) {
663
+ best = license
664
+ }
665
+ }
666
+ return best
667
+ }
668
+
669
+ function csGetOrgLicense (membership, sid) {
670
+ for (const license of membership.organization?.licenses ?? []) {
671
+ if (
672
+ license.service === sid &&
673
+ [CS.LICENSE_STATE.ACTIVE, CS.LICENSE_STATE.APPROVAL_REQUIRED].includes(license.status)
674
+ ) {
675
+ return license
676
+ }
677
+ }
678
+ return null
679
+ }
680
+
681
+ function basic (service) {
682
+ // basic sidenav entry
683
+ return {
684
+ id: service.id,
685
+ title: service.title,
686
+ subtitle: service.subtitle,
687
+ url: '#',
688
+ locked: false,
689
+ disabled: false,
690
+ badge: undefined
691
+ }
692
+ }
693
+
694
+ function disabled (service) {
695
+ // sidenav entry in org-unavailable mode
696
+ return {
697
+ ...basic(service),
698
+ locked: true,
699
+ disabled: true
700
+ }
701
+ }
702
+
703
+ function subscribed (service, oid, env) {
704
+ // sidenav entry in subscribed mode
705
+ return {
706
+ ...basic(service),
707
+ url: service.urlManage(env, oid)
708
+ }
709
+ }
710
+
711
+ function trial (service, oid, env) {
712
+ // sidenav entry in TRIAL mode
713
+ return {
714
+ ...subscribed(service, oid, env),
715
+ badge: 'Trial'
716
+ }
717
+ }
718
+
719
+ function subscribe (service, oid, env) {
720
+ // sidenav entry in SUBSCRIBE mode
721
+ return {
722
+ ...basic(service),
723
+ url: service.urlPlan(env, oid),
724
+ badge: 'Subscribe',
725
+ locked: true
726
+ }
727
+ }
728
+
729
+ function pending (service, oid, env) {
730
+ // sidenav entry in PENDING mode
731
+ return {
732
+ ...basic(service),
733
+ url: service.urlPlan(env, oid),
734
+ badge: 'Pending',
735
+ locked: true
736
+ }
737
+ }
738
+
739
+ function variant (service, license, oid, env, hasRole) {
740
+ // no license = show subscribe ad
741
+ if (!license) {
742
+ // some items are hidden if there is no license
743
+ if ([NAV.DTS.id].includes(service.id)) return null
744
+
745
+ // other items we hint the user to subscribe
746
+ return subscribe(service, oid, env)
747
+ }
748
+
749
+ // pending license = show pending badge
750
+ if ([CS.LICENSE_STATE.APPROVAL_REQUIRED].includes(license.status))
751
+ return pending(service, oid, env)
752
+
753
+ // trial license = show trial badge
754
+ if (license.plan === CS.PLAN.TRIAL) return trial(service, oid, env)
755
+
756
+ // any other license and a matching role = manage link
757
+ if (hasRole) return subscribed(service, oid, env)
758
+
759
+ // license but no role = disabled
760
+ return disabled(service)
761
+ }
762
+
763
+ function csGetNavVariant (membership, service, oid, env) {
764
+ const license = csGetBestOrgLicense(membership, service.services)
765
+ return variant(
766
+ service,
767
+ license,
768
+ oid,
769
+ env,
770
+ !!membership.roles.find(r => service.roles.includes(r.role_urn))
771
+ )
772
+ }
773
+
774
+ function csParseMembership (membership, oid, env) {
775
+ const nav = [subscribed(NAV.CS, oid, env)]
776
+
777
+ nav.push(csGetNavVariant(membership, NAV.DT, oid, env))
778
+ const dts = csGetNavVariant(membership, NAV.DTS, oid, env)
779
+ if (dts) nav.push(dts)
780
+ nav.push(csGetNavVariant(membership, NAV.PP, oid, env))
781
+ nav.push(csGetNavVariant(membership, NAV.WM, oid, env))
782
+ nav.push(csGetNavVariant(membership, NAV.VTK, oid, env))
783
+
784
+ return nav
785
+ }
786
+
787
+ /**
788
+ * Filters and returns services to be shown in the sidenav based on licenses and user roles for a given org id. The expected
789
+ * JSON object corresponds to an memberships property from a CS UserInfo object retrieved via
790
+ * https://auth.castlabs.com/api/v1/userinfo
791
+ * (@see https://auth.castlabs.com/api/v1/docs#tag/User/operation/janus:UserInfo)
792
+ *
793
+ * @param {CsMembership[]} memberships Memberships.
794
+ * @param {string} oid Organization urn.
795
+ * @param {string} env Environment to generate links for (PROD, STAG, TEST, DEV).
796
+ * @returns Array of service navigation objects that the user has access to, in proper order to display in sidenav's service-drawer.
797
+ */
798
+ function csGetNav (memberships, oid, env) {
799
+ for (const membership of memberships) {
800
+ if (membership.organization?.organization_urn === oid) {
801
+ return csParseMembership(membership, oid, env)
802
+ }
803
+ }
804
+
805
+ return [
806
+ // static nav
807
+ subscribed(NAV.CS),
808
+ disabled(NAV.DT),
809
+ disabled(NAV.PP),
810
+ disabled(NAV.WM),
811
+ disabled(NAV.VTK)
812
+ ]
813
+ }
814
+
815
+ /**
816
+ * Filters membership array of CS API to only contain memberships for a given service and role.
817
+ *
818
+ * @param {CsMembership[]} memberships Memberships.
819
+ * @param {string} rid Role urn (optional).
820
+ * @param {string} sid Service urn (optional).
821
+ * @returns Array of memberships that match sid and rid. If any id was null, it was considered as 'any'.
822
+ */
823
+ function csFilterMemberships (memberships, rid, sid) {
824
+ let clone = JSON.parse(JSON.stringify(memberships))
825
+
826
+ // only keep orgs with licenses for required service
827
+ if (sid) {
828
+ clone = clone.filter(membership =>
829
+ membership.organization.licenses.find(license => license.service === sid)
830
+ )
831
+ }
832
+
833
+ // only keep orgs with required role
834
+ if (rid) {
835
+ clone = clone.filter(membership => membership.roles.find(role => role.role_urn === rid))
836
+ }
837
+
838
+ return clone
839
+ }
840
+
841
+ /**
842
+ * Get the link to the current user's account page in CS.
843
+ *
844
+ * @param {string} env Environment to generate links for (PROD, STAG, TEST, DEV).
845
+ * @returns {string} Full url to account page.
846
+ */
847
+ function csGetAccountUrl (env) {
848
+ return getDevTestUrl(
849
+ env,
850
+ 'https://account.test.cs.castlabs.com/account',
851
+ 'https://account.castlabs.com/account'
852
+ )
853
+ }
854
+
340
855
 
341
856
 
342
857
  // -----------------------------------------------------------------------------
@@ -1294,146 +1809,22 @@ function _tokenize (expression) {
1294
1809
  return expression
1295
1810
  }
1296
1811
 
1297
- const ENV = {
1298
- DEV: 'DEV',
1299
- TEST: 'TEST',
1300
- STAG: 'STAG',
1301
- PROD: 'PROD'
1302
- }
1303
-
1304
- const CP = {
1305
- id: 'CP',
1306
- subtitle: 'Access the Content Platform, manage, encode and watermark assets',
1307
- title: 'Content Platform',
1308
- urlManage: function (env, oid) {
1309
- if (env === ENV.PROD) {
1310
- return `https://platform.content.castlabs.com/#/o/${oid ?? ''}`
1311
- } else {
1312
- return `https://platform.content-stag.castlabs.com/#/o/${oid ?? ''}`
1313
- }
1314
- },
1315
- sidenav: false
1316
- }
1317
-
1318
- const CS = {
1319
- id: 'CS',
1320
- subtitle: 'Manage organizations, plans, downloads',
1321
- title: 'Castlabs hub',
1322
- urlManage: function (env, oid) {
1323
- return isDevTest(
1324
- env,
1325
- `https://account.test.cs.castlabs.com/o/${oid ?? ''}`,
1326
- `https://account.castlabs.com/o/${oid ?? ''}`
1327
- )
1328
- },
1329
- sidenav: true
1330
- }
1331
-
1332
- const DT = {
1333
- id: 'DT',
1334
- subtitle: 'Cloud DRM & CAS licensing',
1335
- title: 'DRMtoday',
1336
- urlManage: function (env, oid) {
1337
- return isDevTest(
1338
- env,
1339
- `https://fe.test.drmtoday.com/dashboard/${oid ? `${oid}/` : ''}index`,
1340
- `https://fe.drmtoday.com/dashboard/${oid ? `${oid}/` : ''}index`
1341
- )
1342
- },
1343
- sidenav: true
1344
- }
1345
1812
 
1346
- const DTO = {
1347
- id: 'DTO',
1348
- subtitle: '',
1349
- title: 'DRMtoday Onboard (staging)',
1350
- urlManage: function (env, oid) {
1351
- return `https://onboard.castlabs.com/o/${oid ?? ''}/devices`
1352
- },
1353
- sidenav: false
1354
- }
1355
-
1356
- const DTS = {
1357
- id: 'DTS',
1358
- subtitle: 'Cloud DRM & CAS licensing',
1359
- title: 'DRMtoday (staging)',
1360
- urlManage: function (env, oid) {
1361
- return isDevTest(
1362
- env,
1363
- `https://fe.test.drmtoday.com/dashboard/${oid ? `${oid}/` : ''}index`,
1364
- `https://fe.staging.drmtoday.com/dashboard/${oid ? `${oid}/` : ''}index`
1365
- )
1366
- },
1367
- sidenav: false
1368
- }
1369
-
1370
- const PP = {
1371
- id: 'PP',
1372
- subtitle: 'Cross-platform video players (via Castlabs hub)',
1373
- title: 'PRESTOplay',
1374
- urlManage: function (env, oid) {
1375
- if (env === ENV.PROD) {
1376
- return `https://account.castlabs.com/o/${oid}/prestoplay`
1377
- } else {
1378
- return `https://account.test.cs.castlabs.com/o/${oid}/prestoplay`
1379
- }
1380
- },
1381
- sidenav: true
1382
- }
1383
-
1384
- const VTK = {
1385
- id: 'VTK',
1386
- subtitle: 'Cloud encoding, packaging, watermarking',
1387
- title: 'Video Toolkit',
1388
- urlManage: function (env) {
1389
- if (env === ENV.PROD) {
1390
- return 'https://vtk.castlabs.com/'
1391
- } else {
1392
- return 'https://vtks.castlabs.com/'
1393
- }
1394
- },
1395
- sidenav: true
1396
- }
1397
-
1398
- const WM = {
1399
- id: 'WM',
1400
- subtitle: 'Video & image forensic watermarking',
1401
- title: 'STARDUSTmark',
1402
- urlManage: function (env, oid) {
1403
- if (env === ENV.PROD) {
1404
- return `https://watermark.castlabs.com/#/o/${oid}`
1405
- } else {
1406
- return `https://demo-stag.fwm.castlabs.com/#/o/${oid}`
1407
- }
1408
- },
1409
- sidenav: true
1410
- }
1411
-
1412
- function isDevTest (env = ENV.PROD, urlDevTest, urlOther) {
1413
- return [ENV.DEV, ENV.TEST].includes(env) ? urlDevTest : urlOther
1414
- }
1415
1813
 
1416
1814
  function clGetServices () {
1815
+ // static nav items if no CS integration is available
1417
1816
  return [
1418
1817
  // sorted alphabeticaly by title
1419
- CS,
1420
- CP,
1421
- DT,
1422
- DTS,
1423
- DTO,
1424
- PP,
1425
- WM,
1426
- VTK
1818
+ NAV.CS,
1819
+ NAV.CP,
1820
+ NAV.DT,
1821
+ NAV.DTS,
1822
+ NAV.DTO,
1823
+ NAV.PP,
1824
+ NAV.WM,
1825
+ NAV.VTK
1427
1826
  ]
1428
1827
  }
1429
1828
 
1430
- const NAV = {
1431
- CP,
1432
- CS,
1433
- DT,
1434
- DTS,
1435
- DTO,
1436
- PP,
1437
- WM,
1438
- VTK
1439
- }
1829
+ // compatibility export with previous ui-lib versions
1830
+ const NAV = nav