Skip to content
Open
Show file tree
Hide file tree
Changes from 4 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
2 changes: 2 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
- Upgrade babel packages to latest versions (7.28.0/7.29.0).
- Upgrade webpack to version 5.105.4.
- Upgrade eslint to v10 and migrate to eslint flat config.
- We no longer start terriajs-server when running `yarn gulp dev` as it is not needed for running tests in the browser with jasmine-browser-runner. If you need terriajs-server, you can start it separately by running `yarn gulp terriajs-server` in another terminal.
- Move catalog-search-provider instance from SearchBarModel to Catalog class.

#### 8.12.2 - 2026-03-27

Expand Down
4 changes: 2 additions & 2 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -292,9 +292,9 @@ serveTests.description =
"Start jasmine-browser-runner server for interactive testing.";
serveTests.displayName = "serve-tests";

const dev = gulp.parallel(terriajsServer, watch, serveTests);
const dev = gulp.parallel(watch, serveTests);
dev.description =
"Start TerriaJS server, watch for source changes, and serve tests.";
"Watch for source changes, and serve tests with jasmine-browser-runner.";

const postNpmInstall = copyCesiumAssets;
postNpmInstall.description = "Copy Cesium assets after installation.";
Expand Down
17 changes: 16 additions & 1 deletion lib/Models/Catalog/Catalog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,33 @@ import Terria from "../Terria";
import Group from "./Group";
import { BaseModel } from "../Definition/Model";
import isDefined from "../../Core/isDefined";
import CatalogSearchProviderMixin from "../../ModelMixins/SearchProviders/CatalogSearchProviderMixin";
import CatalogSearchProvider from "../SearchProviders/CatalogSearchProvider";

export default class Catalog {
@observable
group: Group & BaseModel;

@observable
searchProvider: CatalogSearchProviderMixin.Instance | undefined;

Comment on lines +18 to +19
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this be undefined if always intialised in constructor?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed it to detect differently if the catalogue search provider should be initialised, so we can give the possibility to make it undefined

readonly terria: Terria;

private _disposeCreateUserAddedGroup: () => void;

constructor(terria: Terria) {
constructor(
terria: Terria,
searchProvider?: CatalogSearchProviderMixin.Instance
) {
makeObservable(this);
this.terria = terria;
this.searchProvider =
searchProvider ??
new CatalogSearchProvider(
"catalog-search-provider",
terria,
terria.searchBarModel.minCharacters
);
Copy link
Copy Markdown
Collaborator

@na9da na9da Apr 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: I know we have done this elsewhere in the past but it might be a good idea to stick with standard Constructor parameters for models? Using custom constructor parameters is fine if the model is always initialised manually but if at some point we do automatic initialisation from some config, it could create problems.

One other pattern to make creating the instance easier would be to define a static method like CatalogSearchProvider.fromOptions({minCharacters})

this.group = new CatalogGroup("/", this.terria);
this.terria.addModel(this.group);

Expand Down
8 changes: 2 additions & 6 deletions lib/Models/SearchProviders/CatalogSearchProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,16 +110,12 @@ export default class CatalogSearchProvider extends CatalogSearchProviderMixin(
@observable isSearching: boolean = false;
@observable debounceDurationOnceLoaded: number = 300;

constructor(id: string | undefined, terria: Terria) {
constructor(id: string | undefined, terria: Terria, minCharacters?: number) {
super(id, terria);

makeObservable(this);

this.setTrait(
CommonStrata.defaults,
"minCharacters",
terria.searchBarModel.minCharacters
);
this.setTrait(CommonStrata.defaults, "minCharacters", minCharacters);
}

get type() {
Expand Down
4 changes: 0 additions & 4 deletions lib/Models/SearchProviders/SearchBarModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import RuntimeError from "terriajs-cesium/Source/Core/RuntimeError";
import { JsonObject } from "../../Core/Json";
import Result from "../../Core/Result";
import TerriaError from "../../Core/TerriaError";
import CatalogSearchProviderMixin from "../../ModelMixins/SearchProviders/CatalogSearchProviderMixin";
import LocationSearchProviderMixin from "../../ModelMixins/SearchProviders/LocationSearchProviderMixin";
import { SearchBarTraits } from "../../Traits/SearchProviders/SearchBarTraits";
import SearchProviderTraits from "../../Traits/SearchProviders/SearchProviderTraits";
Expand All @@ -26,9 +25,6 @@ import upsertSearchProviderFromJson from "./upsertSearchProviderFromJson";
export class SearchBarModel extends CreateModel(SearchBarTraits) {
private locationSearchProviders = observable.map<string, BaseModel>();

@observable
catalogSearchProvider: CatalogSearchProviderMixin.Instance | undefined;

constructor(readonly terria: Terria) {
super("search-bar-model", terria);

Expand Down
2 changes: 1 addition & 1 deletion lib/Models/Terria.ts
Original file line number Diff line number Diff line change
Expand Up @@ -459,9 +459,9 @@ export default class Terria {
readonly indeterminateTileLoadProgressEvent = new CesiumEvent();
readonly workbench = new Workbench();
readonly overlays = new Workbench();
readonly catalog = new Catalog(this);
readonly baseMapsModel = new BaseMapsModel("basemaps", this);
readonly searchBarModel = new SearchBarModel(this);
readonly catalog = new Catalog(this);
readonly timelineClock = new Clock({ shouldAnimate: false });
// readonly overrides: any = overrides; // TODO: add options.functionOverrides like in master

Expand Down
17 changes: 4 additions & 13 deletions lib/ReactViewModels/SearchState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,19 @@ import {
action,
computed,
IReactionDisposer,
observable,
reaction,
makeObservable,
runInAction
observable,
reaction
} from "mobx";
import filterOutUndefined from "../Core/filterOutUndefined";
import CatalogSearchProviderMixin from "../ModelMixins/SearchProviders/CatalogSearchProviderMixin";
import LocationSearchProviderMixin from "../ModelMixins/SearchProviders/LocationSearchProviderMixin";
import SearchProviderMixin from "../ModelMixins/SearchProviders/SearchProviderMixin";
import CatalogSearchProvider from "../Models/SearchProviders/CatalogSearchProvider";
import SearchProviderResults from "../Models/SearchProviders/SearchProviderResults";
import Terria from "../Models/Terria";
import CatalogSearchProviderMixin from "../ModelMixins/SearchProviders/CatalogSearchProviderMixin";

interface SearchStateOptions {
terria: Terria;
catalogSearchProvider?: CatalogSearchProviderMixin.Instance;
}

export default class SearchState {
Expand Down Expand Up @@ -50,12 +47,6 @@ export default class SearchState {

this.terria = options.terria;

runInAction(() => {
this.terria.searchBarModel.catalogSearchProvider =
options.catalogSearchProvider ||
new CatalogSearchProvider("catalog-search-provider", options.terria);
});

const self = this;

this._catalogSearchDisposer = reaction(
Expand Down Expand Up @@ -121,7 +112,7 @@ export default class SearchState {

@computed
get catalogSearchProvider(): CatalogSearchProviderMixin.Instance | undefined {
return this.terria.searchBarModel.catalogSearchProvider;
return this.terria.catalog.searchProvider;
}

@computed
Expand Down
31 changes: 16 additions & 15 deletions lib/ReactViewModels/ViewState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ import {
action,
computed,
IReactionDisposer,
makeObservable,
observable,
reaction,
runInAction,
makeObservable
runInAction
} from "mobx";
import { ReactNode, MouseEvent, ComponentType, Ref } from "react";
import { ComponentType, MouseEvent, ReactNode, Ref } from "react";
import defined from "terriajs-cesium/Source/Core/defined";
import addedByUser from "../Core/addedByUser";
import {
Expand All @@ -22,9 +22,12 @@ import CatalogMemberMixin, { getName } from "../ModelMixins/CatalogMemberMixin";
import GroupMixin from "../ModelMixins/GroupMixin";
import MappableMixin from "../ModelMixins/MappableMixin";
import ReferenceMixin from "../ModelMixins/ReferenceMixin";
import CatalogSearchProviderMixin from "../ModelMixins/SearchProviders/CatalogSearchProviderMixin";
import CzmlCatalogItem from "../Models/Catalog/CatalogItems/CzmlCatalogItem";
import CommonStrata from "../Models/Definition/CommonStrata";
import { BaseModel } from "../Models/Definition/Model";
import getAncestors from "../Models/getAncestors";
import { getMarkerCatalogItem } from "../Models/LocationMarkerUtils";
import { SelectableDimension } from "../Models/SelectableDimensions/SelectableDimensions";
import Terria from "../Models/Terria";
import { ViewingControl } from "../Models/ViewingControls";
Expand All @@ -37,9 +40,6 @@ import {
TourPoint
} from "./defaultTourPoints";
import SearchState from "./SearchState";
import CatalogSearchProviderMixin from "../ModelMixins/SearchProviders/CatalogSearchProviderMixin";
import { getMarkerCatalogItem } from "../Models/LocationMarkerUtils";
import CzmlCatalogItem from "../Models/Catalog/CatalogItems/CzmlCatalogItem";

export const DATA_CATALOG_NAME = "data-catalog";
export const USER_DATA_NAME = "my-data";
Expand All @@ -50,8 +50,10 @@ export const WORKBENCH_RESIZE_ANIMATION_DURATION = 500;

interface ViewStateOptions {
terria: Terria;
catalogSearchProvider: CatalogSearchProviderMixin.Instance | undefined;
errorHandlingProvider?: any;
/**
* @deprecated
*/
catalogSearchProvider?: CatalogSearchProviderMixin.Instance;
}

/**
Expand Down Expand Up @@ -203,8 +205,6 @@ export default class ViewState {
}
}

errorProvider: any | null = null;

// default value is null, because user has not made decision to show or
// not show story
// will be explicitly set to false when user 1. dismiss story
Expand Down Expand Up @@ -391,13 +391,14 @@ export default class ViewState {
makeObservable(this);
const terria = options.terria;
this.searchState = new SearchState({
terria,
catalogSearchProvider: options.catalogSearchProvider
terria
});
if (options.catalogSearchProvider) {
runInAction(() => {
this.terria.catalog.searchProvider = options.catalogSearchProvider;
});
}

this.errorProvider = options.errorHandlingProvider
? options.errorHandlingProvider
: null;
this.terria = terria;

// When features are picked, show the feature info panel.
Expand Down
3 changes: 1 addition & 2 deletions test/Map/StyledHtmlSpec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ describe("StyledHtml", function () {
baseUrl: "./"
});
viewState = new ViewState({
terria: terria,
catalogSearchProvider: undefined
terria: terria
});
});

Expand Down
9 changes: 3 additions & 6 deletions test/Models/TerriaSpec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -565,8 +565,7 @@ describe("TerriaSpec", function () {
beforeEach(function () {
newTerria = new Terria({ appBaseHref: "/", baseUrl: "./" });
viewState = new ViewState({
terria: terria,
catalogSearchProvider: undefined
terria: terria
});

UrlToCatalogMemberMapping.register(
Expand Down Expand Up @@ -793,8 +792,7 @@ describe("TerriaSpec", function () {
)}`;
newTerria = new Terria({ baseUrl: "./" });
viewState = new ViewState({
terria: terria,
catalogSearchProvider: undefined
terria: terria
});

await Promise.all(
Expand Down Expand Up @@ -904,8 +902,7 @@ describe("TerriaSpec", function () {
"https://magda.example.com/api/v0/registry/records/map-config-example?optionalAspect=terria-config&optionalAspect=terria-init&optionalAspect=group&dereference=true";

viewState = new ViewState({
terria: terria,
catalogSearchProvider: undefined
terria: terria
});
newTerria = new Terria({ baseUrl: "./" });

Expand Down
3 changes: 1 addition & 2 deletions test/Models/Workflows/SelectableDimensionWorkflowSpec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ describe("SelectableDimensionWorkflow", function () {
beforeEach(function () {
terria = new Terria();
viewState = new ViewState({
terria,
catalogSearchProvider: undefined
terria
});
});

Expand Down
9 changes: 1 addition & 8 deletions test/ReactViewModels/ViewStateSpec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ describe("ViewState", function () {
beforeEach(function () {
terria = new Terria();
viewState = new ViewState({
terria,
catalogSearchProvider: undefined
terria
});
});

Expand Down Expand Up @@ -61,12 +60,6 @@ describe("ViewState", function () {
});
});

describe("error provider", function () {
it("creates an empty error provider by default", function () {
expect(viewState.errorProvider).toBeNull();
});
});

describe("tourPointsWithValidRefs", function () {
it("returns tourPoints ordered by priority", function () {
runInAction(() => {
Expand Down
3 changes: 1 addition & 2 deletions test/ReactViews/BottomDock/BottomDockSpec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ describe("BottomDock", function () {
baseUrl: "./"
});
viewState = new ViewState({
terria: terria,
catalogSearchProvider: undefined
terria: terria
});
});

Expand Down
3 changes: 1 addition & 2 deletions test/ReactViews/BottomDock/MapDataCountSpec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ describe("MapDataCount", function () {
baseUrl: "./"
});
viewState = new ViewState({
terria: terria,
catalogSearchProvider: undefined
terria: terria
});
});

Expand Down
3 changes: 1 addition & 2 deletions test/ReactViews/Custom/Chart/BottomDockChartSpec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ describe("BottomDockChart", function () {
baseUrl: "./"
});
viewState = new ViewState({
terria,
catalogSearchProvider: undefined
terria
});
chartItems = [
{
Expand Down
2 changes: 1 addition & 1 deletion test/ReactViews/Custom/Chart/FeatureInfoPanelChartSpec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ describe("FeatureInfoPanelChart", function () {

context = {
terria: new Terria(),
viewState: new ViewState({ terria, catalogSearchProvider: undefined }),
viewState: new ViewState({ terria }),
feature: new TerriaFeature({}),
catalogItem
};
Expand Down
3 changes: 1 addition & 2 deletions test/ReactViews/Custom/Chart/PointOnMapSpec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ describe("PointOnMap", function () {
baseUrl: "./"
});
viewState = new ViewState({
terria,
catalogSearchProvider: undefined
terria
});
});

Expand Down
3 changes: 1 addition & 2 deletions test/ReactViews/Custom/SettingsPanelCustomComponentSpec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ describe("SettingsPanelCustomComponent", function () {

beforeEach(function () {
viewState = new ViewState({
terria: new Terria(),
catalogSearchProvider: undefined
terria: new Terria()
});

registerCustomComponentTypes(viewState.terria);
Expand Down
3 changes: 1 addition & 2 deletions test/ReactViews/DataCatalog/DataCatalogItemSpec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ describe("DataCatalogItem", () => {
baseUrl: "./"
});
viewState = new ViewState({
terria: terria,
catalogSearchProvider: undefined
terria: terria
});
wmsItem = new WebMapServiceCatalogItem("test", terria);

Expand Down
3 changes: 1 addition & 2 deletions test/ReactViews/DataCatalogSpec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ describe("DataCatalog", function () {
baseUrl: "./"
});
viewState = new ViewState({
terria: terria,
catalogSearchProvider: undefined
terria: terria
});
});

Expand Down
3 changes: 1 addition & 2 deletions test/ReactViews/DisclaimerSpec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ describe("Disclaimer", function () {
baseUrl: "./"
});
viewState = new ViewState({
terria: terria,
catalogSearchProvider: undefined
terria: terria
});
});

Expand Down
Loading
Loading