Skip to content

Commit

Permalink
refactor(discover-shared): update request changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Marco Antonio Ghiani committed Apr 11, 2024
1 parent aa0d3fe commit 2f64609
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,8 @@ describe('FeaturesRegistry', () => {
const registry = new FeaturesRegistry<TestFeature>();

registry.register({ id: 'feature-id-1' });
registry.register({ id: 'feature-id-2' });

expect(registry.getFeaturesMap().size).toBe(2);
expect(registry.getById('feature-id-1')).toBeDefined();
});

test('should throw an error when a feature is already registered by the given id', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,21 +28,13 @@ export class FeaturesRegistry<Feature extends BaseFeature = BaseFeature> {
this.features.next(new Map([...featuresMap.entries(), [feature.id, feature]]));
}

/**
* Retrieves all the registered features.
* @returns A Map instance.
*/
getFeaturesMap() {
return this.features.getValue();
}

/**
* Retrieves a registered feature by its id.
* @param id The identifier of the feature to retrieve.
* @returns The feature if found, otherwise undefined.
*/
getById(id: Feature['id']) {
return this.getFeaturesMap().get(id);
getById<Id extends Feature['id']>(id: Id) {
return this.getFeaturesMap().get(id) as Extract<Feature, { id: Id }> | undefined;
}

/**
Expand All @@ -60,4 +52,12 @@ export class FeaturesRegistry<Feature extends BaseFeature = BaseFeature> {
subscribe(callback: (features: FeaturesMap<Feature>) => void): Subscription {
return this.features.subscribe(callback);
}

/**
* Retrieves all the registered features.
* @returns A Map instance.
*/
private getFeaturesMap() {
return this.features.getValue();
}
}
Empty file added plugins/.empty
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -87,18 +87,10 @@ export const contentHeaderTooltipParagraph1 = (
id="xpack.logsExplorer.dataTable.header.content.tooltip.paragraph1"
defaultMessage="Displays the document's {logLevel} and {message} fields."
values={{
logLevel: (
<strong>
{i18n.translate('xpack.logsExplorer..strong.loglevelLabel', {
defaultMessage: 'log.level',
})}
</strong>
),
message: (
<strong>
{i18n.translate('xpack.logsExplorer..strong.messageLabel', { defaultMessage: 'message' })}
</strong>
),
// eslint-disable-next-line @kbn/i18n/strings_should_be_translated_with_i18n
logLevel: <strong>log.level</strong>,
// eslint-disable-next-line @kbn/i18n/strings_should_be_translated_with_i18n
message: <strong>message</strong>,
}}
/>
);
Expand Down

0 comments on commit 2f64609

Please sign in to comment.