From 8c7b2c810b83256d85930e8e4e6c91414c3a61c7 Mon Sep 17 00:00:00 2001 From: Paulo Gustavo Veiga Date: Tue, 16 Feb 2021 21:51:59 -0800 Subject: [PATCH] Fix jslint errors. --- packages/webapp/src/app.tsx | 6 +- packages/webapp/src/classes/app-i18n/index.ts | 6 +- .../client/client-health-sentinel/index.tsx | 2 +- .../src/classes/client/mock-client/index.ts | 13 +++- .../src/classes/client/rest-client/index.ts | 13 ++-- .../components/forgot-password-page/index.tsx | 4 +- .../forgot-password-success-page/index.tsx | 4 +- .../components/form/global-error/index.tsx | 6 +- .../src/components/form/input/index.tsx | 2 +- .../components/form/submit-button/index.tsx | 6 +- .../src/components/layout/footer/index.tsx | 2 +- .../src/components/layout/header/index.tsx | 6 +- .../src/components/login-page/index.tsx | 10 ++- .../account-info-dialog/index.tsx | 2 +- .../change-password-dialog/index.tsx | 2 +- .../maps-page/account-menu/index.tsx | 2 +- .../maps-page/action-chooser/index.tsx | 2 +- .../maps-page/action-chooser/styled.ts | 2 +- .../action-dispatcher/base-dialog/index.tsx | 9 +-- .../action-dispatcher/create-dialog/index.tsx | 4 +- .../action-dispatcher/delete-dialog/index.tsx | 8 +- .../delete-multiselect-dialog/index.tsx | 4 +- .../duplicate-dialog/index.tsx | 4 +- .../action-dispatcher/export-dialog/index.tsx | 8 +- .../action-dispatcher/export-dialog/style.ts | 3 +- .../history-dialog/index.tsx | 6 +- .../action-dispatcher/import-dialog/index.tsx | 9 +-- .../maps-page/action-dispatcher/index.tsx | 8 +- .../action-dispatcher/info-dialog/index.tsx | 6 +- .../action-dispatcher/info-dialog/style.ts | 3 +- .../publish-dialog/index.tsx | 2 +- .../action-dispatcher/publish-dialog/style.ts | 3 +- .../action-dispatcher/rename-dialog/index.tsx | 2 +- .../action-dispatcher/share-dialog/index.tsx | 76 +++++++++++++++++++ .../components/maps-page/help-menu/index.tsx | 2 +- .../webapp/src/components/maps-page/index.tsx | 12 +-- .../maps-page/language-menu/index.tsx | 2 +- .../components/maps-page/maps-list/index.tsx | 9 ++- .../components/registration-page/index.tsx | 2 +- .../registration-success-page/index.tsx | 2 +- packages/webapp/src/redux/clientSlice.ts | 10 ++- packages/webapp/webpack.prod.js | 11 ++- yarn.lock | 7 ++ 43 files changed, 203 insertions(+), 99 deletions(-) create mode 100644 packages/webapp/src/components/maps-page/action-dispatcher/share-dialog/index.tsx diff --git a/packages/webapp/src/app.tsx b/packages/webapp/src/app.tsx index 9d45d198..c343d32c 100644 --- a/packages/webapp/src/app.tsx +++ b/packages/webapp/src/app.tsx @@ -1,4 +1,4 @@ -import React from 'react'; +import React, { ReactElement } from 'react'; import { IntlProvider } from 'react-intl'; import { Route, Switch, Redirect, BrowserRouter as Router } from 'react-router-dom'; @@ -25,14 +25,14 @@ const queryClient = new QueryClient({ } }); -const App = () => { +const App = ():ReactElement => { const appi18n = new AppI18n(); const locale = appi18n.getBrowserLocale(); return locale.message ? ( - + }> diff --git a/packages/webapp/src/classes/app-i18n/index.ts b/packages/webapp/src/classes/app-i18n/index.ts index 10db958e..9af15a03 100644 --- a/packages/webapp/src/classes/app-i18n/index.ts +++ b/packages/webapp/src/classes/app-i18n/index.ts @@ -6,12 +6,12 @@ import 'dayjs/locale/es'; export class Locale { code: LocaleCode; label: string; - message: any; + message: Record ; - constructor(code: LocaleCode, label: string, message: any) { + constructor(code: LocaleCode, label: string, message: unknown) { this.code = code; this.label = label; - this.message = message; + this.message = message as Record; } } diff --git a/packages/webapp/src/classes/client/client-health-sentinel/index.tsx b/packages/webapp/src/classes/client/client-health-sentinel/index.tsx index 5844efe4..43c5c0e9 100644 --- a/packages/webapp/src/classes/client/client-health-sentinel/index.tsx +++ b/packages/webapp/src/classes/client/client-health-sentinel/index.tsx @@ -10,7 +10,7 @@ import DialogActions from '@material-ui/core/DialogActions'; import Button from '@material-ui/core/Button'; import AlertTitle from '@material-ui/lab/AlertTitle'; -const ClientHealthSentinel = () => { +const ClientHealthSentinel = (): React.ReactElement => { const status: ClientStatus = useSelector(activeInstanceStatus); const handleOnClose = () => { diff --git a/packages/webapp/src/classes/client/mock-client/index.ts b/packages/webapp/src/classes/client/mock-client/index.ts index b80e32a0..09d610f0 100644 --- a/packages/webapp/src/classes/client/mock-client/index.ts +++ b/packages/webapp/src/classes/client/mock-client/index.ts @@ -36,14 +36,16 @@ class MockClient implements Client { } deleteAccount(): Promise { - return Promise.resolve(); + return Promise.resolve(); } updateAccountInfo(firstname: string, lastname: string): Promise { - return Promise.resolve(); + console.log("firstname:" + firstname, +lastname) + return Promise.resolve(); } updateAccountPassword(pasword: string): Promise { + console.log("password:" + pasword) return Promise.resolve(); } @@ -53,6 +55,7 @@ class MockClient implements Client { } importMap(model: ImportMapInfo): Promise { + console.log("model:" + model); return Promise.resolve(10); } @@ -72,11 +75,12 @@ class MockClient implements Client { return Promise.resolve(); } revertHistory(id: number, cid: number): Promise { + console.log("model:" + id + cid); return Promise.resolve(); } createMap(map: BasicMapInfo): Promise { - throw new Error("Method not implemented."); + throw new Error("Method not implemented." + map); } fetchLabels(): Promise { @@ -127,6 +131,7 @@ class MockClient implements Client { } } fetchHistory(id: number): Promise { + console.log(`Fetching history for ${id}`) const result = [{ id: 1, lastModificationBy: 'Paulo', @@ -211,6 +216,7 @@ class MockClient implements Client { } registerNewUser(user: NewUser): Promise { + console.log("user:" + user) return Promise.resolve(); } @@ -220,6 +226,7 @@ class MockClient implements Client { } resetPassword(email: string): Promise { + console.log("email:" + email) return Promise.resolve(); } } diff --git a/packages/webapp/src/classes/client/rest-client/index.ts b/packages/webapp/src/classes/client/rest-client/index.ts index 858139e9..812c94a4 100644 --- a/packages/webapp/src/classes/client/rest-client/index.ts +++ b/packages/webapp/src/classes/client/rest-client/index.ts @@ -163,7 +163,7 @@ export default class RestClient implements Client { } fetchHistory(id: number): Promise { - throw new Error('Method not implemented.'); + throw new Error(`Method not implemented. ${id}`); } renameMap(id: number, basicInfo: BasicMapInfo): Promise { @@ -213,6 +213,7 @@ export default class RestClient implements Client { } ).then(response => { const data = response.data; + // eslint-disable-next-line @typescript-eslint/no-explicit-any const maps: MapInfo[] = (data.mindmapsInfo as any[]).map(m => { return { id: m.id, @@ -247,7 +248,7 @@ export default class RestClient implements Client { axios.post(this.baseUrl + '/service/users/', JSON.stringify(user), { headers: { 'Content-Type': 'application/json' } } - ).then(response => { + ).then(() => { // All was ok, let's sent to success page ...; success(); }).catch(error => { @@ -264,7 +265,7 @@ export default class RestClient implements Client { const handler = (success: () => void, reject: (error: ErrorInfo) => void) => { axios.delete(this.baseUrl + `/c/restful/maps/${id}`, { headers: { 'Content-Type': 'application/json' } } - ).then(response => { + ).then(() => { success(); }).catch(error => { const errorInfo = this.parseResponseOnError(error.response); @@ -280,7 +281,7 @@ export default class RestClient implements Client { axios.put(`${this.baseUrl}/service/users/resetPassword?email=${email}`, null, { headers: { 'Content-Type': 'application/json' } } - ).then(response => { + ).then(() => { // All was ok, let's sent to success page ...; success(); }).catch(error => { @@ -335,6 +336,7 @@ export default class RestClient implements Client { } ).then(response => { const data = response.data; + // eslint-disable-next-line @typescript-eslint/no-explicit-any const maps: Label[] = (data.labels as any[]).map(l => { return { id: l.id, @@ -354,7 +356,7 @@ export default class RestClient implements Client { deleteLabel(id: number): Promise { const handler = (success: () => void, reject: (error: ErrorInfo) => void) => { - axios.delete(this.baseUrl + `/c/restful/label/${id}`).then(response => { + axios.delete(this.baseUrl + `/c/restful/label/${id}`).then(() => { success(); }).catch(error => { const errorInfo = this.parseResponseOnError(error.response); @@ -364,6 +366,7 @@ export default class RestClient implements Client { return new Promise(handler); } + // eslint-disable-next-line @typescript-eslint/no-explicit-any private parseResponseOnError = (response: any): ErrorInfo => { let result: ErrorInfo | undefined; if (response) { diff --git a/packages/webapp/src/components/forgot-password-page/index.tsx b/packages/webapp/src/components/forgot-password-page/index.tsx index 610889d4..3b792b03 100644 --- a/packages/webapp/src/components/forgot-password-page/index.tsx +++ b/packages/webapp/src/components/forgot-password-page/index.tsx @@ -32,7 +32,7 @@ const ForgotPassword = () => { } ); - const handleOnSubmit = (event: React.FormEvent) => { + const handleOnSubmit = (event: React.FormEvent) => { event.preventDefault(); mutation.mutate(email); } @@ -59,7 +59,7 @@ const ForgotPassword = () => { ); } -const ForgotPasswordPage = () => { +const ForgotPasswordPage = ():React.ReactElement => { useEffect(() => { document.title = 'Reset Password | WiseMapping'; diff --git a/packages/webapp/src/components/forgot-password-success-page/index.tsx b/packages/webapp/src/components/forgot-password-success-page/index.tsx index 5e7fbc7d..e93b9112 100644 --- a/packages/webapp/src/components/forgot-password-success-page/index.tsx +++ b/packages/webapp/src/components/forgot-password-success-page/index.tsx @@ -3,12 +3,12 @@ import { FormattedMessage } from 'react-intl' import FormContainer from '../layout/form-container'; import Header from '../layout/header' import Footer from '../layout/footer' -import { Link as RouterLink} from 'react-router-dom' +import { Link as RouterLink } from 'react-router-dom' import Typography from '@material-ui/core/Typography'; import Button from '@material-ui/core/Button'; -const ForgotPasswordSuccessPage = () => { +const ForgotPasswordSuccessPage = (): React.ReactElement => { useEffect(() => { document.title = 'Reset Password | WiseMapping'; }); diff --git a/packages/webapp/src/components/form/global-error/index.tsx b/packages/webapp/src/components/form/global-error/index.tsx index f4e5d0f6..7cdc02cf 100644 --- a/packages/webapp/src/components/form/global-error/index.tsx +++ b/packages/webapp/src/components/form/global-error/index.tsx @@ -7,14 +7,14 @@ type GlobalErrorProps = { error?: ErrorInfo; } -const GlobalError = (props: GlobalErrorProps) => { +const GlobalError = (props: GlobalErrorProps): React.ReactElement | null => { const error = props.error; const hasError = Boolean(error?.msg); const errorMsg = error?.msg; - return (hasError ? - : null); + return (hasError ? + : null); }; diff --git a/packages/webapp/src/components/form/input/index.tsx b/packages/webapp/src/components/form/input/index.tsx index 144b986b..a81bdfe7 100644 --- a/packages/webapp/src/components/form/input/index.tsx +++ b/packages/webapp/src/components/form/input/index.tsx @@ -27,7 +27,7 @@ const Input = ({ fullWidth = true, disabled = false -}: InputProps) => { +}: InputProps): React.ReactElement => { const fieldError = error?.fields?.[name]; return ( diff --git a/packages/webapp/src/components/form/submit-button/index.tsx b/packages/webapp/src/components/form/submit-button/index.tsx index aeaa218d..18a2d229 100644 --- a/packages/webapp/src/components/form/submit-button/index.tsx +++ b/packages/webapp/src/components/form/submit-button/index.tsx @@ -6,15 +6,15 @@ type SubmitButton = { value: string; disabled?: boolean; } -const SubmitButton = (props: SubmitButton) => { - const [disabled, setDisabled] = useState(props.disabled ? true : false); +const SubmitButton = (props: SubmitButton): React.ReactElement => { + const [disabled] = useState(props.disabled ? true : false); const intl = useIntl(); let valueTxt = props.value; if (disabled) { valueTxt = intl.formatMessage({ id: "common.wait", defaultMessage: "Please wait ..." }); } - const [value, setValue] = useState(valueTxt); + const [value] = useState(valueTxt); return ( ); } -const SignUpButton = (props: ButtonProps) => { +const SignUpButton = (props: ButtonProps): React.ReactElement => { return ( diff --git a/packages/webapp/src/components/login-page/index.tsx b/packages/webapp/src/components/login-page/index.tsx index 61ac361d..1f1febe6 100644 --- a/packages/webapp/src/components/login-page/index.tsx +++ b/packages/webapp/src/components/login-page/index.tsx @@ -1,6 +1,6 @@ import React, { useEffect } from 'react'; import { FormattedMessage, useIntl } from 'react-intl'; -import { Link as RouterLink} from 'react-router-dom'; +import { Link as RouterLink } from 'react-router-dom'; import Header from '../layout/header'; import Footer from '../layout/footer'; import SubmitButton from '../form/submit-button'; @@ -11,9 +11,11 @@ import Typography from '@material-ui/core/Typography'; import FormControl from '@material-ui/core/FormControl'; import Link from '@material-ui/core/Link'; +type ConfigStatusProps = { + enabled?: boolean +} -const ConfigStatusMessage = (props: any) => { - const enabled = props.enabled +const ConfigStatusMessage = ({ enabled = false }: ConfigStatusProps): React.ReactElement => { let result; if (enabled === true) { result = (
@@ -45,7 +47,7 @@ const LoginError = () => { } -const LoginPage = () => { +const LoginPage = (): React.ReactElement => { const intl = useIntl(); useEffect(() => { diff --git a/packages/webapp/src/components/maps-page/account-menu/account-info-dialog/index.tsx b/packages/webapp/src/components/maps-page/account-menu/account-info-dialog/index.tsx index f4d720bb..aed75398 100644 --- a/packages/webapp/src/components/maps-page/account-menu/account-info-dialog/index.tsx +++ b/packages/webapp/src/components/maps-page/account-menu/account-info-dialog/index.tsx @@ -25,7 +25,7 @@ type AccountInfoModel = { } const defaultModel: AccountInfoModel = { firstname: '', lastname: '', email: '' }; -const AccountInfoDialog = ({ onClose }: AccountInfoDialogProps) => { +const AccountInfoDialog = ({ onClose }: AccountInfoDialogProps):React.ReactElement => { const client: Client = useSelector(activeInstance); const queryClient = useQueryClient(); const [remove, setRemove] = React.useState(false); diff --git a/packages/webapp/src/components/maps-page/account-menu/change-password-dialog/index.tsx b/packages/webapp/src/components/maps-page/account-menu/change-password-dialog/index.tsx index c4ad9a82..f9043cff 100644 --- a/packages/webapp/src/components/maps-page/account-menu/change-password-dialog/index.tsx +++ b/packages/webapp/src/components/maps-page/account-menu/change-password-dialog/index.tsx @@ -19,7 +19,7 @@ type ChangePasswordModel = { } const defaultModel: ChangePasswordModel = { password: '', retryPassword: '' }; -const ChangePasswordDialog = ({ onClose }: ChangePasswordDialogProps) => { +const ChangePasswordDialog = ({ onClose }: ChangePasswordDialogProps):React.ReactElement => { const client: Client = useSelector(activeInstance); const [model, setModel] = React.useState(defaultModel); const [error, setError] = React.useState(); diff --git a/packages/webapp/src/components/maps-page/account-menu/index.tsx b/packages/webapp/src/components/maps-page/account-menu/index.tsx index 5570e126..b31c5ebe 100644 --- a/packages/webapp/src/components/maps-page/account-menu/index.tsx +++ b/packages/webapp/src/components/maps-page/account-menu/index.tsx @@ -15,7 +15,7 @@ import Link from "@material-ui/core/Link"; import ExitToAppOutlined from "@material-ui/icons/ExitToAppOutlined"; type ActionType = 'change-password' | 'account-info' | undefined; -const AccountMenu = () => { +const AccountMenu = (): React.ReactElement => { const [anchorEl, setAnchorEl] = React.useState(null); const open = Boolean(anchorEl); const [action, setAction] = React.useState(undefined); diff --git a/packages/webapp/src/components/maps-page/action-chooser/index.tsx b/packages/webapp/src/components/maps-page/action-chooser/index.tsx index 5834e490..3fc3d804 100644 --- a/packages/webapp/src/components/maps-page/action-chooser/index.tsx +++ b/packages/webapp/src/components/maps-page/action-chooser/index.tsx @@ -24,7 +24,7 @@ interface ActionProps { mapId?: number } -const ActionChooser = (props: ActionProps) => { +const ActionChooser = (props: ActionProps): React.ReactElement => { const { anchor, onClose, mapId } = props; const handleOnClose = (action: ActionType): ((event: React.MouseEvent) => void) => { diff --git a/packages/webapp/src/components/maps-page/action-chooser/styled.ts b/packages/webapp/src/components/maps-page/action-chooser/styled.ts index e37bc963..aa02176c 100644 --- a/packages/webapp/src/components/maps-page/action-chooser/styled.ts +++ b/packages/webapp/src/components/maps-page/action-chooser/styled.ts @@ -5,5 +5,5 @@ export const StyledMenuItem = withStyles({ root: { width: '300px', } - })(MenuItem) + })(MenuItem); \ No newline at end of file diff --git a/packages/webapp/src/components/maps-page/action-dispatcher/base-dialog/index.tsx b/packages/webapp/src/components/maps-page/action-dispatcher/base-dialog/index.tsx index 6ba66e7b..62a8ed6f 100644 --- a/packages/webapp/src/components/maps-page/action-dispatcher/base-dialog/index.tsx +++ b/packages/webapp/src/components/maps-page/action-dispatcher/base-dialog/index.tsx @@ -1,5 +1,5 @@ import React from "react"; -import { FormattedMessage, useIntl } from "react-intl"; +import { FormattedMessage } from "react-intl"; import { ErrorInfo } from "../../../../classes/client"; import { StyledDialog, StyledDialogActions, StyledDialogContent, StyledDialogTitle } from "./style"; import GlobalError from "../../../form/global-error"; @@ -9,7 +9,7 @@ import Button from "@material-ui/core/Button"; export type DialogProps = { onClose: () => void; onSubmit?: (event: React.FormEvent) => void; - children: any; + children: unknown; error?: ErrorInfo; title: string; @@ -19,9 +19,8 @@ export type DialogProps = { actionUrl?: string; } -const BaseDialog = (props: DialogProps) => { - const intl = useIntl(); - const { onClose, onSubmit, actionUrl = "" } = props; +const BaseDialog = (props: DialogProps): React.ReactElement => { + const { onClose, onSubmit } = props; const handleOnSubmit = (e: React.FormEvent) => { e.preventDefault(); diff --git a/packages/webapp/src/components/maps-page/action-dispatcher/create-dialog/index.tsx b/packages/webapp/src/components/maps-page/action-dispatcher/create-dialog/index.tsx index 60cd5d41..6abcc80c 100644 --- a/packages/webapp/src/components/maps-page/action-dispatcher/create-dialog/index.tsx +++ b/packages/webapp/src/components/maps-page/action-dispatcher/create-dialog/index.tsx @@ -2,7 +2,7 @@ import React from 'react'; import { useIntl } from 'react-intl'; import { useMutation } from 'react-query'; import { useSelector } from 'react-redux'; -import FormControl from '@material-ui/core/FormControl'; +import FormControl from '@material-ui/core/FormControl'; import Client, { BasicMapInfo, ErrorInfo } from '../../../../classes/client'; import { activeInstance } from '../../../../redux/clientSlice'; @@ -19,7 +19,7 @@ export type CreateProps = { } const defaultModel: CreateModel = { title: '', description: '' }; -const CreateDialog = ({onClose}: CreateProps) => { +const CreateDialog = ({ onClose }: CreateProps): React.ReactElement => { const client: Client = useSelector(activeInstance); const [model, setModel] = React.useState(defaultModel); const [error, setError] = React.useState(); diff --git a/packages/webapp/src/components/maps-page/action-dispatcher/delete-dialog/index.tsx b/packages/webapp/src/components/maps-page/action-dispatcher/delete-dialog/index.tsx index 275156c3..3c0e48e4 100644 --- a/packages/webapp/src/components/maps-page/action-dispatcher/delete-dialog/index.tsx +++ b/packages/webapp/src/components/maps-page/action-dispatcher/delete-dialog/index.tsx @@ -10,7 +10,7 @@ import Alert from "@material-ui/lab/Alert"; import AlertTitle from "@material-ui/lab/AlertTitle"; -const DeleteDialog = ({ mapId, onClose } : SimpleDialogProps) => { +const DeleteDialog = ({ mapId, onClose }: SimpleDialogProps): React.ReactElement => { const intl = useIntl(); const client: Client = useSelector(activeInstance); const queryClient = useQueryClient(); @@ -36,13 +36,13 @@ const DeleteDialog = ({ mapId, onClose } : SimpleDialogProps) => {
+ title={intl.formatMessage({ id: "action.delete-title", defaultMessage: "Delete" })} + submitButton={intl.formatMessage({ id: "action.delete-title", defaultMessage: "Delete" })}> {alertTitle} + defaultMessage="Deleted mindmap can not be recovered. Do you want to continue ?." /> diff --git a/packages/webapp/src/components/maps-page/action-dispatcher/delete-multiselect-dialog/index.tsx b/packages/webapp/src/components/maps-page/action-dispatcher/delete-multiselect-dialog/index.tsx index 9c1023b0..7e1731e9 100644 --- a/packages/webapp/src/components/maps-page/action-dispatcher/delete-multiselect-dialog/index.tsx +++ b/packages/webapp/src/components/maps-page/action-dispatcher/delete-multiselect-dialog/index.tsx @@ -14,11 +14,11 @@ export type DeleteMultiselectDialogProps = { onClose: () => void } -const DeleteMultiselectDialog = ({ onClose, mapsId }: DeleteMultiselectDialogProps) => { +const DeleteMultiselectDialog = ({ onClose, mapsId }: DeleteMultiselectDialogProps): React.ReactElement => { const intl = useIntl(); const client: Client = useSelector(activeInstance); const queryClient = useQueryClient(); - + const mutation = useMutation((ids: number[]) => client.deleteMaps(ids), { onSuccess: () => handleOnMutationSuccess(onClose, queryClient) diff --git a/packages/webapp/src/components/maps-page/action-dispatcher/duplicate-dialog/index.tsx b/packages/webapp/src/components/maps-page/action-dispatcher/duplicate-dialog/index.tsx index a89153a4..bc44b726 100644 --- a/packages/webapp/src/components/maps-page/action-dispatcher/duplicate-dialog/index.tsx +++ b/packages/webapp/src/components/maps-page/action-dispatcher/duplicate-dialog/index.tsx @@ -1,7 +1,7 @@ import React, { useEffect } from "react"; import { useIntl } from "react-intl"; import { useMutation } from "react-query"; -import FormControl from "@material-ui/core/FormControl"; +import FormControl from "@material-ui/core/FormControl"; import { useSelector } from "react-redux"; import Client, { BasicMapInfo, ErrorInfo } from "../../../../classes/client"; @@ -17,7 +17,7 @@ export type DuplicateModel = { } const defaultModel: DuplicateModel = { title: '', description: '', id: -1 }; -const DuplicateDialog = ({ mapId, onClose }: SimpleDialogProps) => { +const DuplicateDialog = ({ mapId, onClose }: SimpleDialogProps): React.ReactElement => { const service: Client = useSelector(activeInstance); const [model, setModel] = React.useState(defaultModel); const [error, setError] = React.useState(); diff --git a/packages/webapp/src/components/maps-page/action-dispatcher/export-dialog/index.tsx b/packages/webapp/src/components/maps-page/action-dispatcher/export-dialog/index.tsx index 577608be..3fb1e293 100644 --- a/packages/webapp/src/components/maps-page/action-dispatcher/export-dialog/index.tsx +++ b/packages/webapp/src/components/maps-page/action-dispatcher/export-dialog/index.tsx @@ -21,10 +21,12 @@ type ExportDialogProps = { onClose: () => void, } -const ExportDialog = ({ mapId, onClose, enableImgExport, svgXml }: ExportDialogProps) => { +const ExportDialog = ({ mapId, onClose, enableImgExport, svgXml }: ExportDialogProps): React.ReactElement => { const intl = useIntl(); const [submit, setSubmit] = React.useState(false); + // eslint-disable-next-line @typescript-eslint/no-explicit-any const [formExportRef, setExportFormRef] = React.useState(); + // eslint-disable-next-line @typescript-eslint/no-explicit-any const [formTransformtRef, setTransformFormRef] = React.useState(); const [exportGroup, setExportGroup] = React.useState(enableImgExport ? 'image' : 'document'); const [exportFormat, setExportFormat] = React.useState(enableImgExport ? 'svg' : 'xls'); @@ -66,10 +68,10 @@ const ExportDialog = ({ mapId, onClose, enableImgExport, svgXml }: ExportDialogP if (submit) { // Depending on the type of export. It will require differt POST. if (exportFormat == 'pdf' || exportFormat == "svg" || exportFormat == "jpg" || exportFormat == "png") { - formTransformtRef.submit(); + formTransformtRef?.submit(); } else { - formExportRef.submit(); + formExportRef?.submit(); } onClose(); } diff --git a/packages/webapp/src/components/maps-page/action-dispatcher/export-dialog/style.ts b/packages/webapp/src/components/maps-page/action-dispatcher/export-dialog/style.ts index 8a283df3..492e5ca4 100644 --- a/packages/webapp/src/components/maps-page/action-dispatcher/export-dialog/style.ts +++ b/packages/webapp/src/components/maps-page/action-dispatcher/export-dialog/style.ts @@ -1,8 +1,7 @@ -import { Theme } from "@material-ui/core/styles/createMuiTheme"; import createStyles from "@material-ui/core/styles/createStyles"; import makeStyles from "@material-ui/core/styles/makeStyles"; -export const useStyles = makeStyles((theme: Theme) => +export const useStyles = makeStyles(() => createStyles({ select: { height: '40px', diff --git a/packages/webapp/src/components/maps-page/action-dispatcher/history-dialog/index.tsx b/packages/webapp/src/components/maps-page/action-dispatcher/history-dialog/index.tsx index 29fa98f3..b66999c3 100644 --- a/packages/webapp/src/components/maps-page/action-dispatcher/history-dialog/index.tsx +++ b/packages/webapp/src/components/maps-page/action-dispatcher/history-dialog/index.tsx @@ -19,11 +19,11 @@ import Link from "@material-ui/core/Link"; import Paper from "@material-ui/core/Paper"; -const HistoryDialog = ({ mapId, onClose }: SimpleDialogProps) => { +const HistoryDialog = ({ mapId, onClose }: SimpleDialogProps): React.ReactElement => { const intl = useIntl(); const client: Client = useSelector(activeInstance); - const { isLoading, error, data } = useQuery('history', () => { + const { data } = useQuery('history', () => { return client.fetchHistory(mapId); }); const changeHistory: ChangeHistory[] = data ? data : []; @@ -35,7 +35,7 @@ const HistoryDialog = ({ mapId, onClose }: SimpleDialogProps) => { const handleOnClick = (event, vid): void => { event.preventDefault(); client.revertHistory(mapId, vid) - .then((mapId) => { + .then(() => { handleOnClose(); }) }; diff --git a/packages/webapp/src/components/maps-page/action-dispatcher/import-dialog/index.tsx b/packages/webapp/src/components/maps-page/action-dispatcher/import-dialog/index.tsx index b3594653..cc37c0fc 100644 --- a/packages/webapp/src/components/maps-page/action-dispatcher/import-dialog/index.tsx +++ b/packages/webapp/src/components/maps-page/action-dispatcher/import-dialog/index.tsx @@ -22,7 +22,7 @@ export type CreateProps = { } const defaultModel: ImportModel = { title: '' }; -const ImportDialog = ({onClose}: CreateProps) => { +const ImportDialog = ({ onClose }: CreateProps): React.ReactElement => { const client: Client = useSelector(activeInstance); const [model, setModel] = React.useState(defaultModel); const [error, setError] = React.useState(); @@ -66,11 +66,8 @@ const ImportDialog = ({onClose}: CreateProps) => { if (files) { const file = files[0]; - let title = file.name; - title = title.substring(0, title.lastIndexOf(".")); - // Closure to capture the file information. - reader.onload = (event) => { + reader.onload = (event) => { const fileContent = event?.target?.result; model.content = fileContent; @@ -83,7 +80,7 @@ const ImportDialog = ({onClose}: CreateProps) => { } } model.contentType = file.name.lastIndexOf(".wxml") != -1 ? "application/xml" : "application/freemind"; - setModel({...model}); + setModel({ ...model }); }; // Read in the image file as a data URL. diff --git a/packages/webapp/src/components/maps-page/action-dispatcher/index.tsx b/packages/webapp/src/components/maps-page/action-dispatcher/index.tsx index ed8d50d6..199534f8 100644 --- a/packages/webapp/src/components/maps-page/action-dispatcher/index.tsx +++ b/packages/webapp/src/components/maps-page/action-dispatcher/index.tsx @@ -11,6 +11,7 @@ import PublishDialog from './publish-dialog'; import InfoDialog from './info-dialog'; import DeleteMultiselectDialog from './delete-multiselect-dialog'; import ExportDialog from './export-dialog'; +import ShareDialog from './share-dialog'; export type BasicMapInfo = { name: string; @@ -23,12 +24,10 @@ type ActionDialogProps = { onClose: () => void } -const ActionDispatcher = (props: ActionDialogProps) => { - const mapsId = props.mapsId; - const action = props.action; +const ActionDispatcher = ({ mapsId, action, onClose }: ActionDialogProps): React.ReactElement => { const handleOnClose = (): void => { - props.onClose(); + onClose(); } switch (action) { @@ -54,6 +53,7 @@ const ActionDispatcher = (props: ActionDialogProps) => { {action === 'info' && } {action === 'create' && } {action === 'export' && } + {action === 'share' && } ); } diff --git a/packages/webapp/src/components/maps-page/action-dispatcher/info-dialog/index.tsx b/packages/webapp/src/components/maps-page/action-dispatcher/info-dialog/index.tsx index a00ae7c7..ae6aad89 100644 --- a/packages/webapp/src/components/maps-page/action-dispatcher/info-dialog/index.tsx +++ b/packages/webapp/src/components/maps-page/action-dispatcher/info-dialog/index.tsx @@ -3,7 +3,7 @@ import { FormattedMessage, useIntl } from 'react-intl'; import { ErrorInfo } from '../../../../classes/client'; import BaseDialog from '../base-dialog'; -import { SimpleDialogProps } from '..'; +import { SimpleDialogProps } from '..'; import { useStyles } from './style'; import dayjs from 'dayjs'; import { fetchMapById } from '../../../../redux/clientSlice'; @@ -13,7 +13,7 @@ import ListItem from '@material-ui/core/ListItem'; import Typography from '@material-ui/core/Typography'; import List from '@material-ui/core/List'; -const InfoDialog = ({ mapId, onClose }: SimpleDialogProps) => { +const InfoDialog = ({ mapId, onClose }: SimpleDialogProps): React.ReactElement => { const { map } = fetchMapById(mapId); const [error, setError] = React.useState(); @@ -31,7 +31,7 @@ const InfoDialog = ({ mapId, onClose }: SimpleDialogProps) => { description={intl.formatMessage({ id: 'info.description-msg', defaultMessage: 'By publishing the map you make it visible to everyone on the Internet.' })} submitButton={intl.formatMessage({ id: 'info.button', defaultMessage: 'Accept' })}> - + diff --git a/packages/webapp/src/components/maps-page/action-dispatcher/info-dialog/style.ts b/packages/webapp/src/components/maps-page/action-dispatcher/info-dialog/style.ts index f5e85812..1a7a6d6a 100644 --- a/packages/webapp/src/components/maps-page/action-dispatcher/info-dialog/style.ts +++ b/packages/webapp/src/components/maps-page/action-dispatcher/info-dialog/style.ts @@ -1,8 +1,7 @@ -import { Theme } from "@material-ui/core/styles/createMuiTheme"; import createStyles from "@material-ui/core/styles/createStyles"; import makeStyles from "@material-ui/core/styles/makeStyles"; -export const useStyles = makeStyles((theme: Theme) => +export const useStyles = makeStyles(() => createStyles({ textarea: { width: '100%', diff --git a/packages/webapp/src/components/maps-page/action-dispatcher/publish-dialog/index.tsx b/packages/webapp/src/components/maps-page/action-dispatcher/publish-dialog/index.tsx index 43d8b911..731abba3 100644 --- a/packages/webapp/src/components/maps-page/action-dispatcher/publish-dialog/index.tsx +++ b/packages/webapp/src/components/maps-page/action-dispatcher/publish-dialog/index.tsx @@ -20,7 +20,7 @@ import Typography from '@material-ui/core/Typography'; import TextareaAutosize from '@material-ui/core/TextareaAutosize'; -const PublishDialog = ({ mapId, onClose }: SimpleDialogProps) => { +const PublishDialog = ({ mapId, onClose }: SimpleDialogProps): React.ReactElement => { const { map } = fetchMapById(mapId); const client: Client = useSelector(activeInstance); diff --git a/packages/webapp/src/components/maps-page/action-dispatcher/publish-dialog/style.ts b/packages/webapp/src/components/maps-page/action-dispatcher/publish-dialog/style.ts index 5108b275..9cc279ea 100644 --- a/packages/webapp/src/components/maps-page/action-dispatcher/publish-dialog/style.ts +++ b/packages/webapp/src/components/maps-page/action-dispatcher/publish-dialog/style.ts @@ -1,8 +1,7 @@ -import { Theme } from "@material-ui/core/styles/createMuiTheme"; import createStyles from "@material-ui/core/styles/createStyles"; import makeStyles from "@material-ui/core/styles/makeStyles"; -export const useStyles = makeStyles((theme: Theme) => +export const useStyles = makeStyles(() => createStyles({ textarea: { width: '100%', diff --git a/packages/webapp/src/components/maps-page/action-dispatcher/rename-dialog/index.tsx b/packages/webapp/src/components/maps-page/action-dispatcher/rename-dialog/index.tsx index dce915bd..c748240e 100644 --- a/packages/webapp/src/components/maps-page/action-dispatcher/rename-dialog/index.tsx +++ b/packages/webapp/src/components/maps-page/action-dispatcher/rename-dialog/index.tsx @@ -16,7 +16,7 @@ export type RenameModel = { } const defaultModel: RenameModel = { title: '', description: '', id: -1 }; -const RenameDialog = ({ mapId, onClose }: SimpleDialogProps) => { +const RenameDialog = ({ mapId, onClose }: SimpleDialogProps): React.ReactElement => { const service: Client = useSelector(activeInstance); const [model, setModel] = React.useState(defaultModel); const [error, setError] = React.useState(); diff --git a/packages/webapp/src/components/maps-page/action-dispatcher/share-dialog/index.tsx b/packages/webapp/src/components/maps-page/action-dispatcher/share-dialog/index.tsx new file mode 100644 index 00000000..e5f251cb --- /dev/null +++ b/packages/webapp/src/components/maps-page/action-dispatcher/share-dialog/index.tsx @@ -0,0 +1,76 @@ +import React from "react"; +import { useIntl } from "react-intl"; +import { useMutation, useQueryClient } from "react-query"; +import { useSelector } from "react-redux"; +import Client from "../../../../classes/client"; +import { activeInstance } from '../../../../redux/clientSlice'; +import { SimpleDialogProps, handleOnMutationSuccess } from ".."; +import BaseDialog from "../base-dialog"; +import List from "@material-ui/core/List"; +import ListItem from "@material-ui/core/ListItem"; +import ListItemText from "@material-ui/core/ListItemText"; +import IconButton from "@material-ui/core/IconButton"; +import ListItemSecondaryAction from "@material-ui/core/ListItemSecondaryAction"; +import DeleteIcon from '@material-ui/icons/Delete'; +import Paper from "@material-ui/core/Paper"; + + +const ShareDialog = ({ mapId, onClose }: SimpleDialogProps): React.ReactElement => { + const intl = useIntl(); + const client: Client = useSelector(activeInstance); + const queryClient = useQueryClient(); + + const mutation = useMutation((id: number) => client.deleteMap(id), + { + onSuccess: () => handleOnMutationSuccess(onClose, queryClient) + } + ); + + const handleOnClose = (): void => { + onClose(); + }; + + const handleOnSubmit = (): void => { + mutation.mutate(mapId); + } + + // Fetch map model to be rendered ... + return ( +
+ + + +
+ +
+ + + + {[.4, 5, 7, 7, 8, 9, 100, 1, 2, 3].map((value) => { + const labelId = `checkbox-list-label-${value}`; + + return ( + + + + + + + + + ); + })} + + + +
+
+ ); +} + + +export default ShareDialog; \ No newline at end of file diff --git a/packages/webapp/src/components/maps-page/help-menu/index.tsx b/packages/webapp/src/components/maps-page/help-menu/index.tsx index 14dfcded..f377e8c2 100644 --- a/packages/webapp/src/components/maps-page/help-menu/index.tsx +++ b/packages/webapp/src/components/maps-page/help-menu/index.tsx @@ -12,7 +12,7 @@ import MenuItem from "@material-ui/core/MenuItem"; import Link from "@material-ui/core/Link"; import ListItemIcon from "@material-ui/core/ListItemIcon"; -const HelpMenu = () => { +const HelpMenu = (): React.ReactElement => { const [anchorEl, setAnchorEl] = React.useState(null); const open = Boolean(anchorEl); diff --git a/packages/webapp/src/components/maps-page/index.tsx b/packages/webapp/src/components/maps-page/index.tsx index f67ddf47..a7470c91 100644 --- a/packages/webapp/src/components/maps-page/index.tsx +++ b/packages/webapp/src/components/maps-page/index.tsx @@ -1,4 +1,4 @@ -import React, { ErrorInfo, useEffect } from 'react'; +import React, { ErrorInfo, ReactElement, useEffect } from 'react'; import clsx from 'clsx'; import Drawer from '@material-ui/core/Drawer'; import AppBar from '@material-ui/core/AppBar'; @@ -56,10 +56,10 @@ export interface LabelFilter { interface ToolbarButtonInfo { filter: GenericFilter | LabelFilter, label: string - icon: any; + icon: React.ReactElement; } -const MapsPage = () => { +const MapsPage = (): ReactElement => { const classes = useStyles(); const [filter, setFilter] = React.useState({ type: 'all' }); const client: Client = useSelector(activeInstance); @@ -221,7 +221,7 @@ const MapsPage = () => { } interface ListItemProps { - icon: any, + icon: React.ReactElement, label: string, filter: Filter, active?: Filter @@ -241,12 +241,12 @@ const StyleListItem = (props: ListItemProps) => { && (activeFilter.type != 'label' || ((activeFilter as LabelFilter).label == (filter as LabelFilter).label)); - const handleOnClick = (event: any, filter: Filter) => { + const handleOnClick = (event: React.MouseEvent, filter: Filter) => { event.stopPropagation(); onClick(filter); } - const handleOnDelete = (event: any, filter: Filter) => { + const handleOnDelete = (event: React.MouseEvent, filter: Filter) => { event.stopPropagation(); if (!onDeleteLabel) { throw "Illegal state exeption"; diff --git a/packages/webapp/src/components/maps-page/language-menu/index.tsx b/packages/webapp/src/components/maps-page/language-menu/index.tsx index da6f3097..2c5adedd 100644 --- a/packages/webapp/src/components/maps-page/language-menu/index.tsx +++ b/packages/webapp/src/components/maps-page/language-menu/index.tsx @@ -18,7 +18,7 @@ import DialogActions from '@material-ui/core/DialogActions'; import Divider from '@material-ui/core/Divider'; -const LanguageMenu = () => { +const LanguageMenu = (): React.ReactElement => { const queryClient = useQueryClient(); const client: Client = useSelector(activeInstance); const [anchorEl, setAnchorEl] = React.useState(null); diff --git a/packages/webapp/src/components/maps-page/maps-list/index.tsx b/packages/webapp/src/components/maps-page/maps-list/index.tsx index d1f7a79e..e9977b18 100644 --- a/packages/webapp/src/components/maps-page/maps-list/index.tsx +++ b/packages/webapp/src/components/maps-page/maps-list/index.tsx @@ -51,6 +51,7 @@ function descendingComparator(a: T, b: T, orderBy: keyof T) { type Order = 'asc' | 'desc'; +// eslint-disable-next-line @typescript-eslint/no-explicit-any function getComparator( order: Order, orderBy: Key, @@ -195,7 +196,7 @@ const mapsFilter = (filter: Filter, search: string): ((mapInfo: MapInfo) => bool } } -export const MapsList = (props: MapsListProps) => { +export const MapsList = (props: MapsListProps):React.ReactElement => { const classes = useStyles(); const [order, setOrder] = React.useState('asc'); const [filter, setFilter] = React.useState({ type: 'all' }); @@ -280,8 +281,8 @@ export const MapsList = (props: MapsListProps) => { setPage(0); }; - const handleActionClick = (mapId: number): ((event: any) => void) => { - return (event: any): void => { + const handleActionClick = (mapId: number): ((event) => void) => { + return (event): void => { setActiveRowAction( { mapId: mapId, @@ -435,7 +436,7 @@ export const MapsList = (props: MapsListProps) => { return ( handleRowClick(event, row.id)} + onClick={(event) => handleRowClick(event, row.id)} role="checkbox" aria-checked={isItemSelected} tabIndex={-1} diff --git a/packages/webapp/src/components/registration-page/index.tsx b/packages/webapp/src/components/registration-page/index.tsx index facb5c19..1931d3cd 100644 --- a/packages/webapp/src/components/registration-page/index.tsx +++ b/packages/webapp/src/components/registration-page/index.tsx @@ -102,7 +102,7 @@ const RegistrationForm = () => { ); } -const RegistationPage = () => { +const RegistationPage = (): React.ReactElement => { useEffect(() => { document.title = 'Registration | WiseMapping'; diff --git a/packages/webapp/src/components/registration-success-page/index.tsx b/packages/webapp/src/components/registration-success-page/index.tsx index 158bd7f8..a81c5c44 100644 --- a/packages/webapp/src/components/registration-success-page/index.tsx +++ b/packages/webapp/src/components/registration-success-page/index.tsx @@ -8,7 +8,7 @@ import Typography from '@material-ui/core/Typography'; import Button from '@material-ui/core/Button'; -const RegistrationSuccessPage = () => { +const RegistrationSuccessPage = (): React.ReactElement => { useEffect(() => { document.title = 'Reset Password | WiseMapping'; }); diff --git a/packages/webapp/src/redux/clientSlice.ts b/packages/webapp/src/redux/clientSlice.ts index e074f147..247ee018 100644 --- a/packages/webapp/src/redux/clientSlice.ts +++ b/packages/webapp/src/redux/clientSlice.ts @@ -1,4 +1,5 @@ -import { createSlice, PayloadAction } from '@reduxjs/toolkit'; +/* eslint-disable @typescript-eslint/explicit-module-boundary-types */ +import { createSlice } from '@reduxjs/toolkit'; import { useQuery } from 'react-query'; import Client, { AccountInfo, ErrorInfo, MapInfo } from '../classes/client'; import MockClient from '../classes/client/mock-client'; @@ -15,6 +16,7 @@ class RutimeConfig { load() { // Config can be inserted in the html page to define the global properties ... + // eslint-disable-next-line @typescript-eslint/no-explicit-any this.config = (window as any).serverconfig; return this; } @@ -53,8 +55,8 @@ export const clientSlice = createSlice({ name: "client", initialState: initialState, reducers: { - sessionExpired(state, action: PayloadAction) { - state.status = { state: 'session-expired', msg: 'Sessions has expired. You need to login again.' } + sessionExpired(state) { + state.status = { state: 'session-expired', msg: 'Sessions has expired. You need to login again' } } }, }); @@ -87,10 +89,12 @@ export const fetchAccount = (): AccountInfo | undefined => { return data; } +// eslint-disable-next-line @typescript-eslint/no-explicit-any export const activeInstance = (state: any): Client => { return state.client.instance; } +// eslint-disable-next-line @typescript-eslint/no-explicit-any export const activeInstanceStatus = (state: any): ClientStatus => { return state.client.status; } diff --git a/packages/webapp/webpack.prod.js b/packages/webapp/webpack.prod.js index 8efe8108..b2f4da21 100644 --- a/packages/webapp/webpack.prod.js +++ b/packages/webapp/webpack.prod.js @@ -1,6 +1,8 @@ const { merge } = require('webpack-merge'); const common = require('./webpack.common.js'); const path = require('path'); +const HtmlWebpackPlugin = require('html-webpack-plugin'); + const CompressionPlugin = require('compression-webpack-plugin'); @@ -11,6 +13,13 @@ module.exports = merge(common, { minimize: true }, plugins: [ - new CompressionPlugin() + new CompressionPlugin(), + new HtmlWebpackPlugin({ + template: path.join(__dirname, 'public/index.html'), + templateParameters: { + PUBLIC_URL: process.env.PUBLIC_URL ? process.env.PUBLIC_URL : 'https://www.wisemapping.com' + }, + base: process.env.PUBLIC_URL ? process.env.PUBLIC_URL : 'https://www.wisemapping.com' + }) ] }); diff --git a/yarn.lock b/yarn.lock index e71448ac..ec273c24 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3034,6 +3034,10 @@ dayjs@^1.10.4: resolved "https://registry.yarnpkg.com/dayjs/-/dayjs-1.10.4.tgz#8e544a9b8683f61783f570980a8a80eaf54ab1e2" integrity sha512-RI/Hh4kqRc1UKLOAf/T5zdMMX5DQIlDxwUe3wSyMMnEbGunnpENCdbUgM+dW7kXidZqCttBrmw7BhN4TMddkCw== +dayjs@^1.10.4: + version "1.10.4" + resolved "https://registry.yarnpkg.com/dayjs/-/dayjs-1.10.4.tgz#8e544a9b8683f61783f570980a8a80eaf54ab1e2" + debug@2.6.9, debug@^2.2.0, debug@^2.3.3: version "2.6.9" resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f" @@ -6132,7 +6136,10 @@ mkdirp@^0.5.0, mkdirp@^0.5.1, mkdirp@^0.5.5: modify-values@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/modify-values/-/modify-values-1.0.1.tgz#b3939fa605546474e3e3e3c63d64bd43b4ee6022" +<<<<<<< Updated upstream integrity sha512-xV2bxeN6F7oYjZWTe/YPAy6MN2M+sL4u/Rlm2AHCIVGfo2p1yGmBHQ6vHehl4bRTZBdHu3TSkWdYgkwpYzAGSw== +======= +>>>>>>> Stashed changes move-concurrently@^1.0.1: version "1.0.1"