Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions changelogs/fragments/10751.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
fix:
- Update correlations save button tooltip ([#10751](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/10751))
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
EuiDescriptionList,
EuiDescriptionListTitle,
EuiDescriptionListDescription,
EuiToolTip,
} from '@elastic/eui';
import { i18n } from '@osd/i18n';
import { DataView } from '../../../../../../../data/public';
Expand Down Expand Up @@ -187,6 +188,30 @@ export const ConfigureCorrelationModal: React.FC<ConfigureCorrelationModalProps>
);
});

// Compute tooltip message for disabled save button
const disabledReason = useMemo(() => {
if (isLoading) return '';
if (selectedLogDatasetIds.length === 0) {
return i18n.translate('datasetManagement.correlatedDatasets.modal.noLogDatasetsTooltip', {
defaultMessage: 'Please select at least one log dataset',
});
}
if (maxDatasetsError) {
return maxDatasetsError;
}
if (isAnyDatasetEditing) {
return i18n.translate('datasetManagement.correlatedDatasets.modal.datasetEditingTooltip', {
defaultMessage: 'Please save or cancel schema mapping changes',
});
}
if (!allDatasetsReady) {
return i18n.translate('datasetManagement.correlatedDatasets.modal.validatingTooltip', {
defaultMessage: 'Waiting for datasets to be validated',
});
}
return '';
}, [isLoading, selectedLogDatasetIds, maxDatasetsError, isAnyDatasetEditing, allDatasetsReady]);

const canSave =
!isLoading &&
selectedLogDatasetIds.length > 0 &&
Expand Down Expand Up @@ -273,17 +298,19 @@ export const ConfigureCorrelationModal: React.FC<ConfigureCorrelationModalProps>
})}
</EuiButtonEmpty>

<EuiButton
onClick={handleSave}
fill
disabled={!canSave}
isLoading={isLoading}
data-test-subj="saveCorrelationButton"
>
{i18n.translate('datasetManagement.correlatedDatasets.modal.saveButton', {
defaultMessage: 'Save',
})}
</EuiButton>
<EuiToolTip content={disabledReason} position="top">
<EuiButton
onClick={handleSave}
fill
disabled={!canSave}
isLoading={isLoading}
data-test-subj="saveCorrelationButton"
>
{i18n.translate('datasetManagement.correlatedDatasets.modal.saveButton', {
defaultMessage: 'Save',
})}
</EuiButton>
</EuiToolTip>
</EuiModalFooter>
</EuiModal>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ describe('useCorrelations', () => {
version: '1.0.0',
entities: [],
},
references: [],
references: [{ type: 'index-pattern', id: 'dataset-123', name: 'entities[0].index' }],
},
];

Expand Down Expand Up @@ -200,9 +200,18 @@ describe('useCorrelationCount', () => {

it('should return count of correlations', async () => {
const mockCorrelations = [
{ id: 'correlation-1' },
{ id: 'correlation-2' },
{ id: 'correlation-3' },
{
id: 'correlation-1',
references: [{ type: 'index-pattern', id: 'dataset-123', name: 'entities[0].index' }],
},
{
id: 'correlation-2',
references: [{ type: 'index-pattern', id: 'dataset-123', name: 'entities[0].index' }],
},
{
id: 'correlation-3',
references: [{ type: 'index-pattern', id: 'dataset-123', name: 'entities[0].index' }],
},
] as any;

mockFind.mockResolvedValue(mockCorrelations);
Expand Down
18 changes: 16 additions & 2 deletions src/plugins/dataset_management/public/hooks/use_correlations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,15 @@ export function useCorrelations(

try {
const results = await client.find(options);
setCorrelations(results);

// Client-side filtering: only include correlations where datasetId appears in references
const filtered = options.datasetId
? results.filter((correlation) =>
correlation.references.some((ref) => ref.id === options.datasetId)
)
: results;

setCorrelations(filtered);
} catch (err) {
setError(err instanceof Error ? err : new Error('Failed to fetch correlations'));
} finally {
Expand Down Expand Up @@ -85,7 +93,13 @@ export function useCorrelationCount(
try {
const client = new CorrelationsClient(savedObjectsClient);
const correlations = await client.find({ datasetId, perPage: 1000 });
setCount(correlations.length);

// Client-side filtering: only count correlations where datasetId appears in references
const filtered = correlations.filter((correlation) =>
correlation.references.some((ref) => ref.id === datasetId)
);

setCount(filtered.length);
} catch (err) {
setError(err instanceof Error ? err : new Error('Failed to fetch correlation count'));
setCount(0);
Expand Down
Loading