generated from VolkovLabs/volkovlabs-abc-datasource
-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Local mode to access local instance (#51)
* Refactor APIs * Update tests * Add local request mode * Update tests * Update Select to Radio * Fix tests --------- Co-authored-by: Mikhail <[email protected]>
- Loading branch information
1 parent
864749c
commit b35fc76
Showing
10 changed files
with
262 additions
and
35 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,41 @@ | ||
import React from 'react'; | ||
|
||
const actual = jest.requireActual('@grafana/ui'); | ||
|
||
/** | ||
* Mock Select component | ||
*/ | ||
const Select = jest.fn(({ options, onChange, value, ...restProps }) => ( | ||
<select | ||
onChange={(event: any) => { | ||
if (onChange) { | ||
onChange( | ||
options.find((option: any) => { | ||
/** | ||
* Jest convert number to string, so just using not strict comparison | ||
*/ | ||
// eslint-disable-next-line eqeqeq | ||
return option.value == event.target.value; | ||
}) | ||
); | ||
} | ||
}} | ||
/** | ||
* Fix jest warnings because null value. | ||
* For Select component in @grafana/ui should be used null to reset value. | ||
*/ | ||
value={value === null ? '' : value} | ||
{...restProps} | ||
> | ||
{options.map(({ label, value }: any) => ( | ||
<option key={value} value={value}> | ||
{label} | ||
</option> | ||
))} | ||
</select> | ||
)); | ||
|
||
module.exports = { | ||
...actual, | ||
Select, | ||
}; |
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 |
---|---|---|
@@ -1,7 +1,33 @@ | ||
import { TestIds } from './tests'; | ||
|
||
/** | ||
* Datasource test status | ||
* Data Source test status | ||
*/ | ||
export enum DataSourceTestStatus { | ||
SUCCESS = 'success', | ||
ERROR = 'error', | ||
} | ||
|
||
/** | ||
* Request Mode | ||
*/ | ||
export enum RequestMode { | ||
LOCAL = 'local', | ||
REMOTE = 'remote', | ||
} | ||
|
||
/** | ||
* Request Mode Options | ||
*/ | ||
export const RequestModeOptions = [ | ||
{ | ||
label: 'Local', | ||
value: RequestMode.LOCAL, | ||
ariaLabel: TestIds.configEditor.fieldRequestModelOption(RequestMode.LOCAL), | ||
}, | ||
{ | ||
label: 'Remote', | ||
value: RequestMode.REMOTE, | ||
ariaLabel: TestIds.configEditor.fieldRequestModelOption(RequestMode.REMOTE), | ||
}, | ||
]; |
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
Oops, something went wrong.