Move flipper-doctor check running to flipper-server-core

Summary: Per title. Two new server API's: get-healthchecks, and run-healtcheck. Types have all been moved to flipper-common, so that they can be used by doctor, server-core and ui-core packages. Since it were quite some, moved them into a FlipperDoctor namespace.

Reviewed By: nikoant

Differential Revision: D32720510

fbshipit-source-id: 37aa35cde6ebd58479cf0dffec5b7b2da6d22198
This commit is contained in:
Michel Weststrate
2021-12-08 04:25:28 -08:00
committed by Facebook GitHub Bot
parent 2a4fe77404
commit 2480ed30c5
19 changed files with 373 additions and 276 deletions

View File

@@ -24,9 +24,6 @@ import React, {Component} from 'react';
import {connect} from 'react-redux';
import {State as Store} from '../reducers';
import {
HealthcheckResult,
HealthcheckReportCategory,
HealthcheckReport,
startHealthchecks,
finishHealthchecks,
updateHealthcheckResult,
@@ -38,10 +35,10 @@ import runHealthchecks, {
HealthcheckEventsHandler,
} from '../utils/runHealthchecks';
import {getFlipperLib} from 'flipper-plugin';
import {reportUsage} from 'flipper-common';
import {reportUsage, FlipperDoctor} from 'flipper-common';
type StateFromProps = {
healthcheckReport: HealthcheckReport;
healthcheckReport: FlipperDoctor.HealthcheckReport;
} & HealthcheckSettings;
type DispatchFromProps = {
@@ -123,7 +120,9 @@ function CenteredCheckbox(props: {
);
}
function HealthcheckIcon(props: {checkResult: HealthcheckResult}) {
function HealthcheckIcon(props: {
checkResult: FlipperDoctor.HealthcheckResult;
}) {
const {checkResult: check} = props;
switch (props.checkResult.status) {
case 'IN_PROGRESS':
@@ -170,7 +169,7 @@ function HealthcheckIcon(props: {checkResult: HealthcheckResult}) {
function HealthcheckDisplay(props: {
label: string;
result: HealthcheckResult;
result: FlipperDoctor.HealthcheckResult;
selected?: boolean;
onClick?: () => void;
}) {
@@ -194,7 +193,7 @@ function SideMessageDisplay(props: {children: React.ReactNode}) {
return <SideContainerText selectable>{props.children}</SideContainerText>;
}
function ResultMessage(props: {result: HealthcheckResult}) {
function ResultMessage(props: {result: FlipperDoctor.HealthcheckResult}) {
if (status === 'IN_PROGRESS') {
return <p>Doctor is running healthchecks...</p>;
} else if (hasProblems(props.result)) {
@@ -213,12 +212,12 @@ function ResultMessage(props: {result: HealthcheckResult}) {
}
}
function hasProblems(result: HealthcheckResult) {
function hasProblems(result: FlipperDoctor.HealthcheckResult) {
const {status} = result;
return status === 'FAILED' || status === 'WARNING';
}
function hasNewProblems(result: HealthcheckResult) {
function hasNewProblems(result: FlipperDoctor.HealthcheckResult) {
return hasProblems(result) && !result.isAcknowledged;
}
@@ -321,7 +320,7 @@ class DoctorSheet extends Component<Props, State> {
<FlexRow>
<HealthcheckListContainer>
{Object.values(this.props.healthcheckReport.categories).map(
(category: HealthcheckReportCategory) => {
(category: FlipperDoctor.HealthcheckReportCategory) => {
return (
<CategoryContainer key={category.key}>
<HealthcheckDisplay