'use strict'; import React, {Component} from 'react'; import {withTranslation} from '../lib/i18n'; import {LinkButton, requiresAuthenticatedUser, Title, Toolbar, withPageHelpers} from '../lib/page'; import {withErrorHandling} from '../lib/error-handling'; import {Table} from '../lib/table'; import {Icon} from "../lib/bootstrap-components"; import {tableAddDeleteButton, tableRestActionDialogInit, tableRestActionDialogRender} from "../lib/modals"; import {withComponentMixins} from "../lib/decorator-helpers"; import {withForm} from "../lib/form"; import PropTypes from 'prop-types'; @withComponentMixins([ withTranslation, withForm, withErrorHandling, withPageHelpers, requiresAuthenticatedUser ]) export default class List extends Component { constructor(props) { super(props); this.state = {}; tableRestActionDialogInit(this); } static propTypes = { permissions: PropTypes.object } render() { const t = this.props.t; const permissions = this.props.permissions; const createPermitted = permissions.createList; const customFormsPermitted = permissions.createCustomForm || permissions.viewCustomForm; const columns = [ { data: 1, title: t('name'), actions: data => { const perms = data[7]; if (perms.includes('viewSubscriptions')) { return [{label: data[1], link: `/lists/${data[0]}/subscriptions`}]; } else { return [{label: data[1]}]; } } }, { data: 2, title: t('id'), render: data => {data} }, { data: 3, title: t('subscribers') }, { data: 4, title: t('description') }, { data: 5, title: t('namespace') }, { actions: data => { const actions = []; const triggersCount = data[6]; const perms = data[7]; if (perms.includes('viewSubscriptions')) { actions.push({ label: , link: `/lists/${data[0]}/subscriptions` }); } if (perms.includes('edit')) { actions.push({ label: , link: `/lists/${data[0]}/edit` }); } if (perms.includes('viewFields')) { actions.push({ label: , link: `/lists/${data[0]}/fields` }); } if (perms.includes('viewSegments')) { actions.push({ label: , link: `/lists/${data[0]}/segments` }); } if (perms.includes('viewImports')) { actions.push({ label: , link: `/lists/${data[0]}/imports` }); } if (triggersCount > 0) { actions.push({ label: , link: `/lists/${data[0]}/triggers` }); } if (perms.includes('share')) { actions.push({ label: , link: `/lists/${data[0]}/share` }); } tableAddDeleteButton(actions, this, perms, `rest/lists/${data[0]}`, data[1], t('deletingList'), t('listDeleted')); return actions; } } ]; return (
{tableRestActionDialogRender(this)} { createPermitted && } { customFormsPermitted && } {t('lists')} this.table = node} withHeader dataUrl="rest/lists-table" columns={columns} /> ); } }