-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Support registry `show_user` var definition property (elastic/package-registry#266) * Add tests Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
- Loading branch information
1 parent
9c47579
commit ed9a1f1
Showing
6 changed files
with
90 additions
and
6 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
6 changes: 6 additions & 0 deletions
6
...pplications/ingest_manager/sections/agent_config/create_datasource_page/services/index.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,6 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
export { isAdvancedVar } from './is_advanced_var'; |
62 changes: 62 additions & 0 deletions
62
...est_manager/sections/agent_config/create_datasource_page/services/is_advanced_var.test.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,62 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
import { isAdvancedVar } from './is_advanced_var'; | ||
|
||
describe('Ingest Manager - isAdvancedVar', () => { | ||
it('returns true for vars that should be show under advanced options', () => { | ||
expect( | ||
isAdvancedVar({ | ||
name: 'mock_var', | ||
type: 'text', | ||
required: true, | ||
default: 'default string', | ||
}) | ||
).toBe(true); | ||
|
||
expect( | ||
isAdvancedVar({ | ||
name: 'mock_var', | ||
type: 'text', | ||
default: 'default string', | ||
}) | ||
).toBe(true); | ||
|
||
expect( | ||
isAdvancedVar({ | ||
name: 'mock_var', | ||
type: 'text', | ||
}) | ||
).toBe(true); | ||
}); | ||
|
||
it('returns false for vars that should be show by default', () => { | ||
expect( | ||
isAdvancedVar({ | ||
name: 'mock_var', | ||
type: 'text', | ||
required: true, | ||
default: 'default string', | ||
show_user: true, | ||
}) | ||
).toBe(false); | ||
|
||
expect( | ||
isAdvancedVar({ | ||
name: 'mock_var', | ||
type: 'text', | ||
required: true, | ||
}) | ||
).toBe(false); | ||
|
||
expect( | ||
isAdvancedVar({ | ||
name: 'mock_var', | ||
type: 'text', | ||
show_user: true, | ||
}) | ||
).toBe(false); | ||
}); | ||
}); |
13 changes: 13 additions & 0 deletions
13
...s/ingest_manager/sections/agent_config/create_datasource_page/services/is_advanced_var.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,13 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
import { RegistryVarsEntry } from '../../../../types'; | ||
|
||
export const isAdvancedVar = (varDef: RegistryVarsEntry): boolean => { | ||
if (varDef.show_user || (varDef.required && !varDef.default)) { | ||
return false; | ||
} | ||
return true; | ||
}; |