'use strict'; import React, { Component } from 'react'; import { translate } from 'react-i18next'; import {DropdownMenu, Icon} from '../../lib/bootstrap-components'; import { requiresAuthenticatedUser, withPageHelpers, Title, Toolbar, DropdownLink } from '../../lib/page'; import { withErrorHandling, withAsyncErrorHandler } from '../../lib/error-handling'; import { Table } from '../../lib/table'; import axios from '../../lib/axios'; import moment from 'moment'; import { getTemplateTypes } from './helpers'; @translate() @withPageHelpers @withErrorHandling @requiresAuthenticatedUser export default class List extends Component { constructor(props) { super(props); this.templateTypes = getTemplateTypes(props.t); this.state = {}; } @withAsyncErrorHandler async fetchPermissions() { const request = { createMosaicoTemplate: { entityTypeId: 'namespace', requiredOperations: ['createMosaicoTemplate'] } }; const result = await axios.post('/rest/permissions-check', request); this.setState({ createPermitted: result.data.createMosaicoTemplate }); } componentDidMount() { this.fetchPermissions(); } render() { const t = this.props.t; const columns = [ { data: 1, title: t('Name') }, { data: 2, title: t('Description') }, { data: 3, title: t('Type'), render: data => this.templateTypes[data].typeName }, { data: 4, title: t('Created'), render: data => moment(data).fromNow() }, { data: 5, title: t('Namespace') }, { actions: data => { const actions = []; const perms = data[6]; if (perms.includes('edit')) { actions.push({ label: , link: `/templates/mosaico/${data[0]}/edit` }); } if (perms.includes('share')) { actions.push({ label: , link: `/templates/mosaico/${data[0]}/share` }); } return actions; } } ]; return (
{this.state.createPermitted && {t('Blank')} {t('Versafix One')} } {t('Mosaico Templates')} ); } }