forked from opensearch-project/OpenSearch-Dashboards
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from Hailong-am/feature/workspace
workspace template init commit
- Loading branch information
Showing
8 changed files
with
116 additions
and
1 deletion.
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
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,31 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
export interface WorkspaceTemplate { | ||
/** | ||
* Unique identifier for the workspace template | ||
*/ | ||
id: string; | ||
|
||
/** | ||
* Label used for workspace template name. | ||
*/ | ||
label: string; | ||
|
||
/** | ||
* The order that workspace template will be sorted in | ||
*/ | ||
order?: number; | ||
|
||
/** | ||
* Introduction of the template | ||
*/ | ||
description: string; | ||
|
||
/** | ||
* template coverage image location | ||
*/ | ||
coverImage?: string; | ||
} |
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,38 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import { WorkspaceTemplate } from '../types'; | ||
|
||
/** @internal */ | ||
export const DEFAULT_WORKSPACE_TEMPLATES: Record<string, WorkspaceTemplate> = Object.freeze({ | ||
search: { | ||
id: 'search', | ||
label: 'Search', | ||
order: 1000, | ||
description: | ||
"Intro paragraph blur about search, key features, and why you'd want to create ana search workspace", | ||
}, | ||
observability: { | ||
id: 'observability', | ||
label: 'Observability', | ||
order: 2000, | ||
description: | ||
"Intro paragraph blur about observability, key features, and why you'd want to create ana observability workspace", | ||
}, | ||
security_analytics: { | ||
id: 'security_analytics', | ||
label: 'Security Analytics', | ||
order: 3000, | ||
description: | ||
"Intro paragraph blur about security analytics, key features, and why you'd want to create ana security analytics workspace", | ||
}, | ||
general_analysis: { | ||
id: 'general_analysis', | ||
label: 'General Analytics', | ||
order: 4000, | ||
description: | ||
"Intro paragraph blur about analytics, key features, and why you'd want to create ana analytics workspace", | ||
}, | ||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import { ApplicationStart, PublicAppInfo } from 'opensearch-dashboards/public'; | ||
import { useObservable } from 'react-use'; | ||
import { useMemo } from 'react'; | ||
import { WorkspaceTemplate } from '../../../core/types'; | ||
|
||
export function useWorkspaceTemplate(application: ApplicationStart) { | ||
const applications = useObservable(application.applications$); | ||
|
||
return useMemo(() => { | ||
let workspaceTemplates = [] as WorkspaceTemplate[]; | ||
const templateFeatureMap = new Map<string, PublicAppInfo[]>(); | ||
|
||
if (applications) { | ||
applications.forEach((app) => { | ||
const { workspaceTemplate: templates = [] } = app; | ||
workspaceTemplates.push(...templates); | ||
for (const template of templates) { | ||
const features = templateFeatureMap.get(template.id) || []; | ||
features.push(app); | ||
templateFeatureMap.set(template.id, features); | ||
} | ||
}); | ||
|
||
workspaceTemplates = [...new Set(workspaceTemplates)]; | ||
workspaceTemplates.sort((a, b) => (a.order || 0) - (b.order || 0)); | ||
} | ||
|
||
return { workspaceTemplates, templateFeatureMap }; | ||
}, [applications]); | ||
} |