diff --git a/.eslintrc b/.eslintrc
index 71aa2b0..6995446 100644
--- a/.eslintrc
+++ b/.eslintrc
@@ -15,7 +15,7 @@
"@typescript-eslint/explicit-function-return-type": "warn",
"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/no-unused-vars": "error",
- "@typescript-eslint/no-explicit-any": "error",
+ "@typescript-eslint/no-explicit-any": "warn",
"@typescript-eslint/explicit-member-accessibility":[
"error",
{
diff --git a/demo/side-panels-manager/index.html b/demo/side-panels-manager/index.html
index 83416b0..a93dbc4 100644
--- a/demo/side-panels-manager/index.html
+++ b/demo/side-panels-manager/index.html
@@ -4,7 +4,7 @@
UI Managers
-
+
@@ -19,16 +19,6 @@
playback: {
autoplay: true
},
- // translations - for local environment
- ui: {
- translations: {
- "en": {
- "controls": {
- "moreIcon": "More"
- }
- }
- }
- },
plugins: {
somePlugin: {},
uiManagers: {}
diff --git a/demo/side-panels-manager/some-plugin.js b/demo/side-panels-manager/some-plugin.js
index f7b93d3..47cf37a 100644
--- a/demo/side-panels-manager/some-plugin.js
+++ b/demo/side-panels-manager/some-plugin.js
@@ -1,7 +1,7 @@
const { BasePlugin, registerPlugin, ui } = KalturaPlayer;
const { SidePanelModes, SidePanelPositions, ReservedPresetNames } = ui;
-const ICON_PATH = 'M318.641 446.219l236.155-142.257c-0.086-1.754-0.129-3.52-0.129-5.295 0-58.91 47.756-106.667 106.667-106.667s106.667 47.756 106.667 106.667c0 58.91-47.756 106.667-106.667 106.667-33.894 0-64.095-15.808-83.633-40.454l-236.467 142.445c-0.132-3.064-0.394-6.095-0.779-9.087l7.271-12.835-0.117 53.333-7.183-12.743c0.399-3.046 0.67-6.131 0.806-9.252l236.467 142.383c19.538-24.648 49.741-40.457 83.636-40.457 58.91 0 106.667 47.756 106.667 106.667s-47.756 106.667-106.667 106.667c-58.91 0-106.667-47.756-106.667-106.667 0-1.775 0.043-3.539 0.129-5.293l-236.19-142.216c-19.528 24.867-49.868 40.841-83.939 40.841-58.91 0-106.667-47.756-106.667-106.667s47.756-106.667 106.667-106.667c34.091 0 64.447 15.993 83.974 40.886zM234.667 554.667c23.564 0 42.667-19.103 42.667-42.667s-19.103-42.667-42.667-42.667c-23.564 0-42.667 19.103-42.667 42.667s19.103 42.667 42.667 42.667zM661.333 341.333c23.564 0 42.667-19.103 42.667-42.667s-19.103-42.667-42.667-42.667c-23.564 0-42.667 19.103-42.667 42.667s19.103 42.667 42.667 42.667zM661.333 768c23.564 0 42.667-19.103 42.667-42.667s-19.103-42.667-42.667-42.667c-23.564 0-42.667 19.103-42.667 42.667s19.103 42.667 42.667 42.667z';
+const ICON_PATH = 'M16 4c6.627 0 12 5.373 12 12s-5.373 12-12 12S4 22.627 4 16 9.373 4 16 4zm0 2C10.477 6 6 10.477 6 16s4.477 10 10 10 10-4.477 10-10S21.523 6 16 6zm0 9a1 1 0 0 1 1 .99v4.02a.992.992 0 0 1-.883.983L16 21a1 1 0 0 1-1-.99v-4.02c0-.507.383-.926.883-.983L16 15zm0-4.2a1.2 1.2 0 1 1 0 2.4 1.2 1.2 0 0 1 0-2.4z'
import {
@@ -24,7 +24,7 @@ export class somePlugin extends BasePlugin {
super(name, player);
this.player.ready().then(() => {
const panelItemAId = this.player.getService('sidePanelsManager').add({
- label: 'Panel A',
+ label: 'Panel-A',
panelComponent: PanelItemComponent,
iconComponent: {component: IconComponent, svgIcon: {path: ICON_PATH}},
presets: [ReservedPresetNames.Playback, ReservedPresetNames.Live],
@@ -38,8 +38,10 @@ export class somePlugin extends BasePlugin {
}
});
+ this.addUpperBarIcon('Panel-A', panelItemAId, IconComponent);
+
const PanelItemBId = this.player.getService('sidePanelsManager').add({
- label: 'Panel B',
+ label: 'Panel-B',
panelComponent: AnotherPanelItemComponent,
iconComponent: {component: AnotherIconComponent, svgIcon: {path: ICON_PATH}},
presets: [ReservedPresetNames.Playback, ReservedPresetNames.Live],
@@ -47,8 +49,10 @@ export class somePlugin extends BasePlugin {
expandMode: SidePanelModes.ALONGSIDE
});
+ this.addUpperBarIcon('Panel-B', PanelItemBId, AnotherIconComponent);
+
const PanelItemCId = this.player.getService('sidePanelsManager').add({
- label: 'Panel C',
+ label: 'Panel-C',
panelComponent: SomePanelItemComponent,
iconComponent: {component: SomeIconComponent, svgIcon: {path: ICON_PATH}},
presets: [ReservedPresetNames.Playback, ReservedPresetNames.Live],
@@ -56,8 +60,10 @@ export class somePlugin extends BasePlugin {
expandMode: SidePanelModes.OVER
});
+ this.addUpperBarIcon('Panel-C', PanelItemCId, SomeIconComponent);
+
const PanelItemDId = this.player.getService('sidePanelsManager').add({
- label: 'Panel D',
+ label: 'Panel-D',
panelComponent: MorePanelItemComponent,
iconComponent: {component: MoreIconComponent, svgIcon: {path: ICON_PATH}},
presets: [ReservedPresetNames.Playback, ReservedPresetNames.Live],
@@ -65,6 +71,8 @@ export class somePlugin extends BasePlugin {
expandMode: SidePanelModes.ALONGSIDE
});
+ this.addUpperBarIcon('Panel-D', PanelItemDId, MoreIconComponent);
+
this.player.getService('sidePanelsManager').activateItem(panelItemAId);
console.log(this.player.getService('sidePanelsManager').isItemActive(panelItemAId));
// true
@@ -76,6 +84,24 @@ export class somePlugin extends BasePlugin {
});
}
+ addUpperBarIcon(pluginName, panelItemAIconId, IconComponent) {
+ this.player.getService('upperBarManager').add({
+ displayName: pluginName,
+ ariaLabel: pluginName,
+ svgIcon: {path: ICON_PATH},
+ component: IconComponent,
+ onClick: () => this.toggle(panelItemAIconId)
+ });
+ }
+
+ toggle(panelItemId) {
+ if (this.player.getService('sidePanelsManager').isItemActive(panelItemId)) {
+ this.player.getService('sidePanelsManager').deactivateItem(panelItemId);
+ } else {
+ this.player.getService('sidePanelsManager').activateItem(panelItemId);
+ }
+ }
+
static isValid() {
return true;
diff --git a/demo/uppar-bar-manager/index.html b/demo/uppar-bar-manager/index.html
index e855280..6bc0b2a 100644
--- a/demo/uppar-bar-manager/index.html
+++ b/demo/uppar-bar-manager/index.html
@@ -4,7 +4,7 @@
UI Managers
-
+
@@ -24,29 +24,8 @@
playback: {
autoplay: true
},
- // translations - for local environment
- ui: {
- translations: {
- "en": {
- "controls": {
- "moreIcon": "More"
- }
- }
- }
- },
plugins: {
- uiManagers: {
- upperBarManager: {
- pluginsIconsOrder: {
- 'Plugin A': 100,
- 'Plugin B': 110,
- 'Plugin C': 120,
- 'Plugin D': 130,
- 'Plugin E': 140,
- 'Plugin F': 150
- }
- }
- },
+ uiManagers: {},
pluginA: {},
pluginB: {},
pluginC: {},
diff --git a/demo/uppar-bar-manager/plugin-A.js b/demo/uppar-bar-manager/plugin-A.js
index deb9558..f745b1f 100644
--- a/demo/uppar-bar-manager/plugin-A.js
+++ b/demo/uppar-bar-manager/plugin-A.js
@@ -1,7 +1,7 @@
const { BasePlugin, registerPlugin, ui } = KalturaPlayer;
const { h, preact, style } = KalturaPlayer.ui;
-const ICON_PATH = 'M318.641 446.219l236.155-142.257c-0.086-1.754-0.129-3.52-0.129-5.295 0-58.91 47.756-106.667 106.667-106.667s106.667 47.756 106.667 106.667c0 58.91-47.756 106.667-106.667 106.667-33.894 0-64.095-15.808-83.633-40.454l-236.467 142.445c-0.132-3.064-0.394-6.095-0.779-9.087l7.271-12.835-0.117 53.333-7.183-12.743c0.399-3.046 0.67-6.131 0.806-9.252l236.467 142.383c19.538-24.648 49.741-40.457 83.636-40.457 58.91 0 106.667 47.756 106.667 106.667s-47.756 106.667-106.667 106.667c-58.91 0-106.667-47.756-106.667-106.667 0-1.775 0.043-3.539 0.129-5.293l-236.19-142.216c-19.528 24.867-49.868 40.841-83.939 40.841-58.91 0-106.667-47.756-106.667-106.667s47.756-106.667 106.667-106.667c34.091 0 64.447 15.993 83.974 40.886zM234.667 554.667c23.564 0 42.667-19.103 42.667-42.667s-19.103-42.667-42.667-42.667c-23.564 0-42.667 19.103-42.667 42.667s19.103 42.667 42.667 42.667zM661.333 341.333c23.564 0 42.667-19.103 42.667-42.667s-19.103-42.667-42.667-42.667c-23.564 0-42.667 19.103-42.667 42.667s19.103 42.667 42.667 42.667zM661.333 768c23.564 0 42.667-19.103 42.667-42.667s-19.103-42.667-42.667-42.667c-23.564 0-42.667 19.103-42.667 42.667s19.103 42.667 42.667 42.667z';
+const ICON_PATH = 'M8.378 7.084l5.175 19.314c.134.497-.126 1.005-.594 1.19l-.112.037c-.533.143-1.08-.165-1.225-.71L6.447 7.603c-.134-.497.126-1.005.594-1.19l.112-.037c.533-.143 1.08.165 1.225.71zM21.882 7c1.878 0 2.79 1.622 1.84 3.239l-1.386 2.36 2.94 3.246C26.6 17.31 25.842 19 23.868 19h-10.21c-.452 0-.848-.304-.966-.741l-2.68-10c-.17-.635.31-1.259.967-1.259h10.902zm.211 1.994l-.21.006h-9.6l2.144 8h9.196l-3.263-3.604c-.293-.324-.342-.8-.12-1.178l1.757-2.992c.114-.194.168-.23.096-.232z';
class IconComponent extends preact.Component {
render() {
@@ -23,7 +23,9 @@ export class PluginA extends BasePlugin {
addUpperBarIcon() {
this.player.ready().then(() => {
this.iconId = this.player.getService('upperBarManager').add({
- label: 'Plugin A',
+ displayName: 'Plugin-A',
+ ariaLabel: 'Plugin-A',
+ order: 100,
svgIcon: {path: ICON_PATH},
component: IconComponent,
onClick: () => alert('hello from plugin A')
diff --git a/demo/uppar-bar-manager/plugin-B.js b/demo/uppar-bar-manager/plugin-B.js
index 902111e..19f7efb 100644
--- a/demo/uppar-bar-manager/plugin-B.js
+++ b/demo/uppar-bar-manager/plugin-B.js
@@ -1,7 +1,7 @@
const { BasePlugin, registerPlugin, ui } = KalturaPlayer;
const { h, preact, style } = KalturaPlayer.ui;
-const ICON_PATH = 'M318.641 446.219l236.155-142.257c-0.086-1.754-0.129-3.52-0.129-5.295 0-58.91 47.756-106.667 106.667-106.667s106.667 47.756 106.667 106.667c0 58.91-47.756 106.667-106.667 106.667-33.894 0-64.095-15.808-83.633-40.454l-236.467 142.445c-0.132-3.064-0.394-6.095-0.779-9.087l7.271-12.835-0.117 53.333-7.183-12.743c0.399-3.046 0.67-6.131 0.806-9.252l236.467 142.383c19.538-24.648 49.741-40.457 83.636-40.457 58.91 0 106.667 47.756 106.667 106.667s-47.756 106.667-106.667 106.667c-58.91 0-106.667-47.756-106.667-106.667 0-1.775 0.043-3.539 0.129-5.293l-236.19-142.216c-19.528 24.867-49.868 40.841-83.939 40.841-58.91 0-106.667-47.756-106.667-106.667s47.756-106.667 106.667-106.667c34.091 0 64.447 15.993 83.974 40.886zM234.667 554.667c23.564 0 42.667-19.103 42.667-42.667s-19.103-42.667-42.667-42.667c-23.564 0-42.667 19.103-42.667 42.667s19.103 42.667 42.667 42.667zM661.333 341.333c23.564 0 42.667-19.103 42.667-42.667s-19.103-42.667-42.667-42.667c-23.564 0-42.667 19.103-42.667 42.667s19.103 42.667 42.667 42.667zM661.333 768c23.564 0 42.667-19.103 42.667-42.667s-19.103-42.667-42.667-42.667c-23.564 0-42.667 19.103-42.667 42.667s19.103 42.667 42.667 42.667z';
+const ICON_PATH = 'M16 4c6.627 0 12 5.373 12 12s-5.373 12-12 12S4 22.627 4 16 9.373 4 16 4zm0 2C10.477 6 6 10.477 6 16s4.477 10 10 10 10-4.477 10-10S21.523 6 16 6zm0 9a1 1 0 0 1 1 .99v4.02a.992.992 0 0 1-.883.983L16 21a1 1 0 0 1-1-.99v-4.02c0-.507.383-.926.883-.983L16 15zm0-4.2a1.2 1.2 0 1 1 0 2.4 1.2 1.2 0 0 1 0-2.4z'
class IconComponent extends preact.Component {
@@ -24,7 +24,9 @@ export class PluginB extends BasePlugin {
addUpperBarIcon() {
this.player.ready().then(() => {
this.iconId = this.player.getService('upperBarManager').add({
- label: 'Plugin B',
+ displayName: 'Plugin-B',
+ ariaLabel: 'Plugin-B',
+ order: 110,
svgIcon: {path: ICON_PATH},
component: IconComponent,
onClick: () => alert('hello from plugin B')
diff --git a/demo/uppar-bar-manager/plugin-C.js b/demo/uppar-bar-manager/plugin-C.js
index 5d016cc..6b69b92 100644
--- a/demo/uppar-bar-manager/plugin-C.js
+++ b/demo/uppar-bar-manager/plugin-C.js
@@ -1,7 +1,7 @@
const { BasePlugin, registerPlugin, ui } = KalturaPlayer;
const { h, preact, style } = KalturaPlayer.ui;
-const ICON_PATH = 'M318.641 446.219l236.155-142.257c-0.086-1.754-0.129-3.52-0.129-5.295 0-58.91 47.756-106.667 106.667-106.667s106.667 47.756 106.667 106.667c0 58.91-47.756 106.667-106.667 106.667-33.894 0-64.095-15.808-83.633-40.454l-236.467 142.445c-0.132-3.064-0.394-6.095-0.779-9.087l7.271-12.835-0.117 53.333-7.183-12.743c0.399-3.046 0.67-6.131 0.806-9.252l236.467 142.383c19.538-24.648 49.741-40.457 83.636-40.457 58.91 0 106.667 47.756 106.667 106.667s-47.756 106.667-106.667 106.667c-58.91 0-106.667-47.756-106.667-106.667 0-1.775 0.043-3.539 0.129-5.293l-236.19-142.216c-19.528 24.867-49.868 40.841-83.939 40.841-58.91 0-106.667-47.756-106.667-106.667s47.756-106.667 106.667-106.667c34.091 0 64.447 15.993 83.974 40.886zM234.667 554.667c23.564 0 42.667-19.103 42.667-42.667s-19.103-42.667-42.667-42.667c-23.564 0-42.667 19.103-42.667 42.667s19.103 42.667 42.667 42.667zM661.333 341.333c23.564 0 42.667-19.103 42.667-42.667s-19.103-42.667-42.667-42.667c-23.564 0-42.667 19.103-42.667 42.667s19.103 42.667 42.667 42.667zM661.333 768c23.564 0 42.667-19.103 42.667-42.667s-19.103-42.667-42.667-42.667c-23.564 0-42.667 19.103-42.667 42.667s19.103 42.667 42.667 42.667z';
+const ICON_PATH = 'M11.6592 10.245L6.70483 5.29061C6.31701 4.9028 5.68581 4.90476 5.29528 5.29528C4.90204 5.68853 4.90267 6.31688 5.29061 6.70483L10.245 11.6592L5.29061 16.6137C4.9028 17.0015 4.90476 17.6327 5.29528 18.0232C5.68853 18.4165 6.31688 18.4158 6.70483 18.0279L11.6592 13.0735L16.6137 18.0279C17.0015 18.4157 17.6327 18.4137 18.0232 18.0232C18.4165 17.63 18.4158 17.0016 18.0279 16.6137L13.0735 11.6592L18.0279 6.70483C18.4157 6.31701 18.4137 5.68581 18.0232 5.29528C17.63 4.90204 17.0016 4.90267 16.6137 5.29061L11.6592 10.245Z'
class IconComponent extends preact.Component {
render() {
@@ -23,7 +23,9 @@ export class PluginC extends BasePlugin {
addUpperBarIcon() {
this.player.ready().then(() => {
this.iconId = this.player.getService('upperBarManager').add({
- label: 'Plugin C',
+ displayName: 'Plugin-C',
+ ariaLabel: 'Plugin-C',
+ order: 120,
svgIcon: {path: ICON_PATH},
component: IconComponent,
onClick: () => alert('hello from plugin C')
diff --git a/demo/uppar-bar-manager/plugin-D.js b/demo/uppar-bar-manager/plugin-D.js
index 26fe3c8..7822ba1 100644
--- a/demo/uppar-bar-manager/plugin-D.js
+++ b/demo/uppar-bar-manager/plugin-D.js
@@ -1,9 +1,10 @@
const { BasePlugin, registerPlugin, ui } = KalturaPlayer;
const { h, preact, style } = KalturaPlayer.ui;
-const ICON_PATH = 'M318.641 446.219l236.155-142.257c-0.086-1.754-0.129-3.52-0.129-5.295 0-58.91 47.756-106.667 106.667-106.667s106.667 47.756 106.667 106.667c0 58.91-47.756 106.667-106.667 106.667-33.894 0-64.095-15.808-83.633-40.454l-236.467 142.445c-0.132-3.064-0.394-6.095-0.779-9.087l7.271-12.835-0.117 53.333-7.183-12.743c0.399-3.046 0.67-6.131 0.806-9.252l236.467 142.383c19.538-24.648 49.741-40.457 83.636-40.457 58.91 0 106.667 47.756 106.667 106.667s-47.756 106.667-106.667 106.667c-58.91 0-106.667-47.756-106.667-106.667 0-1.775 0.043-3.539 0.129-5.293l-236.19-142.216c-19.528 24.867-49.868 40.841-83.939 40.841-58.91 0-106.667-47.756-106.667-106.667s47.756-106.667 106.667-106.667c34.091 0 64.447 15.993 83.974 40.886zM234.667 554.667c23.564 0 42.667-19.103 42.667-42.667s-19.103-42.667-42.667-42.667c-23.564 0-42.667 19.103-42.667 42.667s19.103 42.667 42.667 42.667zM661.333 341.333c23.564 0 42.667-19.103 42.667-42.667s-19.103-42.667-42.667-42.667c-23.564 0-42.667 19.103-42.667 42.667s19.103 42.667 42.667 42.667zM661.333 768c23.564 0 42.667-19.103 42.667-42.667s-19.103-42.667-42.667-42.667c-23.564 0-42.667 19.103-42.667 42.667s19.103 42.667 42.667 42.667z';
+const ICON_PATH = 'M19.7071 9.29289C20.0676 9.65338 20.0953 10.2206 19.7903 10.6129L19.7071 10.7071L14.415 16L19.7071 21.2929C20.0676 21.6534 20.0953 22.2206 19.7903 22.6129L19.7071 22.7071C19.3466 23.0676 18.7794 23.0953 18.3871 22.7903L18.2929 22.7071L12.2929 16.7071C11.9324 16.3466 11.9047 15.7794 12.2097 15.3871L12.2929 15.2929L18.2929 9.29289C18.6834 8.90237 19.3166 8.90237 19.7071 9.29289Z';
-class IconComponent extends preact.Component {
+
+ class IconComponent extends preact.Component {
render() {
return h('div', { className: 'icon' + ' ' + ui.style.upperBarIcon, tabIndex: 0 }, 'D');
}
@@ -23,7 +24,9 @@ export class PluginD extends BasePlugin {
addUpperBarIcon() {
this.player.ready().then(() => {
this.iconId = this.player.getService('upperBarManager').add({
- label: 'Plugin D',
+ displayName: 'Plugin-D',
+ ariaLabel: 'Plugin-D',
+ order: 130,
component: IconComponent,
svgIcon: {path: ICON_PATH},
onClick: () => alert('hello from plugin D')
diff --git a/demo/uppar-bar-manager/plugin-E.js b/demo/uppar-bar-manager/plugin-E.js
index f15431a..704aa9e 100644
--- a/demo/uppar-bar-manager/plugin-E.js
+++ b/demo/uppar-bar-manager/plugin-E.js
@@ -1,7 +1,7 @@
const { BasePlugin, registerPlugin, ui } = KalturaPlayer;
const { h, preact, style } = KalturaPlayer.ui;
-const ICON_PATH = 'M318.641 446.219l236.155-142.257c-0.086-1.754-0.129-3.52-0.129-5.295 0-58.91 47.756-106.667 106.667-106.667s106.667 47.756 106.667 106.667c0 58.91-47.756 106.667-106.667 106.667-33.894 0-64.095-15.808-83.633-40.454l-236.467 142.445c-0.132-3.064-0.394-6.095-0.779-9.087l7.271-12.835-0.117 53.333-7.183-12.743c0.399-3.046 0.67-6.131 0.806-9.252l236.467 142.383c19.538-24.648 49.741-40.457 83.636-40.457 58.91 0 106.667 47.756 106.667 106.667s-47.756 106.667-106.667 106.667c-58.91 0-106.667-47.756-106.667-106.667 0-1.775 0.043-3.539 0.129-5.293l-236.19-142.216c-19.528 24.867-49.868 40.841-83.939 40.841-58.91 0-106.667-47.756-106.667-106.667s47.756-106.667 106.667-106.667c34.091 0 64.447 15.993 83.974 40.886zM234.667 554.667c23.564 0 42.667-19.103 42.667-42.667s-19.103-42.667-42.667-42.667c-23.564 0-42.667 19.103-42.667 42.667s19.103 42.667 42.667 42.667zM661.333 341.333c23.564 0 42.667-19.103 42.667-42.667s-19.103-42.667-42.667-42.667c-23.564 0-42.667 19.103-42.667 42.667s19.103 42.667 42.667 42.667zM661.333 768c23.564 0 42.667-19.103 42.667-42.667s-19.103-42.667-42.667-42.667c-23.564 0-42.667 19.103-42.667 42.667s19.103 42.667 42.667 42.667z';
+const ICON_PATH = 'M11.6592 10.245L6.70483 5.29061C6.31701 4.9028 5.68581 4.90476 5.29528 5.29528C4.90204 5.68853 4.90267 6.31688 5.29061 6.70483L10.245 11.6592L5.29061 16.6137C4.9028 17.0015 4.90476 17.6327 5.29528 18.0232C5.68853 18.4165 6.31688 18.4158 6.70483 18.0279L11.6592 13.0735L16.6137 18.0279C17.0015 18.4157 17.6327 18.4137 18.0232 18.0232C18.4165 17.63 18.4158 17.0016 18.0279 16.6137L13.0735 11.6592L18.0279 6.70483C18.4157 6.31701 18.4137 5.68581 18.0232 5.29528C17.63 4.90204 17.0016 4.90267 16.6137 5.29061L11.6592 10.245Z'
class IconComponent extends preact.Component {
@@ -24,7 +24,9 @@ export class PluginE extends BasePlugin {
addUpperBarIcon() {
this.player.ready().then(() => {
this.iconId = this.player.getService('upperBarManager').add({
- label: 'Plugin E',
+ displayName: 'Plugin-E',
+ ariaLabel: 'Plugin-E',
+ order: 140,
component: IconComponent,
svgIcon: {path: ICON_PATH},
onClick: () => alert('hello from plugin E')
diff --git a/demo/uppar-bar-manager/plugin-F.js b/demo/uppar-bar-manager/plugin-F.js
index b3cfac0..c3e50b4 100644
--- a/demo/uppar-bar-manager/plugin-F.js
+++ b/demo/uppar-bar-manager/plugin-F.js
@@ -1,7 +1,7 @@
const { BasePlugin, registerPlugin, ui } = KalturaPlayer;
const { h, preact, style } = KalturaPlayer.ui;
-const ICON_PATH = 'M318.641 446.219l236.155-142.257c-0.086-1.754-0.129-3.52-0.129-5.295 0-58.91 47.756-106.667 106.667-106.667s106.667 47.756 106.667 106.667c0 58.91-47.756 106.667-106.667 106.667-33.894 0-64.095-15.808-83.633-40.454l-236.467 142.445c-0.132-3.064-0.394-6.095-0.779-9.087l7.271-12.835-0.117 53.333-7.183-12.743c0.399-3.046 0.67-6.131 0.806-9.252l236.467 142.383c19.538-24.648 49.741-40.457 83.636-40.457 58.91 0 106.667 47.756 106.667 106.667s-47.756 106.667-106.667 106.667c-58.91 0-106.667-47.756-106.667-106.667 0-1.775 0.043-3.539 0.129-5.293l-236.19-142.216c-19.528 24.867-49.868 40.841-83.939 40.841-58.91 0-106.667-47.756-106.667-106.667s47.756-106.667 106.667-106.667c34.091 0 64.447 15.993 83.974 40.886zM234.667 554.667c23.564 0 42.667-19.103 42.667-42.667s-19.103-42.667-42.667-42.667c-23.564 0-42.667 19.103-42.667 42.667s19.103 42.667 42.667 42.667zM661.333 341.333c23.564 0 42.667-19.103 42.667-42.667s-19.103-42.667-42.667-42.667c-23.564 0-42.667 19.103-42.667 42.667s19.103 42.667 42.667 42.667zM661.333 768c23.564 0 42.667-19.103 42.667-42.667s-19.103-42.667-42.667-42.667c-23.564 0-42.667 19.103-42.667 42.667s19.103 42.667 42.667 42.667z';
+const ICON_PATH = 'M8 7H12C13.1046 7 14 7.89543 14 9V13C14 14.1046 13.1046 15 12 15H8C6.89543 15 6 14.1046 6 13V9C6 7.89543 6.89543 7 8 7ZM8 13H12V9H8V13Z M8 18H12C13.1046 18 14 18.8954 14 20V24C14 25.1046 13.1046 26 12 26H8C6.89543 26 6 25.1046 6 24V20C6 18.8954 6.89543 18 8 18ZM8 24H12V20H8V24Z M24 7H20C18.8954 7 18 7.89543 18 9V13C18 14.1046 18.8954 15 20 15H24C25.1046 15 26 14.1046 26 13V9C26 7.89543 25.1046 7 24 7ZM24 13H20V9H24V13Z M20 18H24C25.1046 18 26 18.8954 26 20V24C26 25.1046 25.1046 26 24 26H20C18.8954 26 18 25.1046 18 24V20C18 18.8954 18.8954 18 20 18ZM20 24H24V20H20V24Z';
class IconComponent extends preact.Component {
render() {
@@ -24,7 +24,9 @@ export class PluginF extends BasePlugin {
addUpperBarIcon() {
this.player.ready().then(() => {
this.iconId = this.player.getService('upperBarManager').add({
- label: 'Plugin F',
+ displayName: 'Plugin-F',
+ ariaLabel: 'Plugin-F',
+ order: 150,
component: IconComponent,
svgIcon: {path: ICON_PATH},
onClick: () => alert('hello from plugin F')
diff --git a/src/services/side-panels-manager/models/item-wrapper.tsx b/src/services/side-panels-manager/models/item-wrapper.tsx
index 861844c..8aa0ee3 100644
--- a/src/services/side-panels-manager/models/item-wrapper.tsx
+++ b/src/services/side-panels-manager/models/item-wrapper.tsx
@@ -2,7 +2,6 @@ import { h, createRef, RefObject, FunctionalComponent, ComponentClass } from 'pr
import { KalturaPlayer } from '@playkit-js/kaltura-player-js';
import { PanelItemWrapper } from '../ui/panel-item-wrapper/panel-item-wrapper.component';
import { PanelComponentProps, SidePanelItem } from './side-panel-item';
-import { UpperBarManager } from '../../upper-bar-manager/upper-bar-manager';
/**
* Panel item metadata
@@ -14,26 +13,15 @@ export class ItemWrapper {
public iconId: number | undefined;
public readonly item: SidePanelItem;
private readonly player: KalturaPlayer;
- private readonly upperBarManager: UpperBarManager;
private panelItemComponentRef!: RefObject;
private removePanelComponentFn!: () => void;
private isActive: boolean;
- constructor(item: SidePanelItem, player: KalturaPlayer, onClick: (panelItemId: number) => void) {
+ constructor(item: SidePanelItem, player: KalturaPlayer) {
this.id = ++ItemWrapper.nextId;
this.item = item;
this.player = player;
- this.upperBarManager = this.player.getService('upperBarManager');
this.isActive = false;
this.injectPanelComponent();
- if (item.iconComponent) {
- const itemId = this.id;
- this.iconId = this.upperBarManager.add({
- label: this.item.label,
- svgIcon: this.item.iconComponent!.svgIcon,
- onClick: () => onClick(itemId),
- component: this.item.iconComponent!.component!
- });
- }
}
public activate(): void {
@@ -54,7 +42,6 @@ export class ItemWrapper {
public remove(): void {
this.removePanelComponentFn();
- if (this.item.iconComponent?.component) this.upperBarManager.remove(this.iconId!);
}
public update(): void {
diff --git a/src/services/side-panels-manager/models/side-panel-item.ts b/src/services/side-panels-manager/models/side-panel-item.ts
index 753264c..c0d2674 100644
--- a/src/services/side-panels-manager/models/side-panel-item.ts
+++ b/src/services/side-panels-manager/models/side-panel-item.ts
@@ -1,6 +1,5 @@
import { ComponentClass, FunctionalComponent } from 'preact';
import { PlaykitUI } from '@playkit-js/kaltura-player-js';
-import { SvgIcon } from '../../upper-bar-manager/models/svg-icon';
export type PanelComponentProps = {
isActive: boolean;
@@ -8,10 +7,6 @@ export type PanelComponentProps = {
export interface SidePanelItem {
readonly label: string;
- readonly iconComponent?: {
- component: ComponentClass> | FunctionalComponent>;
- svgIcon: SvgIcon;
- };
readonly panelComponent: ComponentClass | FunctionalComponent;
readonly presets: PlaykitUI.ReservedPresetName[];
readonly position: PlaykitUI.SidePanelPosition;
diff --git a/src/services/side-panels-manager/side-panels-manager.ts b/src/services/side-panels-manager/side-panels-manager.ts
index fabb98c..fee323a 100644
--- a/src/services/side-panels-manager/side-panels-manager.ts
+++ b/src/services/side-panels-manager/side-panels-manager.ts
@@ -28,12 +28,12 @@ export class SidePanelsManager {
public add(item: SidePanelItem): number | void {
if (SidePanelsManager.validateItem(item)) {
- const newItemWrapper: ItemWrapper = new ItemWrapper(item, this.player, (id: number) => this.toggle(id));
+ const newItemWrapper: ItemWrapper = new ItemWrapper(item, this.player);
this.componentsRegistry.set(newItemWrapper.id, newItemWrapper);
this.logger.debug('New Panel Item Added', item);
return newItemWrapper.id;
}
- this.logger.warn('Invalid SidePanelItem parameters', item);
+ this.logger.error('Invalid SidePanelItem parameters', item);
}
public remove(itemId: number): void {
@@ -149,15 +149,13 @@ export class SidePanelsManager {
}
private static validateItem(item: SidePanelItem): boolean {
- const { label, panelComponent, iconComponent, position, expandMode, onActivate, onDeactivate, presets } = item;
+ const { label, panelComponent, position, expandMode, onActivate, onDeactivate, presets } = item;
return !!(
label &&
Object.values(SidePanelPositions).includes(position) &&
Object.values(SidePanelModes).includes(expandMode) &&
presets.every((preset) => Object.values(ReservedPresetNames).includes(preset)) &&
typeof panelComponent === 'function' &&
- ((typeof iconComponent?.component === 'function' && typeof iconComponent?.svgIcon.path === 'string') ||
- iconComponent === undefined) &&
(typeof onActivate === 'function' || onActivate === undefined) &&
(typeof onDeactivate === 'function' || onDeactivate === undefined)
);
diff --git a/src/services/upper-bar-manager/models/icon-dto.ts b/src/services/upper-bar-manager/models/icon-dto.ts
index cce41d4..b30d688 100644
--- a/src/services/upper-bar-manager/models/icon-dto.ts
+++ b/src/services/upper-bar-manager/models/icon-dto.ts
@@ -1,15 +1,20 @@
import { ComponentClass, FunctionalComponent } from 'preact';
import { SvgIcon } from './svg-icon';
-import { KalturaPluginNames } from '../../../types/ui-managers-config';
import { PlaykitUI } from '@playkit-js/kaltura-player-js';
export interface IconDto {
/**
- * An ID (usually the plugin name in case of a plugin) - used for icons order calculations
- * has to be corresponds to the names of the icons (plugins) names in the
- * ui-managers config (under upperBarManager.pluginsIconsOrder)
+ * An ID uniquely identify a control (should be the plugin name in case of a plugin icon)
*/
- label: KalturaPluginNames | string;
+ displayName: string;
+ /**
+ * An HTML Aria label attribute that would be attached to the provided icon - string | of preact-i18n Element
+ */
+ ariaLabel: any;
+ /**
+ * The plugin priority order (the lower the number the higher the priority - the order is from left to right - flows from upper bar (max 5 icon) to dropdown bar(the reset and again from top to bottom))
+ */
+ order: number;
/**
* The icon react component
*/
diff --git a/src/services/upper-bar-manager/models/icon-model.ts b/src/services/upper-bar-manager/models/icon-model.ts
index a30716e..a94abfd 100644
--- a/src/services/upper-bar-manager/models/icon-model.ts
+++ b/src/services/upper-bar-manager/models/icon-model.ts
@@ -2,14 +2,15 @@ import { ComponentClass, FunctionalComponent, RefObject, createRef } from 'preac
import { IconDto } from './icon-dto';
import { IconWrapper } from '../ui/icon-wrapper/icon-wrapper.component';
import { SvgIcon } from './svg-icon';
-import { KalturaPluginNames } from '../../../types/ui-managers-config';
import { PlaykitUI, ui } from '@playkit-js/kaltura-player-js';
const { ReservedPresetNames } = ui;
export class IconModel {
private static nextId = 0;
public readonly id: number;
- public label: KalturaPluginNames | string;
+ public displayName: string;
+ public ariaLabel: any;
+ public order: number;
public componentRef: RefObject;
public onClick: (e: MouseEvent | KeyboardEvent) => void;
public component: ComponentClass> | FunctionalComponent>;
@@ -17,7 +18,9 @@ export class IconModel {
public presets: PlaykitUI.ReservedPresetName[];
constructor(item: IconDto) {
this.id = ++IconModel.nextId;
- this.label = item.label;
+ this.displayName = item.displayName;
+ this.ariaLabel = item.ariaLabel;
+ this.order = item.order;
this.component = item.component;
this.svgIcon = item.svgIcon;
this.onClick = item.onClick;
diff --git a/src/services/upper-bar-manager/ui/dropdown-bar/dropdown-bar.component.tsx b/src/services/upper-bar-manager/ui/dropdown-bar/dropdown-bar.component.tsx
index 3cb610e..75eb21d 100644
--- a/src/services/upper-bar-manager/ui/dropdown-bar/dropdown-bar.component.tsx
+++ b/src/services/upper-bar-manager/ui/dropdown-bar/dropdown-bar.component.tsx
@@ -14,7 +14,7 @@ export class DropdownBar extends Component {
render(): ComponentChild {
return (
- {this.props.controls.map(({ id, label, svgIcon, onClick }) => {
+ {this.props.controls.map(({ id, displayName, ariaLabel, svgIcon, onClick }) => {
return (
{
}}
role="menuitem"
>
-
+
-
+
-
{label}
+
{displayName}
diff --git a/src/services/upper-bar-manager/upper-bar-manager.tsx b/src/services/upper-bar-manager/upper-bar-manager.tsx
index ef6b998..8a071ea 100644
--- a/src/services/upper-bar-manager/upper-bar-manager.tsx
+++ b/src/services/upper-bar-manager/upper-bar-manager.tsx
@@ -3,42 +3,44 @@ import { IconDto } from './models/icon-dto';
import { IconModel } from './models/icon-model';
import { h, RefObject, createRef } from 'preact';
import { DisplayedBar } from './ui/displayed-bar/displayed-bar.component';
-import { KalturaPluginNames } from '../../types/ui-managers-config';
+import { KalturaPluginsDisplayNames } from '../../types/kaltura-plugins-display-names';
const { ReservedPresetAreas, ReservedPresetNames } = ui;
const UPPER_BAR_PRESETS = Object.values(ReservedPresetNames).filter(
(preset) => preset !== ReservedPresetNames.Idle && preset !== ReservedPresetNames.Error
);
-type UpperBarManagerConfig = { pluginsIconsOrder: { [key in KalturaPluginNames | string]: number } };
-type IconsOrder = { [key in KalturaPluginNames | string]: number };
+type IconsOrder = { [key in KalturaPluginsDisplayNames | string]: number };
export class UpperBarManager {
private readonly player: KalturaPlayer;
private readonly logger: Logger;
private readonly componentsRegistry: Map
;
private readonly displayedBarComponentRefs: Record>;
+ private iconsOrder: IconsOrder;
/**
* @ignore
*/
- constructor(player: KalturaPlayer, logger: Logger, config: UpperBarManagerConfig) {
+ constructor(player: KalturaPlayer, logger: Logger) {
this.player = player;
this.componentsRegistry = new Map();
this.logger = logger;
this.displayedBarComponentRefs = {};
+ this.iconsOrder = {} as IconsOrder;
UPPER_BAR_PRESETS.forEach((preset) => (this.displayedBarComponentRefs[preset] = createRef()));
- this.injectDisplayedBarComponentWrapper(config.pluginsIconsOrder);
+ this.injectDisplayedBarComponentWrapper();
}
public add(icon: IconDto): number | undefined {
if (UpperBarManager.validateItem(icon)) {
const newIcon: IconModel = new IconModel(icon);
this.componentsRegistry.set(newIcon.id, newIcon);
+ this.iconsOrder[icon.displayName] = icon.order;
newIcon.presets.forEach((preset) => this.displayedBarComponentRefs[preset].current?.update());
- this.logger.debug(`Icon Id: '${newIcon.id}' '${newIcon.label}' added`);
+ this.logger.debug(`control '${newIcon.displayName}' added, id: '${newIcon.id}' `);
return newIcon.id;
}
- this.logger.warn('Invalid Icon parameters', icon);
+ this.logger.error('icon cannot be added due to invalid parameters', JSON.stringify(icon));
return undefined;
}
@@ -47,9 +49,9 @@ export class UpperBarManager {
if (icon) {
this.componentsRegistry.delete(itemId);
icon.presets.forEach((preset) => this.displayedBarComponentRefs[preset].current?.update());
- this.logger.debug(`Icon Id: '${icon.id}' Label: '${icon.label}' removed`);
+ this.logger.debug(`control '${icon.displayName}' removed, id: '${icon.id}' `);
} else {
- this.logger.warn(`${itemId} is not registered`);
+ this.logger.warn(`control ${itemId} is not registered`);
}
}
@@ -62,16 +64,17 @@ export class UpperBarManager {
if (icon) {
icon.update();
} else {
- this.logger.warn(`${iconId} is not registered`);
+ this.logger.warn(`control ${iconId} is not registered`);
}
}
private getControls(iconsOrder: IconsOrder): IconModel[] {
const icons = Array.from(this.componentsRegistry.values());
- return icons.sort((a, b) => (iconsOrder[a.label] > iconsOrder[b.label] ? 1 : -1));
+ return icons.sort((a, b) => iconsOrder[a.displayName] - iconsOrder[b.displayName]);
}
- private injectDisplayedBarComponentWrapper(iconsOrder: IconsOrder): void {
+ private injectDisplayedBarComponentWrapper(): void {
+ const iconsOrder = this.iconsOrder;
for (const preset of UPPER_BAR_PRESETS) {
this.player.ui.addComponent({
label: 'Right-Upper-Bar-Wrapper',
diff --git a/src/types/kaltura-plugins-display-names.ts b/src/types/kaltura-plugins-display-names.ts
new file mode 100644
index 0000000..0bc0028
--- /dev/null
+++ b/src/types/kaltura-plugins-display-names.ts
@@ -0,0 +1,10 @@
+export type KalturaPluginsDisplayNames =
+ | 'Navigation'
+ | 'Q&A'
+ | 'Transcript'
+ | 'Download'
+ | 'Playlist'
+ | 'Related'
+ | 'Share'
+ | 'Info'
+ | 'Moderation';
\ No newline at end of file
diff --git a/src/types/ui-managers-config.ts b/src/types/ui-managers-config.ts
deleted file mode 100644
index dd93b0e..0000000
--- a/src/types/ui-managers-config.ts
+++ /dev/null
@@ -1,18 +0,0 @@
-export type KalturaPluginNames =
- | 'Navigation'
- | 'Q&A'
- | 'Transcript'
- | 'Download'
- | 'Playlist'
- | 'Related'
- | 'Share'
- | 'Info'
- | 'Moderation';
-
-export type UiManagerConfig = {
- upperBarManager: {
- pluginsIconsOrder: {
- [key in KalturaPluginNames | string]: number;
- };
- };
-};
\ No newline at end of file
diff --git a/src/ui-managers.ts b/src/ui-managers.ts
index d05e28c..8041244 100644
--- a/src/ui-managers.ts
+++ b/src/ui-managers.ts
@@ -1,7 +1,6 @@
import { BasePlugin, KalturaPlayer } from '@playkit-js/kaltura-player-js';
import { SidePanelsManager } from './services/side-panels-manager/side-panels-manager';
import { UpperBarManager } from './services/upper-bar-manager/upper-bar-manager';
-import { UiManagerConfig } from './types/ui-managers-config';
import { FloatingManager } from './services/floating-manager/floating-manager';
import { PresetManager } from './services/preset-manager/preset-manager';
import { ToastManager } from './services/toast-manager/toast-manager';
@@ -13,27 +12,13 @@ export const pluginName = 'uiManagers';
* manages the registration of UI services
* @internal
*/
-export class UIManagers extends BasePlugin {
- protected static defaultConfig: UiManagerConfig = {
- upperBarManager: {
- pluginsIconsOrder: {
- Navigation: 10,
- 'Q&A': 20,
- Transcript: 30,
- Download: 40,
- Playlist: 50,
- Related: 60,
- Share: 70,
- Info: 80,
- Moderation: 90
- }
- }
- };
+export class UIManagers extends BasePlugin {
+ protected static defaultConfig = {};
- constructor(name: string, player: KalturaPlayer, config?: UiManagerConfig) {
+ constructor(name: string, player: KalturaPlayer, config?: never) {
super(name, player, config);
player.registerService('sidePanelsManager', new SidePanelsManager(player, this.logger));
- player.registerService('upperBarManager', new UpperBarManager(player, this.logger, this.config.upperBarManager));
+ player.registerService('upperBarManager', new UpperBarManager(player, this.logger));
const presetManager = new PresetManager({
kalturaPlayer: player,
eventManager: this.eventManager
diff --git a/tests/e2e/upper-bar-manager.spec.js b/tests/e2e/upper-bar-manager.spec.js
index 82e74b5..384227f 100644
--- a/tests/e2e/upper-bar-manager.spec.js
+++ b/tests/e2e/upper-bar-manager.spec.js
@@ -1,11 +1,12 @@
import { expect } from 'chai';
import { createSandbox, spy } from 'sinon';
import '../../src/index';
-import { setup } from '@playkit-js/kaltura-player-js';
+import { setup, ui } from "@playkit-js/kaltura-player-js";
import { IconComponent } from '../mock/compenents/icon.component';
import { config, targetId } from '../mock/config';
import { mediaData } from '../mock/media-sourc';
import '../mock/plugins/index';
+const { ReservedPresetNames } = ui;
describe('Upper Bar Manager', () => {
let player;
@@ -38,11 +39,11 @@ describe('Upper Bar Manager', () => {
await player.ready();
// Do
- const iconId = upperBarManagerService.add({ label: 'icon', component: IconComponent, onClick: () => {} });
+ const iconId = upperBarManagerService.add({ displayName: 'icon', component: IconComponent, onClick: () => {} });
// Expect
expect(upperBarManagerService.componentsRegistry.size).to.equal(1);
- expect(upperBarManagerService.componentsRegistry.get(iconId).label).equal('icon');
+ expect(upperBarManagerService.componentsRegistry.get(iconId).displayName).equal('icon');
});
it('Remove icon', async () => {
@@ -53,7 +54,7 @@ describe('Upper Bar Manager', () => {
await player.ready();
// Do
- const iconId = upperBarManagerService.add({ label: 'icon', component: IconComponent, onClick: () => {} });
+ const iconId = upperBarManagerService.add({ displayName: 'icon', component: IconComponent, onClick: () => {} });
upperBarManagerService.remove(iconId);
// Expect
@@ -68,8 +69,8 @@ describe('Upper Bar Manager', () => {
await player.ready();
// Do
- const iconId1 = upperBarManagerService.add({ label: 'icon1', component: IconComponent, onClick: () => {} });
- const iconId2 = upperBarManagerService.add({ label: 'icon2', component: IconComponent, onClick: () => {} });
+ const iconId1 = upperBarManagerService.add({ displayName: 'icon1', component: IconComponent, onClick: () => {} });
+ const iconId2 = upperBarManagerService.add({ displayName: 'icon2', component: IconComponent, onClick: () => {} });
upperBarManagerService.remove(iconId1);
// Expect
@@ -85,8 +86,8 @@ describe('Upper Bar Manager', () => {
// Do
player.ready().then(() => {
- const icon1Id = upperBarManagerService.add({ label: 'icon1', component: IconComponent, onClick: () => {} });
- const icon2Id = upperBarManagerService.add({ label: 'icon2', component: IconComponent, onClick: () => {} });
+ const icon1Id = upperBarManagerService.add({ displayName: 'icon1', component: IconComponent, onClick: () => {} });
+ const icon2Id = upperBarManagerService.add({ displayName: 'icon2', component: IconComponent, onClick: () => {} });
setTimeout(() => {
const iconModel1 = upperBarManagerService.componentsRegistry.get(icon1Id);
const iconModel2 = upperBarManagerService.componentsRegistry.get(icon2Id);
@@ -107,24 +108,13 @@ describe('Upper Bar Manager', () => {
it('icons order state compatible with the configuration', (done) => {
// Given
const pluginsConfig = {
- uiManagers: {
- upperBarManager: {
- pluginsIconsOrder: {
- pluginC: 100,
- pluginF: 110,
- pluginA: 120,
- pluginD: 130,
- pluginE: 140,
- pluginB: 150
- }
- }
- },
- pluginA: {},
- pluginB: {},
- pluginC: {},
- pluginD: {},
- pluginE: {},
- pluginF: {}
+ uiManagers: {},
+ 'Plugin-A': { iconOrder: 120 },
+ 'Plugin-B': { iconOrder: 150 },
+ 'Plugin-C': { iconOrder: 100 },
+ 'Plugin-D': { iconOrder: 130 },
+ 'Plugin-E': { iconOrder: 140 },
+ 'Plugin-F': { iconOrder: 110 }
};
player = setup({ ...config, plugins: pluginsConfig });
@@ -133,39 +123,29 @@ describe('Upper Bar Manager', () => {
player.ready().then(() => {
setTimeout(() => {
- const displayedBarComponentState = upperBarManagerService.getControls(pluginsConfig.uiManagers.upperBarManager.pluginsIconsOrder);
- expect(displayedBarComponentState[0].label).to.be.equal('pluginC');
- expect(displayedBarComponentState[1].label).to.be.equal('pluginF');
- expect(displayedBarComponentState[2].label).to.be.equal('pluginA');
- expect(displayedBarComponentState[3].label).to.be.equal('pluginD');
- expect(displayedBarComponentState[4].label).to.be.equal('pluginE');
- expect(displayedBarComponentState[5].label).to.be.equal('pluginB');
+ const displayedBarComponentState = upperBarManagerService.getControls(upperBarManagerService.iconsOrder);
+ // const displayedBarComponentState = Array.from(this.componentsRegistry.values());
+ expect(displayedBarComponentState[0].displayName).to.be.equal('Plugin-C');
+ expect(displayedBarComponentState[1].displayName).to.be.equal('Plugin-F');
+ expect(displayedBarComponentState[2].displayName).to.be.equal('Plugin-A');
+ expect(displayedBarComponentState[3].displayName).to.be.equal('Plugin-D');
+ expect(displayedBarComponentState[4].displayName).to.be.equal('Plugin-E');
+ expect(displayedBarComponentState[5].displayName).to.be.equal('Plugin-B');
done();
- });
+ }, 1000);
});
});
it('icons order state is preserved on change media', (done) => {
// Given
const pluginsConfig = {
- uiManagers: {
- upperBarManager: {
- pluginsIconsOrder: {
- pluginC: 100,
- pluginF: 110,
- pluginA: 120,
- pluginD: 130,
- pluginE: 140,
- pluginB: 150
- }
- }
- },
- pluginA: {},
- pluginB: {},
- pluginC: {},
- pluginD: {},
- pluginE: {},
- pluginF: {}
+ uiManagers: {},
+ 'Plugin-A': { iconOrder: 120 },
+ 'Plugin-B': { iconOrder: 150 },
+ 'Plugin-C': { iconOrder: 100 },
+ 'Plugin-D': { iconOrder: 130 },
+ 'Plugin-E': { iconOrder: 140 },
+ 'Plugin-F': { iconOrder: 110 }
};
player = setup({ ...config, plugins: pluginsConfig });
@@ -175,14 +155,14 @@ describe('Upper Bar Manager', () => {
player.ready().then(() => {
setTimeout(() => {
const previousServiceRegistryState = JSON.parse(
- JSON.stringify(Array.from(upperBarManagerService.componentsRegistry.values()).map(({ id, label }) => ({ id, label })))
+ JSON.stringify(Array.from(upperBarManagerService.componentsRegistry.values()).map(({ id, displayName }) => ({ id, displayName })))
);
player.setMedia({ sources: { ...mediaData } });
setTimeout(() => {
const currentServiceRegistryState = Array.from(upperBarManagerService.componentsRegistry.values()).map(
- ({ id, label }) => ({ id, label })
+ ({ id, displayName }) => ({ id, displayName })
);
expect(previousServiceRegistryState).to.be.deep.equal(currentServiceRegistryState);
done();
diff --git a/tests/mock/plugins/plugin-A.js b/tests/mock/plugins/plugin-A.js
index e00122d..baf80b6 100644
--- a/tests/mock/plugins/plugin-A.js
+++ b/tests/mock/plugins/plugin-A.js
@@ -1,25 +1,35 @@
import { BasePlugin, registerPlugin, ui } from '@playkit-js/kaltura-player-js';
const { h, preact } = ui;
+const ICON_PATH = 'M16 4c6.627 0 12 5.373 12 12s-5.373 12-12 12S4 22.627 4 16 9.373 4 16 4zm0 2C10.477 6 6 10.477 6 16s4.477 10 10 10 10-4.477 10-10S21.523 6 16 6zm0 9a1 1 0 0 1 1 .99v4.02a.992.992 0 0 1-.883.983L16 21a1 1 0 0 1-1-.99v-4.02c0-.507.383-.926.883-.983L16 15zm0-4.2a1.2 1.2 0 1 1 0 2.4 1.2 1.2 0 0 1 0-2.4z'
+
+
class IconComponent extends preact.Component {
render() {
return h('div', null, 'A');
}
}
-export const pluginName = 'pluginA';
+export const pluginName = 'Plugin-A';
export class PluginA extends BasePlugin {
static defaultConfig = {};
- constructor(name, player) {
- super(name, player);
+ constructor(name, player, config) {
+ super(name, player, config);
this.player.ready().then(() => {
- const pluginAId = this.player.getService('upperBarManager').add({
- label: 'pluginA',
- component: IconComponent,
- onClick: () => alert('hello from plugin A')
- });
+ this.addUpperBarIcon(config.iconOrder);
+ });
+ }
+
+ addUpperBarIcon(iconOrder) {
+ this.player.getService('upperBarManager').add({
+ displayName: pluginName,
+ ariaLabel: pluginName,
+ order: iconOrder,
+ svgIcon: {path: ICON_PATH},
+ component: IconComponent,
+ onClick: () => {}
});
}
diff --git a/tests/mock/plugins/plugin-B.js b/tests/mock/plugins/plugin-B.js
index 82a3ba2..d28b4d4 100644
--- a/tests/mock/plugins/plugin-B.js
+++ b/tests/mock/plugins/plugin-B.js
@@ -1,25 +1,35 @@
import { BasePlugin, registerPlugin, ui } from '@playkit-js/kaltura-player-js';
const { h, preact } = ui;
+const ICON_PATH = 'M16 4c6.627 0 12 5.373 12 12s-5.373 12-12 12S4 22.627 4 16 9.373 4 16 4zm0 2C10.477 6 6 10.477 6 16s4.477 10 10 10 10-4.477 10-10S21.523 6 16 6zm0 9a1 1 0 0 1 1 .99v4.02a.992.992 0 0 1-.883.983L16 21a1 1 0 0 1-1-.99v-4.02c0-.507.383-.926.883-.983L16 15zm0-4.2a1.2 1.2 0 1 1 0 2.4 1.2 1.2 0 0 1 0-2.4z'
+
+
class IconComponent extends preact.Component {
render() {
return h('div', null, 'B');
}
}
-export const pluginName = 'pluginB';
+export const pluginName = 'Plugin-B';
export class PluginB extends BasePlugin {
static defaultConfig = {};
- constructor(name, player) {
- super(name, player);
+ constructor(name, player, config) {
+ super(name, player, config);
this.player.ready().then(() => {
- const pluginBId = this.player.getService('upperBarManager').add({
- label: 'pluginB',
- component: IconComponent,
- onClick: () => alert('hello from plugin B')
- });
+ this.addUpperBarIcon(config.iconOrder);
+ });
+ }
+
+ addUpperBarIcon(iconOrder) {
+ this.player.getService('upperBarManager').add({
+ displayName: pluginName,
+ ariaLabel: pluginName,
+ order: iconOrder,
+ svgIcon: {path: ICON_PATH},
+ component: IconComponent,
+ onClick: () => {}
});
}
diff --git a/tests/mock/plugins/plugin-C.js b/tests/mock/plugins/plugin-C.js
index 80b9b27..e883862 100644
--- a/tests/mock/plugins/plugin-C.js
+++ b/tests/mock/plugins/plugin-C.js
@@ -1,25 +1,35 @@
import { BasePlugin, registerPlugin, ui } from '@playkit-js/kaltura-player-js';
const { h, preact } = ui;
+const ICON_PATH = 'M16 4c6.627 0 12 5.373 12 12s-5.373 12-12 12S4 22.627 4 16 9.373 4 16 4zm0 2C10.477 6 6 10.477 6 16s4.477 10 10 10 10-4.477 10-10S21.523 6 16 6zm0 9a1 1 0 0 1 1 .99v4.02a.992.992 0 0 1-.883.983L16 21a1 1 0 0 1-1-.99v-4.02c0-.507.383-.926.883-.983L16 15zm0-4.2a1.2 1.2 0 1 1 0 2.4 1.2 1.2 0 0 1 0-2.4z'
+
+
class IconComponent extends preact.Component {
render() {
return h('div', null, 'C');
}
}
-export const pluginName = 'pluginC';
+export const pluginName = 'Plugin-C';
export class PluginC extends BasePlugin {
static defaultConfig = {};
- constructor(name, player) {
- super(name, player);
+ constructor(name, player, config) {
+ super(name, player, config);
this.player.ready().then(() => {
- const pluginCId = this.player.getService('upperBarManager').add({
- label: 'pluginC',
- component: IconComponent,
- onClick: () => alert('hello from plugin C')
- });
+ this.addUpperBarIcon(config.iconOrder);
+ });
+ }
+
+ addUpperBarIcon(iconOrder) {
+ this.player.getService('upperBarManager').add({
+ displayName: pluginName,
+ ariaLabel: pluginName,
+ order: iconOrder,
+ svgIcon: {path: ICON_PATH},
+ component: IconComponent,
+ onClick: () => {}
});
}
diff --git a/tests/mock/plugins/plugin-D.js b/tests/mock/plugins/plugin-D.js
index c030747..994d86f 100644
--- a/tests/mock/plugins/plugin-D.js
+++ b/tests/mock/plugins/plugin-D.js
@@ -1,25 +1,35 @@
import { BasePlugin, registerPlugin, ui } from '@playkit-js/kaltura-player-js';
const { h, preact } = ui;
+const ICON_PATH = 'M16 4c6.627 0 12 5.373 12 12s-5.373 12-12 12S4 22.627 4 16 9.373 4 16 4zm0 2C10.477 6 6 10.477 6 16s4.477 10 10 10 10-4.477 10-10S21.523 6 16 6zm0 9a1 1 0 0 1 1 .99v4.02a.992.992 0 0 1-.883.983L16 21a1 1 0 0 1-1-.99v-4.02c0-.507.383-.926.883-.983L16 15zm0-4.2a1.2 1.2 0 1 1 0 2.4 1.2 1.2 0 0 1 0-2.4z'
+
+
class IconComponent extends preact.Component {
render() {
return h('div', null, 'D');
}
}
-export const pluginName = 'pluginD';
+export const pluginName = 'Plugin-D';
export class PluginD extends BasePlugin {
static defaultConfig = {};
- constructor(name, player) {
- super(name, player);
+ constructor(name, player, config) {
+ super(name, player, config);
this.player.ready().then(() => {
- const pluginDId = this.player.getService('upperBarManager').add({
- label: 'pluginD',
- component: IconComponent,
- onClick: () => alert('hello from plugin D')
- });
+ this.addUpperBarIcon(config.iconOrder);
+ });
+ }
+
+ addUpperBarIcon(iconOrder) {
+ this.player.getService('upperBarManager').add({
+ displayName: pluginName,
+ ariaLabel: pluginName,
+ order: iconOrder,
+ svgIcon: {path: ICON_PATH},
+ component: IconComponent,
+ onClick: () => {}
});
}
diff --git a/tests/mock/plugins/plugin-E.js b/tests/mock/plugins/plugin-E.js
index 1d75c57..e9bfedf 100644
--- a/tests/mock/plugins/plugin-E.js
+++ b/tests/mock/plugins/plugin-E.js
@@ -1,25 +1,35 @@
import { BasePlugin, registerPlugin, ui } from '@playkit-js/kaltura-player-js';
const { h, preact } = ui;
+const ICON_PATH = 'M16 4c6.627 0 12 5.373 12 12s-5.373 12-12 12S4 22.627 4 16 9.373 4 16 4zm0 2C10.477 6 6 10.477 6 16s4.477 10 10 10 10-4.477 10-10S21.523 6 16 6zm0 9a1 1 0 0 1 1 .99v4.02a.992.992 0 0 1-.883.983L16 21a1 1 0 0 1-1-.99v-4.02c0-.507.383-.926.883-.983L16 15zm0-4.2a1.2 1.2 0 1 1 0 2.4 1.2 1.2 0 0 1 0-2.4z'
+
+
class IconComponent extends preact.Component {
render() {
return h('div', null, 'E');
}
}
-export const pluginName = 'pluginE';
+export const pluginName = 'Plugin-E';
export class PluginE extends BasePlugin {
static defaultConfig = {};
- constructor(name, player) {
- super(name, player);
+ constructor(name, player, config) {
+ super(name, player, config);
this.player.ready().then(() => {
- const pluginEId = this.player.getService('upperBarManager').add({
- label: 'pluginE',
- component: IconComponent,
- onClick: () => alert('hello from plugin E')
- });
+ this.addUpperBarIcon(config.iconOrder);
+ });
+ }
+
+ addUpperBarIcon(iconOrder) {
+ this.player.getService('upperBarManager').add({
+ displayName: pluginName,
+ ariaLabel: pluginName,
+ order: iconOrder,
+ svgIcon: {path: ICON_PATH},
+ component: IconComponent,
+ onClick: () => {}
});
}
diff --git a/tests/mock/plugins/plugin-F.js b/tests/mock/plugins/plugin-F.js
index c64d161..b454e0a 100644
--- a/tests/mock/plugins/plugin-F.js
+++ b/tests/mock/plugins/plugin-F.js
@@ -1,25 +1,35 @@
import { BasePlugin, registerPlugin, ui } from '@playkit-js/kaltura-player-js';
const { h, preact } = ui;
+const ICON_PATH = 'M16 4c6.627 0 12 5.373 12 12s-5.373 12-12 12S4 22.627 4 16 9.373 4 16 4zm0 2C10.477 6 6 10.477 6 16s4.477 10 10 10 10-4.477 10-10S21.523 6 16 6zm0 9a1 1 0 0 1 1 .99v4.02a.992.992 0 0 1-.883.983L16 21a1 1 0 0 1-1-.99v-4.02c0-.507.383-.926.883-.983L16 15zm0-4.2a1.2 1.2 0 1 1 0 2.4 1.2 1.2 0 0 1 0-2.4z'
+
+
class IconComponent extends preact.Component {
render() {
return h('div', null, 'F');
}
}
-export const pluginName = 'pluginF';
+export const pluginName = 'Plugin-F';
export class PluginF extends BasePlugin {
static defaultConfig = {};
- constructor(name, player) {
- super(name, player);
+ constructor(name, player, config) {
+ super(name, player, config);
this.player.ready().then(() => {
- const pluginFId = this.player.getService('upperBarManager').add({
- label: 'pluginF',
- component: IconComponent,
- onClick: () => alert('hello from plugin F')
- });
+ this.addUpperBarIcon(config.iconOrder);
+ });
+ }
+
+ addUpperBarIcon(iconOrder) {
+ this.player.getService('upperBarManager').add({
+ displayName: pluginName,
+ ariaLabel: pluginName,
+ order: iconOrder,
+ svgIcon: {path: ICON_PATH},
+ component: IconComponent,
+ onClick: () => {}
});
}
diff --git a/tsconfig.dev.json b/tsconfig.dev.json
index 2c7f812..bb83e73 100644
--- a/tsconfig.dev.json
+++ b/tsconfig.dev.json
@@ -4,6 +4,8 @@
"target": "ES2020",
"module": "ES2020",
"moduleResolution": "node",
- "sourceMap": true
+ "sourceMap": true,
+ "resolveJsonModule": true,
+ "esModuleInterop": true
}
}
diff --git a/tsconfig.json b/tsconfig.json
index 2fdfa8e..ca18615 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -6,6 +6,8 @@
"preserveSymlinks": true,
"jsx": "react",
"jsxFactory": "h",
+ "resolveJsonModule": true,
+ "esModuleInterop": true,
"jsxFragmentFactory": "Fragment",
"allowUnreachableCode": false,
"allowUnusedLabels": false,