Skip to content

feat: remove Run button replace with Reload button #1040

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pdl-live-react/src/page/MyTracesNavItems.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export default function MyTracesNavItems({
const id = "/my/" + encodeURIComponent(title)
return (
<NavItem key={filename} itemId={id} isActive={activeItem === id}>
<Link to={id + hash}>
<Link to={id + hash + "?traceFile=" + filename}>
<Stack>
{title}
<StackItem className="pdl-duration">
Expand Down
1 change: 1 addition & 0 deletions pdl-live-react/src/page/PageBreadcrumbs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export default function PageBreadcrumbs({
breadcrumb2,
}: PageBreadcrumbProps) {
const [searchParams] = useSearchParams()
searchParams.delete("traceFile")
const s = searchParams.toString()
const search = s.length > 0 ? "?" + s : ""
const renderHome = useCallback(
Expand Down
2 changes: 1 addition & 1 deletion pdl-live-react/src/page/welcome/Welcome.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export default function Welcome(props: Props) {
<Page breadcrumb1={props.breadcrumb1}>
<PageSection>
<Flex>
<Title headingLevel="h1">Prompt Declaration Language (PDL)</Title>{" "}
<Title headingLevel="h1">Prompt Declaration Language (PDL)</Title>
<FlexItem flex={flex1}>
<Toolbar />
</FlexItem>
Expand Down
7 changes: 6 additions & 1 deletion pdl-live-react/src/page/welcome/tiles/MyTraces.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,12 @@ export default function MyTraces() {
<Button key={filename} isInline variant="link" icon={<FileIcon />}>
<Link
to={
"/my/" + encodeURIComponent(title) + (s ? `?${s}` : "") + hash
"/my/" +
encodeURIComponent(title) +
(s ? `?${s}` : "") +
hash +
"?traceFile=" +
filename
}
>
{title}
Expand Down
1 change: 1 addition & 0 deletions pdl-live-react/src/view/masonry/MasonryCombo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ export default function MasonryCombo({ value, setValue }: Props) {
perPage={perPage}
setPage={setPage}
setPerPage={setPerPage}
setValue={setValue}
/>
</PageSection>
<PageSection
Expand Down
7 changes: 5 additions & 2 deletions pdl-live-react/src/view/masonry/Toolbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Toolbar, ToolbarGroup, ToolbarContent } from "@patternfly/react-core"
import DarkModeToggle from "../../page/DarkModeToggle"
import ToolbarPaginator from "./ToolbarPaginator"
import ToolbarSMLToggle from "./ToolbarSMLToggle"
import ToolbarReplayButton from "./ToolbarReplayButton"
import ToolbarReloadButton from "./ToolbarReloadButton"
import ToolbarShowSourceButton from "./ToolbarShowSourceButton"

import { isNonScalarPdlBlock } from "../../helpers"
Expand All @@ -19,6 +19,8 @@ export type Props = import("./ToolbarPaginator").Props & {

sml: SML
setSML(sml: SML): void

setValue(value: string): void
}

export default function MasonryToolbar({
Expand All @@ -33,12 +35,13 @@ export default function MasonryToolbar({
perPage,
setPage,
setPerPage,
setValue,
}: Props) {
return (
<Toolbar className="pdl-masonry-toolbar">
<ToolbarContent>
<ToolbarGroup variant="action-group-plain">
<ToolbarReplayButton run={run} isRunning={isRunning} />
<ToolbarReloadButton setValue={setValue} />
</ToolbarGroup>
<ToolbarGroup align={alignEnd} variant="action-group">
<ToolbarPaginator
Expand Down
41 changes: 41 additions & 0 deletions pdl-live-react/src/view/masonry/ToolbarReloadButton.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { invoke } from "@tauri-apps/api/core"
import { useCallback } from "react"
import { useSearchParams } from "react-router"
import { Button, Tooltip } from "@patternfly/react-core"

import Icon from "@patternfly/react-icons/dist/esm/icons/redo-icon"

type Props = {
setValue(value: string): void
}

export default function ToolbarReloadButton({ setValue }: Props) {
const [searchParams] = useSearchParams()
const traceFile = searchParams.get("traceFile")

const enabled = window.__TAURI_INTERNALS__ && searchParams.has("traceFile")
const handleClick = useCallback(async () => {
try {
const buf = await invoke<ArrayBuffer>("read_trace", {
traceFile,
}).catch(console.error)
if (buf) {
const decoder = new TextDecoder("utf-8") // Assuming UTF-8 encoding
const newTraceBuf = decoder.decode(new Uint8Array(buf))
if (newTraceBuf) {
setValue(newTraceBuf)
}
}
} catch (err) {
console.error(err)
}
}, [setValue])

return (
<Tooltip content="Reload this trace">
<Button isDisabled={!enabled} onClick={handleClick} icon={<Icon />}>
Reload
</Button>
</Tooltip>
)
}
Loading