-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add materialized view visual builder and query builders (#129)
* add materialized view visual builder and query builders Signed-off-by: Shenoy Pratik <[email protected]> * organize header and PR comments Signed-off-by: Shenoy Pratik <[email protected]> --------- Signed-off-by: Shenoy Pratik <[email protected]>
- Loading branch information
Showing
20 changed files
with
1,313 additions
and
339 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import { ACCELERATION_INDEX_NAME_REGEX } from '../../../../common/constants'; | ||
|
||
export const pluralizeTime = (timeWindow: number) => { | ||
return timeWindow > 1 ? 's' : ''; | ||
}; | ||
|
||
export const validateIndexName = (value: string) => { | ||
// Check if the value does not begin with underscores or hyphens and all characters are lower case | ||
return ACCELERATION_INDEX_NAME_REGEX.test(value); | ||
}; |
119 changes: 119 additions & 0 deletions
119
public/components/acceleration/selectors/define_index_options.tsx
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,119 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import { | ||
EuiButton, | ||
EuiFieldText, | ||
EuiFlexGroup, | ||
EuiFlexItem, | ||
EuiFormRow, | ||
EuiIconTip, | ||
EuiLink, | ||
EuiMarkdownFormat, | ||
EuiModal, | ||
EuiModalBody, | ||
EuiModalFooter, | ||
EuiModalHeader, | ||
EuiModalHeaderTitle, | ||
EuiSpacer, | ||
EuiText, | ||
} from '@elastic/eui'; | ||
import React, { ChangeEvent, useState } from 'react'; | ||
import { ACCELERATION_INDEX_NAME_INFO } from '../../../../common/constants'; | ||
import { CreateAccelerationForm } from '../../../../common/types'; | ||
import { validateIndexName } from '../create/utils'; | ||
|
||
interface DefineIndexOptionsProps { | ||
accelerationFormData: CreateAccelerationForm; | ||
setAccelerationFormData: React.Dispatch<React.SetStateAction<CreateAccelerationForm>>; | ||
} | ||
|
||
export const DefineIndexOptions = ({ | ||
accelerationFormData, | ||
setAccelerationFormData, | ||
}: DefineIndexOptionsProps) => { | ||
const [indexName, setIndexName] = useState(''); | ||
const [modalComponent, setModalComponent] = useState(<></>); | ||
|
||
const modalValue = ( | ||
<EuiModal maxWidth={850} onClose={() => setModalComponent(<></>)}> | ||
<EuiModalHeader> | ||
<EuiModalHeaderTitle> | ||
<h1>Acceleration index naming</h1> | ||
</EuiModalHeaderTitle> | ||
</EuiModalHeader> | ||
<EuiModalBody> | ||
<EuiFlexGroup> | ||
<EuiFlexItem grow={false}> | ||
<EuiMarkdownFormat>{ACCELERATION_INDEX_NAME_INFO}</EuiMarkdownFormat> | ||
</EuiFlexItem> | ||
</EuiFlexGroup> | ||
</EuiModalBody> | ||
<EuiModalFooter> | ||
<EuiButton onClick={() => setModalComponent(<></>)} fill> | ||
Close | ||
</EuiButton> | ||
</EuiModalFooter> | ||
</EuiModal> | ||
); | ||
|
||
const onChangeIndexName = (e: ChangeEvent<HTMLInputElement>) => { | ||
setAccelerationFormData({ ...accelerationFormData, accelerationIndexName: e.target.value }); | ||
setIndexName(e.target.value); | ||
}; | ||
|
||
const getPreprend = () => { | ||
const dataSource = | ||
accelerationFormData.dataSource !== '' | ||
? accelerationFormData.dataSource | ||
: '{Datasource Name}'; | ||
const database = | ||
accelerationFormData.database !== '' ? accelerationFormData.database : '{Database Name}'; | ||
const dataTable = | ||
accelerationFormData.dataTable !== '' ? accelerationFormData.dataTable : '{Table Name}'; | ||
const prependValue = `flint_${dataSource}_${database}_${dataTable}_`; | ||
return [ | ||
prependValue, | ||
<EuiIconTip type="iInCircle" color="subdued" content={prependValue} position="top" />, | ||
]; | ||
}; | ||
|
||
const getAppend = () => { | ||
const appendValue = | ||
accelerationFormData.accelerationIndexType === 'materialized' ? '' : '_index'; | ||
return appendValue; | ||
}; | ||
|
||
return ( | ||
<> | ||
<EuiText data-test-subj="define-index-header"> | ||
<h3>Index settings</h3> | ||
</EuiText> | ||
<EuiSpacer size="s" /> | ||
<EuiFormRow | ||
label="Index name" | ||
helpText='Must be in lowercase letters. Cannot begin with underscores or hyphens. Spaces, commas, and characters :, ", *, +, /, \, |, ?, #, >, or < are not allowed. | ||
Prefix and suffix are added to the name of generated OpenSearch index.' | ||
labelAppend={ | ||
<EuiText size="xs"> | ||
<EuiLink onClick={() => setModalComponent(modalValue)}>Help</EuiLink> | ||
</EuiText> | ||
} | ||
> | ||
<EuiFieldText | ||
placeholder="Enter index name" | ||
value={accelerationFormData.accelerationIndexType === 'skipping' ? 'skipping' : indexName} | ||
onChange={onChangeIndexName} | ||
aria-label="Enter Index Name" | ||
prepend={getPreprend()} | ||
append={getAppend()} | ||
disabled={accelerationFormData.accelerationIndexType === 'skipping'} | ||
isInvalid={validateIndexName(indexName)} | ||
/> | ||
</EuiFormRow> | ||
{modalComponent} | ||
</> | ||
); | ||
}; |
Oops, something went wrong.