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

[Stack Monitoring] update setup mode data when required #113934

Merged
merged 1 commit into from
Oct 6, 2021
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@ import { useTitle } from '../hooks/use_title';
import { MonitoringToolbar } from '../../components/shared/toolbar';
import { MonitoringTimeContainer } from '../hooks/use_monitoring_time';
import { PageLoading } from '../../components';
import { getSetupModeState, isSetupModeFeatureEnabled } from '../setup_mode/setup_mode';
import {
getSetupModeState,
isSetupModeFeatureEnabled,
updateSetupModeData,
} from '../setup_mode/setup_mode';
import { SetupModeFeature } from '../../../common/enums';

export interface TabMenuItem {
Expand Down Expand Up @@ -54,7 +58,12 @@ export const PageTemplate: React.FC<PageTemplateProps> = ({
}, [getPageData, currentTimerange]);

const onRefresh = () => {
getPageData?.().catch((err) => {
const requests = [getPageData?.()];
if (isSetupModeFeatureEnabled(SetupModeFeature.MetricbeatMigration)) {
requests.push(updateSetupModeData());
}

Promise.allSettled(requests).then((results) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this should be .catch because if I'm not missing anything here we don't have to do anything with results, we only want to process errors. (Although I'm working on the errors page, so I can also change it after you merge it to master)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

allSettled never rejects. Thought it would be appropriate here since requests don't look related and individual error handling may be a good option, but I'll leave it for the tasks dedicated to that :)

Copy link
Contributor

Choose a reason for hiding this comment

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

Didn't notice the allSettled 🙃, I'll work on it in my PR

// TODO: handle errors
});
};
Expand Down