Skip to content

Commit

Permalink
build(deps): bump project dependencies, refactor store modules (#764)
Browse files Browse the repository at this point in the history
- [x] update project dependencies to the latest versions;
- [x] use singular names for store action object and store selector objects;
  • Loading branch information
rfprod authored Aug 19, 2023
1 parent ec44097 commit f89776d
Show file tree
Hide file tree
Showing 90 changed files with 1,257 additions and 1,278 deletions.
4 changes: 2 additions & 2 deletions apps/client/src/app/client.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { AppGqlModule } from '@app/client-gql';
import { AppGrpcModule, AppGrpcService } from '@app/client-grpc';
import { AppMaterialModule } from '@app/client-material';
import { AppPwaOfflineModule } from '@app/client-pwa-offline';
import { AppDiagnosticsStoreModule, diagnosticsActions, IDiagnosticsState } from '@app/client-store-diagnostics';
import { AppDiagnosticsStoreModule, diagnosticsAction, IDiagnosticsState } from '@app/client-store-diagnostics';
import { AppRouterStoreModule } from '@app/client-store-router';
import { AppTranslateModule } from '@app/client-translate';
import { AppElizaModule } from '@app/client-util-eliza';
Expand Down Expand Up @@ -52,6 +52,6 @@ export class AppClientModule {
private readonly store: Store<IDiagnosticsState>,
) {
void this.grpc.getEntityById().subscribe();
this.store.dispatch(diagnosticsActions.connect());
this.store.dispatch(diagnosticsAction.connect());
}
}
18 changes: 9 additions & 9 deletions apps/client/src/app/components/root.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { ComponentFixture, TestBed, TestModuleMetadata } from '@angular/core/testing';
import { Meta, Title } from '@angular/platform-browser';
import { AppServiceWorkerService } from '@app/client-service-worker';
import { chatbotActions } from '@app/client-store-chatbot';
import { routerActions } from '@app/client-store-router';
import { sidebarActions } from '@app/client-store-sidebar';
import { chatbotAction } from '@app/client-store-chatbot';
import { routerAction } from '@app/client-store-router';
import { sidebarAction } from '@app/client-store-sidebar';
import { testingEnvironment } from '@app/client-testing-unit';
import { WEB_CLIENT_APP_ENV } from '@app/client-util';
import { Store } from '@ngrx/store';
Expand Down Expand Up @@ -88,7 +88,7 @@ describe('AppRootComponent', () => {
const storeSpy = jest.spyOn(store, 'dispatch');
component.toggleSidebar();
expect(storeSpy).toHaveBeenCalledTimes(1);
expect(storeSpy).toHaveBeenCalledWith(sidebarActions.toggle());
expect(storeSpy).toHaveBeenCalledWith(sidebarAction.toggle());
});

it('toggleChatbot should call store dispatch events depending on the parameter', () => {
Expand All @@ -99,31 +99,31 @@ describe('AppRootComponent', () => {
second: 2,
};
expect(storeSpy).toHaveBeenCalledTimes(calls.first);
expect(storeSpy).toHaveBeenNthCalledWith(calls.first, chatbotActions.open());
expect(storeSpy).toHaveBeenNthCalledWith(calls.first, chatbotAction.open());

component.toggleChatbot(false);
expect(storeSpy).toHaveBeenCalledTimes(calls.second);
expect(storeSpy).toHaveBeenNthCalledWith(calls.second, chatbotActions.close());
expect(storeSpy).toHaveBeenNthCalledWith(calls.second, chatbotAction.close());
});

it('navButtonClick should call store dispatch', () => {
const storeSpy = jest.spyOn(store, 'dispatch');
component.navButtonClick();
expect(storeSpy).toHaveBeenCalledTimes(1);
expect(storeSpy).toHaveBeenCalledWith(sidebarActions.close({ payload: { navigate: false } }));
expect(storeSpy).toHaveBeenCalledWith(sidebarAction.close({ payload: { navigate: false } }));
});

it('navigateBack should call store dispatch', () => {
const storeSpy = jest.spyOn(store, 'dispatch');
component.navigateBack();
expect(storeSpy).toHaveBeenCalledTimes(1);
expect(storeSpy).toHaveBeenCalledWith(routerActions.back());
expect(storeSpy).toHaveBeenCalledWith(routerAction.back());
});

it('navigateForward should call store dispatch', () => {
const storeSpy = jest.spyOn(store, 'dispatch');
component.navigateForward();
expect(storeSpy).toHaveBeenCalledTimes(1);
expect(storeSpy).toHaveBeenCalledWith(routerActions.forward());
expect(storeSpy).toHaveBeenCalledWith(routerAction.forward());
});
});
28 changes: 14 additions & 14 deletions apps/client/src/app/components/root.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import { AfterContentInit, ChangeDetectionStrategy, Component, DestroyRef, HostB
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { Meta, Title } from '@angular/platform-browser';
import { AppServiceWorkerService } from '@app/client-service-worker';
import { chatbotActions, chatbotSelectors, IChatbotState } from '@app/client-store-chatbot';
import { routerActions } from '@app/client-store-router';
import { ISidebarState, sidebarActions, sidebarSelectors } from '@app/client-store-sidebar';
import { IThemeState, themeActions, themeSelectors } from '@app/client-store-theme';
import { chatbotAction, chatbotSelector, IChatbotState } from '@app/client-store-chatbot';
import { routerAction } from '@app/client-store-router';
import { ISidebarState, sidebarAction, sidebarSelector } from '@app/client-store-sidebar';
import { IThemeState, themeAction, themeSelector } from '@app/client-store-theme';
import { IWebClientAppEnvironment, WEB_CLIENT_APP_ENV } from '@app/client-util';
import { Store } from '@ngrx/store';
import { map } from 'rxjs';
Expand Down Expand Up @@ -47,11 +47,11 @@ export class AppRootComponent implements OnInit, AfterContentInit {
*/
public readonly version = this.env.meta.version;

public readonly sidebarOpen$ = this.store.select(sidebarSelectors.sidebarOpen);
public readonly sidebarOpen$ = this.store.select(sidebarSelector.sidebarOpen);

public readonly chatbotOpen$ = this.store.select(chatbotSelectors.chatbotOpen);
public readonly chatbotOpen$ = this.store.select(chatbotSelector.chatbotOpen);

public readonly darkThemeEnabled$ = this.store.select(themeSelectors.darkThemeEnabled);
public readonly darkThemeEnabled$ = this.store.select(themeSelector.darkThemeEnabled);

public readonly logoSrc$ = this.darkThemeEnabled$.pipe(
map(darkThemeEnabled => {
Expand All @@ -68,32 +68,32 @@ export class AppRootComponent implements OnInit, AfterContentInit {
) {}

public toggleSidebar(): void {
this.store.dispatch(sidebarActions.toggle());
this.store.dispatch(sidebarAction.toggle());
}

public toggleChatbot(event: boolean): void {
if (event) {
this.store.dispatch(chatbotActions.open());
this.store.dispatch(chatbotAction.open());
} else {
this.store.dispatch(chatbotActions.close());
this.store.dispatch(chatbotAction.close());
}
}

public toggleTheme(darkThemeEnabled: boolean): void {
this.darkTheme = darkThemeEnabled;
this.store.dispatch(themeActions.toggleDarkTheme());
this.store.dispatch(themeAction.toggleDarkTheme());
}

public navButtonClick(): void {
this.store.dispatch(sidebarActions.close({ payload: { navigate: false } }));
this.store.dispatch(sidebarAction.close({ payload: { navigate: false } }));
}

public navigateBack(): void {
this.store.dispatch(routerActions.back());
this.store.dispatch(routerAction.back());
}

public navigateForward(): void {
this.store.dispatch(routerActions.forward());
this.store.dispatch(routerAction.forward());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { Store, StoreModule } from '@ngrx/store';
import { MarkdownModule, MarkdownModuleConfig, MarkedOptions } from 'ngx-markdown';

import { testingProviders } from '../../../testing/testing-providers.mock';
import { mdFilesActions } from '../../modules/md-files/md-files.actions';
import { mdFilesAction } from '../../modules/md-files/md-files.actions';
import { IMdFilesState, mdFilesReducerConfig } from '../../modules/md-files/md-files.interface';
import { mdFilesReducerProvider } from '../../modules/md-files/md-files.reducer';
import { AppDocMarkdownReferenceTreeComponent } from './md-reference-tree.component';
Expand Down Expand Up @@ -62,6 +62,6 @@ describe('AppDocMarkdownReferenceTreeComponent', () => {
it('showReadme should call store.dispatch', () => {
const filePath = '/README.md';
component.showReadme(filePath);
expect(storeDispatchSpy).toHaveBeenCalledWith(mdFilesActions.showReadme({ filePath }));
expect(storeDispatchSpy).toHaveBeenCalledWith(mdFilesAction.showReadme({ filePath }));
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { MatTreeNestedDataSource } from '@angular/material/tree';
import { Store } from '@ngrx/store';

import { DOCUMENTATION_ENVIRONMENT, IDocumentationEnvironment } from '../../interfaces/environment.interface';
import { mdFilesActions } from '../../modules/md-files/md-files.actions';
import { mdFilesAction } from '../../modules/md-files/md-files.actions';
import { IMdFilesState } from '../../modules/md-files/md-files.interface';

/**
Expand Down Expand Up @@ -55,6 +55,6 @@ export class AppDocMarkdownReferenceTreeComponent {
typeof node.children !== 'undefined' && node.children.length > 0;

public showReadme(filePath: string): void {
this.store.dispatch(mdFilesActions.showReadme({ filePath }));
this.store.dispatch(mdFilesAction.showReadme({ filePath }));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { map } from 'rxjs';

import { DOCUMENTATION_ENVIRONMENT, IDocumentationEnvironment } from '../../interfaces/environment.interface';
import { IMdFilesState } from '../../modules/md-files/md-files.interface';
import { mdFilesSelectors } from '../../modules/md-files/md-files.selectors';
import { mdFilesSelector } from '../../modules/md-files/md-files.selectors';

@Component({
selector: 'app-documentation-md-reference',
Expand All @@ -18,7 +18,7 @@ export class AppDocMarkdownReferenceComponent {
* Selected markdown file path.
*/
public readonly filePath$ = this.store
.select(mdFilesSelectors.filePath)
.select(mdFilesSelector.filePath)
.pipe(map(filePath => this.sanitizer.sanitize(SecurityContext.HTML, filePath)));

public readonly useEmoji = !this.env.testing;
Expand Down
12 changes: 5 additions & 7 deletions apps/documentation/src/app/modules/md-files/md-files.actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@ import { createAction, props } from '@ngrx/store';

import { IMdFilesStateModel, mdFilesReducerConfig } from './md-files.interface';

const showReadme = createAction(
actionType(mdFilesReducerConfig.featureName, 'show readme'),
props<{ filePath: IMdFilesStateModel['filePath'] }>(),
);

export const mdFilesActions = {
showReadme,
export const mdFilesAction = {
showReadme: createAction(
actionType(mdFilesReducerConfig.featureName, 'show readme'),
props<{ filePath: IMdFilesStateModel['filePath'] }>(),
),
};
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Injectable, Provider } from '@angular/core';
import { createReducer, on } from '@ngrx/store';

import { mdFilesActions } from './md-files.actions';
import { mdFilesAction } from './md-files.actions';
import { mdFilesReducerConfig } from './md-files.interface';

@Injectable({
Expand All @@ -11,7 +11,7 @@ export class AppMdFilesReducer {
public createReducer() {
return createReducer(
mdFilesReducerConfig.initialState,
on(mdFilesActions.showReadme, (state, { filePath }) => ({ ...state, filePath })),
on(mdFilesAction.showReadme, (state, { filePath }) => ({ ...state, filePath })),
);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import { IMdFilesState, IMdFilesStateModel } from './md-files.interface';

const selectMdFilesFeature = (state: IMdFilesState) => state.mdFiles;

const filePath = createSelector(selectMdFilesFeature, (state: IMdFilesStateModel) => state.filePath);

export const mdFilesSelectors = {
filePath,
export const mdFilesSelector = {
filePath: createSelector(selectMdFilesFeature, (state: IMdFilesStateModel) => state.filePath),
};
Loading

0 comments on commit f89776d

Please sign in to comment.