gianm commented on a change in pull request #8672: Druid Doctor
URL: https://github.com/apache/incubator-druid/pull/8672#discussion_r335252410
 
 

 ##########
 File path: web-console/src/dialogs/doctor-dialog/doctor-dialog.tsx
 ##########
 @@ -0,0 +1,201 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { Button, Callout, Classes, Dialog, Intent } from '@blueprintjs/core';
+import { IconNames } from '@blueprintjs/icons';
+import React from 'react';
+
+import { delay, pluralIfNeeded } from '../../utils';
+
+import { DOCTOR_CHECKS } from './doctor-checks';
+
+import './doctor-dialog.scss';
+
+interface Diagnosis {
+  type: 'suggestion' | 'issue';
+  check: string;
+  message: string;
+}
+
+export interface DoctorDialogProps {
+  onClose: () => void;
+}
+
+export interface DoctorDialogState {
+  currentCheckIndex?: number;
+  diagnoses?: Diagnosis[];
+  earlyTermination?: string;
+}
+
+export class DoctorDialog extends React.PureComponent<DoctorDialogProps, 
DoctorDialogState> {
+  private mounted = false;
+
+  constructor(props: DoctorDialogProps, context: any) {
+    super(props, context);
+    this.state = {};
+  }
+
+  componentDidMount(): void {
+    this.mounted = true;
+  }
+
+  componentWillUnmount(): void {
+    this.mounted = false;
+  }
+
+  async doChecks() {
+    this.setState({ currentCheckIndex: 0, diagnoses: [] });
+
+    const addToDiagnoses = (diagnosis: Diagnosis) => {
+      if (!this.mounted) return;
+      this.setState(oldState => ({
+        diagnoses: (oldState.diagnoses || []).concat(diagnosis),
+      }));
+    };
+
+    for (let i = 0; i < DOCTOR_CHECKS.length; i++) {
+      if (!this.mounted) return;
+      this.setState({ currentCheckIndex: i });
+      const check = DOCTOR_CHECKS[i];
+      let terminateChecks = false;
+
+      // Slow down a bit so that the user can read the test name
+      await delay(500);
+
+      if (!this.mounted) return;
+      try {
+        await check.check({
+          addSuggestion: (message: string) => {
+            addToDiagnoses({
+              type: 'suggestion',
+              check: check.name,
+              message,
+            });
+          },
+          addIssue: (message: string) => {
+            addToDiagnoses({
+              type: 'issue',
+              check: check.name,
+              message,
+            });
+          },
+          terminateChecks: () => {
+            if (!this.mounted) return;
+            this.setState({
+              earlyTermination: `${check.name} early terminated the check 
suite`,
 
 Review comment:
   This line made the screenshot confusing to me (I had a moment like, what 
does "Verify own status early terminated" mean? We want to verify that the 
status has early terminated?).
   
   Maybe be more explicit that the check name is part of the message. Also, 
what does it mean when a check early terminated the check suite? Is it because 
the check found a problem? Or because it couldn't run at all? (This should be 
obvious through the message)

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@druid.apache.org
For additional commands, e-mail: commits-h...@druid.apache.org

Reply via email to