From 839ce384c64caa9767125661b4a51364965a907b Mon Sep 17 00:00:00 2001 From: LASER-Yi Date: Sat, 11 Feb 2023 09:12:05 +0800 Subject: [PATCH] Bring back clear action to the mass editor --- frontend/src/pages/views/MassEditor.tsx | 34 ++++++++++++++++++++----- 1 file changed, 27 insertions(+), 7 deletions(-) diff --git a/frontend/src/pages/views/MassEditor.tsx b/frontend/src/pages/views/MassEditor.tsx index 3e6fa1035..02668302d 100644 --- a/frontend/src/pages/views/MassEditor.tsx +++ b/frontend/src/pages/views/MassEditor.tsx @@ -1,10 +1,10 @@ import { useIsAnyMutationRunning, useLanguageProfiles } from "@/apis/hooks"; import { SimpleTable, Toolbox } from "@/components"; -import { Selector } from "@/components/inputs"; +import { Selector, SelectorOption } from "@/components/inputs"; import { useCustomSelection } from "@/components/tables/plugins"; import { GetItemId, useSelectorOptions } from "@/utilities"; import { faCheck, faUndo } from "@fortawesome/free-solid-svg-icons"; -import { Container } from "@mantine/core"; +import { Box, Container } from "@mantine/core"; import { uniqBy } from "lodash"; import { useCallback, useMemo, useState } from "react"; import { UseMutationResult } from "react-query"; @@ -36,6 +36,24 @@ function MassEditor(props: MassEditorProps) { const profileOptions = useSelectorOptions(profiles ?? [], (v) => v.name); + const profileOptionsWithAction = useMemo< + SelectorOption[] + >( + () => [ + { label: "Clear", value: null, group: "Action" }, + ...profileOptions.options, + ], + [profileOptions.options] + ); + + const getKey = useCallback((value: Language.Profile | null) => { + if (value) { + return value.name; + } + + return "Clear"; + }, []); + const { mutateAsync } = mutation; const save = useCallback(() => { @@ -67,15 +85,17 @@ function MassEditor(props: MassEditorProps) { return ( -
+ -
-
+ + Cancel @@ -87,7 +107,7 @@ function MassEditor(props: MassEditorProps) { > Save -
+