/* eslint-disable react/no-multi-comp */ import React from 'react'; import {isCheckAllowed} from '../helpers'; import {gettext} from 'core/utils'; import {IArticle} from 'superdesk-api'; interface IPropsSelectBox { item: IArticle; onMultiSelect( item: IArticle, value: boolean, multiSelectMode: boolean, ): void; } export class SelectBox extends React.Component { render() { if (this.props.item.selected) { this.props.item.selected = isCheckAllowed(this.props.item); } return ( { this.props.onMultiSelect(this.props.item, selected, multiSelectMode); }} data-test-id="multi-select-checkbox" /> ); } } interface IPropsSelectBoxWithoutMutation { item: IArticle; selected: boolean; onSelect(selected: boolean, multiSelectMode: boolean): void; className?: string; 'data-test-id'?: string; } export class SelectBoxWithoutMutation extends React.PureComponent { constructor(props: IPropsSelectBoxWithoutMutation) { super(props); this.toggle = this.toggle.bind(this); } toggle(event) { if (isCheckAllowed(this.props.item)) { const selected = !this.props.selected; const multiSelect = event.shiftKey; this.props.onSelect(selected, multiSelect); } } render() { return ( ); } }