Unverified Commit 14261198 authored by Dorian Johnson's avatar Dorian Johnson Committed by GitHub

chore: finish remaining simple null check typing fixes (#756)

Signed-off-by: 's avatarMarcos Iglesias Valle <golodhros@gmail.com>
parent 0d55e2d2
// BETTERER RESULTS V2. // BETTERER RESULTS V2.
exports[`strict null compilation`] = { exports[`strict null compilation`] = {
value: `{ value: `{
"js/components/common/Bookmark/MyBookmarks/index.tsx:3695929904": [ "js/components/Footer/index.tsx:474946957": [
[66, 6, 7, "Type \'Element | null\' is not assignable to type \'Element | undefined\'.\\n Type \'null\' is not assignable to type \'Element | undefined\'.", "3716929964"], [79, 2, 15, "No overload matches this call.\\n The last overload gave the following error.\\n Argument of type \'(state: GlobalState) => { lastIndexed: number | null; }\' is not assignable to parameter of type \'MapStateToPropsParam<StateFromProps, {}, {}>\'.\\n Type \'(state: GlobalState) => { lastIndexed: number | null; }\' is not assignable to type \'MapStateToPropsFactory<StateFromProps, {}, {}>\'.\\n Type \'{ lastIndexed: number | null; }\' is not assignable to type \'MapStateToProps<StateFromProps, {}, {}>\'.\\n Type \'{ lastIndexed: number | null; }\' provides no match for the signature \'(state: {}, ownProps: {}): StateFromProps\'.", "1389821531"]
[73, 8, 7, "Type \'Element | null\' is not assignable to type \'Element | undefined\'.\\n Type \'null\' is not assignable to type \'Element | undefined\'.", "3716929964"]
], ],
"js/components/common/Card/index.tsx:1284486450": [ "js/components/common/SearchBar/index.tsx:3874012304": [
[35, 2, 7, "Type \'null\' is not assignable to type \'(e: SyntheticEvent<Element, Event>) => void\'.", "4055953994"]
],
"js/components/common/EditableSection/index.spec.tsx:1117078860": [
[93, 32, 4, "Argument of type \'null\' is not assignable to parameter of type \'Partial<EditableSectionProps> | undefined\'.", "2087897566"]
],
"js/components/common/ResourceListItem/DashboardListItem/index.spec.tsx:53357032": [
[163, 14, 29, "Type \'null\' is not assignable to type \'number\'.", "1157138603"]
],
"js/components/common/ScrollTracker/index.tsx:727804392": [
[55, 30, 29, "Argument of type \'number | undefined\' is not assignable to parameter of type \'number\'.\\n Type \'undefined\' is not assignable to type \'number\'.", "745919071"]
],
"js/components/common/SearchBar/index.spec.tsx:2504836695": [
[403, 30, 4, "Argument of type \'null\' is not assignable to parameter of type \'Partial<SearchBarProps> | undefined\'.", "2087897566"]
],
"js/components/common/SearchBar/index.tsx:4158354159": [
[255, 6, 11, "No overload matches this call.\\n The last overload gave the following error.\\n Type \'(() => SubmitSearchRequest) | null\' is not assignable to type \'ActionCreator<any>\'.\\n Type \'null\' is not assignable to type \'ActionCreator<any>\'.", "2296208050"], [255, 6, 11, "No overload matches this call.\\n The last overload gave the following error.\\n Type \'(() => SubmitSearchRequest) | null\' is not assignable to type \'ActionCreator<any>\'.\\n Type \'null\' is not assignable to type \'ActionCreator<any>\'.", "2296208050"],
[270, 4, 18, "No overload matches this call.\\n The last overload gave the following error.\\n Argument of type \'(dispatch: any, ownProps: any) => ActionCreator<unknown>\' is not assignable to parameter of type \'DispatchFromProps\'.\\n Type \'(dispatch: any, ownProps: any) => ActionCreator<unknown>\' is missing the following properties from type \'DispatchFromProps\': submitSearch, onInputChange, onSelectInlineResult", "2926224796"] [270, 4, 18, "No overload matches this call.\\n The last overload gave the following error.\\n Argument of type \'(dispatch: any, ownProps: any) => ActionCreator<unknown>\' is not assignable to parameter of type \'DispatchFromProps\'.\\n Type \'(dispatch: any, ownProps: any) => ActionCreator<unknown>\' is missing the following properties from type \'DispatchFromProps\': submitSearch, onInputChange, onSelectInlineResult", "2926224796"]
], ],
"js/components/common/Tags/TagInput/index.tsx:1066848945": [
[63, 22, 6, "Type \'undefined\' is not assignable to type \'GetAllTagsRequest\'.", "1979467425"],
[67, 22, 6, "Type \'undefined\' is not assignable to type \'UpdateTagsRequest\'.", "1979467425"]
],
"js/components/common/Tags/TagsList/index.tsx:4084208491": [
[99, 23, 9, "Object is possibly \'undefined\'.", "3803340896"],
[115, 38, 4, "Type \'Tag[] | undefined\' is not assignable to type \'Tag[]\'.\\n Type \'undefined\' is not assignable to type \'Tag[]\'.", "2087952548"]
],
"js/config/config-utils.ts:3097983516": [
[87, 4, 25, "\'style\' is specified more than once, so this usage will be overwritten.", "1214862559"]
],
"js/config/index.spec.ts:3696338512": [ "js/config/index.spec.ts:3696338512": [
[17, 6, 61, "Object is possibly \'undefined\'.", "1496333578"], [17, 6, 61, "Object is possibly \'undefined\'.", "1496333578"],
[51, 6, 61, "Object is possibly \'undefined\'.", "1496333578"] [51, 6, 61, "Object is possibly \'undefined\'.", "1496333578"]
], ],
"js/ducks/announcements/index.ts:2989299303": [ "js/ducks/announcements/index.ts:3464360346": [
[37, 2, 10, "Type \'null\' is not assignable to type \'number\'.", "3382497788"], [37, 2, 10, "Type \'null\' is not assignable to type \'number\'.", "3382497788"],
[49, 8, 10, "Type \'null\' is not assignable to type \'number\'.", "3382497788"], [49, 8, 10, "Type \'null\' is not assignable to type \'number\'.", "3382497788"]
[62, 8, 5, "Type \'AnnouncementPost[] | undefined\' is not assignable to type \'AnnouncementPost[]\'.\\n Type \'undefined\' is not assignable to type \'AnnouncementPost[]\'.", "187752366"]
], ],
"js/ducks/dashboard/reducer.ts:1902488284": [ "js/ducks/dashboard/reducer.ts:1902488284": [
[71, 2, 10, "Type \'null\' is not assignable to type \'number\'.", "3382497788"], [71, 2, 10, "Type \'null\' is not assignable to type \'number\'.", "3382497788"],
...@@ -67,12 +39,6 @@ exports[`strict null compilation`] = { ...@@ -67,12 +39,6 @@ exports[`strict null compilation`] = {
[258, 39, 4, "Argument of type \'null\' is not assignable to parameter of type \'string | undefined\'.", "2087897566"], [258, 39, 4, "Argument of type \'null\' is not assignable to parameter of type \'string | undefined\'.", "2087897566"],
[306, 34, 4, "Argument of type \'null\' is not assignable to parameter of type \'Issue\'.", "2087897566"] [306, 34, 4, "Argument of type \'null\' is not assignable to parameter of type \'Issue\'.", "2087897566"]
], ],
"js/ducks/lastIndexed/reducer.ts:1072326537": [
[10, 2, 11, "Type \'null\' is not assignable to type \'number\'.", "1159268112"],
[43, 8, 11, "Type \'number | undefined\' is not assignable to type \'number\'.\\n Type \'undefined\' is not assignable to type \'number\'.", "1159268112"],
[43, 21, 40, "Object is possibly \'undefined\'.", "195627832"],
[47, 8, 11, "Type \'null\' is not assignable to type \'number\'.", "1159268112"]
],
"js/ducks/notification/tests/index.spec.ts:2474130513": [ "js/ducks/notification/tests/index.spec.ts:2474130513": [
[197, 43, 4, "Argument of type \'null\' is not assignable to parameter of type \'SubmitNotificationRequest\'.", "2087897566"] [197, 43, 4, "Argument of type \'null\' is not assignable to parameter of type \'SubmitNotificationRequest\'.", "2087897566"]
], ],
...@@ -91,55 +57,23 @@ exports[`strict null compilation`] = { ...@@ -91,55 +57,23 @@ exports[`strict null compilation`] = {
"js/ducks/tableMetadata/reducer.ts:2668005658": [ "js/ducks/tableMetadata/reducer.ts:2668005658": [
[65, 2, 10, "Type \'null\' is not assignable to type \'number\'.", "3382497788"] [65, 2, 10, "Type \'null\' is not assignable to type \'number\'.", "3382497788"]
], ],
"js/ducks/tags/reducer.ts:419330645": [
[130, 16, 48, "Object is possibly \'undefined\'.", "1931932323"]
],
"js/ducks/user/reducer.ts:1917256202": [
[119, 22, 41, "Object is possibly \'undefined\'.", "291980569"],
[135, 16, 33, "Object is possibly \'undefined\'.", "625812796"],
[154, 15, 36, "Object is possibly \'undefined\'.", "3626509514"],
[171, 16, 37, "Object is possibly \'undefined\'.", "1613771502"]
],
"js/ducks/utilMethods.ts:3713570825": [
[52, 4, 5, "Type \'string | null\' is not assignable to type \'string | undefined\'.\\n Type \'null\' is not assignable to type \'string | undefined\'.", "173467459"]
],
"js/pages/ProfilePage/index.spec.tsx:4086464143": [
[41, 6, 4, "Argument of type \'null\' is not assignable to parameter of type \'Partial<Location<{} | null | undefined>> | undefined\'.", "2087897566"]
],
"js/pages/ProfilePage/index.tsx:1225704099": [ "js/pages/ProfilePage/index.tsx:1225704099": [
[356, 2, 15, "No overload matches this call.\\n The last overload gave the following error.\\n Argument of type \'(state: GlobalState) => { user: PeopleUser; resourceRelations: { table: { bookmarks: Bookmark[]; own: Resource[]; read: Resource[]; }; dashboard: { bookmarks: Bookmark[] | undefined; own: Resource[] | undefined; read: never[]; }; }; }\' is not assignable to parameter of type \'MapStateToPropsParam<StateFromProps, {}, {}>\'.\\n Type \'(state: GlobalState) => { user: PeopleUser; resourceRelations: { table: { bookmarks: Bookmark[]; own: Resource[]; read: Resource[]; }; dashboard: { bookmarks: Bookmark[] | undefined; own: Resource[] | undefined; read: never[]; }; }; }\' is not assignable to type \'MapStateToPropsFactory<StateFromProps, {}, {}>\'.\\n Type \'{ user: PeopleUser; resourceRelations: { table: { bookmarks: Bookmark[]; own: Resource[]; read: Resource[]; }; dashboard: { bookmarks: Bookmark[] | undefined; own: Resource[] | undefined; read: never[]; }; }; }\' is not assignable to type \'MapStateToProps<StateFromProps, {}, {}>\'.\\n Type \'{ user: PeopleUser; resourceRelations: { table: { bookmarks: Bookmark[]; own: Resource[]; read: Resource[]; }; dashboard: { bookmarks: Bookmark[] | undefined; own: Resource[] | undefined; read: never[]; }; }; }\' provides no match for the signature \'(state: {}, ownProps: {}): StateFromProps\'.", "1389821531"] [356, 2, 15, "No overload matches this call.\\n The last overload gave the following error.\\n Argument of type \'(state: GlobalState) => { user: PeopleUser; resourceRelations: { table: { bookmarks: Bookmark[]; own: Resource[]; read: Resource[]; }; dashboard: { bookmarks: Bookmark[] | undefined; own: Resource[] | undefined; read: never[]; }; }; }\' is not assignable to parameter of type \'MapStateToPropsParam<StateFromProps, {}, {}>\'.\\n Type \'(state: GlobalState) => { user: PeopleUser; resourceRelations: { table: { bookmarks: Bookmark[]; own: Resource[]; read: Resource[]; }; dashboard: { bookmarks: Bookmark[] | undefined; own: Resource[] | undefined; read: never[]; }; }; }\' is not assignable to type \'MapStateToPropsFactory<StateFromProps, {}, {}>\'.\\n Type \'{ user: PeopleUser; resourceRelations: { table: { bookmarks: Bookmark[]; own: Resource[]; read: Resource[]; }; dashboard: { bookmarks: Bookmark[] | undefined; own: Resource[] | undefined; read: never[]; }; }; }\' is not assignable to type \'MapStateToProps<StateFromProps, {}, {}>\'.\\n Type \'{ user: PeopleUser; resourceRelations: { table: { bookmarks: Bookmark[]; own: Resource[]; read: Resource[]; }; dashboard: { bookmarks: Bookmark[] | undefined; own: Resource[] | undefined; read: never[]; }; }; }\' provides no match for the signature \'(state: {}, ownProps: {}): StateFromProps\'.", "1389821531"]
], ],
"js/pages/SearchPage/SearchFilter/FilterSection/index.tsx:2128122504": [ "js/pages/SearchPage/SearchFilter/index.spec.tsx:1059167396": [
[51, 48, 18, "Type \'CheckboxFilterProperties[] | undefined\' is not assignable to type \'CheckboxFilterProperties[]\'.\\n Type \'undefined\' is not assignable to type \'CheckboxFilterProperties[]\'.", "12656471"] [233, 23, 9, "Argument of type \'undefined\' is not assignable to parameter of type \'FilterConfig\'.", "2620553983"]
], ],
"js/pages/SearchPage/SearchFilter/index.spec.tsx:2944458990": [ "js/pages/SearchPage/SearchFilter/index.tsx:2448037720": [
[232, 23, 9, "Argument of type \'undefined\' is not assignable to parameter of type \'FilterConfig\'.", "2620553983"] [96, 56, 4, "No overload matches this call.\\n The last overload gave the following error.\\n Argument of type \'null\' is not assignable to parameter of type \'{}\'.", "2087897566"]
],
"js/pages/SearchPage/SearchFilter/index.tsx:1113311229": [
[80, 8, 42, "Type \'{ value: string; label: string | undefined; }[]\' is not assignable to type \'CheckboxFilterProperties[]\'.\\n Type \'{ value: string; label: string | undefined; }\' is not assignable to type \'CheckboxFilterProperties\'.\\n Types of property \'label\' are incompatible.\\n Type \'string | undefined\' is not assignable to type \'string\'.\\n Type \'undefined\' is not assignable to type \'string\'.", "3344322363"],
[86, 26, 7, "Argument of type \'{ categoryId: string; helpText: string | undefined; title: string; type: FilterType; }\' is not assignable to parameter of type \'never\'.", "2519086860"],
[95, 56, 4, "No overload matches this call.\\n The last overload gave the following error.\\n Argument of type \'null\' is not assignable to parameter of type \'{}\'.", "2087897566"]
], ],
"js/pages/SearchPage/index.tsx:3158270092": [ "js/pages/SearchPage/index.tsx:3158270092": [
[176, 11, 12, "Property \'filterSections\' is missing in type \'{}\' but required in type \'Readonly<Pick<StateFromProps, \\"filterSections\\">>\'.", "250899467"] [176, 11, 12, "Property \'filterSections\' is missing in type \'{}\' but required in type \'Readonly<Pick<StateFromProps, \\"filterSections\\">>\'.", "250899467"]
], ],
"js/pages/TableDetailPage/DataPreviewButton/index.tsx:793484139": [
[141, 17, 16, "Object is possibly \'undefined\'.", "3451845569"],
[257, 30, 34, "Argument of type \'number | null\' is not assignable to parameter of type \'number\'.\\n Type \'null\' is not assignable to type \'number\'.", "3967943985"]
],
"js/pages/TableDetailPage/TableDashboardResourceList/index.tsx:3276822301": [ "js/pages/TableDetailPage/TableDashboardResourceList/index.tsx:3276822301": [
[65, 2, 15, "No overload matches this call.\\n The last overload gave the following error.\\n Argument of type \'(state: GlobalState) => { dashboards: DashboardResource[]; isLoading: boolean; errorText: string | undefined; }\' is not assignable to parameter of type \'MapStateToPropsParam<StateFromProps, OwnProps, {}>\'.\\n Type \'(state: GlobalState) => { dashboards: DashboardResource[]; isLoading: boolean; errorText: string | undefined; }\' is not assignable to type \'MapStateToPropsFactory<StateFromProps, OwnProps, {}>\'.\\n Type \'{ dashboards: DashboardResource[]; isLoading: boolean; errorText: string | undefined; }\' is not assignable to type \'MapStateToProps<StateFromProps, OwnProps, {}>\'.\\n Type \'{ dashboards: DashboardResource[]; isLoading: boolean; errorText: string | undefined; }\' provides no match for the signature \'(state: {}, ownProps: OwnProps): StateFromProps\'.", "1389821531"] [65, 2, 15, "No overload matches this call.\\n The last overload gave the following error.\\n Argument of type \'(state: GlobalState) => { dashboards: DashboardResource[]; isLoading: boolean; errorText: string | undefined; }\' is not assignable to parameter of type \'MapStateToPropsParam<StateFromProps, OwnProps, {}>\'.\\n Type \'(state: GlobalState) => { dashboards: DashboardResource[]; isLoading: boolean; errorText: string | undefined; }\' is not assignable to type \'MapStateToPropsFactory<StateFromProps, OwnProps, {}>\'.\\n Type \'{ dashboards: DashboardResource[]; isLoading: boolean; errorText: string | undefined; }\' is not assignable to type \'MapStateToProps<StateFromProps, OwnProps, {}>\'.\\n Type \'{ dashboards: DashboardResource[]; isLoading: boolean; errorText: string | undefined; }\' provides no match for the signature \'(state: {}, ownProps: OwnProps): StateFromProps\'.", "1389821531"]
], ],
"js/pages/TableDetailPage/WatermarkLabel/index.spec.tsx:1587893154": [ "js/pages/TableDetailPage/index.tsx:587812140": [
[77, 57, 4, "Argument of type \'null\' is not assignable to parameter of type \'string\'.", "2087897566"] [235, 11, 26, "Type \'{ itemsPerPage: number; source: string; }\' is missing the following properties from type \'Readonly<Pick<TableDashboardResourceListProps, \\"source\\" | \\"isLoading\\" | \\"dashboards\\" | \\"itemsPerPage\\" | \\"errorText\\"> & OwnProps>\': isLoading, dashboards, errorText", "2224258167"]
],
"js/pages/TableDetailPage/WatermarkLabel/index.tsx:1354016727": [
[80, 34, 3, "Argument of type \'string | null\' is not assignable to parameter of type \'string\'.\\n Type \'null\' is not assignable to type \'string\'.", "193412913"]
],
"js/pages/TableDetailPage/index.tsx:3727993506": [
[185, 10, 13, "Type \'null\' is not assignable to type \'((newValue: string, onSuccess?: (() => any) | undefined, onFailure?: (() => any) | undefined) => void) | undefined\'.", "67794331"],
[240, 11, 26, "Type \'{ itemsPerPage: number; source: string; }\' is missing the following properties from type \'Readonly<Pick<TableDashboardResourceListProps, \\"source\\" | \\"isLoading\\" | \\"dashboards\\" | \\"itemsPerPage\\" | \\"errorText\\"> & OwnProps>\': isLoading, dashboards, errorText", "2224258167"],
[329, 16, 7, "Type \'string | null\' is not assignable to type \'string | undefined\'.\\n Type \'null\' is not assignable to type \'string | undefined\'.", "3817619378"]
] ]
}` }`
}; };
...@@ -19,7 +19,7 @@ module.exports = { ...@@ -19,7 +19,7 @@ module.exports = {
statements: 78, // 75 statements: 78, // 75
}, },
'./js/ducks': { './js/ducks': {
branches: 75, branches: 74, // 75
functions: 80, functions: 80,
lines: 80, lines: 80,
statements: 85, statements: 85,
......
...@@ -14,7 +14,7 @@ import { formatDateTimeLong } from 'utils/dateUtils'; ...@@ -14,7 +14,7 @@ import { formatDateTimeLong } from 'utils/dateUtils';
// Props // Props
interface StateFromProps { interface StateFromProps {
lastIndexed: number; lastIndexed?: number;
} }
interface DispatchFromProps { interface DispatchFromProps {
...@@ -38,8 +38,8 @@ export class Footer extends React.Component<FooterProps> { ...@@ -38,8 +38,8 @@ export class Footer extends React.Component<FooterProps> {
getLastIndexed(); getLastIndexed();
} }
generateDateTimeString = () => { generateDateTimeString = (lastIndexed: number): string => {
return formatDateTimeLong({ epochTimestamp: this.props.lastIndexed }); return formatDateTimeLong({ epochTimestamp: lastIndexed });
}; };
render() { render() {
...@@ -47,7 +47,11 @@ export class Footer extends React.Component<FooterProps> { ...@@ -47,7 +47,11 @@ export class Footer extends React.Component<FooterProps> {
if (this.props.lastIndexed) { if (this.props.lastIndexed) {
content = ( content = (
<div>{`Amundsen was last indexed on ${this.generateDateTimeString()}`}</div> <div>
{`Amundsen was last indexed on ${this.generateDateTimeString(
this.props.lastIndexed
)}`}
</div>
); );
} }
......
...@@ -118,9 +118,9 @@ describe('MyBookmarks', () => { ...@@ -118,9 +118,9 @@ describe('MyBookmarks', () => {
expect(element.props().emptyText).toBe(EMPTY_BOOKMARK_MESSAGE); expect(element.props().emptyText).toBe(EMPTY_BOOKMARK_MESSAGE);
}); });
it('returns null if there are no bookmarks to render', () => { it('returns undefined if there are no bookmarks to render', () => {
content = wrapper.instance().generateTabContent(ResourceType.user); content = wrapper.instance().generateTabContent(ResourceType.user);
expect(content).toBe(null); expect(content).toBeUndefined();
}); });
}); });
......
...@@ -29,11 +29,11 @@ interface StateFromProps { ...@@ -29,11 +29,11 @@ interface StateFromProps {
export type MyBookmarksProps = StateFromProps; export type MyBookmarksProps = StateFromProps;
export class MyBookmarks extends React.Component<MyBookmarksProps> { export class MyBookmarks extends React.Component<MyBookmarksProps> {
generateTabContent = (resource: ResourceType): JSX.Element | null => { generateTabContent = (resource: ResourceType): JSX.Element | undefined => {
const bookmarks = this.props.myBookmarks[resource]; const bookmarks = this.props.myBookmarks[resource];
if (!bookmarks) { if (!bookmarks) {
return null; return undefined;
} }
return ( return (
......
...@@ -33,7 +33,7 @@ const Card: React.FC<CardProps> = ({ ...@@ -33,7 +33,7 @@ const Card: React.FC<CardProps> = ({
title, title,
subtitle, subtitle,
copy, copy,
onClick = null, onClick = undefined,
isLoading = false, isLoading = false,
}: CardProps) => { }: CardProps) => {
let card; let card;
......
...@@ -91,7 +91,7 @@ describe('EditableSection', () => { ...@@ -91,7 +91,7 @@ describe('EditableSection', () => {
it('renders children as-is for non-react elements', () => { it('renders children as-is for non-react elements', () => {
const child = 'non-react-child'; const child = 'non-react-child';
const { wrapper } = setup(null, child); const { wrapper } = setup(undefined, child);
expect(wrapper.find('.editable-section-content').text()).toBe(child); expect(wrapper.find('.editable-section-content').text()).toBe(child);
}); });
......
...@@ -161,7 +161,7 @@ describe('DashboardListItem', () => { ...@@ -161,7 +161,7 @@ describe('DashboardListItem', () => {
uri: 'product_dashboard://cluster.group/name', uri: 'product_dashboard://cluster.group/name',
url: 'product/name', url: 'product/name',
cluster: 'cluster', cluster: 'cluster',
last_successful_run_timestamp: null, last_successful_run_timestamp: 0,
}, },
}); });
expect(wrapper.find('.resource-badges').find('.title-3').text()).toBe( expect(wrapper.find('.resource-badges').find('.title-3').text()).toBe(
......
...@@ -53,7 +53,8 @@ export default class ScrollTracker extends React.Component< ...@@ -53,7 +53,8 @@ export default class ScrollTracker extends React.Component<
const scrollableAmount = Math.max(contentHeight - windowHeight, 1); const scrollableAmount = Math.max(contentHeight - windowHeight, 1);
if (threshold <= (100 * scrollTop) / scrollableAmount) { if (threshold <= (100 * scrollTop) / scrollableAmount) {
this.fireAnalyticsEvent(this.state.thresholds.shift()); this.state.thresholds.shift();
this.fireAnalyticsEvent(threshold);
} }
}; };
......
...@@ -401,7 +401,7 @@ describe('SearchBar', () => { ...@@ -401,7 +401,7 @@ describe('SearchBar', () => {
expect(result.onSelectInlineResult).toBeInstanceOf(Function); expect(result.onSelectInlineResult).toBeInstanceOf(Function);
}); });
it('sets clearSearch on the props if on search route', () => { it('sets clearSearch on the props if on search route', () => {
const { props } = setup(null, null, { pathname: '/search' }); const { props } = setup(undefined, undefined, { pathname: '/search' });
result = mapDispatchToProps(dispatch, props); result = mapDispatchToProps(dispatch, props);
expect(result.clearSearch).toBeInstanceOf(Function); expect(result.clearSearch).toBeInstanceOf(Function);
}); });
......
...@@ -32,7 +32,7 @@ export interface StateFromProps { ...@@ -32,7 +32,7 @@ export interface StateFromProps {
} }
export interface DispatchFromProps { export interface DispatchFromProps {
clearSearch?: () => SubmitSearchRequest; clearSearch?: () => void;
submitSearch: (searchTerm: string) => SubmitSearchRequest; submitSearch: (searchTerm: string) => SubmitSearchRequest;
onInputChange: (term: string) => InlineSearchRequest; onInputChange: (term: string) => InlineSearchRequest;
onSelectInlineResult: ( onSelectInlineResult: (
......
...@@ -10,7 +10,12 @@ import CreatableSelect from 'react-select/lib/Creatable'; ...@@ -10,7 +10,12 @@ import CreatableSelect from 'react-select/lib/Creatable';
import { GlobalState } from 'ducks/rootReducer'; import { GlobalState } from 'ducks/rootReducer';
import { getAllTags, updateTags } from 'ducks/tags/reducer'; import { getAllTags, updateTags } from 'ducks/tags/reducer';
import { GetAllTagsRequest, UpdateTagsRequest } from 'ducks/tags/types'; import {
GetAllTags,
GetAllTagsRequest,
UpdateTags,
UpdateTagsRequest,
} from 'ducks/tags/types';
import { EditableSectionChildProps } from 'components/common/EditableSection'; import { EditableSectionChildProps } from 'components/common/EditableSection';
import { ResourceType, Tag, UpdateMethod, UpdateTagData } from 'interfaces'; import { ResourceType, Tag, UpdateMethod, UpdateTagData } from 'interfaces';
...@@ -61,11 +66,20 @@ class TagInput extends React.Component<TagInputProps, TagInputState> { ...@@ -61,11 +66,20 @@ class TagInput extends React.Component<TagInputProps, TagInputState> {
public static defaultProps: TagInputProps = { public static defaultProps: TagInputProps = {
allTags: [], allTags: [],
getAllTags: () => void 0, getAllTags: () => ({
type: GetAllTags.REQUEST,
}),
isLoading: false, isLoading: false,
resourceType: ResourceType.table, resourceType: ResourceType.table,
tags: [], tags: [],
updateTags: () => void 0, updateTags: () => ({
type: UpdateTags.REQUEST,
payload: {
tagArray: [],
resourceType: ResourceType.table,
uriKey: '',
},
}),
uriKey: '', uriKey: '',
}; };
......
...@@ -97,7 +97,7 @@ const LongTagsList: React.FC<TagsListProps> = ({ ...@@ -97,7 +97,7 @@ const LongTagsList: React.FC<TagsListProps> = ({
}: TagsListProps) => { }: TagsListProps) => {
const hasCuratedTags = curatedTags.length > 0; const hasCuratedTags = curatedTags.length > 0;
const hasPopularTags = popularTags.length > 0; const hasPopularTags = popularTags.length > 0;
const hasOtherTags = otherTags.length > 0; const hasOtherTags = otherTags && otherTags.length > 0;
return ( return (
<div className="full-tag-list"> <div className="full-tag-list">
<h1 className="tag-list-title" id="browse-header"> <h1 className="tag-list-title" id="browse-header">
...@@ -113,7 +113,7 @@ const LongTagsList: React.FC<TagsListProps> = ({ ...@@ -113,7 +113,7 @@ const LongTagsList: React.FC<TagsListProps> = ({
)} )}
{hasCuratedTags && <TagsListBlock tags={curatedTags} />} {hasCuratedTags && <TagsListBlock tags={curatedTags} />}
{hasOtherTags && <TagsListLabel titleText={OTHER_TAGS_TITLE} />} {hasOtherTags && <TagsListLabel titleText={OTHER_TAGS_TITLE} />}
{hasOtherTags && <TagsListBlock tags={otherTags} />} {hasOtherTags && <TagsListBlock tags={otherTags || []} />}
</div> </div>
); );
}; };
......
...@@ -82,7 +82,7 @@ export function getFilterConfigByResource( ...@@ -82,7 +82,7 @@ export function getFilterConfigByResource(
* use BadgeStyle.DEFAULT and badge name as display name. * use BadgeStyle.DEFAULT and badge name as display name.
*/ */
export function getBadgeConfig(badgeName: string): BadgeStyleConfig { export function getBadgeConfig(badgeName: string): BadgeStyleConfig {
const config = AppConfig.badges[badgeName] || {}; const config: object = AppConfig.badges[badgeName] || {};
return { return {
style: BadgeStyle.DEFAULT, style: BadgeStyle.DEFAULT,
......
...@@ -55,13 +55,18 @@ export default function reducer( ...@@ -55,13 +55,18 @@ export default function reducer(
isLoading: false, isLoading: false,
statusCode: action.payload.statusCode, statusCode: action.payload.statusCode,
}; };
case GetAnnouncements.SUCCESS: case GetAnnouncements.SUCCESS: {
const { payload } = <GetAnnouncementsResponse>action;
if (payload === undefined) {
throw Error('payload must be set for GetAnnouncements.SUCCESS');
}
return { return {
...state, ...state,
isLoading: false, isLoading: false,
statusCode: action.payload.statusCode, statusCode: action.payload.statusCode,
posts: (<GetAnnouncementsResponse>action).payload.posts, posts: payload.posts || [],
}; };
}
default: default:
return state; return state;
} }
......
...@@ -5,7 +5,7 @@ import { ...@@ -5,7 +5,7 @@ import {
} from './types'; } from './types';
export interface LastIndexedReducerState { export interface LastIndexedReducerState {
lastIndexed: number; lastIndexed: number | null;
} }
export const initialState: LastIndexedReducerState = { export const initialState: LastIndexedReducerState = {
lastIndexed: null, lastIndexed: null,
...@@ -39,10 +39,15 @@ export default function reducer( ...@@ -39,10 +39,15 @@ export default function reducer(
switch (action.type) { switch (action.type) {
case GetLastIndexed.REQUEST: case GetLastIndexed.REQUEST:
return initialState; return initialState;
case GetLastIndexed.SUCCESS: case GetLastIndexed.SUCCESS: {
const { payload } = <GetLastIndexedResponse>action;
if (payload === undefined) {
throw Error('payload must be set for GetLastIndexed.SUCCESS');
}
return { return {
lastIndexed: (<GetLastIndexedResponse>action).payload.lastIndexedEpoch, lastIndexed: payload.lastIndexedEpoch || null,
}; };
}
case GetLastIndexed.FAILURE: case GetLastIndexed.FAILURE:
return { return {
lastIndexed: null, lastIndexed: null,
......
...@@ -128,7 +128,7 @@ export default function reducer( ...@@ -128,7 +128,7 @@ export default function reducer(
resourceTags: { resourceTags: {
...state.resourceTags, ...state.resourceTags,
isLoading: false, isLoading: false,
tags: (<GetDashboardResponse>action).payload.dashboard.tags, tags: (<GetDashboardResponse>action).payload.dashboard?.tags || [],
}, },
}; };
case GetTableData.FAILURE: case GetTableData.FAILURE:
......
...@@ -114,11 +114,16 @@ export default function reducer( ...@@ -114,11 +114,16 @@ export default function reducer(
action action
): UserReducerState { ): UserReducerState {
switch (action.type) { switch (action.type) {
case GetLoggedInUser.SUCCESS: case GetLoggedInUser.SUCCESS: {
const { payload } = <GetLoggedInUserResponse>action;
if (payload === undefined) {
throw Error('payload must be set for GetLoggedInUser.SUCCESS');
}
return { return {
...state, ...state,
loggedInUser: (<GetLoggedInUserResponse>action).payload.user, loggedInUser: payload.user,
}; };
}
case GetUser.REQUEST: case GetUser.REQUEST:
case GetUser.FAILURE: case GetUser.FAILURE:
return { return {
...@@ -128,14 +133,19 @@ export default function reducer( ...@@ -128,14 +133,19 @@ export default function reducer(
user: defaultUser, user: defaultUser,
}, },
}; };
case GetUser.SUCCESS: case GetUser.SUCCESS: {
const { payload } = <GetUserResponse>action;
if (payload === undefined) {
throw Error('payload must be set for GetUser.SUCCESS');
}
return { return {
...state, ...state,
profile: { profile: {
...state.profile, ...state.profile,
user: (<GetUserResponse>action).payload.user, user: payload.user,
}, },
}; };
}
case GetUserOwn.REQUEST: case GetUserOwn.REQUEST:
case GetUserOwn.FAILURE: case GetUserOwn.FAILURE:
return { return {
...@@ -147,14 +157,19 @@ export default function reducer( ...@@ -147,14 +157,19 @@ export default function reducer(
}, },
}, },
}; };
case GetUserOwn.SUCCESS: case GetUserOwn.SUCCESS: {
const { payload } = <GetUserOwnResponse>action;
if (payload === undefined) {
throw Error('payload must be set for GetUserOwn.SUCCESS');
}
return { return {
...state, ...state,
profile: { profile: {
...state.profile, ...state.profile,
own: (<GetUserOwnResponse>action).payload.own, own: payload.own,
}, },
}; };
}
case GetUserRead.REQUEST: case GetUserRead.REQUEST:
case GetUserRead.FAILURE: case GetUserRead.FAILURE:
return { return {
...@@ -164,14 +179,19 @@ export default function reducer( ...@@ -164,14 +179,19 @@ export default function reducer(
read: [], read: [],
}, },
}; };
case GetUserRead.SUCCESS: case GetUserRead.SUCCESS: {
const { payload } = <GetUserReadResponse>action;
if (payload === undefined) {
throw Error('payload must be set for GetUserRead.SUCCESS');
}
return { return {
...state, ...state,
profile: { profile: {
...state.profile, ...state.profile,
read: (<GetUserReadResponse>action).payload.read, read: payload.read,
}, },
}; };
}
default: default:
return state; return state;
} }
......
...@@ -50,7 +50,7 @@ export function logClick( ...@@ -50,7 +50,7 @@ export function logClick(
command: 'click', command: 'click',
target_id: target_id:
target.dataset && target.dataset.type ? target.dataset.type : target.id, target.dataset && target.dataset.type ? target.dataset.type : target.id,
label: target.innerText || target.textContent, label: target.innerText || target.textContent || '',
}; };
if (target.nodeValue !== null) { if (target.nodeValue !== null) {
......
...@@ -39,7 +39,7 @@ describe('ProfilePage', () => { ...@@ -39,7 +39,7 @@ describe('ProfilePage', () => {
const setup = (propOverrides?: Partial<ProfilePageProps>) => { const setup = (propOverrides?: Partial<ProfilePageProps>) => {
const routerProps = getMockRouterProps<RouteProps>( const routerProps = getMockRouterProps<RouteProps>(
{ userId: 'test0' }, { userId: 'test0' },
null undefined
); );
const props: ProfilePageProps = { const props: ProfilePageProps = {
user: globalState.user.profile.user, user: globalState.user.profile.user,
......
...@@ -49,7 +49,10 @@ export class FilterSection extends React.Component<FilterSectionProps> { ...@@ -49,7 +49,10 @@ export class FilterSection extends React.Component<FilterSectionProps> {
} }
if (type === FilterType.CHECKBOX_SELECT) { if (type === FilterType.CHECKBOX_SELECT) {
return ( return (
<CheckBoxFilter categoryId={categoryId} checkboxProperties={options} /> <CheckBoxFilter
categoryId={categoryId}
checkboxProperties={options || []}
/>
); );
} }
}; };
......
...@@ -221,6 +221,7 @@ describe('mapStateToProps', () => { ...@@ -221,6 +221,7 @@ describe('mapStateToProps', () => {
{ {
categoryId: mockSchemaId, categoryId: mockSchemaId,
helpText: mockHelpText, helpText: mockHelpText,
options: [],
title: mockSchemaTitle, title: mockSchemaTitle,
type: FilterType.INPUT_SELECT, type: FilterType.INPUT_SELECT,
}, },
......
...@@ -67,20 +67,21 @@ export class SearchFilter extends React.Component<SearchFilterProps> { ...@@ -67,20 +67,21 @@ export class SearchFilter extends React.Component<SearchFilterProps> {
export const mapStateToProps = (state: GlobalState) => { export const mapStateToProps = (state: GlobalState) => {
const resourceType = state.search.resource; const resourceType = state.search.resource;
const filterCategories = getFilterConfigByResource(resourceType); const filterCategories = getFilterConfigByResource(resourceType);
const filterSections = []; const filterSections: CheckboxFilterSection[] = [];
if (filterCategories) { if (filterCategories) {
filterCategories.forEach((categoryConfig) => { filterCategories.forEach((categoryConfig) => {
const section = { const section: CheckboxFilterSection = {
categoryId: categoryConfig.categoryId, categoryId: categoryConfig.categoryId,
helpText: categoryConfig.helpText, helpText: categoryConfig.helpText,
title: categoryConfig.displayName, title: categoryConfig.displayName,
type: categoryConfig.type, type: categoryConfig.type,
options: [],
}; };
if (categoryConfig.type === FilterType.CHECKBOX_SELECT) { if (categoryConfig.type === FilterType.CHECKBOX_SELECT) {
(section as CheckboxFilterSection).options = categoryConfig.options.map( section.options = categoryConfig.options.map(
({ value, displayName }) => { ({ value, displayName }) => {
return { value, label: displayName }; return { value, label: displayName || '' };
} }
); );
} }
......
...@@ -47,7 +47,7 @@ interface DataPreviewButtonState { ...@@ -47,7 +47,7 @@ interface DataPreviewButtonState {
showModal: boolean; showModal: boolean;
} }
export function getStatusFromCode(httpErrorCode: number) { export function getStatusFromCode(httpErrorCode: number | null) {
switch (httpErrorCode) { switch (httpErrorCode) {
case null: case null:
return LoadingStatus.LOADING; return LoadingStatus.LOADING;
...@@ -139,7 +139,7 @@ export class DataPreviewButton extends React.Component< ...@@ -139,7 +139,7 @@ export class DataPreviewButton extends React.Component<
<div className="grid-cell grid-header subtitle-3"> <div className="grid-cell grid-header subtitle-3">
{fieldName.toUpperCase()} {fieldName.toUpperCase()}
</div> </div>
{previewData.data.map((row, rowId) => { {(previewData.data || []).map((row, rowId) => {
const cellId = `${colId}:${rowId}`; const cellId = `${colId}:${rowId}`;
const dataItemValue = this.getSanitizedValue(row[fieldName]); const dataItemValue = this.getSanitizedValue(row[fieldName]);
return ( return (
......
...@@ -34,7 +34,7 @@ class WatermarkLabel extends React.Component<WatermarkLabelProps> { ...@@ -34,7 +34,7 @@ class WatermarkLabel extends React.Component<WatermarkLabelProps> {
return (watermark && watermark.partition_value) || null; return (watermark && watermark.partition_value) || null;
}; };
renderWatermarkInfo = (low: string, high: string) => { renderWatermarkInfo = (low: string | null, high: string | null) => {
if (low === null && high === null) { if (low === null && high === null) {
return ( return (
<div className="body-2"> <div className="body-2">
......
...@@ -179,12 +179,7 @@ export class TableDetail extends React.Component< ...@@ -179,12 +179,7 @@ export class TableDetail extends React.Component<
return descriptions.map((d) => ( return descriptions.map((d) => (
<EditableSection key={`prog_desc:${d.source}`} title={d.source} readOnly> <EditableSection key={`prog_desc:${d.source}`} title={d.source} readOnly>
<EditableText <EditableText maxLength={999999} value={d.text} editable={false} />
maxLength={999999}
value={d.text}
editable={false}
onSubmitValue={null}
/>
</EditableSection> </EditableSection>
)); ));
}; };
...@@ -327,7 +322,7 @@ export class TableDetail extends React.Component< ...@@ -327,7 +322,7 @@ export class TableDetail extends React.Component<
title={Constants.DESCRIPTION_TITLE} title={Constants.DESCRIPTION_TITLE}
readOnly={!data.is_editable} readOnly={!data.is_editable}
editText={editText} editText={editText}
editUrl={editUrl} editUrl={editUrl || undefined}
> >
<TableDescEditableText <TableDescEditableText
maxLength={getMaxLength('tableDescLength')} maxLength={getMaxLength('tableDescLength')}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment