From f05daa8223d7b95e2f1c95d11a88558111ff512b Mon Sep 17 00:00:00 2001 From: LASER-Yi Date: Sun, 22 Aug 2021 20:03:36 +0800 Subject: [PATCH] no log: Remove loose object from all tables --- frontend/src/@types/react-table.d.ts | 3 +- frontend/src/DisplayItem/Episodes/table.tsx | 10 +++---- frontend/src/DisplayItem/Movies/index.tsx | 20 +++++-------- frontend/src/DisplayItem/Series/index.tsx | 19 +++++------- .../generic/BaseItemView/table.tsx | 6 +--- frontend/src/Settings/Languages/modal.tsx | 22 +++++++------- frontend/src/Settings/Languages/table.tsx | 8 ++--- .../src/Settings/components/pathMapper.tsx | 14 ++++----- frontend/src/System/Logs/table.tsx | 10 ++----- frontend/src/Wanted/Movies/index.tsx | 4 +-- frontend/src/Wanted/Series/index.tsx | 2 +- .../components/modals/SeriesUploadModal.tsx | 29 +++++++------------ 12 files changed, 61 insertions(+), 86 deletions(-) diff --git a/frontend/src/@types/react-table.d.ts b/frontend/src/@types/react-table.d.ts index 05bb31cf3..272639da3 100644 --- a/frontend/src/@types/react-table.d.ts +++ b/frontend/src/@types/react-table.d.ts @@ -51,8 +51,7 @@ declare module "react-table" { interface CustomTableProps> extends useSelectionProps { - externalUpdate?: TableUpdater; - loose?: any[]; + update?: TableUpdater; } interface CustomTableState> diff --git a/frontend/src/DisplayItem/Episodes/table.tsx b/frontend/src/DisplayItem/Episodes/table.tsx index a7dc02036..a10bc7084 100644 --- a/frontend/src/DisplayItem/Episodes/table.tsx +++ b/frontend/src/DisplayItem/Episodes/table.tsx @@ -147,28 +147,28 @@ const Table: FunctionComponent = ({ { Header: "Actions", accessor: "sonarrEpisodeId", - Cell: ({ row, externalUpdate }) => { + Cell: ({ row, update }) => { return ( { - externalUpdate && externalUpdate(row, "manual-search"); + update && update(row, "manual-search"); }} > { - externalUpdate && externalUpdate(row, "history"); + update && update(row, "history"); }} > { - externalUpdate && externalUpdate(row, "tools"); + update && update(row, "tools"); }} > @@ -206,7 +206,7 @@ const Table: FunctionComponent = ({ = () => { const movies = useMovieEntities(); const loader = useReduxAction(movieUpdateByRange); + const profiles = useLanguageProfiles(); + const columns: Column[] = useMemo[]>( () => [ { @@ -67,14 +69,8 @@ const MovieView: FunctionComponent = () => { { Header: "Languages Profile", accessor: "profileId", - Cell: ({ value, loose }) => { - if (loose) { - // Define in generic/BaseItemView/table.tsx - const profiles = loose[0] as Language.Profile[]; - return profiles.find((v) => v.profileId === value)?.name ?? null; - } else { - return null; - } + Cell: ({ value }) => { + return profiles?.find((v) => v.profileId === value)?.name ?? null; }, }, { @@ -97,17 +93,17 @@ const MovieView: FunctionComponent = () => { { accessor: "radarrId", selectHide: true, - Cell: ({ row, value, externalUpdate }) => { + Cell: ({ row, update }) => { return ( externalUpdate && externalUpdate(row, "edit")} + onClick={() => update && update(row, "edit")} > ); }, }, ], - [] + [profiles] ); return ( diff --git a/frontend/src/DisplayItem/Series/index.tsx b/frontend/src/DisplayItem/Series/index.tsx index 81f37c021..53d0da7e3 100644 --- a/frontend/src/DisplayItem/Series/index.tsx +++ b/frontend/src/DisplayItem/Series/index.tsx @@ -4,7 +4,7 @@ import { Badge, ProgressBar } from "react-bootstrap"; import { Link } from "react-router-dom"; import { Column } from "react-table"; import { seriesUpdateAll, seriesUpdateByRange } from "../../@redux/actions"; -import { useSerieEntities } from "../../@redux/hooks"; +import { useLanguageProfiles, useSerieEntities } from "../../@redux/hooks"; import { useReduxAction } from "../../@redux/hooks/base"; import { SeriesApi } from "../../apis"; import { ActionBadge } from "../../components"; @@ -16,6 +16,7 @@ interface Props {} const SeriesView: FunctionComponent = () => { const series = useSerieEntities(); const loader = useReduxAction(seriesUpdateByRange); + const profiles = useLanguageProfiles(); const columns: Column[] = useMemo[]>( () => [ { @@ -53,14 +54,8 @@ const SeriesView: FunctionComponent = () => { { Header: "Languages Profile", accessor: "profileId", - Cell: ({ value, loose }) => { - if (loose) { - // Define in generic/BaseItemView/table.tsx - const profiles = loose[0] as Language.Profile[]; - return profiles.find((v) => v.profileId === value)?.name ?? null; - } else { - return null; - } + Cell: ({ value }) => { + return profiles?.find((v) => v.profileId === value)?.name ?? null; }, }, { @@ -98,17 +93,17 @@ const SeriesView: FunctionComponent = () => { { accessor: "sonarrSeriesId", selectHide: true, - Cell: ({ row, externalUpdate }) => ( + Cell: ({ row, update }) => ( { - externalUpdate && externalUpdate(row, "edit"); + update && update(row, "edit"); }} > ), }, ], - [] + [profiles] ); return ( diff --git a/frontend/src/DisplayItem/generic/BaseItemView/table.tsx b/frontend/src/DisplayItem/generic/BaseItemView/table.tsx index 72c9f234b..a06b66a54 100644 --- a/frontend/src/DisplayItem/generic/BaseItemView/table.tsx +++ b/frontend/src/DisplayItem/generic/BaseItemView/table.tsx @@ -2,7 +2,6 @@ import { uniqBy } from "lodash"; import React, { useCallback, useMemo } from "react"; import { TableOptions, TableUpdater, useRowSelect } from "react-table"; import { SharedProps } from "."; -import { useLanguageProfiles } from "../../../@redux/hooks"; import { AsyncPageTable, ItemEditorModal, @@ -45,12 +44,9 @@ function Table({ [dirtyItems, orderList] ); - const profiles = useLanguageProfiles(); - const options: Partial & TableStyleProps> = { - loose: [profiles], emptyText: `No ${name} Found`, - externalUpdate: updateRow, + update: updateRow, }; return ( diff --git a/frontend/src/Settings/Languages/modal.tsx b/frontend/src/Settings/Languages/modal.tsx index d5aaf1f34..92854ef22 100644 --- a/frontend/src/Settings/Languages/modal.tsx +++ b/frontend/src/Settings/Languages/modal.tsx @@ -135,7 +135,7 @@ const LanguagesProfileModal: FunctionComponent = ( { Header: "Language", accessor: "language", - Cell: ({ value, row, externalUpdate }) => { + Cell: ({ value, row, update }) => { const code = value; const item = row.original; const lang = useMemo( @@ -150,7 +150,7 @@ const LanguagesProfileModal: FunctionComponent = ( onChange={(l) => { if (l) { item.language = l.code2; - externalUpdate && externalUpdate(row, item); + update && update(row, item); } }} > @@ -161,7 +161,7 @@ const LanguagesProfileModal: FunctionComponent = ( { Header: "Forced", accessor: "forced", - Cell: ({ row, value, externalUpdate }) => { + Cell: ({ row, value, update }) => { const item = row.original; return ( = ( checked={value === "True"} onChange={(v) => { item.forced = v.target.checked ? "True" : "False"; - externalUpdate && externalUpdate(row, item); + update && update(row, item); }} > ); @@ -179,7 +179,7 @@ const LanguagesProfileModal: FunctionComponent = ( { Header: "HI", accessor: "hi", - Cell: ({ row, value, externalUpdate }) => { + Cell: ({ row, value, update }) => { const item = row.original; return ( = ( checked={value === "True"} onChange={(v) => { item.hi = v.target.checked ? "True" : "False"; - externalUpdate && externalUpdate(row, item); + update && update(row, item); }} > ); @@ -197,7 +197,7 @@ const LanguagesProfileModal: FunctionComponent = ( { Header: "Exclude Audio", accessor: "audio_exclude", - Cell: ({ row, value, externalUpdate }) => { + Cell: ({ row, value, update }) => { const item = row.original; return ( = ( checked={value === "True"} onChange={(v) => { item.audio_exclude = v.target.checked ? "True" : "False"; - externalUpdate && externalUpdate(row, item); + update && update(row, item); }} > ); @@ -215,11 +215,11 @@ const LanguagesProfileModal: FunctionComponent = ( { id: "action", accessor: "id", - Cell: ({ row, externalUpdate }) => { + Cell: ({ row, update }) => { return ( externalUpdate && externalUpdate(row)} + onClick={() => update && update(row)} > ); }, @@ -245,7 +245,7 @@ const LanguagesProfileModal: FunctionComponent = ( responsive={false} columns={columns} data={current.items} - externalUpdate={updateRow} + update={updateRow} >