TopBar home icon (#3740)

* Adding home button

Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>

* Highlight catalog entity on route match

Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>

* Wait for general entites to load

Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>

* Adding WelcomePage catalog entity

Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>

* Highlight general entities in hotbar if their route matches

Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>

* Fixing tests

Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>

* Moving active entities sync to helper function

Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>

* Fix welcome page test

Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
This commit is contained in:
Alex Andreev authored and GitHub committed 2021-09-07 15:18:46 +03:00
1 parent 995cdac328
commit 16c4656a7d
8 files changed
+102 -4

No files matched your search

+22 -2
View File
@@ -21,7 +21,7 @@
import { observable } from "mobx";
import { GeneralEntity } from "../../common/catalog-entities/general";
import { catalogURL, preferencesURL } from "../../common/routes";
import { catalogURL, preferencesURL, welcomeURL } from "../../common/routes";
import { catalogEntityRegistry } from "../catalog";
export const catalogEntity = new GeneralEntity({
@@ -62,9 +62,29 @@ const preferencesEntity = new GeneralEntity({
}
});
const welcomePageEntity = new GeneralEntity({
metadata: {
uid: "welcome-page-entity",
name: "Welcome Page",
source: "app",
labels: {}
},
spec: {
path: welcomeURL(),
icon: {
material: "meeting_room",
background: "#3d90ce"
}
},
status: {
phase: "active",
}
});
const generalEntities = observable([
catalogEntity,
preferencesEntity
preferencesEntity,
welcomePageEntity
]);
export function syncGeneralEntities() {
@@ -0,0 +1,36 @@
/**
* Copyright (c) 2021 OpenLens Authors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
import { when } from "mobx";
import { catalogCategoryRegistry } from "../../../common/catalog";
import { catalogEntityRegistry } from "../../../renderer/api/catalog-entity-registry";
import { isActiveRoute } from "../../../renderer/navigation";
export async function setEntityOnRouteMatch() {
await when(() => catalogEntityRegistry.entities.size > 0);
const entities = catalogEntityRegistry.getItemsForCategory(catalogCategoryRegistry.getByName("General"));
const activeEntity = entities.find(entity => isActiveRoute(entity.spec.path));
if (activeEntity) {
catalogEntityRegistry.activeEntity = activeEntity;
}
}