fix(workflow-block): fix redeploy header to not repeatedly show redeploy when redeploy is not necessary (#1973)

* fix(workflow-block): fix redeploy header to not repeatedly show redeploy when redeploy is not necessary

* cleanup
This commit is contained in:
Waleed
2025-11-13 15:40:09 -08:00
committed by GitHub
parent 6f4f8cfad2
commit b67b4ff8fb
4 changed files with 34 additions and 43 deletions

View File

@@ -35,19 +35,12 @@ export function useChildDeployment(childWorkflowId: string | undefined): UseChil
try {
setIsLoading(true)
// Fetch both deployment versions and workflow metadata in parallel
const [deploymentsRes, workflowRes] = await Promise.all([
fetch(`/api/workflows/${wfId}/deployments`, {
cache: 'no-store',
headers: { 'Cache-Control': 'no-cache' },
}),
fetch(`/api/workflows/${wfId}`, {
cache: 'no-store',
headers: { 'Cache-Control': 'no-cache' },
}),
])
const statusRes = await fetch(`/api/workflows/${wfId}/status`, {
cache: 'no-store',
headers: { 'Cache-Control': 'no-cache' },
})
if (!deploymentsRes.ok || !workflowRes.ok) {
if (!statusRes.ok) {
if (!cancelled) {
setActiveVersion(null)
setIsDeployed(null)
@@ -56,32 +49,30 @@ export function useChildDeployment(childWorkflowId: string | undefined): UseChil
return
}
const deploymentsJson = await deploymentsRes.json()
const workflowJson = await workflowRes.json()
const statusData = await statusRes.json()
const versions = Array.isArray(deploymentsJson?.data?.versions)
? deploymentsJson.data.versions
: Array.isArray(deploymentsJson?.versions)
? deploymentsJson.versions
: []
const deploymentsRes = await fetch(`/api/workflows/${wfId}/deployments`, {
cache: 'no-store',
headers: { 'Cache-Control': 'no-cache' },
})
const active = versions.find((v: any) => v.isActive)
const workflowUpdatedAt = workflowJson?.data?.updatedAt || workflowJson?.updatedAt
let activeVersion = null
if (deploymentsRes.ok) {
const deploymentsJson = await deploymentsRes.json()
const versions = Array.isArray(deploymentsJson?.data?.versions)
? deploymentsJson.data.versions
: Array.isArray(deploymentsJson?.versions)
? deploymentsJson.versions
: []
const active = versions.find((v: any) => v.isActive)
activeVersion = active ? Number(active.version) : null
}
if (!cancelled) {
const v = active ? Number(active.version) : null
const deployed = v != null
setActiveVersion(v)
setIsDeployed(deployed)
// Check if workflow has been updated since deployment
if (deployed && active?.createdAt && workflowUpdatedAt) {
const deploymentTime = new Date(active.createdAt).getTime()
const updateTime = new Date(workflowUpdatedAt).getTime()
setNeedsRedeploy(updateTime > deploymentTime)
} else {
setNeedsRedeploy(false)
}
setActiveVersion(activeVersion)
setIsDeployed(statusData.isDeployed || false)
setNeedsRedeploy(statusData.needsRedeployment || false)
}
} catch {
if (!cancelled) {

View File

@@ -31,7 +31,7 @@ export const baseStyles = {
},
button: {
display: 'inline-block',
backgroundColor: '#802FFF',
backgroundColor: '#6F3DFA',
color: '#ffffff',
fontWeight: 'bold',
fontSize: '16px',
@@ -42,7 +42,7 @@ export const baseStyles = {
margin: '20px 0',
},
link: {
color: '#802FFF',
color: '#6F3DFA',
textDecoration: 'underline',
},
footer: {
@@ -79,7 +79,7 @@ export const baseStyles = {
width: '249px',
},
sectionCenter: {
borderBottom: '1px solid #802FFF',
borderBottom: '1px solid #6F3DFA',
width: '102px',
},
}

View File

@@ -78,12 +78,12 @@ export const CareersConfirmationEmail = ({
href='https://docs.sim.ai'
target='_blank'
rel='noopener noreferrer'
style={{ color: '#802FFF', textDecoration: 'none' }}
style={{ color: '#6F3DFA', textDecoration: 'none' }}
>
documentation
</a>{' '}
to learn more about what we're building, or check out our{' '}
<a href={`${baseUrl}/studio`} style={{ color: '#802FFF', textDecoration: 'none' }}>
<a href={`${baseUrl}/studio`} style={{ color: '#6F3DFA', textDecoration: 'none' }}>
blog
</a>{' '}
for the latest updates.

View File

@@ -144,7 +144,7 @@ export const CareersSubmissionEmail = ({
<td style={{ padding: '8px 0', fontSize: '14px', color: '#333333' }}>
<a
href={`mailto:${email}`}
style={{ color: '#802FFF', textDecoration: 'none' }}
style={{ color: '#6F3DFA', textDecoration: 'none' }}
>
{email}
</a>
@@ -163,7 +163,7 @@ export const CareersSubmissionEmail = ({
Phone:
</td>
<td style={{ padding: '8px 0', fontSize: '14px', color: '#333333' }}>
<a href={`tel:${phone}`} style={{ color: '#802FFF', textDecoration: 'none' }}>
<a href={`tel:${phone}`} style={{ color: '#6F3DFA', textDecoration: 'none' }}>
{phone}
</a>
</td>
@@ -231,7 +231,7 @@ export const CareersSubmissionEmail = ({
href={linkedin}
target='_blank'
rel='noopener noreferrer'
style={{ color: '#802FFF', textDecoration: 'none' }}
style={{ color: '#6F3DFA', textDecoration: 'none' }}
>
View Profile
</a>
@@ -255,7 +255,7 @@ export const CareersSubmissionEmail = ({
href={portfolio}
target='_blank'
rel='noopener noreferrer'
style={{ color: '#802FFF', textDecoration: 'none' }}
style={{ color: '#6F3DFA', textDecoration: 'none' }}
>
View Portfolio
</a>