Skip to content

Commit

Permalink
move casting to a better place
Browse files Browse the repository at this point in the history
  • Loading branch information
tomaskikutis committed Jan 24, 2024
1 parent d016d8c commit 035e13f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
5 changes: 3 additions & 2 deletions client/extensions/orangelogic-extension/src/extension.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import {ISuperdesk, IExtension, IExtensionActivationResult} from 'superdesk-api';
import {ISuperdesk, IExtension, IExtensionActivationResult, ISearchPanelWidgetProps} from 'superdesk-api';
import {searchPanelWidgetFactory} from './search-panel-widget';

const extension: IExtension = {
activate: (superdesk: ISuperdesk) => {
const result: IExtensionActivationResult = {
contributions: {
searchPanelWidgets: [
searchPanelWidgetFactory(superdesk.localization.gettext),
// casting is required because of limitations on use of generics in superdesk-api
searchPanelWidgetFactory(superdesk.localization.gettext) as React.ComponentType<ISearchPanelWidgetProps<unknown>>,
],
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ interface IMediaTypeLabel {

export const searchPanelWidgetFactory = (
gettext: ISuperdesk['localization']['gettext'],
): React.ComponentType<ISearchPanelWidgetProps<unknown>> => {
): React.ComponentType<ISearchPanelWidgetProps<IParams>> => {
const mediaTypes: Array<IMediaTypeLabel> = [
{
type: 'Image',
Expand All @@ -30,7 +30,7 @@ export const searchPanelWidgetFactory = (
},
];

class SearchPanelWidget extends React.PureComponent<ISearchPanelWidgetProps<IParams>> {
return class SearchPanelWidget extends React.PureComponent<ISearchPanelWidgetProps<IParams>> {
toggleMediaType(type: IMediaType) {
const mediaTypes = this.props.params.mediaTypes || {};

Expand Down Expand Up @@ -76,7 +76,4 @@ export const searchPanelWidgetFactory = (
);
}
};

// casting is required because of limitations on use of generics in superdesk-api
return SearchPanelWidget as React.ComponentType<ISearchPanelWidgetProps<unknown>>;
};

0 comments on commit 035e13f

Please sign in to comment.