Skip to content

Commit

Permalink
addressing comments
Browse files Browse the repository at this point in the history
Signed-off-by: Sean Li <[email protected]>
  • Loading branch information
sejli committed Sep 17, 2024
1 parent e8b244e commit 783d4b8
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,5 @@ export interface LanguageConfig {
showDocLinks?: boolean;
editorSupportedAppNames?: string[];
supportedAppNames?: string[];
noTimeField?: boolean;
disableDatePicker?: boolean;
}
15 changes: 9 additions & 6 deletions src/plugins/data/public/ui/dataset_selector/configurator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,17 @@ export const Configurator = ({
return languages[0];
});

const requiresTimeField = (ds: Dataset, lang: string, fields: DatasetField[]) => {
const displayTimeFieldSelector = (ds: Dataset, lang: string, fields: DatasetField[]) => {
if (
languageService.getLanguage(lang)?.noTimeField ||
languageService.getLanguage(lang)?.disableDatePicker ||
ds.type === DEFAULT_DATA.SET_TYPES.INDEX_PATTERN
) {
return false;
}
if (fields && fields.length > 0) {
return true;
}
return false;
};

useEffect(() => {
Expand Down Expand Up @@ -111,7 +112,7 @@ export const Configurator = ({
<EuiFieldText disabled value={dataset.title} />
</EuiFormRow>
{dataset.type === DEFAULT_DATA.SET_TYPES.INDEX_PATTERN &&
!languageService.getLanguage(language)?.noTimeField && (
!languageService.getLanguage(language)?.disableDatePicker && (
<EuiFormRow
label={i18n.translate(
'data.explorer.datasetSelector.advancedSelector.configurator.datasetLabel',
Expand All @@ -123,7 +124,7 @@ export const Configurator = ({
<EuiFieldText disabled value={dataset.timeFieldName ?? 'No time field'} />
</EuiFormRow>
)}
{requiresTimeField(dataset, language, timeFields) && (
{displayTimeFieldSelector(dataset, language, timeFields) && (
<EuiFormRow
label={i18n.translate(
'data.explorer.datasetSelector.advancedSelector.configurator.timeFieldLabel',
Expand All @@ -147,7 +148,7 @@ export const Configurator = ({
setTimeFieldName(e.target.value);
setDataset({ ...dataset, timeFieldName: value });
}}
hasNoInitialSelection={dataset.type === DEFAULT_DATA.SET_TYPES.INDEX}
hasNoInitialSelection={dataset.type !== DEFAULT_DATA.SET_TYPES.INDEX_PATTERN}
/>
</EuiFormRow>
)}
Expand Down Expand Up @@ -192,7 +193,9 @@ export const Configurator = ({
onConfirm(dataset);
}}
fill
disabled={timeFieldName === undefined && requiresTimeField(dataset, language, timeFields)}
disabled={
timeFieldName === undefined && displayTimeFieldSelector(dataset, language, timeFields)
}
>
<FormattedMessage
id="data.explorer.datasetSelector.advancedSelector.confirm"
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/query_enhancements/public/plugin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ export class QueryEnhancementsPlugin
editor: enhancedSQLQueryEditor,
editorSupportedAppNames: ['discover'],
supportedAppNames: ['discover', 'data-explorer'],
noTimeField: true,
disableDatePicker: true,
};
queryString.getLanguageService().registerLanguage(sqlLanguageConfig);

Expand Down

0 comments on commit 783d4b8

Please sign in to comment.