Skip to content

Commit

Permalink
Simplify theme update effect and minor fixes (#275)
Browse files Browse the repository at this point in the history
  • Loading branch information
Rodri77 authored Feb 23, 2025
1 parent ec0af41 commit 36e66c2
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 16 deletions.
5 changes: 2 additions & 3 deletions apps/connect-dev/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@ export default function Home() {
baseUrl="http://localhost:4000"
params={{
token: process.env['OPENINT_TOKEN'],
connectionId: 'conn_github_01JH6FR8H2E1G79HJVYEANYM7T',
view: 'manage-deeplink',
theme: 'light',
view: 'manage',
theme: 'dark',
}}
height={500}
width={350}
Expand Down
4 changes: 1 addition & 3 deletions apps/web/app/dashboard/(authenticated)/connect/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,7 @@ export default function MagicLinkPage() {
<SchemaForm
// Omit theme from schema since there's a bug where the tailwind theme setting
// is shared between connect and console
schema={customerRouterSchema.createMagicLink.input.omit({
theme: true,
})}
schema={customerRouterSchema.createMagicLink.input}
uiSchema={uiSchema}
loading={createMagicLink.isLoading}
formData={{
Expand Down
5 changes: 5 additions & 0 deletions apps/web/app/global.css
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,11 @@
@apply flex h-10 w-full rounded-lg border border-input bg-transparent px-3 py-2 text-sm ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50;
}

/* Select component */
.schema-form select {
@apply flex h-10 w-full rounded-lg border border-input bg-transparent px-3 py-2 text-sm ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50;
}

/* .schema-form .checkbox label {
@apply
} */
Expand Down
12 changes: 2 additions & 10 deletions packages/engine-frontend/components/ConnectionPortal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export function ConnectionPortal({className}: ConnectionPortalProps) {
const pathname = usePathname()
const {theme, setTheme} = useTheme()
const connectionId = searchParams.get('connectionId')
const themeParam = searchParams.get('theme')

const {toast} = useToast()
const ctx = _trpcReact.useContext()
Expand All @@ -63,20 +64,11 @@ export function ConnectionPortal({className}: ConnectionPortalProps) {
})

useEffect(() => {
const themeParam = searchParams.get('theme')

// Only update if there's a valid theme parameter that differs from current theme
if (themeParam && isValidTheme(themeParam) && themeParam !== theme) {
setTheme(themeParam)
} else if (!themeParam && theme) {
// Only update URL if there's no theme parameter but we have a theme set
const params = new URLSearchParams(searchParams)
params.set('theme', theme)
router.replace(`${pathname}?${params.toString()}`, {
scroll: false,
})
}
}, [searchParams, setTheme, theme, pathname, router])
}, [themeParam, setTheme, theme])

const deleteConnection = _trpcReact.deleteConnection.useMutation({
onSuccess: () => {
Expand Down

0 comments on commit 36e66c2

Please sign in to comment.