Skip to content

Commit e2bcdad

Browse files
[O2B-1181] Add easy to reach no-anonymous toggle (#1451)
* [O2B-1181] Add easy to reach no-anonymous toggle * Place properly the toggle
1 parent 9e9a9f5 commit e2bcdad

4 files changed

Lines changed: 21 additions & 14 deletions

File tree

lib/public/Model.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,9 @@ export default class Model extends Observable {
8181
this.simulationPasses = new SimulationPassesModel(this);
8282
this.simulationPasses.bubbleTo(this);
8383

84+
/**
85+
* @type {LogsModel}
86+
*/
8487
this.logs = new LogsModel(this);
8588
this.logs.bubbleTo(this);
8689

lib/public/components/Filters/LogsFilter/author/AuthorFilterModel.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,15 @@ export class AuthorFilterModel extends FilterInputModel {
4040
*
4141
* @returns {void}
4242
*/
43-
applyExcludeAnonymousFilter() {
43+
toggleAnonymousFilter() {
4444
if (this.isAnonymousExcluded()) {
45-
return;
45+
this._raw = this._raw.split(',')
46+
.filter((author) => author.trim() !== '!Anonymous')
47+
.join(',');
48+
} else {
49+
this._raw += super.isEmpty ? '!Anonymous' : ', !Anonymous';
4650
}
4751

48-
this._raw += super.isEmpty ? '!Anonymous' : ', !Anonymous';
4952
this._value = this.valueFromRaw(this._raw);
5053
this.notify();
5154
}

lib/public/components/Filters/LogsFilter/author/authorFilter.js

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
import { h } from '/js/src/index.js';
1515
import { iconX } from '/js/src/icons.js';
16+
import { switchInput } from '../../../common/form/switchInput.js';
1617

1718
/**
1819
* Returns a text input field that can be used to filter logs by author
@@ -40,19 +41,15 @@ const resetAuthorFilterButton = (authorFilterModel) => h(
4041
);
4142

4243
/**
43-
* Returns a button that can be used to exclude anonymous authors
44+
* Returns a toggle that can be used to exclude anonymous authors
4445
*
4546
* @param {AuthorFilterModel} authorFilterModel The author filter model object
4647
* @return {Component} A button component that can be used to exclude anonymous authors
4748
*/
48-
const excludeAnonymousButton = (authorFilterModel) => h(
49-
'input.btn.btn-primary',
50-
{
51-
type: 'button',
52-
value: 'No Anonymous',
53-
disabled: authorFilterModel.isAnonymousExcluded(),
54-
onclick: () => authorFilterModel.applyExcludeAnonymousFilter(),
55-
},
49+
export const excludeAnonymousLogAuthorToggle = (authorFilterModel) => switchInput(
50+
authorFilterModel.isAnonymousExcluded(),
51+
() => authorFilterModel.toggleAnonymousFilter(),
52+
{ labelAfter: 'No Anonymous' },
5653
);
5754

5855
/**
@@ -64,5 +61,5 @@ const excludeAnonymousButton = (authorFilterModel) => h(
6461
export const authorFilter = ({ authorFilter }) => h('.flex-row.items-center.g3', [
6562
authorFilterTextInput(authorFilter),
6663
resetAuthorFilterButton(authorFilter),
67-
excludeAnonymousButton(authorFilter),
64+
excludeAnonymousLogAuthorToggle(authorFilter),
6865
]);

lib/public/views/Logs/Overview/index.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import { estimateDisplayableRowsCount } from '../../../utilities/estimateDisplay
1818
import { paginationComponent } from '../../../components/Pagination/paginationComponent.js';
1919
import { frontLink } from '../../../components/common/navigation/frontLink.js';
2020
import { filtersPanelPopover } from '../../../components/Filters/common/filtersPanelPopover.js';
21+
import { excludeAnonymousLogAuthorToggle } from '../../../components/Filters/LogsFilter/author/authorFilter.js';
2122

2223
const TABLEROW_HEIGHT = 69;
2324
// Estimate of the navbar and pagination elements height total; Needs to be updated in case of changes;
@@ -36,7 +37,10 @@ const logOverviewScreen = ({ logs: { overviewModel: logsOverviewModel } }) => {
3637

3738
return h('', [
3839
h('.flex-row.justify-between.header-container.pv2', [
39-
filtersPanelPopover(logsOverviewModel, logsActiveColumns),
40+
h('.flex-row.g3', [
41+
filtersPanelPopover(logsOverviewModel, logsActiveColumns),
42+
excludeAnonymousLogAuthorToggle(logsOverviewModel.authorFilter),
43+
]),
4044
actionButtons(),
4145
]),
4246
h('.w-100.flex-column', [

0 commit comments

Comments
 (0)