Skip to content
Snippets Groups Projects
Unverified Commit a673bc22 authored by xgui3783's avatar xgui3783 Committed by GitHub
Browse files

Merge pull request #679 from HumanBrainProject/bugfix_disableMultiregionSelection

bugfix: temporarily disable multiregion selection
parents c8b8a349 fc5add9d
No related branches found
No related tags found
No related merge requests found
......@@ -22,3 +22,11 @@
## Under the hood stuff
- Updated how dataset retrieval work. It will now query on a region basis
## Breaking changes
- Temporarily disabled multiregion selection
> as a result of the UI overhaul, multi-region selection as it existed before will break the UI in several ways. As a result, it will be disabled temporarily until higher hierarchy region selection can be implemented properly.
>
> Any existing URL which points to a multi-region selection state will be shown a message `Selecting multiple regions has been temporarily disabled in v2.3.0`
......@@ -7,6 +7,7 @@ import { Action, Store } from '@ngrx/store'
import { defaultRootState } from '../services/stateStore.service'
import { cold } from 'jasmine-marbles'
import { HttpClientTestingModule } from '@angular/common/http/testing'
import { AngularMaterialModule } from 'src/ui/sharedModules/angularMaterial.module'
const bigbrainJson = require('!json-loader!src/res/ext/bigbrain.json')
......@@ -16,7 +17,8 @@ describe('atlasviewer.history.service.ts', () => {
beforeEach(() => {
TestBed.configureTestingModule({
imports: [
HttpClientTestingModule
HttpClientTestingModule,
AngularMaterialModule,
],
providers: [
AtlasViewerHistoryUseEffect,
......
......@@ -8,6 +8,7 @@ import { AtlasViewerConstantsServices } from "src/atlasViewer/atlasViewer.consta
import { cvtSearchParamToState, cvtStateToSearchParam } from "./atlasViewer.urlUtil";
import { viewerStateHelperStoreName } from '../services/state/viewerState.store.helper'
import { PureContantService } from "src/util";
import { MatSnackBar } from "@angular/material/snack-bar";
const getSearchParamStringFromState = state => {
try {
return cvtStateToSearchParam(state).toString()
......@@ -58,7 +59,9 @@ export class AtlasViewerHistoryUseEffect implements OnDestroy {
}
} else {
// if non empty search param
const newState = cvtSearchParamToState(search, storeState)
const newState = cvtSearchParamToState(search, storeState, error => {
this.snackbar.open(`${error.message}`, 'Dismiss')
})
return {
type: GENERAL_ACTION_TYPES.APPLY_STATE,
state: newState,
......@@ -127,7 +130,8 @@ export class AtlasViewerHistoryUseEffect implements OnDestroy {
private store$: Store<IavRootStoreInterface>,
private actions$: Actions,
private constantService: AtlasViewerConstantsServices,
private pureConstantSErvice: PureContantService
private pureConstantSErvice: PureContantService,
private snackbar: MatSnackBar
) {
this.setNewSearchString$.subscribe(newSearchString => {
......
......@@ -31,6 +31,46 @@ const fetchedTemplateRootState = {
describe('atlasViewer.urlService.service.ts', () => {
describe('cvtSearchParamToState', () => {
/**
* for 2.3.0 onwards
* multi region selection has been temporarily disabled.
* search param parse needs to return emtpy array when encountered
*/
it('> filters out multi region selection an returns an empty array', () => {
const searchString = `?templateSelected=Waxholm+Space+rat+brain+MRI%2FDTI&parcellationSelected=Waxholm+Space+rat+brain+atlas+v2&cRegionsSelected=%7B%22v2%22%3A%2213.a.b.19.6.c.q.x.1.1L.Y.1K.r.s.y.z._.1G.-.Z.18.v.f.g.1J.1C.k.14.15.7.1E.1F.10.11.12.1D.1S.A.1V.1W.1X.1Y.1Z.1a.1i.1j.1k.1m.1n.1o.1p.U.V.W.3.1I.e.d.1T.1H.m.h.n.1U.o.t.2.17.p.w.4.5.1A.1B.u.l.j.16%22%7D&cNavigation=0.0.0.-W000..2-8Bnd.2_tvb9._yymE._tYzz..1Sjt..9Hnn%7E.Lqll%7E.Vcf..9fo`
const searchparam = new URLSearchParams(searchString)
const regionObj = JSON.parse(searchparam.get('cRegionsSelected'))
const totalRegions = []
for (const key in regionObj) {
for (const el of regionObj[key].split('.')) {
totalRegions.push(el)
}
}
expect(totalRegions.length).toBeGreaterThan(1)
const newState = cvtSearchParamToState(searchparam, fetchedTemplateRootState)
expect(newState?.viewerState?.regionsSelected).toEqual([])
})
/**
* leaves single region selection intact
*/
it('> leaves single region selection intact', () => {
const searchString = '?templateSelected=Waxholm+Space+rat+brain+MRI%2FDTI&parcellationSelected=Waxholm+Space+rat+brain+atlas+v2&cRegionsSelected=%7B"v2"%3A"1S"%7D&cNavigation=0.0.0.-W000..2-8Bnd.2_tvb9._yymE._tYzz..1Sjt..9Hnn~.Lqll~.Vcf..9fo'
const searchparam = new URLSearchParams(searchString)
const regionObj = JSON.parse(searchparam.get('cRegionsSelected'))
const totalRegions = []
for (const key in regionObj) {
for (const el of regionObj[key].split('.')) {
totalRegions.push(el)
}
}
expect(totalRegions.length).toEqual(1)
const newState = cvtSearchParamToState(searchparam, fetchedTemplateRootState)
expect(newState?.viewerState?.regionsSelected?.length).toEqual(1)
})
it('> convert empty search param to empty state', () => {
const searchparam = new URLSearchParams()
expect(() => cvtSearchParamToState(searchparam, defaultRootState)).toThrow()
......
......@@ -13,7 +13,9 @@ export const PARSING_SEARCHPARAM_ERROR = {
const PARSING_SEARCHPARAM_WARNING = {
UNKNOWN_PARCELLATION: 'UNKNOWN_PARCELLATION',
DECODE_CIPHER_ERROR: 'DECODE_CIPHER_ERROR',
ID_ERROR: 'ID_ERROR'
ID_ERROR: 'ID_ERROR',
DEPRECATION_ERROR: `DEPRECATION_ERROR`
}
export const CVT_STATE_TO_SEARCHPARAM_ERROR = {
......@@ -90,7 +92,7 @@ export const cvtStateToSearchParam = (state: any): URLSearchParams => {
}
const { TEMPLATE_NOT_FOUND, TEMPALTE_NOT_SET, PARCELLATION_NOT_UPDATED } = PARSING_SEARCHPARAM_ERROR
const { UNKNOWN_PARCELLATION, DECODE_CIPHER_ERROR, ID_ERROR } = PARSING_SEARCHPARAM_WARNING
const { UNKNOWN_PARCELLATION, DECODE_CIPHER_ERROR, ID_ERROR, DEPRECATION_ERROR } = PARSING_SEARCHPARAM_WARNING
const parseSearchParamForTemplateParcellationRegion = (searchparams: URLSearchParams, state: IavRootStoreInterface, cb?: (arg: any) => void) => {
......@@ -193,7 +195,13 @@ const parseSearchParamForTemplateParcellationRegion = (searchparams: URLSearchPa
return {
templateSelected,
parcellationSelected,
regionsSelected
regionsSelected: (() => {
if (regionsSelected.length > 1) {
cb({ type: DEPRECATION_ERROR, message: `Selecting multiple regions has been temporarily disabled in v2.3.0` })
return []
}
return regionsSelected
})()
}
}
......
import {MAT_DIALOG_DEFAULT_OPTIONS, MatDialogConfig, MatDialogModule} from "@angular/material/dialog";
import {MatButtonModule} from "@angular/material/button";
import {MatSnackBarModule} from "@angular/material/snack-bar";
import {MatSnackBarModule, MAT_SNACK_BAR_DEFAULT_OPTIONS} from "@angular/material/snack-bar";
import {MatCardModule} from "@angular/material/card";
import {MatCheckboxModule} from "@angular/material/checkbox";
import {MatTabsModule} from "@angular/material/tabs";
......@@ -96,6 +96,11 @@ const defaultDialogOption: MatDialogConfig = new MatDialogConfig()
...defaultDialogOption,
panelClass: 'iav-dialog-class',
},
},{
provide: MAT_SNACK_BAR_DEFAULT_OPTIONS,
useValue: {
duration: 2500
}
}],
})
export class AngularMaterialModule { }
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment