Add workspace filter to historypreview as well (#2582)

* Add workspace filter to historypreview as well

* PR feedback
This commit is contained in:
Matt Rubens 2025-04-13 22:27:28 -04:00 committed by GitHub
parent 1c03234d64
commit eab61289a2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 24 additions and 4 deletions

View file

@ -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>
))}

View file

@ -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 */}