-
Notifications
You must be signed in to change notification settings - Fork 906
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(core): add categories for application data sources (#5058)
- Loading branch information
1 parent
906a30e
commit 7f42310
Showing
13 changed files
with
106 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
app/scripts/modules/core/src/application/nav/defaultCategories.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { navigationCategoryRegistry } from './navigationCategory.registry'; | ||
|
||
export const INFRASTRUCTURE_KEY = 'infrastructure'; | ||
export const DELIVERY_KEY = 'delivery'; | ||
|
||
navigationCategoryRegistry.register({ | ||
key: DELIVERY_KEY, | ||
label: 'Delivery', | ||
icon: 'fa fa-tasks', | ||
primary: true, | ||
order: 100, | ||
}); | ||
|
||
navigationCategoryRegistry.register({ | ||
key: INFRASTRUCTURE_KEY, | ||
label: 'Infrastructure', | ||
icon: 'fa fa-cloud', | ||
primary: true, | ||
order: 200, | ||
}); |
46 changes: 46 additions & 0 deletions
46
app/scripts/modules/core/src/application/nav/navigationCategory.registry.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import { cloneDeep } from 'lodash'; | ||
|
||
export interface INavigationCategory { | ||
key: string; | ||
label: string; | ||
icon?: string; | ||
primary: boolean; | ||
order: number; | ||
} | ||
|
||
export class NavigationCategoryRegistry { | ||
private categories: INavigationCategory[] = []; | ||
private orderOverrides: Map<string, number> = new Map(); | ||
|
||
public register(category: INavigationCategory): void { | ||
this.categories.push(category); | ||
} | ||
|
||
public get(key: string): INavigationCategory { | ||
return cloneDeep(this.categories.find(c => c.key === key)); | ||
} | ||
|
||
public has(key: string): boolean { | ||
return this.categories.some(c => c.key === key); | ||
} | ||
|
||
public getAll(): INavigationCategory[] { | ||
return this.categories.slice().sort((a, b) => this.getOrder(a) - this.getOrder(b)); | ||
} | ||
|
||
public overrideCategoryOrder(key: string, order: number): void { | ||
this.orderOverrides.set(key, order); | ||
} | ||
|
||
public getHighestOrder(): number { | ||
return Math.max(...this.categories.map(c => c.order).concat(Array.from(this.orderOverrides.values()))); | ||
} | ||
|
||
public getOrder(category: INavigationCategory): number { | ||
const { key, order } = category; | ||
return this.orderOverrides.has(key) ? this.orderOverrides.get(key) : order; | ||
} | ||
|
||
} | ||
|
||
export const navigationCategoryRegistry = new NavigationCategoryRegistry(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters