Checks for dependencies during deletion.
This commit is contained in:
parent
0a08088893
commit
efbfa2b366
20 changed files with 246 additions and 121 deletions
|
@ -105,8 +105,15 @@ export class DeleteModalDialog extends Component {
|
|||
const t = props.t;
|
||||
|
||||
this.entityTypeLabels = {
|
||||
'namespace': t('Namespace'),
|
||||
'list': t('List'),
|
||||
'customForm': t('Custom forms'),
|
||||
'campaign': t('Campaign'),
|
||||
'template': t('Template')
|
||||
'template': t('Template'),
|
||||
'sendConfiguration': t('Send configuration'),
|
||||
'report': t('Report'),
|
||||
'reportTemplate': t('Report template'),
|
||||
'mosaicoTemplate': t('Mosaico template')
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -141,8 +148,12 @@ export class DeleteModalDialog extends Component {
|
|||
<p>{t('Cannote delete "{{name}}" due to the following dependencies:', {name, nsSeparator: '|'})}</p>
|
||||
<ul className={styles.dependenciesList}>
|
||||
{err.data.dependencies.map(dep =>
|
||||
<li key={dep.link}><Link to={dep.link}>{this.entityTypeLabels[dep.entityTypeId]}: {dep.name}</Link></li>
|
||||
dep.link ?
|
||||
<li key={dep.link}><Link to={dep.link}>{this.entityTypeLabels[dep.entityTypeId]}: {dep.name}</Link></li>
|
||||
: // if no dep.link is present, it means the user has no permission to view the entity, thus only id without the link is shown
|
||||
<li key={dep.id}>{this.entityTypeLabels[dep.entityTypeId]}: [{dep.id}]</li>
|
||||
)}
|
||||
{err.data.andMore && <li>{t('... and more')}</li>}
|
||||
</ul>
|
||||
</div>
|
||||
);
|
||||
|
|
|
@ -26,7 +26,8 @@
|
|||
|
||||
.mt-treetable-container.mt-treetable-inactivable>table.fancytree-ext-table.fancytree-container>tbody>tr.fancytree-active>td span.fancytree-title,
|
||||
.mt-treetable-container.mt-treetable-inactivable>table.fancytree-ext-table.fancytree-container>tbody>tr.fancytree-active>td span.fancytree-expander,
|
||||
.mt-treetable-container.mt-treetable-inactivable .fancytree-container span.fancytree-node.fancytree-active span.fancytree-title {
|
||||
.mt-treetable-container.mt-treetable-inactivable .fancytree-container span.fancytree-node.fancytree-active span.fancytree-title,
|
||||
.mt-treetable-container.mt-treetable-inactivable .fancytree-container>tbody>tr.fancytree-active>td {
|
||||
outline: 0px none;
|
||||
color: #333333;
|
||||
}
|
||||
|
|
|
@ -104,6 +104,7 @@ class TreeTable extends Component {
|
|||
const data = [];
|
||||
for (const unsafeEntry of unsafeData) {
|
||||
const entry = Object.assign({}, unsafeEntry);
|
||||
entry.unsanitizedTitle = entry.title;
|
||||
entry.title = ReactDOMServer.renderToStaticMarkup(<div>{entry.title}</div>);
|
||||
entry.description = ReactDOMServer.renderToStaticMarkup(<div>{entry.description}</div>);
|
||||
if (entry.children) {
|
||||
|
@ -137,15 +138,32 @@ class TreeTable extends Component {
|
|||
const linksContainer = jQuery(`<span class="${styles.actionLinks}"/>`);
|
||||
|
||||
const actions = this.props.actions(node);
|
||||
for (const {label, link} of actions) {
|
||||
const lnkHtml = ReactDOMServer.renderToStaticMarkup(<a href={link}>{label}</a>);
|
||||
const lnk = jQuery(lnkHtml);
|
||||
lnk.click((evt) => {
|
||||
evt.preventDefault();
|
||||
this.navigateTo(link)
|
||||
});
|
||||
linksContainer.append(lnk);
|
||||
|
||||
for (const action of actions) {
|
||||
if (action.action) {
|
||||
const html = ReactDOMServer.renderToStaticMarkup(<a href="">{action.label}</a>);
|
||||
const elem = jQuery(html);
|
||||
elem.click((evt) => { evt.preventDefault(); action.action(this) });
|
||||
linksContainer.append(elem);
|
||||
|
||||
} else if (action.link) {
|
||||
const html = ReactDOMServer.renderToStaticMarkup(<a href={action.link}>{action.label}</a>);
|
||||
const elem = jQuery(html);
|
||||
elem.click((evt) => { evt.preventDefault(); this.navigateTo(action.link) });
|
||||
linksContainer.append(elem);
|
||||
|
||||
} else if (action.href) {
|
||||
const html = ReactDOMServer.renderToStaticMarkup(<a href={action.href}>{action.label}</a>);
|
||||
const elem = jQuery(html);
|
||||
linksContainer.append(elem);
|
||||
|
||||
} else {
|
||||
const html = ReactDOMServer.renderToStaticMarkup(<span>{action.label}</span>);
|
||||
const elem = jQuery(html);
|
||||
linksContainer.append(elem);
|
||||
}
|
||||
}
|
||||
|
||||
tdList.eq(tdIdx).html(linksContainer);
|
||||
tdIdx += 1;
|
||||
}
|
||||
|
|
|
@ -25,7 +25,6 @@ export default class CUD extends Component {
|
|||
this.state = {};
|
||||
|
||||
this.initForm();
|
||||
this.hasChildren = false;
|
||||
}
|
||||
|
||||
static propTypes = {
|
||||
|
@ -42,10 +41,6 @@ export default class CUD extends Component {
|
|||
const entry = data[idx];
|
||||
|
||||
if (entry.key === this.props.entity.id) {
|
||||
if (entry.children.length > 0) {
|
||||
this.hasChildren = true;
|
||||
}
|
||||
|
||||
data.splice(idx, 1);
|
||||
return true;
|
||||
}
|
||||
|
@ -158,25 +153,10 @@ export default class CUD extends Component {
|
|||
}
|
||||
}
|
||||
|
||||
async onDeleteError(error) {
|
||||
if (error instanceof interoperableErrors.ChildDetectedError) {
|
||||
this.disableForm();
|
||||
this.setFormStatusMessage('danger',
|
||||
<span>
|
||||
<strong>{t('The namespace cannot be deleted.')}</strong>{' '}
|
||||
{t('There has been a child namespace found. This is most likely because someone else has changed the parent of some namespace in the meantime. Refresh your page to start anew with fresh data.')}
|
||||
</span>
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
throw error;
|
||||
}
|
||||
|
||||
render() {
|
||||
const t = this.props.t;
|
||||
const isEdit = !!this.props.entity;
|
||||
const canDelete = isEdit && !this.isEditGlobal() && !this.hasChildren && this.props.entity.permissions.includes('delete');
|
||||
const canDelete = isEdit && !this.isEditGlobal() && this.props.entity.permissions.includes('delete');
|
||||
|
||||
return (
|
||||
<div>
|
||||
|
@ -188,8 +168,7 @@ export default class CUD extends Component {
|
|||
backUrl={`/namespaces/${this.props.entity.id}/edit`}
|
||||
successUrl="/namespaces"
|
||||
deletingMsg={t('Deleting namespace ...')}
|
||||
deletedMsg={t('Namespace deleted')}
|
||||
onErrorAsync={::this.onDeleteError}/>
|
||||
deletedMsg={t('Namespace deleted')} />
|
||||
}
|
||||
|
||||
<Title>{isEdit ? t('Edit Namespace') : t('Create Namespace')}</Title>
|
||||
|
|
|
@ -13,6 +13,7 @@ import {
|
|||
tableDeleteDialogInit,
|
||||
tableDeleteDialogRender
|
||||
} from "../lib/modals";
|
||||
import {getGlobalNamespaceId} from "../../../shared/namespaces";
|
||||
|
||||
@translate()
|
||||
@withErrorHandling
|
||||
|
@ -50,7 +51,6 @@ export default class List extends Component {
|
|||
|
||||
const actions = node => {
|
||||
const actions = [];
|
||||
console.log(node);
|
||||
|
||||
if (node.data.permissions.includes('edit')) {
|
||||
actions.push({
|
||||
|
@ -66,7 +66,9 @@ export default class List extends Component {
|
|||
});
|
||||
}
|
||||
|
||||
tableDeleteDialogAddDeleteButton(actions, this, node.data.permissions, node.key, node.key);
|
||||
if (Number.parseInt(node.key) !== getGlobalNamespaceId()) {
|
||||
tableDeleteDialogAddDeleteButton(actions, this, node.data.permissions, node.key, node.data.unsanitizedTitle);
|
||||
}
|
||||
|
||||
return actions;
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue