/* eslint-disable react/no-multi-comp */ import React from 'react'; import {getGenericListPageComponent, GenericListPageComponent} from 'core/ui/components/ListPage/generic-list-page'; import {ListItemColumn, ListItemActionsMenu, ListItem} from 'core/components/ListItem'; import {getFormFieldPreviewComponent} from 'core/ui/components/generic-form/form-field'; import {IInternalDestination} from 'superdesk-interfaces/InternalDestination'; import {IFormField, IFormGroup} from 'superdesk-api'; import {FormFieldType} from 'core/ui/components/generic-form/interfaces/form'; import {gettext} from 'core/utils'; function getNameField(): IFormField { return { label: gettext('Destination name'), type: FormFieldType.textSingleLine, field: 'name', required: true, }; } function getIsActiveField(): IFormField { return { label: gettext('Active'), type: FormFieldType.checkbox, field: 'is_active', }; } function getContentFilterField(): IFormField { return { label: gettext('Content filter'), type: FormFieldType.contentFilterSingleValue, field: 'filter', }; } function getDeskField(): IFormField { return { label: gettext('Desk'), type: FormFieldType.deskSingleValue, field: 'desk', required: true, }; } function getStageField(): IFormField { return { label: gettext('Stage'), type: FormFieldType.stageSingleValue, field: 'stage', component_parameters: { deskField: 'desk', }, }; } function getMacroField(): IFormField { return { label: gettext('Macro'), type: FormFieldType.macroSingleValue, field: 'macro', component_parameters: { deskField: 'desk', }, }; } function getSendAfterScheduleField(): IFormField { return { label: gettext('Send only after publish schedule'), type: FormFieldType.checkbox, field: 'send_after_schedule', }; } const renderRow = ( key: string, item: IInternalDestination, page: GenericListPageComponent, ) => ( page.openPreview(item._id)} inactive={!item.is_active} data-test-id="internal-destinations-item" > {getFormFieldPreviewComponent(item, getNameField())} { item.is_active ? null : ( {gettext('Inactive')} ) }
); export class InternalDestinations extends React.Component { render() { const formConfig: IFormGroup = { direction: 'vertical', type: 'inline', form: [ getIsActiveField(), getSendAfterScheduleField(), getNameField(), getContentFilterField(), getDeskField(), getStageField(), getMacroField(), ], }; const InternalDestinationsPageComponent = getGenericListPageComponent('internal_destinations', formConfig); return ( ); } }