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.
supports configure workspace features with wildcard (#96)
supports configure workspace features with wildcard --------- Signed-off-by: Yulong Ruan <ruanyl@amazon.com>
- Loading branch information
1 parent
88be9b2
commit 665a303
Showing
13 changed files
with
166 additions
and
30 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
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,14 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
export interface WorkspaceAttribute { | ||
id: string; | ||
name: string; | ||
description?: string; | ||
features?: string[]; | ||
color?: string; | ||
icon?: string; | ||
defaultVISTheme?: 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
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,83 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import { featureMatchesConfig } from './utils'; | ||
|
||
describe('workspace utils: featureMatchesConfig', () => { | ||
it('feature configured with `*` should match any features', () => { | ||
const match = featureMatchesConfig(['*']); | ||
expect(match({ id: 'dev_tools', category: { id: 'management', label: 'Management' } })).toBe( | ||
true | ||
); | ||
expect( | ||
match({ id: 'discover', category: { id: 'opensearchDashboards', label: 'Library' } }) | ||
).toBe(true); | ||
}); | ||
|
||
it('should NOT match the config if feature id not matches', () => { | ||
const match = featureMatchesConfig(['discover', 'dashboards', 'visualize']); | ||
expect(match({ id: 'dev_tools', category: { id: 'management', label: 'Management' } })).toBe( | ||
false | ||
); | ||
}); | ||
|
||
it('should match the config if feature id matches', () => { | ||
const match = featureMatchesConfig(['discover', 'dashboards', 'visualize']); | ||
expect( | ||
match({ id: 'discover', category: { id: 'opensearchDashboards', label: 'Library' } }) | ||
).toBe(true); | ||
}); | ||
|
||
it('should match the config if feature category matches', () => { | ||
const match = featureMatchesConfig(['discover', 'dashboards', '@management', 'visualize']); | ||
expect(match({ id: 'dev_tools', category: { id: 'management', label: 'Management' } })).toBe( | ||
true | ||
); | ||
}); | ||
|
||
it('should match any features but not the excluded feature id', () => { | ||
const match = featureMatchesConfig(['*', '!discover']); | ||
expect(match({ id: 'dev_tools', category: { id: 'management', label: 'Management' } })).toBe( | ||
true | ||
); | ||
expect( | ||
match({ id: 'discover', category: { id: 'opensearchDashboards', label: 'Library' } }) | ||
).toBe(false); | ||
}); | ||
|
||
it('should match any features but not the excluded feature category', () => { | ||
const match = featureMatchesConfig(['*', '!@management']); | ||
expect(match({ id: 'dev_tools', category: { id: 'management', label: 'Management' } })).toBe( | ||
false | ||
); | ||
expect(match({ id: 'integrations', category: { id: 'management', label: 'Management' } })).toBe( | ||
false | ||
); | ||
expect( | ||
match({ id: 'discover', category: { id: 'opensearchDashboards', label: 'Library' } }) | ||
).toBe(true); | ||
}); | ||
|
||
it('should match features of a category but NOT the excluded feature', () => { | ||
const match = featureMatchesConfig(['@management', '!dev_tools']); | ||
expect(match({ id: 'dev_tools', category: { id: 'management', label: 'Management' } })).toBe( | ||
false | ||
); | ||
expect(match({ id: 'integrations', category: { id: 'management', label: 'Management' } })).toBe( | ||
true | ||
); | ||
}); | ||
|
||
it('a config presents later in the config array should override the previous config', () => { | ||
// though `dev_tools` is excluded, but this config will override by '@management' as dev_tools has category 'management' | ||
const match = featureMatchesConfig(['!dev_tools', '@management']); | ||
expect(match({ id: 'dev_tools', category: { id: 'management', label: 'Management' } })).toBe( | ||
true | ||
); | ||
expect(match({ id: 'integrations', category: { id: 'management', label: 'Management' } })).toBe( | ||
true | ||
); | ||
}); | ||
}); |
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