From 7914077acb1e63ead53087cc60cb121c3ff76dba Mon Sep 17 00:00:00 2001 From: Tomas Bures Date: Sun, 12 Jan 2020 12:07:14 +0100 Subject: [PATCH] Added 'sendToTestUsers' permission to templates to control if a user can send a template to test users. (Up till now this was permitted by default.) Campaigns list is now by default ordered by 'Created' in descending order. Fixed display bug - two clicks on main menu item made it disappear Campaign Status is now protected by 'view' permission. (Up till now it was 'viewStats' permission.) Fixes in campaign status to hide send buttons and test send button if a user does not have necessary permissions. Templates, Mosaico templates and Campaigns (edit and content) are now displayed to user even if the user does have only 'view' permission (not 'edit'). A banner is displayed that the user cannot save any changes and buttons are removed from the edit pages. This is to allow users to copy settings and content from existing campaigns which they are not supposed to edit. A better solution would be to display the edit and content form in read-only mode, but this seems to be a bit complicated. --- client/src/campaigns/CUD.js | 25 ++- client/src/campaigns/Content.js | 21 +- client/src/campaigns/List.js | 8 +- client/src/campaigns/Status.js | 217 +++++++++++--------- client/src/campaigns/TestSendModalDialog.js | 4 +- client/src/campaigns/root.js | 6 +- client/src/lib/table.js | 7 +- client/src/lists/subscriptions/CUD.js | 1 + client/src/scss/variables.scss | 1 + client/src/templates/CUD.js | 21 +- client/src/templates/List.js | 2 +- client/src/templates/mosaico/CUD.js | 30 ++- client/src/templates/mosaico/List.js | 2 +- client/src/templates/root.js | 4 +- server/config/default.yaml | 8 +- server/models/campaigns.js | 5 + 16 files changed, 227 insertions(+), 135 deletions(-) diff --git a/client/src/campaigns/CUD.js b/client/src/campaigns/CUD.js index 72044ba7..cb38f3b8 100644 --- a/client/src/campaigns/CUD.js +++ b/client/src/campaigns/CUD.js @@ -36,6 +36,7 @@ import {getMailerTypes} from "../send-configurations/helpers"; import {getCampaignLabels} from "./helpers"; import {withComponentMixins} from "../lib/decorator-helpers"; import interoperableErrors from "../../../shared/interoperable-errors"; +import {Trans} from "react-i18next"; @withComponentMixins([ withTranslation, @@ -104,6 +105,7 @@ export default class CUD extends Component { this.nextListEntryId = 0; this.initForm({ + leaveConfirmation: !props.entity || props.entity.permissions.includes('edit'), onChange: { send_configuration: ::this.onSendConfigurationChanged }, @@ -535,6 +537,7 @@ export default class CUD extends Component { render() { const t = this.props.t; const isEdit = !!this.props.entity; + const canModify = !isEdit || this.props.entity.permissions.includes('edit'); const canDelete = isEdit && this.props.entity.permissions.includes('delete'); let extraSettings = null; @@ -751,6 +754,12 @@ export default class CUD extends Component { {isEdit ? this.editTitles[this.getFormValue('type')] : this.createTitles[this.getFormValue('type')]} + {!canModify && +
+ Warning! You do not have necessary permissions to edit this campaign. Any changes that you perform here will be lost. +
+ } + {isEdit && this.props.entity.status === CampaignStatus.SENDING &&
{t('formCannotBeEditedBecauseTheCampaignIs')} @@ -808,13 +817,17 @@ export default class CUD extends Component { {templateEdit} - {!isEdit && (sourceTypeKey === CampaignSource.CUSTOM || sourceTypeKey === CampaignSource.CUSTOM_FROM_TEMPLATE || sourceTypeKey === CampaignSource.CUSTOM_FROM_CAMPAIGN) ? -