Unverified Commit 37ee7640 authored by Dorian Johnson's avatar Dorian Johnson Committed by GitHub

chore: cleanup simple typings (#753)

Signed-off-by: 's avatarMarcos Iglesias Valle <golodhros@gmail.com>
parent cd2c3659
// BETTERER RESULTS V2.
exports[`strict null compilation`] = {
value: `{
"js/components/Feedback/index.tsx:48207164": [
[45, 6, 7, "Type \'FC<any> | undefined\' is not assignable to type \'FC<any>\'.\\n Type \'undefined\' is not assignable to type \'FunctionComponent<any>\'.", "3716929964"]
],
"js/components/NavBar/index.spec.tsx:4130335159": [
[53, 54, 8, "Argument of type \'Partial<Location<{} | null | undefined>> | undefined\' is not assignable to parameter of type \'Partial<Location<{} | null | undefined>>\'.\\n Type \'undefined\' is not assignable to type \'Partial<Location<{} | null | undefined>>\'.", "2700611480"],
[99, 39, 4, "Argument of type \'null\' is not assignable to parameter of type \'Partial<NavBarProps> | undefined\'.", "2087897566"],
[100, 32, 36, "No overload matches this call.\\n Overload 1 of 3, \'(node: ReactElement<any, string | ((props: any) => ReactElement<any, string | ... | (new (props: any) => Component<any, any, any>)> | null) | (new (props: any) => Component<any, any, any>)>, options?: ShallowRendererProps | undefined): ShallowWrapper<...>\', gave the following error.\\n Argument of type \'Element | null\' is not assignable to parameter of type \'ReactElement<any, string | ((props: any) => ReactElement<any, string | ... | (new (props: any) => Component<any, any, any>)> | null) | (new (props: any) => Component<any, any, any>)>\'.\\n Type \'null\' is not assignable to type \'ReactElement<any, string | ((props: any) => ReactElement<any, string | ... | (new (props: any) => Component<any, any, any>)> | null) | (new (props: any) => Component<any, any, any>)>\'.\\n Overload 2 of 3, \'(node: ReactElement<any, string | ((props: any) => ReactElement<any, string | ... | (new (props: any) => Component<any, any, any>)> | null) | (new (props: any) => Component<any, any, any>)>, options?: ShallowRendererProps | undefined): ShallowWrapper<...>\', gave the following error.\\n Argument of type \'Element | null\' is not assignable to parameter of type \'ReactElement<any, string | ((props: any) => ReactElement<any, string | ... | (new (props: any) => Component<any, any, any>)> | null) | (new (props: any) => Component<any, any, any>)>\'.\\n Type \'null\' is not assignable to type \'ReactElement<any, string | ((props: any) => ReactElement<any, string | ... | (new (props: any) => Component<any, any, any>)> | null) | (new (props: any) => Component<any, any, any>)>\'.\\n Overload 3 of 3, \'(node: ReactElement<any, string | ((props: any) => ReactElement<any, string | ... | (new (props: any) => Component<any, any, any>)> | null) | (new (props: any) => Component<any, any, any>)>, options?: ShallowRendererProps | undefined): ShallowWrapper<...>\', gave the following error.\\n Argument of type \'Element | null\' is not assignable to parameter of type \'ReactElement<any, string | ((props: any) => ReactElement<any, string | ... | (new (props: any) => Component<any, any, any>)> | null) | (new (props: any) => Component<any, any, any>)>\'.\\n Type \'null\' is not assignable to type \'ReactElement<any, string | ((props: any) => ReactElement<any, string | ... | (new (props: any) => Component<any, any, any>)> | null) | (new (props: any) => Component<any, any, any>)>\'.", "788521834"],
[110, 39, 4, "Argument of type \'null\' is not assignable to parameter of type \'Partial<NavBarProps> | undefined\'.", "2087897566"]
],
"js/components/common/Announcements/AnnouncementsList/index.spec.tsx:3063969618": [
[97, 23, 124, "Object is possibly \'null\'.", "4248337497"]
],
"js/components/common/Announcements/AnnouncementsList/index.tsx:2274670610": [
[73, 4, 11, "Type \'Element\' is not assignable to type \'null\'.", "3768376622"],
[76, 4, 11, "Type \'Element[]\' is not assignable to type \'null\'.", "3768376622"],
[88, 4, 11, "Type \'Element\' is not assignable to type \'null\'.", "3768376622"],
[91, 4, 11, "Type \'Element[]\' is not assignable to type \'null\'.", "3768376622"]
],
"js/components/common/Bookmark/MyBookmarks/index.tsx:3008297487": [
[66, 6, 7, "Type \'Element | null\' is not assignable to type \'never\'.\\n Type \'null\' is not assignable to type \'never\'.", "3716929964"],
[67, 6, 3, "Type \'string\' is not assignable to type \'never\'.", "193424690"],
[68, 6, 5, "Type \'string\' is not assignable to type \'never\'.", "183222373"],
[73, 8, 7, "Type \'Element | null\' is not assignable to type \'never\'.\\n Type \'null\' is not assignable to type \'never\'.", "3716929964"],
[74, 8, 3, "Type \'string\' is not assignable to type \'never\'.", "193424690"],
[75, 8, 5, "Type \'string\' is not assignable to type \'never\'.", "183222373"]
],
"js/components/common/Card/index.spec.tsx:3613684009": [
[161, 23, 100, "Object is possibly \'null\'.", "1846024709"]
"js/components/common/Bookmark/MyBookmarks/index.tsx:3695929904": [
[66, 6, 7, "Type \'Element | null\' is not assignable to type \'Element | undefined\'.\\n Type \'null\' is not assignable to type \'Element | undefined\'.", "3716929964"],
[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": [
[35, 2, 7, "Type \'null\' is not assignable to type \'(e: SyntheticEvent<Element, Event>) => void\'.", "4055953994"]
......@@ -36,19 +17,6 @@ exports[`strict null compilation`] = {
"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/EditableSection/index.tsx:3911151831": [
[130, 12, 7, "Type \'((event: MouseEvent<HTMLDivElement, MouseEvent>) => void) | null\' is not assignable to type \'((event: MouseEvent<HTMLDivElement, MouseEvent>) => void) | undefined\'.\\n Type \'null\' is not assignable to type \'((event: MouseEvent<HTMLDivElement, MouseEvent>) => void) | undefined\'.", "4055953994"]
],
"js/components/common/EditableText/index.tsx:4277986546": [
[55, 4, 13, "Type \'null\' is not assignable to type \'(newValue: string, onSuccess?: (() => any) | undefined, onFailure?: (() => any) | undefined) => void\'.", "67794331"],
[56, 4, 14, "Type \'null\' is not assignable to type \'((onSuccess?: (() => any) | undefined, onFailure?: (() => any) | undefined) => void) | undefined\'.", "608289123"],
[92, 4, 22, "Cannot invoke an object which is possibly \'undefined\'.", "2225424112"],
[96, 4, 22, "Cannot invoke an object which is possibly \'undefined\'.", "2225424112"],
[111, 6, 22, "Cannot invoke an object which is possibly \'undefined\'.", "2225424112"]
],
"js/components/common/EntityCard/EntityCardSection/index.tsx:1870704847": [
[40, 4, 23, "Object is possibly \'null\'.", "1725552512"]
],
"js/components/common/Flag/index.tsx:814006609": [
[26, 27, 8, "Argument of type \'CaseType | null\' is not assignable to parameter of type \'CaseType\'.\\n Type \'null\' is not assignable to type \'CaseType\'.", "4036080041"]
],
......@@ -56,24 +24,12 @@ exports[`strict null compilation`] = {
[21, 6, 9, "Type \'null\' is not assignable to type \'boolean | undefined\'.", "1517648899"],
[24, 6, 8, "Type \'null\' is not assignable to type \'boolean | undefined\'.", "2673870115"]
],
"js/components/common/OwnerEditor/index.tsx:487917110": [
[119, 27, 6, "Type \'import(\\"./js/interfaces/Enums\\").UpdateMethod\' is not assignable to type \'never\'.", "1469012122"],
[119, 56, 2, "Type \'string\' is not assignable to type \'never\'.", "5861160"],
[124, 27, 6, "Type \'import(\\"./js/interfaces/Enums\\").UpdateMethod\' is not assignable to type \'never\'.", "1469012122"],
[124, 53, 2, "Type \'string\' is not assignable to type \'never\'.", "5861160"],
"js/components/common/OwnerEditor/index.tsx:459308532": [
[147, 12, 5, "Property \'value\' does not exist on type \'HTMLInputElement | null\'.", "189936718"]
],
"js/components/common/ResourceListItem/DashboardListItem/index.spec.tsx:53357032": [
[163, 14, 29, "Type \'null\' is not assignable to type \'number\'.", "1157138603"]
],
"js/components/common/ResourceListItem/TableListItem/index.spec.tsx:218296957": [
[161, 14, 18, "Type \'null\' is not assignable to type \'string | undefined\'.", "3750638477"],
[229, 14, 6, "Type \'null\' is not assignable to type \'Badge[] | undefined\'.", "1502764275"]
],
"js/components/common/ResourceListItem/UserListItem/index.tsx:942740425": [
[29, 21, 49, "Argument of type \'Element\' is not assignable to parameter of type \'never\'.", "2430213531"],
[32, 21, 49, "Argument of type \'Element\' is not assignable to parameter of type \'never\'.", "1883272571"]
],
"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"]
],
......@@ -91,28 +47,14 @@ exports[`strict null compilation`] = {
[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"]
],
"js/components/common/Tags/TagInput/index.tsx:3754832290": [
"js/components/common/Tags/TagInput/index.tsx:1066848945": [
[63, 22, 6, "Type \'undefined\' is not assignable to type \'GetAllTagsRequest\'.", "1979467425"],
[66, 4, 4, "Type \'undefined\' is not assignable to type \'Tag[]\'.", "2087952548"],
[67, 22, 6, "Type \'undefined\' is not assignable to type \'UpdateTagsRequest\'.", "1979467425"],
[100, 31, 10, "Type \'import(\\"./js/interfaces/Enums\\").UpdateMethod\' is not assignable to type \'never\'.", "3392756765"],
[100, 64, 7, "Type \'string\' is not assignable to type \'never\'.", "1671693616"],
[102, 31, 10, "Type \'import(\\"./js/interfaces/Enums\\").UpdateMethod\' is not assignable to type \'never\'.", "3392756765"],
[102, 61, 7, "Type \'string\' is not assignable to type \'never\'.", "1671693616"]
[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/components/common/Tags/index.tsx:171117907": [
[67, 49, 13, "Object is possibly \'undefined\'.", "4085240695"],
[77, 4, 11, "Type \'Tag[]\' is not assignable to type \'never[]\'.\\n Type \'Tag\' is not assignable to type \'never\'.", "4011456884"],
[80, 4, 9, "Type \'Tag[]\' is not assignable to type \'never[]\'.", "3803340896"],
[90, 15, 11, "Object is possibly \'undefined\'.", "2324562820"],
[90, 29, 11, "Object is possibly \'undefined\'.", "430779911"],
[93, 4, 11, "Type \'Tag[]\' is not assignable to type \'never[]\'.", "255414113"],
[98, 4, 9, "Type \'Tag[]\' is not assignable to type \'never[]\'.", "3803340896"]
],
"js/config/config-utils.ts:3097983516": [
[87, 4, 25, "\'style\' is specified more than once, so this usage will be overwritten.", "1214862559"]
],
......@@ -125,23 +67,13 @@ exports[`strict null compilation`] = {
[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/bookmark/index.spec.ts:2451112669": [
[86, 13, 7, "Object is possibly \'undefined\'.", "2531329355"],
[104, 13, 7, "Object is possibly \'undefined\'.", "2531329355"],
[124, 13, 7, "Object is possibly \'undefined\'.", "2531329355"],
[144, 13, 7, "Object is possibly \'undefined\'.", "2531329355"],
[145, 13, 7, "Object is possibly \'undefined\'.", "2531329355"]
],
"js/ducks/bookmark/reducer.ts:1596344454": [
[126, 21, 38, "Object is possibly \'undefined\'.", "2378953250"],
[139, 26, 45, "Object is possibly \'undefined\'.", "2845005480"],
[143, 14, 11, "Property \'resourceKey\' does not exist on type \'{ resourceKey: string; resourceType: ResourceType; } | undefined\'.", "2431704504"],
[143, 27, 12, "Property \'resourceType\' does not exist on type \'{ resourceKey: string; resourceType: ResourceType; } | undefined\'.", "2937713623"]
],
"js/ducks/dashboard/reducer.ts:562296055": [
[49, 2, 17, "Type \'null\' is not assignable to type \'number\'.", "2818833716"],
[61, 2, 17, "Type \'null\' is not assignable to type \'number\'.", "3048879712"],
[64, 2, 17, "Type \'null\' is not assignable to type \'number\'.", "1885086497"],
"js/ducks/dashboard/reducer.ts:1902488284": [
[71, 2, 10, "Type \'null\' is not assignable to type \'number\'.", "3382497788"],
[83, 8, 10, "Type \'null\' is not assignable to type \'number\'.", "3382497788"]
],
......@@ -170,9 +102,6 @@ exports[`strict null compilation`] = {
[43, 21, 40, "Object is possibly \'undefined\'.", "195627832"],
[47, 8, 11, "Type \'null\' is not assignable to type \'number\'.", "1159268112"]
],
"js/ducks/lastIndexed/tests/index.spec.ts:3678025492": [
[37, 13, 7, "Object is possibly \'undefined\'.", "2531329355"]
],
"js/ducks/notification/tests/index.spec.ts:2474130513": [
[197, 43, 4, "Argument of type \'null\' is not assignable to parameter of type \'SubmitNotificationRequest\'.", "2087897566"]
],
......@@ -215,12 +144,6 @@ exports[`strict null compilation`] = {
"js/ducks/tags/reducer.ts:419330645": [
[130, 16, 48, "Object is possibly \'undefined\'.", "1931932323"]
],
"js/ducks/user/index.spec.ts:3598813627": [
[65, 13, 7, "Object is possibly \'undefined\'.", "2531329355"],
[84, 13, 7, "Object is possibly \'undefined\'.", "2531329355"],
[103, 13, 7, "Object is possibly \'undefined\'.", "2531329355"],
[122, 13, 7, "Object is possibly \'undefined\'.", "2531329355"]
],
"js/ducks/user/reducer.ts:1917256202": [
[119, 22, 41, "Object is possibly \'undefined\'.", "291980569"],
[135, 16, 33, "Object is possibly \'undefined\'.", "625812796"],
......@@ -252,32 +175,9 @@ exports[`strict null compilation`] = {
"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>>\'.", "2087897566"]
],
"js/pages/ProfilePage/index.tsx:1096157973": [
[178, 6, 7, "Type \'Element\' is not assignable to type \'never\'.", "3716929964"],
[179, 6, 3, "Type \'string\' is not assignable to type \'never\'.", "193424690"],
[180, 6, 5, "Type \'string\' is not assignable to type \'never\'.", "183222373"],
[185, 8, 7, "Type \'Element\' is not assignable to type \'never\'.", "3716929964"],
[186, 8, 3, "Type \'string\' is not assignable to type \'never\'.", "193424690"],
[187, 8, 5, "Type \'string\' is not assignable to type \'never\'.", "183222373"],
[204, 6, 6, "Type \'Element\' is not assignable to type \'null\'.", "1320372020"],
[206, 6, 6, "Type \'Element\' is not assignable to type \'null\'.", "1320372020"],
[211, 6, 8, "Type \'Element\' is not assignable to type \'null\'.", "2362717523"],
[215, 6, 8, "Type \'Element\' is not assignable to type \'null\'.", "2362717523"],
[222, 6, 7, "Type \'Element\' is not assignable to type \'null\'.", "2834855792"],
[224, 6, 7, "Type \'Element\' is not assignable to type \'null\'.", "2834855792"],
[240, 6, 9, "Type \'Element\' is not assignable to type \'null\'.", "4194995369"],
[244, 6, 9, "Type \'Element\' is not assignable to type \'null\'.", "4194995369"],
[260, 6, 11, "Type \'Element\' is not assignable to type \'null\'.", "4082075310"],
[264, 6, 11, "Type \'Element\' is not assignable to type \'null\'.", "4082075310"],
[280, 6, 10, "Type \'Element\' is not assignable to type \'null\'.", "1383320160"],
[284, 6, 10, "Type \'Element\' is not assignable to type \'null\'.", "1383320160"],
"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"]
],
"js/pages/SearchPage/SearchFilter/FilterSection/index.spec.tsx:3610496091": [
[59, 13, 7, "Object is possibly \'undefined\'.", "3716929964"],
[72, 13, 7, "Object is possibly \'undefined\'.", "3716929964"],
[73, 13, 7, "Object is possibly \'undefined\'.", "3716929964"]
],
"js/pages/SearchPage/SearchFilter/FilterSection/index.tsx:2128122504": [
[51, 48, 18, "Type \'CheckboxFilterProperties[] | undefined\' is not assignable to type \'CheckboxFilterProperties[]\'.\\n Type \'undefined\' is not assignable to type \'CheckboxFilterProperties[]\'.", "12656471"]
],
......@@ -305,9 +205,6 @@ exports[`strict null compilation`] = {
[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/SourceLink/index.spec.tsx:4194369848": [
[42, 21, 100, "Object is possibly \'null\'.", "1316242242"]
],
"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"]
],
......@@ -328,9 +225,6 @@ exports[`strict null compilation`] = {
[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"]
],
"js/utils/navigationUtils.ts:1127210474": [
[19, 50, 21, "Type \'undefined\' cannot be used as an index type.", "602535635"]
],
"webpack.common.ts:1615757453": [
[42, 24, 20, "No overload matches this call.\\n Overload 1 of 2, \'(...items: ConcatArray<never>[]): never[]\', gave the following error.\\n Argument of type \'string\' is not assignable to parameter of type \'ConcatArray<never>\'.\\n Overload 2 of 2, \'(...items: ConcatArray<never>[]): never[]\', gave the following error.\\n Argument of type \'string\' is not assignable to parameter of type \'ConcatArray<never>\'.", "806093104"]
]
......
......@@ -18,7 +18,7 @@ export interface FeedbackProps {
}
interface FeedbackState {
content: React.FC<any>;
content?: React.FC<any>;
feedbackType: FeedbackType;
isOpen: boolean;
}
......
......@@ -98,7 +98,7 @@ describe('AnnouncementsList', () => {
const actual = wrapper
.find('a.announcements-list-more-link')
.getDOMNode()
.attributes.getNamedItem('href').value;
.attributes.getNamedItem('href')?.value;
expect(actual).toEqual(expected);
});
......
......@@ -68,10 +68,10 @@ const AnnouncementsList: React.FC<AnnouncementsListProps> = ({
isLoading,
}: AnnouncementsListProps) => {
const isEmpty = announcements.length === 0;
let listContent = null;
let listContent: JSX.Element[] = [];
if (isEmpty) {
listContent = <EmptyAnnouncementItem />;
listContent = [<EmptyAnnouncementItem />];
}
if (announcements.length > 0) {
listContent = getLatestsAnnouncements(
......@@ -86,7 +86,7 @@ const AnnouncementsList: React.FC<AnnouncementsListProps> = ({
));
}
if (hasError) {
listContent = <AnnouncementErrorItem />;
listContent = [<AnnouncementErrorItem />];
}
if (isLoading) {
listContent = times(3).map((_, index) => (
......
......@@ -12,7 +12,7 @@ import {
indexDashboardsEnabled,
} from 'config/config-utils';
import PaginatedResourceList from 'components/common/ResourceList/PaginatedResourceList';
import TabsComponent from 'components/common/TabsComponent';
import TabsComponent, { TabInfo } from 'components/common/TabsComponent';
import ShimmeringResourceLoader from 'components/common/ShimmeringResourceLoader';
import {
BOOKMARK_TITLE,
......@@ -29,7 +29,7 @@ interface StateFromProps {
export type MyBookmarksProps = StateFromProps;
export class MyBookmarks extends React.Component<MyBookmarksProps> {
generateTabContent = (resource: ResourceType) => {
generateTabContent = (resource: ResourceType): JSX.Element | null => {
const bookmarks = this.props.myBookmarks[resource];
if (!bookmarks) {
......@@ -60,8 +60,8 @@ export class MyBookmarks extends React.Component<MyBookmarksProps> {
return `${getDisplayNameByResource(resource)} (${bookmarks.length})`;
};
generateTabInfo = () => {
const tabInfo = [];
generateTabInfo = (): TabInfo[] => {
const tabInfo: TabInfo[] = [];
tabInfo.push({
content: this.generateTabContent(ResourceType.table),
......
......@@ -162,7 +162,7 @@ describe('Card', () => {
const actual = wrapper
.find('a.card')
.getDOMNode()
.attributes.getNamedItem('href').value;
.attributes.getNamedItem('href')?.value;
expect(actual).toEqual(expected);
});
......
......@@ -128,7 +128,7 @@ export class EditableSection extends React.Component<
<label className="editable-section-label">
<div
className="editable-section-label-wrapper"
onClick={!readOnly ? this.preventDefault : null}
onClick={!readOnly ? this.preventDefault : undefined}
>
<span className="section-title title-3">
{EditableSection.convertText(title)}
......
......@@ -21,7 +21,7 @@ export interface StateFromProps {
export interface DispatchFromProps {
getLatestValue?: (onSuccess?: () => any, onFailure?: () => any) => void;
onSubmitValue: (
onSubmitValue?: (
newValue: string,
onSuccess?: () => any,
onFailure?: () => any
......@@ -53,8 +53,6 @@ class EditableText extends React.Component<
public static defaultProps: EditableTextProps = {
editable: true,
maxLength: 250,
onSubmitValue: null,
getLatestValue: null,
value: '',
};
......@@ -90,11 +88,11 @@ class EditableText extends React.Component<
}
exitEditMode = () => {
this.props.setEditMode(false);
this.props.setEditMode?.(false);
};
enterEditMode = () => {
this.props.setEditMode(true);
this.props.setEditMode?.(true);
};
refreshText = () => {
......@@ -109,14 +107,14 @@ class EditableText extends React.Component<
updateText = () => {
const newValue = this.textAreaRef.current.value;
const onSuccessCallback = () => {
this.props.setEditMode(false);
this.props.setEditMode?.(false);
this.setState({ value: newValue });
};
const onFailureCallback = () => {
this.exitEditMode();
};
this.props.onSubmitValue(newValue, onSuccessCallback, onFailureCallback);
this.props.onSubmitValue?.(newValue, onSuccessCallback, onFailureCallback);
};
render() {
......
......@@ -38,7 +38,7 @@ class EntityCardSection extends React.Component<
if (this.props.isEditable) {
this.setState({ readOnly: !this.state.readOnly });
}
this.editButton.current.blur();
this.editButton.current?.blur();
}
render() {
......
......@@ -113,7 +113,7 @@ export class OwnerEditor extends React.Component<
const { itemProps, tempItemProps } = this.state;
const { setEditMode, onUpdateList } = this.props;
const updateArray = [];
const updateArray: UpdateOwnerPayload[] = [];
Object.keys(itemProps).forEach((key) => {
if (!tempItemProps.hasOwnProperty(key)) {
......
......@@ -159,7 +159,7 @@ describe('TableListItem', () => {
badges: [{ tag_name: 'badgeName' }],
name: 'tableName',
schema: 'tableSchema',
schema_description: null,
schema_description: undefined,
},
});
expect(
......@@ -227,7 +227,7 @@ describe('TableListItem', () => {
database: '',
description: 'I am the description',
key: '',
badges: null,
badges: undefined,
name: 'tableName',
schema: 'tableSchema',
schema_description: 'schemaDescription',
......
......@@ -19,13 +19,13 @@ class UserListItem extends React.Component<UserListItemProps, {}> {
return `/user/${user.user_id}?index=${logging.index}&source=${logging.source}`;
};
renderUserInfo = (user: UserResource) => {
renderUserInfo = (user: UserResource): JSX.Element[] | null => {
const { role_name, team_name, user_id } = user;
if (!role_name && !team_name) {
return null;
}
const listItems = [];
const listItems: JSX.Element[] = [];
if (role_name) {
listItems.push(<li key={`${user_id}:role_name`}>{role_name}</li>);
}
......
......@@ -14,7 +14,7 @@ export interface TabsProps {
}
export interface TabInfo {
content: JSX.Element;
content?: JSX.Element;
key: string;
title: string | JSX.Element;
}
......
......@@ -64,7 +64,7 @@ class TagInput extends React.Component<TagInputProps, TagInputState> {
getAllTags: () => void 0,
isLoading: false,
resourceType: ResourceType.table,
tags: undefined,
tags: [],
updateTags: () => void 0,
uriKey: '',
};
......@@ -95,12 +95,12 @@ class TagInput extends React.Component<TagInputProps, TagInputState> {
handleSaveModalEdit = () => {
const tagArray = Object.keys(this.batchEditSet).reduce(
(previousValue, tag) => {
const action = this.batchEditSet[tag];
(previousValue: UpdateTagData[], tagName) => {
const action = this.batchEditSet[tagName];
if (action === BatchEditState.DELETE) {
previousValue.push({ methodName: UpdateMethod.DELETE, tagName: tag });
previousValue.push({ methodName: UpdateMethod.DELETE, tagName });
} else if (action === BatchEditState.PUT) {
previousValue.push({ methodName: UpdateMethod.PUT, tagName: tag });
previousValue.push({ methodName: UpdateMethod.PUT, tagName });
}
return previousValue;
},
......
......@@ -65,13 +65,15 @@ export const mapStateToProps = (state: GlobalState) => {
// TODO: These functions are selectors, consider moving them into the ducks
const allTags = state.tags.allTags.tags;
const allTagsNoZeros = allTags.filter((tag) => tag.tag_count > 0);
const allTagsNoZeros = allTags.filter(
(tag) => tag.tag_count !== undefined && tag.tag_count > 0
);
const curatedTagsList = getCuratedTags();
let curatedTags = [];
let popularTags = [];
let otherTags = [];
let curatedTags: Tag[] = [];
let popularTags: Tag[] = [];
let otherTags: Tag[] = [];
if (curatedTagsList.length > 0) {
// keeping curated tags with zero usage count
......@@ -88,6 +90,9 @@ export const mapStateToProps = (state: GlobalState) => {
} else {
const tagsByUsage = allTagsNoZeros
.sort((a, b) => {
if (a.tag_count === undefined || b.tag_count === undefined) {
return 0;
}
return a.tag_count - b.tag_count;
})
.reverse();
......
......@@ -84,7 +84,7 @@ describe('bookmark ducks', () => {
const action = addBookmarkSuccess(bookmarks);
const { payload } = action;
expect(action.type).toBe(AddBookmark.SUCCESS);
expect(payload.bookmarks).toBe(bookmarks);
expect(payload?.bookmarks).toBe(bookmarks);
});
it('getBookmarks - returns the action to get bookmarks', () => {
......@@ -102,7 +102,7 @@ describe('bookmark ducks', () => {
const action = getBookmarksSuccess(bookmarks);
const { payload } = action;
expect(action.type).toBe(GetBookmarks.SUCCESS);
expect(payload.bookmarks).toBe(bookmarks);
expect(payload?.bookmarks).toBe(bookmarks);
});
it('getBookmarksForUser - returns the action to get bookmarks for a user', () => {
......@@ -122,7 +122,7 @@ describe('bookmark ducks', () => {
const action = getBookmarksForUserSuccess(bookmarks);
const { payload } = action;
expect(action.type).toBe(GetBookmarksForUser.SUCCESS);
expect(payload.bookmarks).toBe(bookmarks);
expect(payload?.bookmarks).toBe(bookmarks);
});
it('removeBookmark - returns the action to remove a bookmark', () => {
......@@ -142,8 +142,8 @@ describe('bookmark ducks', () => {
const action = removeBookmarkSuccess(testResourceKey, testResourceType);
const { payload } = action;
expect(action.type).toBe(RemoveBookmark.SUCCESS);
expect(payload.resourceKey).toBe(testResourceKey);
expect(payload.resourceType).toBe(testResourceType);
expect(payload?.resourceKey).toBe(testResourceKey);
expect(payload?.resourceType).toBe(testResourceType);
});
});
......
......@@ -47,22 +47,22 @@ export const initialDashboardState: DashboardMetadata = {
badges: [],
chart_names: [],
cluster: '',
created_timestamp: null,
created_timestamp: 0,
description: '',
frequent_users: [],
group_name: '',
group_url: '',
last_run_state: '',
last_run_timestamp: null,
last_successful_run_timestamp: null,
last_run_timestamp: 0,
last_successful_run_timestamp: 0,
name: '',
owners: [],
product: '',
queries: [],
recent_view_count: null,
recent_view_count: 0,
tables: [],
tags: [],
updated_timestamp: null,
updated_timestamp: 0,
uri: '',
url: '',
};
......
......@@ -35,7 +35,7 @@ describe('lastIndexed ducks', () => {
const action = getLastIndexedSuccess(testEpoch);
const { payload } = action;
expect(action.type).toBe(GetLastIndexed.SUCCESS);
expect(payload.lastIndexedEpoch).toBe(testEpoch);
expect(payload?.lastIndexedEpoch).toBe(testEpoch);
});
});
......
......@@ -63,7 +63,7 @@ describe('user ducks', () => {
const action = getLoggedInUserSuccess(currentUser);
const { payload } = action;
expect(action.type).toBe(GetLoggedInUser.SUCCESS);
expect(payload.user).toBe(currentUser);
expect(payload?.user).toBe(currentUser);
});
it('getLoggedInUserFailure - returns the action to process the failure', () => {
......@@ -82,7 +82,7 @@ describe('user ducks', () => {
const action = getUserSuccess(otherUser.user);
const { payload } = action;
expect(action.type).toBe(GetUser.SUCCESS);
expect(payload.user).toBe(otherUser.user);
expect(payload?.user).toBe(otherUser.user);
});
it('getUserFailure - returns the action to process the failure', () => {
......@@ -101,7 +101,7 @@ describe('user ducks', () => {
const action = getUserOwnSuccess(otherUser.own);
const { payload } = action;
expect(action.type).toBe(GetUserOwn.SUCCESS);
expect(payload.own).toBe(otherUser.own);
expect(payload?.own).toBe(otherUser.own);
});
it('getUserOwnFailure - returns the action to process the failure', () => {
......@@ -120,7 +120,7 @@ describe('user ducks', () => {
const action = getUserReadSuccess(otherUser.read);
const { payload } = action;
expect(action.type).toBe(GetUserRead.SUCCESS);
expect(payload.read).toBe(otherUser.read);
expect(payload?.read).toBe(otherUser.read);
});
it('getUserReadFailure - returns the action to process the failure', () => {
......
......@@ -10,7 +10,7 @@ import { bindActionCreators } from 'redux';
import Breadcrumb from 'components/common/Breadcrumb';
import Flag from 'components/common/Flag';
import TabsComponent from 'components/common/TabsComponent';
import TabsComponent, { TabInfo } from 'components/common/TabsComponent';
import { BadgeStyle } from 'config/config-types';
import { GlobalState } from 'ducks/rootReducer';
......@@ -173,7 +173,7 @@ export class ProfilePage extends React.Component<
};
generateTabInfo = () => {
const tabInfo = [];
const tabInfo: TabInfo[] = [];
tabInfo.push({
content: this.generateTabContent(ResourceType.table),
......@@ -200,14 +200,14 @@ export class ProfilePage extends React.Component<
const { user } = this.props;
const isLoading = !user.display_name && !user.email && !user.employee_type;
let avatar = null;
let avatar: JSX.Element | null = null;
if (isLoading) {
avatar = <div className="shimmering-circle is-shimmer-animated" />;
} else if (user.display_name && user.display_name.length > 0) {
avatar = <Avatar name={user.display_name} size={AVATAR_SIZE} round />;
}
let userName = null;
let userName: JSX.Element | null = null;
if (isLoading) {
userName = (
<div className="shimmering-text title-text is-shimmer-animated" />
......@@ -218,7 +218,7 @@ export class ProfilePage extends React.Component<
);
}
let bullets = null;
let bullets: JSX.Element | null = null;
if (isLoading) {
bullets = <div className="shimmering-text bullets is-shimmer-animated" />;
} else {
......@@ -236,7 +236,7 @@ export class ProfilePage extends React.Component<
);
}
let emailLink = null;
let emailLink: JSX.Element | null = null;
if (isLoading) {
emailLink = (
<div className="shimmering-text header-link is-shimmer-animated" />
......@@ -256,7 +256,7 @@ export class ProfilePage extends React.Component<
);
}
let profileLink = null;
let profileLink: JSX.Element | null = null;
if (isLoading) {
profileLink = (
<div className="shimmering-text header-link is-shimmer-animated" />
......@@ -276,7 +276,7 @@ export class ProfilePage extends React.Component<
);
}
let githubLink = null;
let githubLink: JSX.Element | null = null;
if (isLoading) {
githubLink = (
<div className="shimmering-text header-link is-shimmer-animated" />
......
......@@ -55,9 +55,8 @@ describe('FilterSection', () => {
const { props, wrapper } = setup({ type: FilterType.INPUT_SELECT });
const content = wrapper.instance().renderFilterComponent();
// @ts-ignore: This check works but TypeScript complains
expect(content.type.displayName).toBe('Connect(InputFilter)');
expect(content.props.categoryId).toBe(props.categoryId);
expect(content?.type.displayName).toBe('Connect(InputFilter)');
expect(content?.props.categoryId).toBe(props.categoryId);
});
it('returns a CheckBoxFilter w/ correct props if props.type == FilterType.CHECKBOX_SELECT', () => {
......@@ -68,10 +67,9 @@ describe('FilterSection', () => {
});
const content = wrapper.instance().renderFilterComponent();
// @ts-ignore: This check works but TypeScript complains
expect(content.type.displayName).toBe('Connect(CheckBoxFilter)');
expect(content.props.categoryId).toBe(props.categoryId);
expect(content.props.checkboxProperties).toBe(mockOptions);
expect(content?.type.displayName).toBe('Connect(CheckBoxFilter)');
expect(content?.props.categoryId).toBe(props.categoryId);
expect(content?.props.checkboxProperties).toBe(mockOptions);
});
});
......
......@@ -43,7 +43,7 @@ describe('render SourceLink', () => {
const actual = wrapper
.find('.header-link')
.getDOMNode()
.attributes.getNamedItem('href').value;
.attributes.getNamedItem('href')?.value;
expect(actual).toEqual(expected);
});
......
......@@ -17,7 +17,10 @@ export const DEFAULT_SEARCH_ROUTE = '/search';
export const generateSearchUrl = (searchParams: SearchParams): string => {
const filtersForResource =
(searchParams.filters && searchParams.filters[searchParams.resource]) || {};
(searchParams.filters &&
searchParams.resource &&
searchParams.filters[searchParams.resource]) ||
{};
const hasFilters = Object.keys(filtersForResource).length > 0;
// If there is no search input return the search route url
......
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