Skip to content

Commit 67d6a34

Browse files
committed
fix(platform): commit detail history before presentation
1 parent 6d4fe36 commit 67d6a34

2 files changed

Lines changed: 21 additions & 11 deletions

File tree

‎apps/sim/platform/app/(shell)/integrations/_components/fixtures/integration-details/integration-details.tsx‎

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use client'
22

3-
import { useState } from 'react'
3+
import { useState, useTransition } from 'react'
44
import { generateId } from '@sim/utils/id'
55
import Link from 'next/link'
66
import { useQueryStates } from 'nuqs'
@@ -53,12 +53,15 @@ export function IntegrationDetails({
5353
onAddSkill,
5454
}: IntegrationDetailsProps) {
5555
const [view, setView] = useQueryStates(credentialParams)
56+
const [isOpening, startOpening] = useTransition()
5657
const [enrollment, setEnrollment] = useState<{
5758
connection: CredentialConnection
5859
credential?: IntegrationCredential
5960
} | null>(null)
6061
const [disconnecting, setDisconnecting] = useState<IntegrationCredential | null>(null)
61-
const selected = integration.credentials.find((credential) => credential.id === view.credential)
62+
const selected = isOpening
63+
? undefined
64+
: integration.credentials.find((credential) => credential.id === view.credential)
6265
const connections = catalog?.connections ?? []
6366
const selectedScope = selected?.scope
6467
const workspace =
@@ -81,9 +84,11 @@ export function IntegrationDetails({
8184
)
8285
)
8386
}
84-
async function open(credential: IntegrationCredential) {
85-
await setView({})
86-
void setView({ credential: credential.id }, { history: 'push', scroll: false })
87+
function open(credential: IntegrationCredential) {
88+
startOpening(async () => {
89+
await setView({})
90+
await setView({ credential: credential.id }, { history: 'push', scroll: false })
91+
})
8792
}
8893
function save(credential: IntegrationCredential) {
8994
const current = integration.credentials.find((entry) => entry.id === credential.id)
@@ -271,7 +276,7 @@ export function IntegrationDetails({
271276
<CredentialList
272277
integrationName={integration.name}
273278
credentials={integration.credentials}
274-
onOpen={(credential) => void open(credential)}
279+
onOpen={open}
275280
/>
276281
{catalog && (
277282
<IntegrationCapabilities

‎apps/sim/platform/app/(shell)/integrations/_components/integration-center/integration-center.tsx‎

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use client'
22

3-
import { useState } from 'react'
3+
import { useState, useTransition } from 'react'
44
import { usePathname, useRouter, useSearchParams } from 'next/navigation'
55
import { useQueryStates } from 'nuqs'
66
import styles from '@/platform/app/(shell)/integrations/_components/integration-center/integration-center.module.css'
@@ -62,6 +62,7 @@ export function IntegrationCenter({
6262
const router = useRouter()
6363
const search = useSearchParams()
6464
const [view, setView] = useQueryStates(centerParams, { history: 'replace', shallow: true })
65+
const [isOpening, startOpening] = useTransition()
6566
const [creating, setCreating] = useState<IntegrationResource['kind'] | null>(null)
6667
const [deleting, setDeleting] = useState<IntegrationResource | null>(null)
6768
const tabs = library
@@ -115,15 +116,19 @@ export function IntegrationCenter({
115116
)
116117
.sort(compare)
117118
.map((app) => ({ ...app, href: serializeCenter(app.href, { ...view, resource: null }) }))
118-
const editing = library?.data.resources.find((resource) => resource.id === view.resource)
119+
const editing = isOpening
120+
? undefined
121+
: library?.data.resources.find((resource) => resource.id === view.resource)
119122
const empty =
120123
current === 'apps'
121124
? !visibleApps.length
122125
: !resources.length && !(current === 'credentials' && credentialLinks.length)
123126

124-
async function open(resource: IntegrationResource) {
125-
await setView({})
126-
void setView({ resource: resource.id }, { history: 'push', scroll: false })
127+
function open(resource: IntegrationResource) {
128+
startOpening(async () => {
129+
await setView({})
130+
await setView({ resource: resource.id }, { history: 'push', scroll: false })
131+
})
127132
}
128133

129134
async function navigate(href: string) {

0 commit comments

Comments
 (0)