Skip to content

Commit b67b4ff

Browse files
authored
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
1 parent 6f4f8cf commit b67b4ff

File tree

4 files changed

+34
-43
lines changed

4 files changed

+34
-43
lines changed

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/workflow-block/hooks/use-child-deployment.ts

Lines changed: 25 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -35,19 +35,12 @@ export function useChildDeployment(childWorkflowId: string | undefined): UseChil
3535
try {
3636
setIsLoading(true)
3737

38-
// Fetch both deployment versions and workflow metadata in parallel
39-
const [deploymentsRes, workflowRes] = await Promise.all([
40-
fetch(`/api/workflows/${wfId}/deployments`, {
41-
cache: 'no-store',
42-
headers: { 'Cache-Control': 'no-cache' },
43-
}),
44-
fetch(`/api/workflows/${wfId}`, {
45-
cache: 'no-store',
46-
headers: { 'Cache-Control': 'no-cache' },
47-
}),
48-
])
38+
const statusRes = await fetch(`/api/workflows/${wfId}/status`, {
39+
cache: 'no-store',
40+
headers: { 'Cache-Control': 'no-cache' },
41+
})
4942

50-
if (!deploymentsRes.ok || !workflowRes.ok) {
43+
if (!statusRes.ok) {
5144
if (!cancelled) {
5245
setActiveVersion(null)
5346
setIsDeployed(null)
@@ -56,32 +49,30 @@ export function useChildDeployment(childWorkflowId: string | undefined): UseChil
5649
return
5750
}
5851

59-
const deploymentsJson = await deploymentsRes.json()
60-
const workflowJson = await workflowRes.json()
52+
const statusData = await statusRes.json()
6153

62-
const versions = Array.isArray(deploymentsJson?.data?.versions)
63-
? deploymentsJson.data.versions
64-
: Array.isArray(deploymentsJson?.versions)
65-
? deploymentsJson.versions
66-
: []
54+
const deploymentsRes = await fetch(`/api/workflows/${wfId}/deployments`, {
55+
cache: 'no-store',
56+
headers: { 'Cache-Control': 'no-cache' },
57+
})
6758

68-
const active = versions.find((v: any) => v.isActive)
69-
const workflowUpdatedAt = workflowJson?.data?.updatedAt || workflowJson?.updatedAt
59+
let activeVersion = null
60+
if (deploymentsRes.ok) {
61+
const deploymentsJson = await deploymentsRes.json()
62+
const versions = Array.isArray(deploymentsJson?.data?.versions)
63+
? deploymentsJson.data.versions
64+
: Array.isArray(deploymentsJson?.versions)
65+
? deploymentsJson.versions
66+
: []
7067

71-
if (!cancelled) {
72-
const v = active ? Number(active.version) : null
73-
const deployed = v != null
74-
setActiveVersion(v)
75-
setIsDeployed(deployed)
68+
const active = versions.find((v: any) => v.isActive)
69+
activeVersion = active ? Number(active.version) : null
70+
}
7671

77-
// Check if workflow has been updated since deployment
78-
if (deployed && active?.createdAt && workflowUpdatedAt) {
79-
const deploymentTime = new Date(active.createdAt).getTime()
80-
const updateTime = new Date(workflowUpdatedAt).getTime()
81-
setNeedsRedeploy(updateTime > deploymentTime)
82-
} else {
83-
setNeedsRedeploy(false)
84-
}
72+
if (!cancelled) {
73+
setActiveVersion(activeVersion)
74+
setIsDeployed(statusData.isDeployed || false)
75+
setNeedsRedeploy(statusData.needsRedeployment || false)
8576
}
8677
} catch {
8778
if (!cancelled) {

apps/sim/components/emails/base-styles.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export const baseStyles = {
3131
},
3232
button: {
3333
display: 'inline-block',
34-
backgroundColor: '#802FFF',
34+
backgroundColor: '#6F3DFA',
3535
color: '#ffffff',
3636
fontWeight: 'bold',
3737
fontSize: '16px',
@@ -42,7 +42,7 @@ export const baseStyles = {
4242
margin: '20px 0',
4343
},
4444
link: {
45-
color: '#802FFF',
45+
color: '#6F3DFA',
4646
textDecoration: 'underline',
4747
},
4848
footer: {
@@ -79,7 +79,7 @@ export const baseStyles = {
7979
width: '249px',
8080
},
8181
sectionCenter: {
82-
borderBottom: '1px solid #802FFF',
82+
borderBottom: '1px solid #6F3DFA',
8383
width: '102px',
8484
},
8585
}

apps/sim/components/emails/careers-confirmation-email.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,12 +78,12 @@ export const CareersConfirmationEmail = ({
7878
href='https://docs.sim.ai'
7979
target='_blank'
8080
rel='noopener noreferrer'
81-
style={{ color: '#802FFF', textDecoration: 'none' }}
81+
style={{ color: '#6F3DFA', textDecoration: 'none' }}
8282
>
8383
documentation
8484
</a>{' '}
8585
to learn more about what we're building, or check out our{' '}
86-
<a href={`${baseUrl}/studio`} style={{ color: '#802FFF', textDecoration: 'none' }}>
86+
<a href={`${baseUrl}/studio`} style={{ color: '#6F3DFA', textDecoration: 'none' }}>
8787
blog
8888
</a>{' '}
8989
for the latest updates.

apps/sim/components/emails/careers-submission-email.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ export const CareersSubmissionEmail = ({
144144
<td style={{ padding: '8px 0', fontSize: '14px', color: '#333333' }}>
145145
<a
146146
href={`mailto:${email}`}
147-
style={{ color: '#802FFF', textDecoration: 'none' }}
147+
style={{ color: '#6F3DFA', textDecoration: 'none' }}
148148
>
149149
{email}
150150
</a>
@@ -163,7 +163,7 @@ export const CareersSubmissionEmail = ({
163163
Phone:
164164
</td>
165165
<td style={{ padding: '8px 0', fontSize: '14px', color: '#333333' }}>
166-
<a href={`tel:${phone}`} style={{ color: '#802FFF', textDecoration: 'none' }}>
166+
<a href={`tel:${phone}`} style={{ color: '#6F3DFA', textDecoration: 'none' }}>
167167
{phone}
168168
</a>
169169
</td>
@@ -231,7 +231,7 @@ export const CareersSubmissionEmail = ({
231231
href={linkedin}
232232
target='_blank'
233233
rel='noopener noreferrer'
234-
style={{ color: '#802FFF', textDecoration: 'none' }}
234+
style={{ color: '#6F3DFA', textDecoration: 'none' }}
235235
>
236236
View Profile
237237
</a>
@@ -255,7 +255,7 @@ export const CareersSubmissionEmail = ({
255255
href={portfolio}
256256
target='_blank'
257257
rel='noopener noreferrer'
258-
style={{ color: '#802FFF', textDecoration: 'none' }}
258+
style={{ color: '#6F3DFA', textDecoration: 'none' }}
259259
>
260260
View Portfolio
261261
</a>

0 commit comments

Comments
 (0)