Skip to content

Commit 5581826

Browse files
timdeschryverbrandonroberts
authored andcommitted
fix(StoreDevTools): rename action list filters (#1589)
Closes #1557 BREAKING CHANGE: `actionsWhitelist` is renamed to `actionsSafelist` `actionsBlacklist` is renamed to `actionsBlocklist` BEFORE: ```ts StoreDevtoolsModule.instrument({ actionsWhitelist: ['...'], actionsBlacklist: ['...'] }) ``` AFTER: ```ts StoreDevtoolsModule.instrument({ actionsSafelist: ['...'], actionsBlocklist: ['...'] }) ```
1 parent ced2d3d commit 5581826

File tree

9 files changed

+40
-40
lines changed

9 files changed

+40
-40
lines changed

modules/store-devtools/spec/extension.spec.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -374,23 +374,23 @@ describe('DevtoolsExtension', () => {
374374
});
375375
});
376376

377-
describe('with Action and actionsBlacklist', () => {
377+
describe('with Action and actionsBlocklist', () => {
378378
const NORMAL_ACTION = 'NORMAL_ACTION';
379-
const BLACKLISTED_ACTION = 'BLACKLISTED_ACTION';
379+
const BLOCKED_ACTION = 'BLOCKED_ACTION';
380380

381381
beforeEach(() => {
382382
devtoolsExtension = new DevtoolsExtension(
383383
reduxDevtoolsExtension,
384384
createConfig({
385-
actionsBlacklist: [BLACKLISTED_ACTION],
385+
actionsBlocklist: [BLOCKED_ACTION],
386386
}),
387387
<any>null
388388
);
389389
// Subscription needed or else extension connection will not be established.
390390
devtoolsExtension.actions$.subscribe(() => null);
391391
});
392392

393-
it('should ignore blacklisted action', () => {
393+
it('should ignore the blocked action', () => {
394394
const options = createOptions();
395395
const state = createState();
396396

@@ -403,30 +403,30 @@ describe('DevtoolsExtension', () => {
403403
state
404404
);
405405
devtoolsExtension.notify(
406-
new PerformAction({ type: BLACKLISTED_ACTION }, 1234567),
406+
new PerformAction({ type: BLOCKED_ACTION }, 1234567),
407407
state
408408
);
409409
expect(extensionConnection.send).toHaveBeenCalledTimes(2);
410410
});
411411
});
412412

413-
describe('with Action and actionsWhitelist', () => {
413+
describe('with Action and actionsSafelist', () => {
414414
const NORMAL_ACTION = 'NORMAL_ACTION';
415-
const WHITELISTED_ACTION = 'WHITELISTED_ACTION';
415+
const SAFE_ACTION = 'SAFE_ACTION';
416416

417417
beforeEach(() => {
418418
devtoolsExtension = new DevtoolsExtension(
419419
reduxDevtoolsExtension,
420420
createConfig({
421-
actionsWhitelist: [WHITELISTED_ACTION],
421+
actionsSafelist: [SAFE_ACTION],
422422
}),
423423
<any>null
424424
);
425425
// Subscription needed or else extension connection will not be established.
426426
devtoolsExtension.actions$.subscribe(() => null);
427427
});
428428

429-
it('should only keep whitelisted action', () => {
429+
it('should only keep the safe action', () => {
430430
const options = createOptions();
431431
const state = createState();
432432

@@ -439,7 +439,7 @@ describe('DevtoolsExtension', () => {
439439
state
440440
);
441441
devtoolsExtension.notify(
442-
new PerformAction({ type: WHITELISTED_ACTION }, 1234567),
442+
new PerformAction({ type: SAFE_ACTION }, 1234567),
443443
state
444444
);
445445
expect(extensionConnection.send).toHaveBeenCalledTimes(1);

modules/store-devtools/spec/integration.spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,9 @@ describe('Devtools Integration', () => {
6666
devtools.refresh();
6767
});
6868

69-
it('should not throw if actions are blacklisted', (done: any) => {
69+
it('should not throw if actions are blocked', (done: any) => {
7070
const { store, devtools } = setup({
71-
actionsBlacklist: ['FOO'],
71+
actionsBlocklist: ['FOO'],
7272
});
7373
store.subscribe();
7474
devtools.dispatcher.subscribe((action: Action) => {
@@ -80,9 +80,9 @@ describe('Devtools Integration', () => {
8080
devtools.refresh();
8181
});
8282

83-
it('should not throw if actions are whitelisted', (done: any) => {
83+
it('should not throw if actions are safe', (done: any) => {
8484
const { store, devtools } = setup({
85-
actionsWhitelist: ['BAR'],
85+
actionsSafelist: ['BAR'],
8686
});
8787
store.subscribe();
8888
devtools.dispatcher.subscribe((action: Action) => {

modules/store-devtools/spec/store.spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -478,9 +478,9 @@ describe('Store Devtools', () => {
478478
expect(fixture.getState()).toBe(5);
479479
});
480480

481-
it('should respect the blacklist option', () => {
481+
it('should respect the blocked option', () => {
482482
const fixture = createStore(counter, {
483-
actionsBlacklist: ['INCREMENT'],
483+
actionsBlocklist: ['INCREMENT'],
484484
});
485485

486486
expect(fixture.getState()).toBe(0);
@@ -517,9 +517,9 @@ describe('Store Devtools', () => {
517517
expect(fixture.getState()).toBe(5);
518518
});
519519

520-
it('should respect the whitelist option', () => {
520+
it('should respect the safe option', () => {
521521
const fixture = createStore(counter, {
522-
actionsWhitelist: ['DECREMENT'],
522+
actionsSafelist: ['DECREMENT'],
523523
});
524524

525525
expect(fixture.getState()).toBe(0);

modules/store-devtools/src/config.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ export class StoreDevtoolsConfig {
2121
serialize?: boolean | SerializationOptions;
2222
logOnly?: boolean;
2323
features?: any;
24-
actionsBlacklist?: string[];
25-
actionsWhitelist?: string[];
24+
actionsBlocklist?: string[];
25+
actionsSafelist?: string[];
2626
predicate?: Predicate;
2727
}
2828

modules/store-devtools/src/devtools.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,8 @@ export class StoreDevtools implements Observer<any> {
8787
reducedLiftedState = filterLiftedState(
8888
reducedLiftedState,
8989
config.predicate,
90-
config.actionsWhitelist,
91-
config.actionsBlacklist
90+
config.actionsSafelist,
91+
config.actionsBlocklist
9292
);
9393
}
9494
// Extension should be sent the sanitized lifted state

modules/store-devtools/src/extension.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,8 @@ export class DevtoolsExtension {
113113
currentState,
114114
action,
115115
this.config.predicate,
116-
this.config.actionsWhitelist,
117-
this.config.actionsBlacklist
116+
this.config.actionsSafelist,
117+
this.config.actionsBlocklist
118118
)
119119
) {
120120
return;

modules/store-devtools/src/reducer.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -369,8 +369,8 @@ export function liftReducerWith(
369369
liftedState.computedStates[currentStateIndex],
370370
liftedAction,
371371
options.predicate,
372-
options.actionsWhitelist,
373-
options.actionsBlacklist
372+
options.actionsSafelist,
373+
options.actionsBlocklist
374374
))
375375
) {
376376
// If recording is paused or if the action should be ignored, overwrite the last state

modules/store-devtools/src/utils.ts

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export function unliftState(liftedState: LiftedState) {
2626
const { computedStates, currentStateIndex } = liftedState;
2727

2828
// At start up NgRx dispatches init actions,
29-
// When these init actions are being filtered out by the predicate or black/white list options
29+
// When these init actions are being filtered out by the predicate or safe/block list options
3030
// we don't have a complete computed states yet.
3131
// At this point it could happen that we're out of bounds, when this happens we fall back to the last known state
3232
if (currentStateIndex >= computedStates.length) {
@@ -112,7 +112,7 @@ export function sanitizeState(
112112
* Read the config and tell if actions should be filtered
113113
*/
114114
export function shouldFilterActions(config: StoreDevtoolsConfig) {
115-
return config.predicate || config.actionsWhitelist || config.actionsBlacklist;
115+
return config.predicate || config.actionsSafelist || config.actionsBlocklist;
116116
}
117117

118118
/**
@@ -121,8 +121,8 @@ export function shouldFilterActions(config: StoreDevtoolsConfig) {
121121
export function filterLiftedState(
122122
liftedState: LiftedState,
123123
predicate?: Predicate,
124-
whitelist?: string[],
125-
blacklist?: string[]
124+
safelist?: string[],
125+
blocklist?: string[]
126126
): LiftedState {
127127
const filteredStagedActionIds: number[] = [];
128128
const filteredActionsById: LiftedActions = {};
@@ -136,8 +136,8 @@ export function filterLiftedState(
136136
liftedState.computedStates[idx],
137137
liftedAction,
138138
predicate,
139-
whitelist,
140-
blacklist
139+
safelist,
140+
blocklist
141141
)
142142
) {
143143
return;
@@ -161,13 +161,13 @@ export function isActionFiltered(
161161
state: any,
162162
action: LiftedAction,
163163
predicate?: Predicate,
164-
whitelist?: string[],
165-
blacklist?: string[]
164+
safelist?: string[],
165+
blockedlist?: string[]
166166
) {
167167
const predicateMatch = predicate && !predicate(state, action.action);
168-
const whitelistMatch =
169-
whitelist && !action.action.type.match(whitelist.join('|'));
170-
const blacklistMatch =
171-
blacklist && action.action.type.match(blacklist.join('|'));
172-
return predicateMatch || whitelistMatch || blacklistMatch;
168+
const safelistMatch =
169+
safelist && !action.action.type.match(safelist.join('|'));
170+
const blocklistMatch =
171+
blockedlist && action.action.type.match(blockedlist.join('|'));
172+
return predicateMatch || safelistMatch || blocklistMatch;
173173
}

projects/ngrx.io/content/guide/store-devtools/config.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ function - takes `state` object and index as arguments, and should return a `sta
3838

3939
For more detailed information see [Redux DevTools Serialize](https://github.com/zalmoxisus/redux-devtools-extension/blob/master/docs/API/Arguments.md#serialize)
4040

41-
### `actionsBlacklist` / `actionsWhitelist`
41+
### `actionsSafelist` / `actionsBlocklist`
4242

4343
array of strings as regex - actions types to be hidden / shown in the monitors, [more information here](https://github.com/zalmoxisus/redux-devtools-extension/blob/master/docs/API/Arguments.md#actionsblacklist--actionswhitelist).
4444

0 commit comments

Comments
 (0)