Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(fix) Fix misplaced metrics extension slot #191

Merged
merged 5 commits into from
Mar 25, 2024

Conversation

arodidev
Copy link
Contributor

@arodidev arodidev commented Mar 21, 2024

Requirements

Summary

This PR is a follow up fix to an error introduces by this PR.

Screenshots

None.

Related Issue

None.

Other

None.

@arodidev arodidev marked this pull request as ready for review March 21, 2024 11:05
@denniskigen
Copy link
Member

Could you attach a screenshot that confirms that this works as you expect?

import { ExtensionSlot } from '@openmrs/esm-framework';
import React from 'react';

const PageMetrics: React.FC = () => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: I'd just call this Metrics for consistency with the file name.

@denniskigen denniskigen changed the title (fix) replace mispaced extension slot (fix) Fix misplaced metrics extension slot Mar 21, 2024
@@ -24,6 +24,8 @@ export const homeWidgetDbLink = getSyncLifecycle(createDashboardLink(dashboardMe

export const homeWidgetDashboard = getSyncLifecycle(homeWidgetDashboardComponent, options);

export const metricsSlot = getAsyncLifecycle(() => import('./metrics/metrics.component'), options);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be named better @denniskigen should we just call this metrics,metricsContainer or MetricsComponent

Suggested change
export const metricsSlot = getAsyncLifecycle(() => import('./metrics/metrics.component'), options);
export const metricsContainer = getSyncLifecycle(MetricsComponent, options);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is resolved.

import { ExtensionSlot } from '@openmrs/esm-framework';
import React from 'react';

const PageMetrics: React.FC = () => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The naming in the index should trickle down here

@@ -24,6 +24,8 @@ export const homeWidgetDbLink = getSyncLifecycle(createDashboardLink(dashboardMe

export const homeWidgetDashboard = getSyncLifecycle(homeWidgetDashboardComponent, options);

export const metrics = getAsyncLifecycle(() => import('./metrics/metrics.component'), options);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
export const metrics = getAsyncLifecycle(() => import('./metrics/metrics.component'), options);
export const metrics = getSyncLifecycle(Metrics, options);

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add the import Metrics from ./metrics/metrics.component at the top of the file

Copy link
Contributor Author

@arodidev arodidev Mar 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't getAsyncLifecycle better for app performance? Or does it have specific use cases? Reference.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there's a bit of misalignment on when to use getAsyncLifecycle and when to use getSyncLifecycle

homeWidgetDashboard uses getSyncLifecycle to load a component that is similar to metrics. Let's leave as is for now and will circle back.

@pirupius pirupius merged commit 2bfbdb5 into openmrs:main Mar 25, 2024
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants