Added "Name" and "Email" filters to members screen

closes https://github.com/TryGhost/Team/issues/1408
closes https://github.com/TryGhost/Team/issues/1409

- adds new text-based filters that match against member names and emails that allows more specific filtering than search
  - new filter operators introduced for "contains", "does not contain", "starts with", and "ends with"
This commit is contained in:
Kevin Ansfield 2022-03-10 16:45:18 +00:00
parent a5002e8765
commit 79afb5fc9c
4 changed files with 22 additions and 66 deletions

View File

@ -9,8 +9,8 @@ import {tracked} from '@glimmer/tracking';
const FILTER_PROPERTIES = [
// Basic
{label: 'Name', name: 'name', group: 'Basic', valueType: 'text', feature: 'membersContainsFilters'},
{label: 'Email', name: 'email', group: 'Basic', valueType: 'text', feature: 'membersContainsFilters'},
{label: 'Name', name: 'name', group: 'Basic', valueType: 'text'},
{label: 'Email', name: 'email', group: 'Basic', valueType: 'text'},
// {label: 'Location', name: 'location', group: 'Basic'},
{label: 'Label', name: 'label', group: 'Basic', valueType: 'array'},
{label: 'Newsletter subscription', name: 'subscribed', group: 'Basic'},
@ -141,23 +141,14 @@ export default class MembersFilter extends Component {
@service settings;
@service store;
@tracked filters = this.feature.membersContainsFilters
? new TrackedArray([
new Filter({
type: 'name',
relation: 'is',
value: '',
relationOptions: FILTER_RELATIONS_OPTIONS.name
})
])
: new TrackedArray([
new Filter({
type: 'label',
relation: 'is',
value: [],
relationOptions: FILTER_RELATIONS_OPTIONS.label
})
]);
@tracked filters = new TrackedArray([
new Filter({
type: 'name',
relation: 'is',
value: '',
relationOptions: FILTER_RELATIONS_OPTIONS.name
})
]);
availableFilterRelationsOptions = FILTER_RELATIONS_OPTIONS;
availableFilterValueOptions = FILTER_VALUE_OPTIONS;
@ -204,21 +195,12 @@ export default class MembersFilter extends Component {
@action
addFilter() {
if (this.feature.membersContainsFilters) {
this.filters.push(new Filter({
type: 'name',
relation: 'is',
value: '',
relationOptions: FILTER_RELATIONS_OPTIONS.name
}));
} else {
this.filters.push(new Filter({
type: 'label',
relation: 'is',
value: [],
relationOptions: FILTER_RELATIONS_OPTIONS.label
}));
}
this.filters.push(new Filter({
type: 'name',
relation: 'is',
value: '',
relationOptions: FILTER_RELATIONS_OPTIONS.name
}));
this.applySoftFilter();
}
@ -503,21 +485,12 @@ export default class MembersFilter extends Component {
resetFilter() {
const filters = [];
if (this.feature.membersContainsFilters) {
filters.push(new Filter({
type: 'name',
relation: 'is',
value: '',
relationOptions: FILTER_RELATIONS_OPTIONS.name
}));
} else {
filters.push(new Filter({
type: 'label',
relation: 'is',
value: [],
relationOptions: FILTER_RELATIONS_OPTIONS.label
}));
}
filters.push(new Filter({
type: 'name',
relation: 'is',
value: '',
relationOptions: FILTER_RELATIONS_OPTIONS.name
}));
this.filters = new TrackedArray(filters);
this.args.onResetFilter();

View File

@ -90,9 +90,6 @@ export default class FeatureService extends Service {
@feature('membersTableStatus')
membersTableStatus;
@feature('membersContainsFilters')
membersContainsFilters;
@feature('selectablePortalLinks')
selectablePortalLinks;

View File

@ -326,19 +326,6 @@
</div>
</div>
</div>
<div class="gh-expandable-block">
<div class="gh-expandable-header">
<div>
<h4 class="gh-expandable-title">Members "Contains" filters</h4>
<p class="gh-expandable-description">
Filter members by matching parts of their name and email fields
</p>
</div>
<div class="for-switch">
<GhFeatureFlag @flag="membersContainsFilters" />
</div>
</div>
</div>
</div>
</div>
{{/if}}

View File

@ -19,7 +19,6 @@ describe('Acceptance: Members filtering', function () {
beforeEach(async function () {
this.server.loadFixtures('configs');
this.server.loadFixtures('settings');
enableLabsFlag(this.server, 'membersContainsFilters');
enableLabsFlag(this.server, 'multipleProducts');
// test with stripe connected and email turned on