Compare commits

..

1 Commits

Author SHA1 Message Date
sunilyadav840
bb134a2441 fixed ts strict issue of useSubscription useDatabaseAccount markdown-cells text-file 2021-08-30 18:28:33 +05:30
7 changed files with 29 additions and 38 deletions

View File

@@ -1,7 +1,7 @@
import { shallow } from "enzyme";
import React from "react";
import "../../../../externals/jquery.typeahead.min.js";
import { shallow } from "enzyme";
import { InputTypeaheadComponent, InputTypeaheadComponentProps } from "./InputTypeaheadComponent";
import "../../../../externals/jquery.typeahead.min.js";
describe("inputTypeahead", () => {
it("renders <input />", () => {
@@ -12,12 +12,6 @@ describe("inputTypeahead", () => {
],
placeholder: "placeholder",
useTextarea: false,
onNewValue: () => {
("");
},
submitFct: () => {
("");
},
};
const wrapper = shallow(<InputTypeaheadComponent {...props} />);
@@ -32,12 +26,6 @@ describe("inputTypeahead", () => {
],
placeholder: "placeholder",
useTextarea: true,
onNewValue: () => {
("");
},
submitFct: () => {
("");
},
};
const wrapper = shallow(<InputTypeaheadComponent {...props} />);

View File

@@ -33,7 +33,7 @@ export interface InputTypeaheadComponentProps {
/**
* The current string value of <input>
*/
onNewValue: (newValue?: string) => void;
onNewValue?: (newValue: string) => void;
// inputValue?:ko.Observable<string>;
/**
@@ -55,7 +55,7 @@ export interface InputTypeaheadComponentProps {
/**
* This function gets called when pressing ENTER on the input box
*/
submitFct?: (inputValue?: string, selection?: Item) => void;
submitFct?: (inputValue: string, selection: Item) => void;
/**
* Typehead comes with a Search button that we normally remove.
@@ -76,7 +76,7 @@ export interface InputTypeaheadComponentProps {
interface InputTypeaheadComponentState {
isSuggestionVisible: boolean;
selectedChoice?: Item;
selectedChoice: Item;
filteredChoices: Item[];
}
@@ -96,21 +96,21 @@ export class InputTypeaheadComponent extends React.Component<
};
}
private onRenderCell = (item?: Item): JSX.Element => {
private onRenderCell = (item: Item): JSX.Element => {
return (
<div className="input-typeahead-chocies-container" onClick={() => this.onChoiceClick(item)}>
<p className="choice-caption">{item?.caption}</p>
<span>{item?.value}</span>
<p className="choice-caption">{item.caption}</p>
<span>{item.value}</span>
</div>
);
};
private onChoiceClick = (item?: Item): void => {
this.props.onNewValue(item?.caption);
private onChoiceClick = (item: Item): void => {
this.props.onNewValue(item.caption);
this.setState({ isSuggestionVisible: false, selectedChoice: item });
};
private handleChange = (value?: string): void => {
private handleChange = (value: string): void => {
if (!value) {
this.setState({ isSuggestionVisible: true });
}
@@ -130,7 +130,7 @@ export class InputTypeaheadComponent extends React.Component<
}
};
private filterChoiceByValue = (choices: Item[], searchKeyword?: string): Item[] => {
private filterChoiceByValue = (choices: Item[], searchKeyword: string): Item[] => {
return choices.filter((choice) =>
// @ts-ignore
Object.keys(choice).some((key) => choice[key].toLowerCase().includes(searchKeyword.toLowerCase()))
@@ -138,7 +138,7 @@ export class InputTypeaheadComponent extends React.Component<
};
public render(): JSX.Element {
const { defaultValue, useTextarea, placeholder, onNewValue, submitFct } = this.props;
const { defaultValue, useTextarea, placeholder, onNewValue } = this.props;
const { isSuggestionVisible, selectedChoice, filteredChoices } = this.state;
const theme = getTheme();
@@ -185,7 +185,7 @@ export class InputTypeaheadComponent extends React.Component<
styles={iconButtonStyles}
iconProps={searchIcon}
ariaLabel="Search Button"
onClick={() => submitFct && submitFct(defaultValue, selectedChoice)}
onClick={() => this.props.submitFct(defaultValue, selectedChoice)}
/>
)}
</Stack>

View File

@@ -18,7 +18,7 @@ const EditorContainer = styled.div`
`;
interface MappedStateProps {
mimetype: string;
mimetype: string | null;
text: string;
contentRef: ContentRef;
theme?: "light" | "dark";
@@ -37,7 +37,7 @@ interface TextFileState {
class EditorPlaceholder extends React.PureComponent<MonacoEditorProps> {
render(): JSX.Element {
// TODO: Show a little blocky placeholder
return undefined;
return <div />;
}
}
@@ -83,7 +83,7 @@ interface InitialProps {
}
function makeMapStateToTextFileProps(
initialState: AppState,
_initialState: AppState,
initialProps: InitialProps
): (state: AppState) => MappedStateProps {
const { contentRef } = initialProps;
@@ -106,7 +106,7 @@ function makeMapStateToTextFileProps(
}
const makeMapDispatchToTextFileProps = (
initialDispatch: Dispatch,
_initialDispatch: Dispatch,
initialProps: InitialProps
): ((dispatch: Dispatch) => MappedDispatchProps) => {
const { contentRef } = initialProps;

View File

@@ -99,7 +99,7 @@ export class PureMarkdownCell extends React.Component<ComponentProps & DispatchP
}
export const makeMapStateToProps = (
initialState: AppState,
_initialState: AppState,
ownProps: ComponentProps
): ((state: AppState) => StateProps) => {
const { id, contentRef } = ownProps;
@@ -134,7 +134,7 @@ export const makeMapStateToProps = (
};
const makeMapDispatchToProps = (
initialDispatch: Dispatch,
_initialDispatch: Dispatch,
ownProps: ComponentProps
): ((dispatch: Dispatch) => DispatchProps) => {
const { id, contentRef } = ownProps;

View File

@@ -32,8 +32,9 @@ export async function fetchDatabaseAccounts(subscriptionId: string, accessToken:
export function useDatabaseAccounts(subscriptionId: string, armToken: string): DatabaseAccount[] | undefined {
const { data } = useSWR(
() => (armToken && subscriptionId ? ["databaseAccounts", subscriptionId, armToken] : undefined),
(_, subscriptionId, armToken) => fetchDatabaseAccounts(subscriptionId, armToken)
// eslint-disable-next-line no-null/no-null
() => (armToken && subscriptionId ? ["databaseAccounts", subscriptionId, armToken] : null),
(_: string, subscriptionId: string, armToken: string) => fetchDatabaseAccounts(subscriptionId, armToken)
);
return data;
}

View File

@@ -34,8 +34,9 @@ export async function fetchSubscriptions(accessToken: string): Promise<Subscript
export function useSubscriptions(armToken: string): Subscription[] | undefined {
const { data } = useSWR(
() => (armToken ? ["subscriptions", armToken] : undefined),
(_, armToken) => fetchSubscriptions(armToken)
// eslint-disable-next-line no-null/no-null
() => (armToken ? ["subscriptions", armToken] : null),
(_: string, armToken: string) => fetchSubscriptions(armToken)
);
return data;
}

View File

@@ -8,8 +8,9 @@
"noUnusedParameters": true
},
"files": [
"./src/Explorer/Controls/InputTypeahead/InputTypeaheadComponent.tsx",
"./src/Explorer/Controls/InputTypeahead/InputTypeaheadComponent.test.tsx",
"./src/hooks/useDatabaseAccounts.tsx",
"./src/hooks/useSubscriptions.tsx",
"./src/Explorer/Notebook/NotebookComponent/contents/file/text-file.tsx",
"./src/AuthType.ts",
"./src/Bindings/ReactBindingHandler.ts",
"./src/Common/ArrayHashMap.ts",