Skip to content

Commit

Permalink
Merge pull request #4567 from spadgett/typescript-3.8.3
Browse files Browse the repository at this point in the history
TypeScript 3.8.3
  • Loading branch information
openshift-merge-robot committed Mar 10, 2020
2 parents 618a7ae + 263f09d commit e8d79fc
Show file tree
Hide file tree
Showing 20 changed files with 106 additions and 78 deletions.
2 changes: 1 addition & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@
"ts-jest": "21.x",
"ts-loader": "5.3.3",
"ts-node": "5.x",
"typescript": "3.7.2",
"typescript": "3.8.3",
"webpack": "4.40.2",
"webpack-bundle-analyzer": "^3.5.0",
"webpack-cli": "^3.3.9",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ export const VolumeSnapshotModal = withHandlePromise((props: VolumeSnapshotModal
const [snapshotWeek, setSnapshotWeek] = React.useState(0); // For Weekly schedule
const [snapshotTime, setSnapshotTime] = React.useState('00:01'); // For weekly and monthly
const [snapshotMonth, setSnapshotMonth] = React.useState(1); // For monthly schedule
const [snapshotName, setSnapshotName] = React.useState();
const [scheduleLabel, setScheduleLabel] = React.useState();
const [snapshotName, setSnapshotName] = React.useState<string>();
const [scheduleLabel, setScheduleLabel] = React.useState<string>();
const [scheduleType, setScheduleType] = React.useState(snapshotTypes.Single);

const makeLabel = (): string => {
Expand Down
11 changes: 11 additions & 0 deletions frontend/packages/console-shared/src/types/resource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,17 @@ import { DEPLOYMENT_STRATEGY } from '../constants';
import { OverviewItemAlerts, PodControllerOverviewItem } from './pod';
import { ClusterServiceVersionKind } from '@console/operator-lifecycle-manager';

export type APIError = {
status?: string;
message?: string;
reason?: string;
details?: {
name?: string;
kind?: string;
};
code?: number;
};

export type BuildConfigOverviewItem = K8sResourceKind & {
builds: K8sResourceKind[];
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export const TopologyDataController: React.FC<TopologyDataControllerProps> = ({
serviceBinding,
filters,
}) => {
const [helmResourcesMap, setHelmResourcesMap] = React.useState();
const [helmResourcesMap, setHelmResourcesMap] = React.useState<HelmReleaseResourcesMap>();
const { resources, utils } = getResourceList(namespace, resourceList);
if (serviceBinding) {
resources.push({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ type FilterDropdownProps = {
};

const FilterDropdown: React.FC<FilterDropdownProps> = ({ filters, onChange }) => {
const [isOpen, setIsOpen] = React.useState();
const [isOpen, setIsOpen] = React.useState(false);
const selected = Object.keys(filters).filter((key) => filters[key]);

const onToggle = (open: boolean): void => setIsOpen(open);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ describe('RevisionRow', () => {
});

it('should show "-" in case of no status', () => {
revData = _.omit(revData, 'obj.status');
revData = _.omit(revData, 'obj.status') as RevisionRowProps;
const wrapper = shallow(<RevisionRow {...revData} />);
const conditionColData = wrapper.find(TableData).at(4);
expect(conditionColData.props().children).toEqual('-');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ describe('RouteRow', () => {
});

it('should not show ExternalLink for associated route if not found in status', () => {
routeData = _.omit(routeData, 'obj.status');
routeData = _.omit(routeData, 'obj.status') as RouteRowProps;
const wrapper = shallow(<RouteRow {...routeData} />);
const serviceDataTable = wrapper.find(TableData).at(2);
expect(serviceDataTable.find(ExternalLink)).toHaveLength(0);
Expand All @@ -47,7 +47,7 @@ describe('RouteRow', () => {
});

it('should show "-" in case of no status', () => {
routeData = _.omit(routeData, 'obj.status');
routeData = _.omit(routeData, 'obj.status') as RouteRowProps;
const wrapper = shallow(<RouteRow {...routeData} />);
const conditionColData = wrapper.find(TableData).at(4);
expect(conditionColData.props().children).toEqual('-');
Expand All @@ -63,7 +63,7 @@ describe('RouteRow', () => {
});

it('should show "-" in case of no traffic', () => {
routeData = _.omit(routeData, 'obj.status.traffic');
routeData = _.omit(routeData, 'obj.status.traffic') as RouteRowProps;
const wrapper = shallow(<RouteRow {...routeData} />);
const trafficColData = wrapper.find(TableData).at(5);
expect(trafficColData.props().children).toEqual('-');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ describe('ServiceRow', () => {
});

it('should show "-" in case of no url', () => {
svcData = _.omit(svcData, 'obj.status.url');
svcData = _.omit(svcData, 'obj.status.url') as ServiceRowProps;
wrapper = shallow(<ServiceRow {...svcData} />);
const urlColData = wrapper.find(TableData).at(2);
expect(urlColData.props().children).toEqual('-');
Expand All @@ -47,7 +47,7 @@ describe('ServiceRow', () => {
});

it('should show "-" in generations for no associated generation', () => {
svcData = _.omit(svcData, 'obj.metadata.generation');
svcData = _.omit(svcData, 'obj.metadata.generation') as ServiceRowProps;
wrapper = shallow(<ServiceRow {...svcData} />);
const generationColData = wrapper.find(TableData).at(3);
expect(generationColData.props().children).toEqual('-');
Expand All @@ -59,7 +59,7 @@ describe('ServiceRow', () => {
});

it('should show "-" in conditions for no associated generation', () => {
svcData = _.omit(svcData, 'obj.status');
svcData = _.omit(svcData, 'obj.status') as ServiceRowProps;
wrapper = shallow(<ServiceRow {...svcData} />);
const conditionsColData = wrapper.find(TableData).at(5);
expect(conditionsColData.props().children).toEqual('-');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,17 @@ const onResize = (rows, cols) => {
);
};

interface WebSocket {
destroy(): void;
send(data: any): void;
}

// KubeVirt serial console is accessed via WebSocket proxy in k8s API.
// Protocol used is "plain.kubevirt.io", means binary and single channel - forwarding of unix socket only (vmhandler sources).
export const SerialConsoleConnector: React.FC<SerialConsoleConnectorProps> = (props) => {
const [status, setStatus] = React.useState(LOADING);
const [passKeys, setPassKeys] = React.useState(false);
const [ws, setWS] = React.useState();
const [ws, setWS] = React.useState<WebSocket>();
const childSerialconsole = React.useRef(null);

const onBackendDisconnected = React.useCallback(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,11 +206,6 @@ type ElementProps = {
element: Node;
};

type CreateConnectorOptions = {
handleAngle?: number;
handleLength?: number;
};

export type WithCreateConnectorProps = {
onShowCreateConnector: () => void;
onHideCreateConnector: () => void;
Expand Down
7 changes: 4 additions & 3 deletions frontend/public/components/api-explorer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import * as fuzzy from 'fuzzysearch';
import { Tooltip } from '@patternfly/react-core';
import { sortable } from '@patternfly/react-table';

import { ALL_NAMESPACES_KEY, FLAGS } from '@console/shared';
import { ALL_NAMESPACES_KEY, FLAGS, APIError } from '@console/shared';
import { connectToModel } from '../kinds';
import { LocalResourceAccessReviewsModel, ResourceAccessReviewsModel } from '../models';
import {
Expand All @@ -21,6 +21,7 @@ import {
getResourceDescription,
referenceForModel,
ResourceAccessReviewRequest,
ResourceAccessReviewResponse,
} from '../module/k8s';
import { connectToFlags, FlagsObject } from '../reducers/features';
import { RootState } from '../redux';
Expand Down Expand Up @@ -472,8 +473,8 @@ const APIResourceAccessReview: React.FC<APIResourceTabProps> = ({
const [showUsers, setShowUsers] = React.useState(true);
const [showGroups, setShowGroups] = React.useState(true);
const [showServiceAccounts, setShowServiceAccounts] = React.useState(false);
const [accessResponse, setAccessResponse] = React.useState();
const [error, setError] = React.useState(null);
const [accessResponse, setAccessResponse] = React.useState<ResourceAccessReviewResponse>();
const [error, setError] = React.useState<APIError>();

// perform the access review
React.useEffect(() => {
Expand Down
15 changes: 9 additions & 6 deletions frontend/public/components/catalog/catalog-page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@ import * as _ from 'lodash-es';
import { Helmet } from 'react-helmet';
import { safeLoad } from 'js-yaml';

import { ANNOTATIONS, FLAGS } from '@console/shared';
import { ANNOTATIONS, FLAGS, APIError } from '@console/shared';
import { CatalogTileViewPage } from './catalog-items';
import {
k8sListPartialMetadata,
referenceForModel,
serviceClassDisplayName,
K8sResourceCommon,
K8sResourceKind,
PartialObjectMetadata,
} from '../../module/k8s';
Expand Down Expand Up @@ -292,11 +293,13 @@ export const Catalog = connectToFlags<CatalogProps>(
const { flags, mock, namespace } = props;
const openshiftFlag = flags[FLAGS.OPENSHIFT];
const serviceCatalogFlag = flags[FLAGS.SERVICE_CATALOG];
const [templateMetadata, setTemplateMetadata] = React.useState();
const [templateError, setTemplateError] = React.useState();
const [projectTemplateMetadata, setProjectTemplateMetadata] = React.useState();
const [projectTemplateError, setProjectTemplateError] = React.useState();
const [helmCharts, setHelmCharts] = React.useState();
const [templateMetadata, setTemplateMetadata] = React.useState<K8sResourceCommon>();
const [templateError, setTemplateError] = React.useState<APIError>();
const [projectTemplateMetadata, setProjectTemplateMetadata] = React.useState<K8sResourceCommon[]>(
null,
);
const [projectTemplateError, setProjectTemplateError] = React.useState<APIError>();
const [helmCharts, setHelmCharts] = React.useState<HelmChartEntries>();

const loadTemplates = openshiftFlag && !mock;

Expand Down
23 changes: 15 additions & 8 deletions frontend/public/components/graphs/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,24 @@ export type DataPoint<X = Date | number | string> = {
description?: string;
};

export type PrometheusLabels = { [key: string]: string };
export type PrometheusValue = [number, string];

// Only covers range and instant vector responses for now.
export type PrometheusResult = {
metric: PrometheusLabels;
values?: PrometheusValue[];
value?: PrometheusValue;
};

export type PrometheusData = {
resultType: 'matrix' | 'vector' | 'scalar' | 'string';
result: PrometheusResult[];
};

export type PrometheusResponse = {
status: string;
data: {
resultType: 'matrix' | 'vector' | 'scalar' | 'string';
result: {
metric: { [key: string]: any };
values?: [number, string | number][];
value?: [number, string | number];
}[];
};
data: PrometheusData;
errorType?: string;
error?: string;
warnings?: string[];
Expand Down
13 changes: 7 additions & 6 deletions frontend/public/components/monitoring.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ import { Table, TableData, TableRow, TextFilter } from './factory';
import { confirmModal } from './modals';
import MonitoringDashboardsPage from './monitoring/dashboards';
import { graphStateToProps, QueryBrowserPage, ToggleGraph } from './monitoring/metrics';
import { Labels, QueryBrowser, QueryObj } from './monitoring/query-browser';
import { PrometheusLabels } from './graphs';
import { QueryBrowser, QueryObj } from './monitoring/query-browser';
import { CheckBoxes } from './row-filter';
import { formatPrometheusDuration } from './utils/datetime';
import { AlertmanagerYAMLEditorWrapper } from './monitoring/alert-manager-yaml-editor';
Expand Down Expand Up @@ -1550,8 +1551,8 @@ type Silences = {

type PrometheusAlert = {
activeAt?: string;
annotations: Labels;
labels: Labels & {
annotations: PrometheusLabels;
labels: PrometheusLabels & {
alertname: string;
};
state: AlertStates;
Expand All @@ -1565,9 +1566,9 @@ export type Alert = PrometheusAlert & {

type PrometheusRule = {
alerts: PrometheusAlert[];
annotations: Labels;
annotations: PrometheusLabels;
duration: number;
labels: Labels;
labels: PrometheusLabels;
name: string;
query: string;
};
Expand Down Expand Up @@ -1650,7 +1651,7 @@ type AlertingPageProps = {
};

type GraphProps = {
filterLabels?: Labels;
filterLabels?: PrometheusLabels;
hideGraphs: boolean;
patchQuery: (index: number, patch: QueryObj) => any;
rule: Rule;
Expand Down
4 changes: 2 additions & 2 deletions frontend/public/components/monitoring/dashboards/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -413,9 +413,9 @@ const MonitoringDashboardsPage_: React.FC<MonitoringDashboardsPageProps> = ({
match,
patchAllVariables,
}) => {
const [board, setBoard] = React.useState();
const [board, setBoard] = React.useState<string>();
const [boards, setBoards] = React.useState<Board[]>([]);
const [error, setError] = React.useState();
const [error, setError] = React.useState<string>();
const [isLoading, , , setLoaded] = useBoolean(true);

const safeFetch = React.useCallback(useSafeFetch(), []);
Expand Down
16 changes: 10 additions & 6 deletions frontend/public/components/monitoring/metrics.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ import {
import * as UIActions from '../../actions/ui';
import { RootState } from '../../redux';
import { fuzzyCaseInsensitive } from '../factory/table-filters';
import { PROMETHEUS_BASE_PATH } from '../graphs';
import { PrometheusData, PrometheusLabels, PROMETHEUS_BASE_PATH } from '../graphs';
import { getPrometheusURL, PrometheusEndpoint } from '../graphs/helpers';
import { getPrometheusExpressionBrowserURL } from '../graphs/prometheus-graph';
import {
Expand All @@ -59,7 +59,7 @@ import {
useSafeFetch,
} from '../utils';
import { setAllQueryArguments } from '../utils/router';
import { colors, Error, Labels, QueryObj, QueryBrowser } from './query-browser';
import { colors, Error, QueryObj, QueryBrowser } from './query-browser';

const aggregationOperators = [
'avg()',
Expand Down Expand Up @@ -219,7 +219,7 @@ const MetricsDropdown_: React.FC<MetricsDropdownProps> = ({
namespace,
setMetrics,
}) => {
const [items, setItems] = React.useState();
const [items, setItems] = React.useState<MetricsDropdownItems>();
const [isError, setIsError] = React.useState(false);

const safeFetch = React.useCallback(useSafeFetch(), []);
Expand Down Expand Up @@ -602,7 +602,7 @@ const QueryTable_: React.FC<QueryTableProps> = ({
query,
series,
}) => {
const [data, setData] = React.useState();
const [data, setData] = React.useState<PrometheusData>();
const [error, setError] = React.useState();
const [page, setPage] = React.useState(1);
const [perPage, setPerPage] = React.useState(50);
Expand Down Expand Up @@ -1024,6 +1024,10 @@ type MetricsActionsMenuProps = {
setAllExpanded: (isExpanded: boolean) => never;
};

type MetricsDropdownItems = {
[key: string]: string;
};

type MetricsDropdownProps = {
insertText: (index: number, newText: string, replaceFrom: number, replaceTo: number) => never;
namespace?: string;
Expand Down Expand Up @@ -1054,7 +1058,7 @@ type QueryKebabProps = {
isDisabledSeriesEmpty: boolean;
isEnabled: boolean;
patchQuery: (patch: QueryObj) => void;
series: Labels[];
series: PrometheusLabels[];
toggleIsEnabled: () => never;
};

Expand All @@ -1074,7 +1078,7 @@ type QueryTableProps = {
isExpanded: boolean;
namespace?: string;
query: string;
series: Labels[];
series: PrometheusLabels[];
};

type SeriesButtonProps = {
Expand Down

0 comments on commit e8d79fc

Please sign in to comment.