-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reverting notebooks changes, add docs/validation to datasources, expl…
…orer minor fixes (#1101) (#1103) * Add documentation linking and validation for query permissions * Update test with link * Add form validation for name field * reverting notebook changes from #974 & #985 * Remove console log * surrounding events functionally working * small surrounding flyout ui changes --------- (cherry picked from commit 4a8b500) Signed-off-by: Derek Ho <[email protected]> Signed-off-by: Shenoy Pratik <[email protected]> Signed-off-by: Paul Sebastian <[email protected]> Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Shenoy Pratik <[email protected]> Co-authored-by: Paul Sebastian <[email protected]>
- Loading branch information
1 parent
e4cec76
commit 3f169c4
Showing
22 changed files
with
913 additions
and
201 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,68 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import { EuiText, EuiFormRow, EuiFieldText } from '@elastic/eui'; | ||
import React, { useEffect, useState } from 'react'; | ||
import { coreRefs } from '../../../../../public/framework/core_refs'; | ||
|
||
interface ConfigureNameProps { | ||
currentName: string; | ||
currentError: string; | ||
setErrorForForm: React.Dispatch<React.SetStateAction<string>>; | ||
setNameForRequest: React.Dispatch<React.SetStateAction<string>>; | ||
} | ||
|
||
export const NameRow = (props: ConfigureNameProps) => { | ||
const { setNameForRequest, currentName, currentError, setErrorForForm } = props; | ||
const { pplService } = coreRefs; | ||
|
||
const [name, setName] = useState<string>(currentName); | ||
const [existingNames, setExistingNames] = useState<string[]>([]); | ||
|
||
useEffect(() => { | ||
pplService!.fetch({ query: 'show datasources', format: 'jdbc' }).then((dataconnections) => | ||
setExistingNames( | ||
dataconnections.jsonData.map((x) => { | ||
return x.DATASOURCE_NAME; | ||
}) | ||
) | ||
); | ||
}, []); | ||
|
||
const onBlur = (e) => { | ||
if (e.target.value === '') { | ||
setErrorForForm('Name is a required parameter.'); | ||
} else if (existingNames.includes(e.target.value)) { | ||
setErrorForForm('Name must be unique across data sources.'); | ||
} else { | ||
setErrorForForm(''); | ||
} | ||
|
||
setNameForRequest(e.target.value); | ||
}; | ||
|
||
return ( | ||
<EuiFormRow label="Data source name" isInvalid={currentError.length !== 0} error={currentError}> | ||
<> | ||
<EuiText size="xs"> | ||
<p> | ||
Connection name that OpenSearch Dashboards references. This name should be descriptive | ||
and concise. | ||
</p> | ||
</EuiText> | ||
<EuiFieldText | ||
data-test-subj="name" | ||
placeholder="Title" | ||
value={name} | ||
onChange={(e) => { | ||
setName(e.target.value); | ||
}} | ||
onBlur={onBlur} | ||
isInvalid={currentError.length !== 0} | ||
/> | ||
</> | ||
</EuiFormRow> | ||
); | ||
}; |
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
Oops, something went wrong.