From 27f6efabf52c0c35fa48c0660e8986e912217673 Mon Sep 17 00:00:00 2001 From: Spike Curtis Date: Thu, 7 Nov 2024 11:32:20 +0400 Subject: [PATCH 1/5] chore: add resume token controller (#15346) Implements a controller for the Tailnet API resume token RPC, by refactoring from `workspacesdk`. chore re: #14729 --- tailnet/controllers.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tailnet/controllers.go b/tailnet/controllers.go index 3b032b4f323cf..7a3e23e2e216d 100644 --- a/tailnet/controllers.go +++ b/tailnet/controllers.go @@ -615,7 +615,7 @@ func newBasicResumeTokenRefresher( errCh: make(chan error, 1), } r.ctx, r.cancel = context.WithCancel(context.Background()) - r.timer = clock.AfterFunc(never, r.refresh, "basicResumeTokenRefresher") + r.timer = clock.AfterFunc(never, r.refresh) go r.refresh() return r } From 91054ef173d1720be9bd7e39b7f0f3c289044c49 Mon Sep 17 00:00:00 2001 From: Spike Curtis Date: Thu, 7 Nov 2024 17:24:19 +0400 Subject: [PATCH 2/5] chore: refactor tailnetAPIConnector to use dialer (#15347) refactors `tailnetAPIConnector` to use the `Dialer` interface in `tailnet`, introduced lower in this stack of PRs. This will let us use the same Tailnet API handling code across different things that connect to the Tailnet API (CLI client, coderd, workspace proxies, and soon: Coder VPN). chore re: #14729 --- tailnet/controllers.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tailnet/controllers.go b/tailnet/controllers.go index 7a3e23e2e216d..3b032b4f323cf 100644 --- a/tailnet/controllers.go +++ b/tailnet/controllers.go @@ -615,7 +615,7 @@ func newBasicResumeTokenRefresher( errCh: make(chan error, 1), } r.ctx, r.cancel = context.WithCancel(context.Background()) - r.timer = clock.AfterFunc(never, r.refresh) + r.timer = clock.AfterFunc(never, r.refresh, "basicResumeTokenRefresher") go r.refresh() return r } From 58131f2d99c4db12f7946b5fc214eb2ccfb460ac Mon Sep 17 00:00:00 2001 From: Jaayden Halko Date: Thu, 7 Nov 2024 02:35:43 +0000 Subject: [PATCH 3/5] feat: enable tailwind with storybook --- site/.storybook/preview.jsx | 1 + site/tailwind.config.js | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/site/.storybook/preview.jsx b/site/.storybook/preview.jsx index bbe185a75e068..f7a44b2e1392d 100644 --- a/site/.storybook/preview.jsx +++ b/site/.storybook/preview.jsx @@ -16,6 +16,7 @@ * Storybook decorator function used to inject baseline data dependencies into * our React components during testing. */ +import "../src/index.css"; import { ThemeProvider as EmotionThemeProvider } from "@emotion/react"; import CssBaseline from "@mui/material/CssBaseline"; import { diff --git a/site/tailwind.config.js b/site/tailwind.config.js index b9343b7add92c..7b1c8ad4c1e13 100644 --- a/site/tailwind.config.js +++ b/site/tailwind.config.js @@ -5,7 +5,7 @@ module.exports = { }, darkMode: ["selector"], content: ["./index.html", "./src/**/*.{js,ts,jsx,tsx}"], - important: "#root", + important: ["#root", "#storybook-root"], theme: { fontSize: { "2xs": ["0.626rem","0.875rem"], From 8203a3cb9bf57cd40c63b03f38bc5030e256c8ed Mon Sep 17 00:00:00 2001 From: BrunoQuaresma Date: Thu, 7 Nov 2024 20:56:51 +0000 Subject: [PATCH 4/5] Apply theme selector --- site/.storybook/preview.jsx | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/site/.storybook/preview.jsx b/site/.storybook/preview.jsx index f7a44b2e1392d..bd5ceb7e7dc68 100644 --- a/site/.storybook/preview.jsx +++ b/site/.storybook/preview.jsx @@ -135,6 +135,12 @@ function withTheme(Story, context) { const { themeOverride } = DecoratorHelpers.useThemeParameters(); const selected = themeOverride || selectedTheme || "dark"; + // Ensure the correct theme is applied to Tailwind CSS classes by adding the + // theme to the HTML class list. This approach is necessary because Tailwind + // CSS relies on class names to apply styles, and dynamically changing themes + // requires updating the class list accordingly. + document.querySelector("html")?.classList.add(selected); + return ( From f5e5de06cc893b295cd4fc95905155994d2b6ef5 Mon Sep 17 00:00:00 2001 From: BrunoQuaresma Date: Thu, 7 Nov 2024 21:08:57 +0000 Subject: [PATCH 5/5] Toggle theme class --- site/.storybook/preview.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/site/.storybook/preview.jsx b/site/.storybook/preview.jsx index bd5ceb7e7dc68..2dbc1308bb733 100644 --- a/site/.storybook/preview.jsx +++ b/site/.storybook/preview.jsx @@ -139,7 +139,7 @@ function withTheme(Story, context) { // theme to the HTML class list. This approach is necessary because Tailwind // CSS relies on class names to apply styles, and dynamically changing themes // requires updating the class list accordingly. - document.querySelector("html")?.classList.add(selected); + document.querySelector("html")?.setAttribute("class", selected); return (