Browse Source

Add workspace filter to historypreview as well (#2582)

* Add workspace filter to historypreview as well

* PR feedback
Matt Rubens 9 months ago
parent
commit
eab61289a2

+ 19 - 2
webview-ui/src/components/history/HistoryPreview.tsx

@@ -2,7 +2,7 @@ import { memo } from "react"
 
 import { vscode } from "@/utils/vscode"
 import { formatLargeNumber, formatDate } from "@/utils/format"
-import { Button } from "@/components/ui"
+import { Button, Checkbox } from "@/components/ui"
 
 import { useAppTranslation } from "../../i18n/TranslationContext"
 import { CopyButton } from "./CopyButton"
@@ -12,7 +12,7 @@ type HistoryPreviewProps = {
 	showHistoryView: () => void
 }
 const HistoryPreview = ({ showHistoryView }: HistoryPreviewProps) => {
-	const { tasks } = useTaskSearch()
+	const { tasks, showAllWorkspaces, setShowAllWorkspaces } = useTaskSearch()
 	const { t } = useAppTranslation()
 
 	return (
@@ -26,6 +26,17 @@ const HistoryPreview = ({ showHistoryView }: HistoryPreviewProps) => {
 					{t("history:viewAll")}
 				</Button>
 			</div>
+			<div className="flex items-center gap-2 mb-2">
+				<Checkbox
+					id="show-all-workspaces"
+					checked={showAllWorkspaces}
+					onCheckedChange={(checked) => setShowAllWorkspaces(checked === true)}
+					variant="description"
+				/>
+				<label htmlFor="show-all-workspaces" className="text-xs text-vscode-foreground cursor-pointer">
+					{t("history:showAllWorkspaces")}
+				</label>
+			</div>
 			{tasks.slice(0, 3).map((item) => (
 				<div
 					key={item.id}
@@ -74,6 +85,12 @@ const HistoryPreview = ({ showHistoryView }: HistoryPreviewProps) => {
 								</>
 							)}
 						</div>
+						{showAllWorkspaces && item.workspace && (
+							<div className="flex flex-row gap-1 text-vscode-descriptionForeground text-xs mt-1">
+								<span className="codicon codicon-folder scale-80" />
+								<span>{item.workspace}</span>
+							</div>
+						)}
 					</div>
 				</div>
 			))}

+ 5 - 2
webview-ui/src/components/history/HistoryView.tsx

@@ -156,13 +156,16 @@ const HistoryView = ({ onDone }: HistoryViewProps) => {
 						</VSCodeRadio>
 					</VSCodeRadioGroup>
 
-					<div className="flex items-center gap-2" onClick={() => setShowAllWorkspaces(!showAllWorkspaces)}>
+					<div className="flex items-center gap-2">
 						<Checkbox
+							id="show-all-workspaces-view"
 							checked={showAllWorkspaces}
 							onCheckedChange={(checked) => setShowAllWorkspaces(checked === true)}
 							variant="description"
 						/>
-						<span className="text-vscode-foreground">{t("history:showAllWorkspaces")}</span>
+						<label htmlFor="show-all-workspaces-view" className="text-vscode-foreground cursor-pointer">
+							{t("history:showAllWorkspaces")}
+						</label>
 					</div>
 
 					{/* Select all control in selection mode */}