[Log Explorer] Show only dataset name in dataset selector (#166703)

closes https://github.com/elastic/kibana/issues/166247

## 📝  Summary

This PR changes the display of datasets in the dataset selector so that
we only show the dataset name and not the whole index pattern.

ex: 

- `logs-foo-*` ➡️ `foo`
- `logs-bar-*` ➡️ `bar`

##   Testing
1. Navigate to the observability log explorer
2. Click the dataset selector and choose Uncategorized
3. Observe how the datasets are represented

## 🎥 Demo


8a6a1212-46d5-4ceb-bf38-cf13d1b3e555
This commit is contained in:
mohamedhamed-ahmed 2023-09-20 15:34:53 +02:00 committed by GitHub
parent 50bef40a1f
commit 27056ca66c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 14 additions and 10 deletions

View file

@ -67,7 +67,9 @@ export class Dataset {
}
public static create(dataset: DatasetDeps, parentIntegration?: IntegrationBase) {
return new Dataset(dataset, parentIntegration);
const datasetTitle = dataset.title || dataset.name.split('-')[1];
return new Dataset({ ...dataset, title: datasetTitle }, parentIntegration);
}
public static createAllLogsDataset() {

View file

@ -83,7 +83,7 @@ export const DatasetsList = ({
return datasets.map((dataset) => (
<EuiContextMenuItem key={dataset.id} onClick={() => onDatasetClick(dataset)}>
{dataset.name}
{dataset.title}
</EuiContextMenuItem>
));
};

View file

@ -14,7 +14,8 @@ const initialPackageMap = {
};
const initialPackagesTexts = Object.values(initialPackageMap);
const expectedUncategorized = ['logs-gaming-*', 'logs-manufacturing-*', 'logs-retail-*'];
const uncategorized = ['logs-gaming-*', 'logs-manufacturing-*', 'logs-retail-*'];
const expectedUncategorized = uncategorized.map((dataset) => dataset.split('-')[1]);
export default function ({ getService, getPageObjects }: FtrProviderContext) {
const browser = getService('browser');
@ -511,7 +512,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
const menuEntries = await PageObjects.observabilityLogExplorer.getCurrentPanelEntries();
expect(menuEntries.length).to.be(1);
expect(await menuEntries[0].getVisibleText()).to.be('logs-retail-*');
expect(await menuEntries[0].getVisibleText()).to.be('retail');
});
});
@ -529,7 +530,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
await retry.try(async () => {
const menuEntries = await PageObjects.observabilityLogExplorer.getCurrentPanelEntries();
expect(await menuEntries[0].getVisibleText()).to.be('logs-gaming-*');
expect(await menuEntries[0].getVisibleText()).to.be(expectedUncategorized[0]);
menuEntries[0].click();
});
@ -537,7 +538,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
const selectorButton =
await PageObjects.observabilityLogExplorer.getDatasetSelectorButton();
expect(await selectorButton.getVisibleText()).to.be('logs-gaming-*');
expect(await selectorButton.getVisibleText()).to.be(expectedUncategorized[0]);
});
});
});

View file

@ -14,7 +14,8 @@ const initialPackageMap = {
};
const initialPackagesTexts = Object.values(initialPackageMap);
const expectedUncategorized = ['logs-gaming-*', 'logs-manufacturing-*', 'logs-retail-*'];
const uncategorized = ['logs-gaming-*', 'logs-manufacturing-*', 'logs-retail-*'];
const expectedUncategorized = uncategorized.map((dataset) => dataset.split('-')[1]);
export default function ({ getService, getPageObjects }: FtrProviderContext) {
const browser = getService('browser');
@ -518,7 +519,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
const menuEntries = await PageObjects.observabilityLogExplorer.getCurrentPanelEntries();
expect(menuEntries.length).to.be(1);
expect(await menuEntries[0].getVisibleText()).to.be('logs-retail-*');
expect(await menuEntries[0].getVisibleText()).to.be('retail');
});
});
@ -536,7 +537,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
await retry.try(async () => {
const menuEntries = await PageObjects.observabilityLogExplorer.getCurrentPanelEntries();
expect(await menuEntries[0].getVisibleText()).to.be('logs-gaming-*');
expect(await menuEntries[0].getVisibleText()).to.be(expectedUncategorized[0]);
menuEntries[0].click();
});
@ -544,7 +545,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
const selectorButton =
await PageObjects.observabilityLogExplorer.getDatasetSelectorButton();
expect(await selectorButton.getVisibleText()).to.be('logs-gaming-*');
expect(await selectorButton.getVisibleText()).to.be(expectedUncategorized[0]);
});
});
});