switch the web console to use react pure components (#7845)

This commit is contained in:
Vadim Ogievetsky 2019-06-07 08:31:46 -07:00 committed by Fangjin Yang
parent 0ca867efbf
commit ca5afd29b8
44 changed files with 44 additions and 44 deletions

View File

@ -44,7 +44,7 @@ interface ReactTableCustomPaginationState {
page: string | number; page: string | number;
} }
export class ReactTableCustomPagination extends React.Component<ReactTableCustomPaginationProps, ReactTableCustomPaginationState> { export class ReactTableCustomPagination extends React.PureComponent<ReactTableCustomPaginationProps, ReactTableCustomPaginationState> {
constructor(props: ReactTableCustomPaginationProps) { constructor(props: ReactTableCustomPaginationProps) {
super(props); super(props);

View File

@ -26,7 +26,7 @@ import { ReactTableCustomPagination } from './react-table-custom-pagination';
/* tslint:disable:max-classes-per-file */ /* tslint:disable:max-classes-per-file */
class NoData extends React.Component { class NoData extends React.PureComponent {
render() { render() {
const { children } = this.props; const { children } = this.props;
if (!children) return null; if (!children) return null;

View File

@ -30,7 +30,7 @@ export interface ActionCellProps extends React.Props<any> {
actions?: BasicAction[]; actions?: BasicAction[];
} }
export class ActionCell extends React.Component<ActionCellProps, {}> { export class ActionCell extends React.PureComponent<ActionCellProps, {}> {
static COLUMN_ID = 'actions'; static COLUMN_ID = 'actions';
static COLUMN_LABEL = 'Actions'; static COLUMN_LABEL = 'Actions';
static COLUMN_WIDTH = 70; static COLUMN_WIDTH = 70;

View File

@ -28,7 +28,7 @@ export interface ActionIconProps extends React.Props<any> {
onClick?: () => void; onClick?: () => void;
} }
export class ActionIcon extends React.Component<ActionIconProps, {}> { export class ActionIcon extends React.PureComponent<ActionIconProps, {}> {
render() { render() {
const { className, icon, onClick } = this.props; const { className, icon, onClick } = this.props;

View File

@ -28,7 +28,7 @@ export interface ArrayInputProps {
disabled?: boolean; disabled?: boolean;
} }
export class ArrayInput extends React.Component<ArrayInputProps, { stringValue: string }> { export class ArrayInput extends React.PureComponent<ArrayInputProps, { stringValue: string }> {
constructor(props: ArrayInputProps) { constructor(props: ArrayInputProps) {
super(props); super(props);
this.state = { this.state = {

View File

@ -68,7 +68,7 @@ export interface AutoFormState<T> {
jsonInputsValidity: any; jsonInputsValidity: any;
} }
export class AutoForm<T extends Record<string, any>> extends React.Component<AutoFormProps<T>, AutoFormState<T>> { export class AutoForm<T extends Record<string, any>> extends React.PureComponent<AutoFormProps<T>, AutoFormState<T>> {
static makeLabelName(label: string): string { static makeLabelName(label: string): string {
let newLabel = label.split(/(?=[A-Z])/).join(' ').toLowerCase().replace(/\./g, ' '); let newLabel = label.split(/(?=[A-Z])/).join(' ').toLowerCase().replace(/\./g, ' ');
newLabel = newLabel[0].toUpperCase() + newLabel.slice(1); newLabel = newLabel[0].toUpperCase() + newLabel.slice(1);

View File

@ -23,7 +23,7 @@ import './center-message.scss';
export interface CenterMessageProps extends React.Props<any> { export interface CenterMessageProps extends React.Props<any> {
} }
export class CenterMessage extends React.Component<CenterMessageProps, {}> { export class CenterMessage extends React.PureComponent<CenterMessageProps, {}> {
render() { render() {
return <div className="center-message bp3-input"> return <div className="center-message bp3-input">
<div className="center-message-inner"> <div className="center-message-inner">

View File

@ -28,7 +28,7 @@ export interface ClearableInputProps extends React.Props<any> {
placeholder: string; placeholder: string;
} }
export class ClearableInput extends React.Component<ClearableInputProps, {}> { export class ClearableInput extends React.PureComponent<ClearableInputProps, {}> {
render() { render() {
const { className, value, onChange, placeholder } = this.props; const { className, value, onChange, placeholder } = this.props;

View File

@ -22,7 +22,7 @@ export interface ExternalLinkProps extends React.Props<any> {
href: string; href: string;
} }
export class ExternalLink extends React.Component<ExternalLinkProps, {}> { export class ExternalLink extends React.PureComponent<ExternalLinkProps, {}> {
render() { render() {
const { href, children } = this.props; const { href, children } = this.props;

View File

@ -60,7 +60,7 @@ export interface HeaderBarState {
overlordDynamicConfigDialogOpen: boolean; overlordDynamicConfigDialogOpen: boolean;
} }
export class HeaderBar extends React.Component<HeaderBarProps, HeaderBarState> { export class HeaderBar extends React.PureComponent<HeaderBarProps, HeaderBarState> {
constructor(props: HeaderBarProps) { constructor(props: HeaderBarProps) {
super(props); super(props);
this.state = { this.state = {

View File

@ -29,7 +29,7 @@ interface JSONCollapseState {
isOpen: boolean; isOpen: boolean;
} }
export class JSONCollapse extends React.Component<JSONCollapseProps, JSONCollapseState> { export class JSONCollapse extends React.PureComponent<JSONCollapseProps, JSONCollapseState> {
constructor(props: any) { constructor(props: any) {
super(props); super(props);
this.state = { this.state = {

View File

@ -34,7 +34,7 @@ interface JSONInputState {
stringValue: string; stringValue: string;
} }
export class JSONInput extends React.Component<JSONInputProps, JSONInputState> { export class JSONInput extends React.PureComponent<JSONInputProps, JSONInputState> {
constructor(props: JSONInputProps) { constructor(props: JSONInputProps) {
super(props); super(props);
this.state = { this.state = {

View File

@ -28,7 +28,7 @@ export interface LoaderProps extends React.Props<any> {
export interface LoaderState { export interface LoaderState {
} }
export class Loader extends React.Component<LoaderProps, LoaderState> { export class Loader extends React.PureComponent<LoaderProps, LoaderState> {
render() { render() {
const { loadingText, loading } = this.props; const { loadingText, loading } = this.props;

View File

@ -21,7 +21,7 @@ import * as React from 'react';
import './menu-checkbox.scss'; import './menu-checkbox.scss';
export class MenuCheckbox extends React.Component<ICheckboxProps, {}> { export class MenuCheckbox extends React.PureComponent<ICheckboxProps, {}> {
render() { render() {
return <li className="menu-checkbox"> return <li className="menu-checkbox">

View File

@ -47,7 +47,7 @@ export interface RuleEditorState {
isOpen: boolean; isOpen: boolean;
} }
export class RuleEditor extends React.Component<RuleEditorProps, RuleEditorState> { export class RuleEditor extends React.PureComponent<RuleEditorProps, RuleEditorState> {
static ruleToString(rule: Rule): string { static ruleToString(rule: Rule): string {
return rule.type + (rule.period ? `(${rule.period})` : '') + (rule.interval ? `(${rule.interval})` : ''); return rule.type + (rule.period ? `(${rule.period})` : '') + (rule.interval ? `(${rule.interval})` : '');
} }

View File

@ -36,7 +36,7 @@ export interface ShowJsonState {
jsonValue: string; jsonValue: string;
} }
export class ShowJson extends React.Component<ShowJsonProps, ShowJsonState> { export class ShowJson extends React.PureComponent<ShowJsonProps, ShowJsonState> {
constructor(props: ShowJsonProps, context: any) { constructor(props: ShowJsonProps, context: any) {
super(props, context); super(props, context);
this.state = { this.state = {

View File

@ -46,7 +46,7 @@ export interface ShowLogState {
tail: boolean; tail: boolean;
} }
export class ShowLog extends React.Component<ShowLogProps, ShowLogState> { export class ShowLog extends React.PureComponent<ShowLogProps, ShowLogState> {
public log = React.createRef<HTMLTextAreaElement>(); public log = React.createRef<HTMLTextAreaElement>();
constructor(props: ShowLogProps, context: any) { constructor(props: ShowLogProps, context: any) {

View File

@ -79,7 +79,7 @@ export interface SqlControlState {
} }
@HotkeysTarget @HotkeysTarget
export class SqlControl extends React.Component<SqlControlProps, SqlControlState> { export class SqlControl extends React.PureComponent<SqlControlProps, SqlControlState> {
constructor(props: SqlControlProps, context: any) { constructor(props: SqlControlProps, context: any) {
super(props, context); super(props, context);
this.state = { this.state = {

View File

@ -39,7 +39,7 @@ interface ShortParts {
suffix: string; suffix: string;
} }
export class TableCell extends React.Component<NullTableCellProps, {}> { export class TableCell extends React.PureComponent<NullTableCellProps, {}> {
static MAX_CHARS_TO_SHOW = 50; static MAX_CHARS_TO_SHOW = 50;
static possiblyTruncate(str: string): React.ReactNode { static possiblyTruncate(str: string): React.ReactNode {

View File

@ -34,7 +34,7 @@ interface TableColumnSelectorState {
} }
export class TableColumnSelector extends React.Component<TableColumnSelectorProps, TableColumnSelectorState> { export class TableColumnSelector extends React.PureComponent<TableColumnSelectorProps, TableColumnSelectorState> {
constructor(props: TableColumnSelectorProps) { constructor(props: TableColumnSelectorProps) {
super(props); super(props);

View File

@ -24,7 +24,7 @@ export interface ViewControlBarProps {
label: string; label: string;
} }
export class ViewControlBar extends React.Component<ViewControlBarProps, {}> { export class ViewControlBar extends React.PureComponent<ViewControlBarProps, {}> {
constructor(props: ViewControlBarProps) { constructor(props: ViewControlBarProps) {
super(props); super(props);
} }

View File

@ -54,7 +54,7 @@ export interface ConsoleApplicationState {
capabilitiesLoading: boolean; capabilitiesLoading: boolean;
} }
export class ConsoleApplication extends React.Component<ConsoleApplicationProps, ConsoleApplicationState> { export class ConsoleApplication extends React.PureComponent<ConsoleApplicationProps, ConsoleApplicationState> {
static MESSAGE_KEY = 'druid-console-message'; static MESSAGE_KEY = 'druid-console-message';
static MESSAGE_DISMISSED = 'dismissed'; static MESSAGE_DISMISSED = 'dismissed';
private capabilitiesQueryManager: QueryManager<string, string>; private capabilitiesQueryManager: QueryManager<string, string>;

View File

@ -30,7 +30,7 @@ export interface AboutDialogProps extends React.Props<any> {
export interface AboutDialogState { export interface AboutDialogState {
} }
export class AboutDialog extends React.Component<AboutDialogProps, AboutDialogState> { export class AboutDialog extends React.PureComponent<AboutDialogProps, AboutDialogState> {
constructor(props: AboutDialogProps) { constructor(props: AboutDialogProps) {
super(props); super(props);
this.state = {}; this.state = {};

View File

@ -47,7 +47,7 @@ export interface AsyncAlertDialogState {
working: boolean; working: boolean;
} }
export class AsyncActionDialog extends React.Component<AsyncAlertDialogProps, AsyncAlertDialogState> { export class AsyncActionDialog extends React.PureComponent<AsyncAlertDialogProps, AsyncAlertDialogState> {
constructor(props: AsyncAlertDialogProps) { constructor(props: AsyncAlertDialogProps) {
super(props); super(props);
this.state = { this.state = {

View File

@ -36,7 +36,7 @@ export interface CompactionDialogState {
allJSONValid: boolean; allJSONValid: boolean;
} }
export class CompactionDialog extends React.Component<CompactionDialogProps, CompactionDialogState> { export class CompactionDialog extends React.PureComponent<CompactionDialogProps, CompactionDialogState> {
constructor(props: CompactionDialogProps) { constructor(props: CompactionDialogProps) {
super(props); super(props);
this.state = { this.state = {

View File

@ -37,7 +37,7 @@ export interface CoordinatorDynamicConfigDialogState {
historyRecords: any[]; historyRecords: any[];
} }
export class CoordinatorDynamicConfigDialog extends React.Component<CoordinatorDynamicConfigDialogProps, CoordinatorDynamicConfigDialogState> { export class CoordinatorDynamicConfigDialog extends React.PureComponent<CoordinatorDynamicConfigDialogProps, CoordinatorDynamicConfigDialogState> {
private historyQueryManager: QueryManager<string, any>; private historyQueryManager: QueryManager<string, any>;
constructor(props: CoordinatorDynamicConfigDialogProps) { constructor(props: CoordinatorDynamicConfigDialogProps) {

View File

@ -31,7 +31,7 @@ interface HistoryDialogState {
} }
export class HistoryDialog extends React.Component<HistoryDialogProps, HistoryDialogState> { export class HistoryDialog extends React.PureComponent<HistoryDialogProps, HistoryDialogState> {
constructor(props: HistoryDialogProps) { constructor(props: HistoryDialogProps) {
super(props); super(props);
this.state = { this.state = {

View File

@ -40,7 +40,7 @@ export interface LookupEditDialogProps extends React.Props<any> {
export interface LookupEditDialogState { export interface LookupEditDialogState {
} }
export class LookupEditDialog extends React.Component<LookupEditDialogProps, LookupEditDialogState> { export class LookupEditDialog extends React.PureComponent<LookupEditDialogProps, LookupEditDialogState> {
constructor(props: LookupEditDialogProps) { constructor(props: LookupEditDialogProps) {
super(props); super(props);

View File

@ -38,7 +38,7 @@ export interface OverlordDynamicConfigDialogState {
historyRecords: any[]; historyRecords: any[];
} }
export class OverlordDynamicConfigDialog extends React.Component<OverlordDynamicConfigDialogProps, OverlordDynamicConfigDialogState> { export class OverlordDynamicConfigDialog extends React.PureComponent<OverlordDynamicConfigDialogProps, OverlordDynamicConfigDialogState> {
private historyQueryManager: QueryManager<string, any>; private historyQueryManager: QueryManager<string, any>;
constructor(props: OverlordDynamicConfigDialogProps) { constructor(props: OverlordDynamicConfigDialogProps) {

View File

@ -33,7 +33,7 @@ export interface QueryPlanDialogState {
} }
export class QueryPlanDialog extends React.Component<QueryPlanDialogProps, QueryPlanDialogState> { export class QueryPlanDialog extends React.PureComponent<QueryPlanDialogProps, QueryPlanDialogState> {
constructor(props: QueryPlanDialogProps) { constructor(props: QueryPlanDialogProps) {
super(props); super(props);

View File

@ -51,7 +51,7 @@ export interface RetentionDialogState {
historyRecords: any[]; historyRecords: any[];
} }
export class RetentionDialog extends React.Component<RetentionDialogProps, RetentionDialogState> { export class RetentionDialog extends React.PureComponent<RetentionDialogProps, RetentionDialogState> {
private historyQueryManager: QueryManager<string, any>; private historyQueryManager: QueryManager<string, any>;
constructor(props: RetentionDialogProps) { constructor(props: RetentionDialogProps) {

View File

@ -49,7 +49,7 @@ export interface SnitchDialogState {
showHistory?: boolean; showHistory?: boolean;
} }
export class SnitchDialog extends React.Component<SnitchDialogProps, SnitchDialogState> { export class SnitchDialog extends React.PureComponent<SnitchDialogProps, SnitchDialogState> {
constructor(props: SnitchDialogProps) { constructor(props: SnitchDialogProps) {
super(props); super(props);

View File

@ -33,7 +33,7 @@ export interface SpecDialogState {
spec: string; spec: string;
} }
export class SpecDialog extends React.Component<SpecDialogProps, SpecDialogState> { export class SpecDialog extends React.PureComponent<SpecDialogProps, SpecDialogState> {
static validJson(json: string): boolean { static validJson(json: string): boolean {
try { try {
JSON.parse(json); JSON.parse(json);

View File

@ -33,7 +33,7 @@ interface SupervisorTableActionDialogState {
activeTab: 'payload' | 'status' | 'stats' | 'history'; activeTab: 'payload' | 'status' | 'stats' | 'history';
} }
export class SupervisorTableActionDialog extends React.Component<SupervisorTableActionDialogProps, SupervisorTableActionDialogState> { export class SupervisorTableActionDialog extends React.PureComponent<SupervisorTableActionDialogProps, SupervisorTableActionDialogState> {
constructor(props: SupervisorTableActionDialogProps) { constructor(props: SupervisorTableActionDialogProps) {
super(props); super(props);
this.state = { this.state = {

View File

@ -34,7 +34,7 @@ interface TableActionDialogProps extends IDialogProps {
bottomButtons?: React.ReactNode; bottomButtons?: React.ReactNode;
} }
export class TableActionDialog extends React.Component<TableActionDialogProps, {}> { export class TableActionDialog extends React.PureComponent<TableActionDialogProps, {}> {
constructor(props: TableActionDialogProps) { constructor(props: TableActionDialogProps) {
super(props); super(props);
this.state = {}; this.state = {};

View File

@ -33,7 +33,7 @@ interface TaskTableActionDialogState {
activeTab: 'payload' | 'status' | 'reports' | 'log'; activeTab: 'payload' | 'status' | 'reports' | 'log';
} }
export class TaskTableActionDialog extends React.Component<TaskTableActionDialogProps, TaskTableActionDialogState> { export class TaskTableActionDialog extends React.PureComponent<TaskTableActionDialogProps, TaskTableActionDialogState> {
constructor(props: TaskTableActionDialogProps) { constructor(props: TaskTableActionDialogProps) {
super(props); super(props);
this.state = { this.state = {

View File

@ -83,7 +83,7 @@ export interface DatasourcesViewState {
dropReloadInterval: string; dropReloadInterval: string;
} }
export class DatasourcesView extends React.Component<DatasourcesViewProps, DatasourcesViewState> { export class DatasourcesView extends React.PureComponent<DatasourcesViewProps, DatasourcesViewState> {
static DISABLED_COLOR = '#0a1500'; static DISABLED_COLOR = '#0a1500';
static FULLY_AVAILABLE_COLOR = '#57d500'; static FULLY_AVAILABLE_COLOR = '#57d500';
static PARTIALLY_AVAILABLE_COLOR = '#ffbf00'; static PARTIALLY_AVAILABLE_COLOR = '#ffbf00';

View File

@ -76,7 +76,7 @@ export interface HomeViewState {
serverCountError: string | null; serverCountError: string | null;
} }
export class HomeView extends React.Component<HomeViewProps, HomeViewState> { export class HomeView extends React.PureComponent<HomeViewProps, HomeViewState> {
private statusQueryManager: QueryManager<string, any>; private statusQueryManager: QueryManager<string, any>;
private datasourceQueryManager: QueryManager<string, any>; private datasourceQueryManager: QueryManager<string, any>;
private segmentQueryManager: QueryManager<string, any>; private segmentQueryManager: QueryManager<string, any>;

View File

@ -222,7 +222,7 @@ export interface LoadDataViewState {
selectedMetricSpec: MetricSpec | null; selectedMetricSpec: MetricSpec | null;
} }
export class LoadDataView extends React.Component<LoadDataViewProps, LoadDataViewState> { export class LoadDataView extends React.PureComponent<LoadDataViewProps, LoadDataViewState> {
constructor(props: LoadDataViewProps) { constructor(props: LoadDataViewProps) {
super(props); super(props);

View File

@ -61,7 +61,7 @@ export interface LookupsViewState {
deleteLookupTier: string | null; deleteLookupTier: string | null;
} }
export class LookupsView extends React.Component<LookupsViewProps, LookupsViewState> { export class LookupsView extends React.PureComponent<LookupsViewProps, LookupsViewState> {
private lookupsGetQueryManager: QueryManager<string, {lookupEntries: any[], tiers: string[]}>; private lookupsGetQueryManager: QueryManager<string, {lookupEntries: any[], tiers: string[]}>;
private tableColumnSelectionHandler: TableColumnSelectionHandler; private tableColumnSelectionHandler: TableColumnSelectionHandler;

View File

@ -80,7 +80,7 @@ interface SegmentQueryResultRow {
is_overshadowed: number; is_overshadowed: number;
} }
export class SegmentsView extends React.Component<SegmentsViewProps, SegmentsViewState> { export class SegmentsView extends React.PureComponent<SegmentsViewProps, SegmentsViewState> {
private segmentsSqlQueryManager: QueryManager<QueryAndSkip, SegmentQueryResultRow[]>; private segmentsSqlQueryManager: QueryManager<QueryAndSkip, SegmentQueryResultRow[]>;
private segmentsJsonQueryManager: QueryManager<any, SegmentQueryResultRow[]>; private segmentsJsonQueryManager: QueryManager<any, SegmentQueryResultRow[]>;
private tableColumnSelectionHandler: TableColumnSelectionHandler; private tableColumnSelectionHandler: TableColumnSelectionHandler;

View File

@ -108,7 +108,7 @@ interface MiddleManagerQueryResultRow {
interface ServerResultRow extends ServerQueryResultRow, Partial<LoadQueueStatus>, Partial<MiddleManagerQueryResultRow> {} interface ServerResultRow extends ServerQueryResultRow, Partial<LoadQueueStatus>, Partial<MiddleManagerQueryResultRow> {}
export class ServersView extends React.Component<ServersViewProps, ServersViewState> { export class ServersView extends React.PureComponent<ServersViewProps, ServersViewState> {
private serverQueryManager: QueryManager<string, ServerQueryResultRow[]>; private serverQueryManager: QueryManager<string, ServerQueryResultRow[]>;
private serverTableColumnSelectionHandler: TableColumnSelectionHandler; private serverTableColumnSelectionHandler: TableColumnSelectionHandler;

View File

@ -62,7 +62,7 @@ interface SqlQueryResult {
queryElapsed: number; queryElapsed: number;
} }
export class SqlView extends React.Component<SqlViewProps, SqlViewState> { export class SqlView extends React.PureComponent<SqlViewProps, SqlViewState> {
static trimSemicolon(query: string): string { static trimSemicolon(query: string): string {
// Trims out a trailing semicolon while preserving space (https://bit.ly/1n1yfkJ) // Trims out a trailing semicolon while preserving space (https://bit.ly/1n1yfkJ)
return query.replace(/;+(\s*)$/, '$1'); return query.replace(/;+(\s*)$/, '$1');

View File

@ -109,7 +109,7 @@ function statusToColor(status: string): string {
} }
} }
export class TasksView extends React.Component<TasksViewProps, TasksViewState> { export class TasksView extends React.PureComponent<TasksViewProps, TasksViewState> {
private supervisorQueryManager: QueryManager<string, SupervisorQueryResultRow[]>; private supervisorQueryManager: QueryManager<string, SupervisorQueryResultRow[]>;
private taskQueryManager: QueryManager<string, TaskQueryResultRow[]>; private taskQueryManager: QueryManager<string, TaskQueryResultRow[]>;
private supervisorTableColumnSelectionHandler: TableColumnSelectionHandler; private supervisorTableColumnSelectionHandler: TableColumnSelectionHandler;