Skip to content

chore(site): update and refactor all custom hook tests that rely on React Router #12219

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

Merged
merged 20 commits into from
Mar 8, 2024
Merged
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
0b186bf
chore: rename useTab to useSearchParamsKey and add test
Parkreiner Feb 19, 2024
a7a0944
chore: mark old renderHookWithAuth as deprecated (temp)
Parkreiner Feb 19, 2024
ec3ba4f
fix: update imports for useResourcesNav
Parkreiner Feb 19, 2024
6d7ef9f
Merge branch 'main' into mes/hook-test-revamps-4
Parkreiner Mar 3, 2024
afffb26
refactor: change API for useSearchParamsKey
Parkreiner Mar 3, 2024
590f02b
chore: let user pass in their own URLSearchParams value
Parkreiner Mar 3, 2024
9e00ea6
refactor: clean up comments for clarity
Parkreiner Mar 3, 2024
d7110c5
fix: update import
Parkreiner Mar 3, 2024
2cc63d7
wip: commit progress on useWorkspaceDuplication revamp
Parkreiner Mar 3, 2024
26089e3
chore: migrate duplication test to new helper
Parkreiner Mar 3, 2024
8057397
refactor: update code for clarity
Parkreiner Mar 3, 2024
f8f87a3
refactor: reorder test cases for clarity
Parkreiner Mar 3, 2024
dcc89dc
refactor: split off hook helper into separate file
Parkreiner Mar 3, 2024
1ab6f03
refactor: remove reliance on internal React Router state property
Parkreiner Mar 4, 2024
b32603f
refactor: move variables around for more clarity
Parkreiner Mar 4, 2024
b0fabde
refactor: more updates for clarity
Parkreiner Mar 4, 2024
b94decc
refactor: reorganize test cases for clarity
Parkreiner Mar 4, 2024
3e41877
refactor: clean up test cases for useWorkspaceDupe
Parkreiner Mar 8, 2024
1fcf9e2
refactor: clean up test cases for useWorkspaceDupe
Parkreiner Mar 8, 2024
13f5e53
Merge branch 'main' into mes/hook-test-revamps-4
Parkreiner Mar 8, 2024
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
Prev Previous commit
Next Next commit
fix: update import
  • Loading branch information
Parkreiner committed Mar 3, 2024
commit d7110c51fd9e988bd326f656ea219405efb1a518
13 changes: 8 additions & 5 deletions site/src/pages/WorkspaceBuildPage/WorkspaceBuildPageView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import {
} from "modules/workspaces/WorkspaceBuild/WorkspaceBuildData";
import { Sidebar, SidebarCaption, SidebarItem } from "./Sidebar";
import { TAB_PADDING_X, TabLink, Tabs, TabsList } from "components/Tabs/Tabs";
import { useTab } from "hooks";
import { useSearchParamsKey } from "hooks/useSearchParamsKey";
import { AgentLogs, useAgentLogs } from "modules/resources/AgentLogs";

export const LOGS_TAB_KEY = "logs";
Expand All @@ -51,14 +51,17 @@ export const WorkspaceBuildPageView: FC<WorkspaceBuildPageViewProps> = ({
activeBuildNumber,
}) => {
const theme = useTheme();
const tab = useTab(LOGS_TAB_KEY, "build");
const tabState = useSearchParamsKey({
key: LOGS_TAB_KEY,
defaultValue: "build",
});

if (!build) {
return <Loader />;
}

const agents = build.resources.flatMap((r) => r.agents ?? []);
const selectedAgent = agents.find((a) => a.id === tab.value);
const selectedAgent = agents.find((a) => a.id === tabState.value);

return (
<DashboardFullPage>
Expand Down Expand Up @@ -141,7 +144,7 @@ export const WorkspaceBuildPageView: FC<WorkspaceBuildPageViewProps> = ({
</Sidebar>

<div css={{ height: "100%", overflowY: "auto", width: "100%" }}>
<Tabs active={tab.value}>
<Tabs active={tabState.value}>
<TabsList>
<TabLink to={`?${LOGS_TAB_KEY}=build`} value="build">
Build
Expand Down Expand Up @@ -187,7 +190,7 @@ export const WorkspaceBuildPageView: FC<WorkspaceBuildPageViewProps> = ({
</Alert>
)}

{tab.value === "build" ? (
{tabState.value === "build" ? (
<BuildLogsContent logs={logs} />
) : (
<AgentLogsContent agent={selectedAgent!} />
Expand Down