Ghost/ghost/admin/app/controllers/settings/audit-log.js
Daniel Lockyer adaecde430
Split event and resource filtering apart
refs https://github.com/TryGhost/Toolbox/issues/356

- events and resources needed to be filtered and sent to the API
  differently
- this commit splits them apart and wires up the toggles to query params
  and therefore API requests
2022-08-22 17:14:34 +02:00

45 lines
1.2 KiB
JavaScript

import Controller from '@ember/controller';
import {action} from '@ember/object';
import {inject as service} from '@ember/service';
import {tracked} from '@glimmer/tracking';
export default class AuditLogController extends Controller {
@service router;
@service settings;
@service store;
queryParams = ['excludedEvents', 'excludedResources', 'user'];
@tracked excludedEvents = null;
@tracked excludedResources = null;
@tracked user = null;
get fullExcludedEvents() {
return (this.excludedEvents || '').split(',');
}
get fullExcludedResources() {
return (this.excludedResources || '').split(',');
}
get userRecord() {
if (!this.user) {
return null;
}
// TODO: {reload: true} here shouldn't be needed but without it
// the template renders nothing if the record is already in the store
return this.store.findRecord('user', this.user, {reload: true});
}
@action
changeExcludedItems({excludedEvents, excludedResources} = {}) {
this.router.transitionTo({queryParams: {excludedEvents, excludedResources}});
}
@action
changeUser(user) {
this.router.transitionTo({queryParams: {user: user?.id}});
}
}