Some preparations for activity log.
Fixed issue #524 Table now displays horizontal scrollbar when the viewport is too narrow (typically on mobile)
This commit is contained in:
parent
4f408a26d5
commit
e0bee9ed42
28 changed files with 353 additions and 97 deletions
|
@ -6,6 +6,10 @@ const shares = require('./shares');
|
|||
const tools = require('../lib/tools');
|
||||
const { enforce } = require('../lib/helpers');
|
||||
|
||||
const {BlacklistActivityType} = require('../../shared/activity-log');
|
||||
const activityLog = require('../lib/activity-log');
|
||||
|
||||
|
||||
async function listDTAjax(context, params) {
|
||||
shares.enforceGlobalPermission(context, 'manageBlacklist');
|
||||
|
||||
|
@ -44,14 +48,21 @@ async function add(context, email) {
|
|||
if (!existing) {
|
||||
await tx('blacklist').insert({email});
|
||||
}
|
||||
|
||||
await activityLog.logBlacklistActivity(BlacklistActivityType.ADD, email);
|
||||
});
|
||||
}
|
||||
|
||||
async function remove(context, email) {
|
||||
enforce(email, 'Email has to be set');
|
||||
|
||||
shares.enforceGlobalPermission(context, 'manageBlacklist');
|
||||
await knex('blacklist').where('email', email).del();
|
||||
return await knex.transaction(async tx => {
|
||||
shares.enforceGlobalPermission(context, 'manageBlacklist');
|
||||
|
||||
await tx('blacklist').where('email', email).del();
|
||||
|
||||
await activityLog.logBlacklistActivity(BlacklistActivityType.REMOVE, email);
|
||||
});
|
||||
}
|
||||
|
||||
async function isBlacklisted(email) {
|
||||
|
|
|
@ -21,6 +21,9 @@ const {LinkId} = require('./links');
|
|||
const feedcheck = require('../lib/feedcheck');
|
||||
const contextHelpers = require('../lib/context-helpers');
|
||||
|
||||
const {EntityActivityType, CampaignActivityType} = require('../../shared/activity-log');
|
||||
const activityLog = require('../lib/activity-log');
|
||||
|
||||
const allowedKeysCommon = ['name', 'description', 'segment', 'namespace',
|
||||
'send_configuration', 'from_name_override', 'from_email_override', 'reply_to_override', 'subject_override', 'data', 'click_tracking_disabled', 'open_tracking_disabled', 'unsubscribe_url'];
|
||||
|
||||
|
@ -533,6 +536,8 @@ async function _createTx(tx, context, entity, content) {
|
|||
}).where('id', id);
|
||||
}
|
||||
|
||||
await activityLog.logEntityActivity('campaign', EntityActivityType.CREATE, id, {status: filteredEntity.status});
|
||||
|
||||
return id;
|
||||
});
|
||||
}
|
||||
|
@ -591,6 +596,8 @@ async function updateWithConsistencyCheck(context, entity, content) {
|
|||
await tx('campaigns').where('id', entity.id).update(filteredEntity);
|
||||
|
||||
await shares.rebuildPermissionsTx(tx, { entityTypeId: 'campaign', entityId: entity.id });
|
||||
|
||||
await activityLog.logEntityActivity('campaign', EntityActivityType.UPDATE, entity.id, {status: filteredEntity.status});
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -628,6 +635,8 @@ async function _removeTx(tx, context, id, existing = null) {
|
|||
.del();
|
||||
|
||||
await tx('campaigns').where('id', id).del();
|
||||
|
||||
await activityLog.logEntityActivity('campaign', EntityActivityType.REMOVE, id);
|
||||
}
|
||||
|
||||
|
||||
|
@ -863,6 +872,8 @@ async function _changeStatus(context, campaignId, permittedCurrentStates, newSta
|
|||
status: newState,
|
||||
scheduled
|
||||
});
|
||||
|
||||
await activityLog.logEntityActivity('campaign', CampaignActivityType.STATUS_CHANGE, campaignId, {status: newState});
|
||||
});
|
||||
|
||||
senders.scheduleCheck();
|
||||
|
|
|
@ -16,6 +16,8 @@ const { cleanupFromPost } = require('../lib/helpers');
|
|||
const Handlebars = require('handlebars');
|
||||
const { getTrustedUrl, getSandboxUrl, getPublicUrl } = require('../lib/urls');
|
||||
const { getMergeTagsForBases } = require('../../shared/templates');
|
||||
const {ListActivityType} = require('../../shared/activity-log');
|
||||
const activityLog = require('../lib/activity-log');
|
||||
|
||||
|
||||
const allowedKeysCreate = new Set(['name', 'key', 'default_value', 'type', 'group', 'settings']);
|
||||
|
@ -565,6 +567,8 @@ async function createTx(tx, context, listId, entity) {
|
|||
await knex.schema.raw('ALTER TABLE `subscription__' + listId + '` ADD `source_' + columnName +'` int(11) DEFAULT NULL');
|
||||
}
|
||||
|
||||
await activityLog.logEntityActivity('list', ListActivityType.CREATE_FIELD, listId, {fieldId: id});
|
||||
|
||||
return id;
|
||||
}
|
||||
|
||||
|
@ -594,6 +598,8 @@ async function updateWithConsistencyCheck(context, listId, entity) {
|
|||
|
||||
await tx('custom_fields').where({list: listId, id: entity.id}).update(filterObject(entity, allowedKeysUpdate));
|
||||
await _sortIn(tx, listId, entity.id, entity.orderListBefore, entity.orderSubscribeBefore, entity.orderManageBefore);
|
||||
|
||||
await activityLog.logEntityActivity('list', ListActivityType.UPDATE_FIELD, listId, {fieldId: entity.id});
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -620,6 +626,8 @@ async function removeTx(tx, context, listId, id) {
|
|||
|
||||
await segments.removeRulesByColumnTx(tx, context, listId, existing.column);
|
||||
}
|
||||
|
||||
await activityLog.logEntityActivity('list', ListActivityType.REMOVE_FIELD, listId, {fieldId: id});
|
||||
}
|
||||
|
||||
async function remove(context, listId, id) {
|
||||
|
|
|
@ -10,6 +10,8 @@ const {ImportSource, MappingType, ImportStatus, RunStatus, prepFinished, prepFin
|
|||
const fs = require('fs-extra-promise');
|
||||
const path = require('path');
|
||||
const importer = require('../lib/importer');
|
||||
const {ListActivityType} = require('../../shared/activity-log');
|
||||
const activityLog = require('../lib/activity-log');
|
||||
|
||||
const files = require('./files');
|
||||
const filesDir = path.join(files.filesDir, 'imports');
|
||||
|
@ -117,6 +119,8 @@ async function create(context, listId, entity, files) {
|
|||
const ids = await tx('imports').insert(filteredEntity);
|
||||
const id = ids[0];
|
||||
|
||||
await activityLog.logEntityActivity('list', ListActivityType.CREATE_IMPORT, listId, {importId: id, importStatus: entity.status});
|
||||
|
||||
return id;
|
||||
});
|
||||
|
||||
|
@ -148,6 +152,8 @@ async function updateWithConsistencyCheck(context, listId, entity) {
|
|||
filteredEntity.mapping = JSON.stringify(filteredEntity.mapping);
|
||||
|
||||
await tx('imports').where({list: listId, id: entity.id}).update(filteredEntity);
|
||||
|
||||
await activityLog.logEntityActivity('list', ListActivityType.UPDATE_IMPORT, listId, {importId: entity.id, importStatus: entity.status});
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -170,6 +176,8 @@ async function removeTx(tx, context, listId, id) {
|
|||
await tx('import_failed').whereIn('run', function() {this.from('import_runs').select('id').where('import', id)}).del();
|
||||
await tx('import_runs').where('import', id).del();
|
||||
await tx('imports').where({list: listId, id}).del();
|
||||
|
||||
await activityLog.logEntityActivity('list', ListActivityType.REMOVE_IMPORT, listId, {importId: id});
|
||||
}
|
||||
|
||||
async function remove(context, listId, id) {
|
||||
|
@ -208,6 +216,8 @@ async function start(context, listId, id) {
|
|||
status: RunStatus.SCHEDULED,
|
||||
mapping: entity.mapping
|
||||
});
|
||||
|
||||
await activityLog.logEntityActivity('list', ListActivityType.IMPORT_STATUS_CHANGE, listId, {importId: id, importStatus: ImportStatus.RUN_SCHEDULED});
|
||||
});
|
||||
|
||||
importer.scheduleCheck();
|
||||
|
@ -234,6 +244,8 @@ async function stop(context, listId, id) {
|
|||
await tx('import_runs').where('import', id).whereIn('status', [RunStatus.SCHEDULED, RunStatus.RUNNING]).update({
|
||||
status: RunStatus.STOPPING
|
||||
});
|
||||
|
||||
await activityLog.logEntityActivity('list', ListActivityType.IMPORT_STATUS_CHANGE, listId, {importId: id, importStatus: ImportStatus.RUN_STOPPING});
|
||||
});
|
||||
|
||||
importer.scheduleCheck();
|
||||
|
|
|
@ -14,6 +14,9 @@ const imports = require('./imports');
|
|||
const entitySettings = require('../lib/entity-settings');
|
||||
const dependencyHelpers = require('../lib/dependency-helpers');
|
||||
|
||||
const {EntityActivityType} = require('../../shared/activity-log');
|
||||
const activityLog = require('../lib/activity-log');
|
||||
|
||||
const {UnsubscriptionMode, FieldWizard} = require('../../shared/lists');
|
||||
|
||||
const allowedKeys = new Set(['name', 'description', 'default_form', 'public_subscribe', 'unsubscription_mode', 'contact_email', 'homepage', 'namespace', 'to_name', 'listunsubscribe_disabled', 'send_configuration']);
|
||||
|
@ -196,6 +199,8 @@ async function create(context, entity) {
|
|||
await fields.createTx(tx, context, id, fld);
|
||||
}
|
||||
|
||||
await activityLog.logEntityActivity('list', EntityActivityType.CREATE, id);
|
||||
|
||||
return id;
|
||||
});
|
||||
}
|
||||
|
@ -221,6 +226,8 @@ async function updateWithConsistencyCheck(context, entity) {
|
|||
await tx('lists').where('id', entity.id).update(filterObject(entity, allowedKeys));
|
||||
|
||||
await shares.rebuildPermissionsTx(tx, { entityTypeId: 'list', entityId: entity.id });
|
||||
|
||||
await activityLog.logEntityActivity('list', EntityActivityType.UPDATE, entity.id);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -244,6 +251,8 @@ async function remove(context, id) {
|
|||
|
||||
await tx('lists').where('id', id).del();
|
||||
await knex.schema.dropTableIfExists('subscription__' + id);
|
||||
|
||||
await activityLog.logEntityActivity('list', EntityActivityType.REMOVE, id);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -10,6 +10,8 @@ const moment = require('moment');
|
|||
const fields = require('./fields');
|
||||
const subscriptions = require('./subscriptions');
|
||||
const dependencyHelpers = require('../lib/dependency-helpers');
|
||||
const {ListActivityType} = require('../../shared/activity-log');
|
||||
const activityLog = require('../lib/activity-log');
|
||||
|
||||
const allowedKeys = new Set(['name', 'settings']);
|
||||
|
||||
|
@ -304,6 +306,8 @@ async function create(context, listId, entity) {
|
|||
const ids = await tx('segments').insert(filteredEntity);
|
||||
const id = ids[0];
|
||||
|
||||
await activityLog.logEntityActivity('list', ListActivityType.CREATE_SEGMENT, listId, {segmentId: id});
|
||||
|
||||
return id;
|
||||
});
|
||||
}
|
||||
|
@ -327,6 +331,8 @@ async function updateWithConsistencyCheck(context, listId, entity) {
|
|||
await _validateAndPreprocess(tx, listId, entity, false);
|
||||
|
||||
await tx('segments').where({list: listId, id: entity.id}).update(filterObject(entity, allowedKeys));
|
||||
|
||||
await activityLog.logEntityActivity('list', ListActivityType.UPDATE_SEGMENT, listId, {segmentId: entity.id});
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -346,6 +352,8 @@ async function removeTx(tx, context, listId, id) {
|
|||
|
||||
// The listId "where" is here to prevent deleting segment of a list for which a user does not have permission
|
||||
await tx('segments').where({list: listId, id}).del();
|
||||
|
||||
await activityLog.logEntityActivity('list', ListActivityType.REMOVE_SEGMENT, listId, {segmentId: id});
|
||||
}
|
||||
|
||||
async function remove(context, listId, id) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue