Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(daffio): remove extraneous api call to guides list. #2735

Merged
merged 1 commit into from
Jan 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,7 @@ import {
} from '@daffodil/design/sidebar';

import { DaffioSidebarViewportContainer } from './sidebar-viewport.component';
import {
OpenSidebar,
CloseSidebar,
SetSidebarState,
} from '../../actions/sidebar.actions';
import { CloseSidebar } from '../../actions/sidebar.actions';
import * as fromSidebar from '../../reducers/index';

describe('DaffioSidebarViewportContainer', () => {
Expand Down Expand Up @@ -109,21 +105,5 @@ describe('DaffioSidebarViewportContainer', () => {
expect(store.dispatch).toHaveBeenCalledWith(new CloseSidebar());
});
});

describe('open', () => {
it('should call store.dispatch with a OpenSidebar action', () => {
component.open();

expect(store.dispatch).toHaveBeenCalledWith(new OpenSidebar());
});
});

describe('setVisibility', () => {
it('should call store.dispatch with a SetSidebarAction action', () => {
component.setVisibility(true);

expect(store.dispatch).toHaveBeenCalledWith(new SetSidebarState({ open: true }));
});
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ import {
Store,
select,
} from '@ngrx/store';
import { DaffioDoc } from 'apps/daffio/src/app/docs/models/doc';
import { DaffioDocsService } from 'apps/daffio/src/app/docs/services/docs.service';
import {
map,
Observable,
Expand All @@ -17,13 +15,8 @@ import {
import { DaffSidebarMode } from '@daffodil/design/sidebar';
import { DaffRouterNamedViewService } from '@daffodil/router';

import { DaffioGuideList } from '../../../../docs/models/guide-list';
import { DaffioRouterNamedViewsEnum } from '../../../../named-views/models/named-views.enum';
import {
CloseSidebar,
OpenSidebar,
SetSidebarState,
} from '../../actions/sidebar.actions';
import { CloseSidebar } from '../../actions/sidebar.actions';
import * as fromDaffioSidebar from '../../reducers/index';

@Component({
Expand All @@ -38,13 +31,11 @@ export class DaffioSidebarViewportContainer implements OnInit {
readonly sidebarFooterNamedView = DaffioRouterNamedViewsEnum.SIDEBARFOOTER;

showSidebar$: Observable<boolean>;
sidebarContents$: Observable<DaffioGuideList>;
mode$: Observable<DaffSidebarMode>;
showSidebarHeader$: Observable<boolean>;
showSidebarFooter$: Observable<boolean>;

ngOnInit() {
this.sidebarContents$ = this.docService.getGuideList();
this.showSidebar$ = this.store.pipe(select(fromDaffioSidebar.selectShowSidebar));
this.mode$ = this.store.pipe(select(fromDaffioSidebar.selectSidebarMode));
this.showSidebarHeader$ = this.namedViewService.namedViews$.pipe(map((namedViews) => !!namedViews[this.sidebarHeaderNamedView]));
Expand All @@ -53,18 +44,9 @@ export class DaffioSidebarViewportContainer implements OnInit {

constructor(
private store: Store<fromDaffioSidebar.State>,
private docService: DaffioDocsService<DaffioDoc, DaffioGuideList>,
private namedViewService: DaffRouterNamedViewService) { }

close() {
this.store.dispatch(new CloseSidebar());
}

open() {
this.store.dispatch(new OpenSidebar());
}

setVisibility(state: boolean) {
this.store.dispatch(new SetSidebarState({ open: state }));
}
}