Skip to content

Commit

Permalink
feat(FEC-13318): support click event from timeline service (#333)
Browse files Browse the repository at this point in the history
  • Loading branch information
lianbenjamin committed Aug 23, 2023
1 parent fdc361b commit a26d7ef
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 8 deletions.
9 changes: 5 additions & 4 deletions cypress/e2e/navigation.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -323,8 +323,9 @@ describe('Navigation plugin', () => {
]
})
);
cy.get('[data-testid="navigation_questionStateLabel"]').should('be.visible');
cy.get('[data-testid="navigation_questionStateLabel"]').should($div => {
cy.get('[data-testid="navigation_questionStateLabel"]')
.should('exist')
.should($div => {
expect($div.text()).to.eq('Answered');
});
});
Expand Down Expand Up @@ -371,7 +372,7 @@ describe('Navigation plugin', () => {
})
);
cy.get('[data-testid="navigation_questionStateLabel"]')
.should('be.visible')
.should('exist')
.should($div => {
expect($div.text()).to.eq('Correct');
});
Expand All @@ -395,7 +396,7 @@ describe('Navigation plugin', () => {
})
);
cy.get('[data-testid="navigation_questionStateLabel"]')
.should('be.visible')
.should('exist')
.should($div => {
expect($div.text()).to.eq('Incorrect');
});
Expand Down
6 changes: 3 additions & 3 deletions src/components/navigation/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ export class Navigation extends Component<NavigationProps, NavigationState> {
return styles.smallWidth;
};

private _handleSearchFilterChange = (property: string) => (data: ItemTypes | string | null) => {
public handleSearchFilterChange = (property: string) => (data: ItemTypes | string | null) => {
const searchFilter: SearchFilter = {
...this.state.searchFilter,
[property]: data
Expand All @@ -219,7 +219,7 @@ export class Navigation extends Component<NavigationProps, NavigationState> {
{!hasError && (
<div class={[styles.searchWrapper, this._getHeaderStyles()].join(' ')}>
<NavigationSearch
onChange={this._handleSearchFilterChange('searchQuery')}
onChange={this.handleSearchFilterChange('searchQuery')}
searchQuery={searchFilter.searchQuery}
toggledWithEnter={toggledWithEnter}
kitchenSinkActive={kitchenSinkActive}
Expand All @@ -231,7 +231,7 @@ export class Navigation extends Component<NavigationProps, NavigationState> {

{!hasError && (
<TranslatedNavigationFilter
onChange={this._handleSearchFilterChange('activeTab')}
onChange={this.handleSearchFilterChange('activeTab')}
activeTab={searchFilter.activeTab}
availableTabs={searchFilter.availableTabs}
totalResults={searchFilter.searchQuery.length > 0 ? convertedData.length : null}
Expand Down
11 changes: 10 additions & 1 deletion src/navigation-plugin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export class NavigationPlugin extends KalturaPlayer.core.BasePlugin {
private _activeCaptionMapId: string = '';
private _quizQuestionData: ItemData[] = [];
private _pluginButtonRef: HTMLButtonElement | null = null;
private _navigationPluginRef: Navigation | null = null;

private _player: KalturaPlayerTypes.Player;
private _navigationPanel = -1;
Expand Down Expand Up @@ -350,6 +351,7 @@ export class NavigationPlugin extends KalturaPlayer.core.BasePlugin {
kitchenSinkActive={this.isPluginActive()}
toggledWithEnter={this._triggeredByKeyboard}
itemsOrder={this._itemsOrder}
ref={node => this._navigationPluginRef = node}
/>
);
},
Expand Down Expand Up @@ -407,7 +409,13 @@ export class NavigationPlugin extends KalturaPlayer.core.BasePlugin {
if (this._itemsFilter[ItemTypes.Caption]) {
this.eventManager.listen(this._player, this._player.Event.TEXT_TRACK_CHANGED, this._handleLanguageChange);
}
this.eventManager.listen(this._player, 'TimelinePreviewArrowClicked', this._handleClickOnPluginIcon);
this.eventManager.listen(this._player, 'TimelinePreviewArrowClicked', this._handleTimelinePreviewClick);
}

private _handleTimelinePreviewClick = ({payload}: any) => {
const {e, byKeyboard, cuePointType} = payload;
this._handleClickOnPluginIcon(e, byKeyboard);
this._navigationPluginRef?.handleSearchFilterChange('activeTab')(cuePointType);
}

private _seekTo = (time: number) => {
Expand Down Expand Up @@ -457,6 +465,7 @@ export class NavigationPlugin extends KalturaPlayer.core.BasePlugin {
this._navigationPanel = -1;
this._navigationIcon = -1;
this._pluginButtonRef = null;
this._navigationPluginRef = null;
}
this._activeCuePointsMap = this._getDefaultActiveCuePointsMap();
this._activeCaptionMapId = '';
Expand Down

0 comments on commit a26d7ef

Please sign in to comment.