Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 | <script setup lang="ts">
import type { NodeProps } from '@vue-flow/core'
import { Clock, Calendar } from 'lucide-vue-next'
import { ElTooltip } from 'element-plus'
import BaseNode from '@/components/nodes/BaseNode.vue'
import { useTestWorkflow } from '@/composables/trigger/useTestWorkflow'
interface ScheduleTriggerData {
label?: string
cron?: string
timezone?: string
}
const props = defineProps<NodeProps<ScheduleTriggerData>>()
const emit = defineEmits<{
'open-config': []
'test-node': []
'updateNodeInternals': [nodeId: string]
}>()
const { testWorkflow, isButtonDisabled, buttonLabel, buttonTooltip } = useTestWorkflow(props.id)
const formatCron = (cron?: string): string => {
if (!cron) return 'Not configured'
const patterns: Record<string, string> = {
'* * * * *': 'Every minute',
'0 * * * *': 'Every hour',
'0 0 * * *': 'Daily at midnight',
'0 9 * * *': 'Daily at 9:00 AM',
'0 0 * * 0': 'Weekly (Sunday)',
'0 0 1 * *': 'Monthly (1st day)',
}
return patterns[cron] || cron
}
</script>
<template>
<BaseNode
:node-props="props"
:show-input-handle="false"
node-class="schedule-trigger-node"
default-label="Schedule"
action-button-tooltip="Test Schedule"
@open-config="emit('open-config')"
@action-button="emit('test-node')"
@updateNodeInternals="emit('updateNodeInternals', $event)"
>
<template #icon>
<Clock :size="24" />
<Calendar :size="12" class="icon-decoration" />
</template>
<template #badge>
<div class="schedule-info">
<div v-if="props.data?.cron" class="cron-badge">
{{ formatCron(props.data.cron) }}
</div>
<div v-if="props.data?.timezone" class="timezone-badge">
{{ props.data.timezone }}
</div>
</div>
</template>
<template #left-actions>
<ElTooltip :content="buttonTooltip" placement="left">
<button
class="test-workflow-button"
:disabled="isButtonDisabled"
@click="testWorkflow"
>
{{ buttonLabel }}
</button>
</ElTooltip>
</template>
</BaseNode>
</template>
<style lang="scss">
@use '@/styles/nodes/base' as *;
$node-color: var(--rf-color-primary);
.schedule-trigger-node {
@include node-base();
@include node-handle($node-color);
.node-body {
@include node-glass($node-color);
&:hover {
box-shadow:
0 6px 20px rgba($node-color, 0.3),
inset 0 0 0 1px rgba($node-color, 0.2);
}
}
.node-icon {
@include node-icon(var(--rf-size-icon-md), var(--rf-gradient-primary));
}
}
</style>
<style lang="scss" scoped>
$node-color: var(--rf-color-primary);
.icon-decoration {
position: absolute;
top: calc(var(--rf-spacing-3xs) * -1);
right: calc(var(--rf-spacing-3xs) * -1);
color: var(--rf-color-success);
}
.schedule-info {
display: flex;
flex-direction: column;
gap: var(--rf-spacing-2xs);
}
.cron-badge {
font-size: var(--rf-font-size-xs);
color: $node-color;
background: rgba($node-color, var(--rf-opacity-overlay));
padding: var(--rf-spacing-3xs) var(--rf-spacing-xs);
border-radius: var(--rf-radius-small);
display: inline-block;
font-weight: var(--rf-font-weight-medium);
}
.timezone-badge {
font-size: var(--rf-font-size-2xs);
color: var(--rf-color-text-secondary);
background: var(--rf-color-bg-secondary);
padding: var(--rf-spacing-4xs) var(--rf-spacing-2xs);
border-radius: var(--rf-radius-small);
display: inline-block;
max-width: 100%;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.test-workflow-button {
padding: var(--rf-spacing-2xs) var(--rf-spacing-sm);
border-radius: var(--rf-radius-base);
background: var(--rf-gradient-primary);
border: none;
color: var(--rf-color-white);
font-size: var(--rf-font-size-xs);
font-weight: var(--rf-font-weight-medium);
cursor: pointer;
display: flex;
align-items: center;
justify-content: center;
transition: all var(--rf-transition-fast);
box-shadow: var(--rf-shadow-base);
white-space: nowrap;
&:hover:not(:disabled) {
transform: translateY(-2px);
box-shadow: var(--rf-shadow-md);
background: var(--rf-gradient-primary-dark);
}
&:active:not(:disabled) {
transform: translateY(0);
box-shadow: var(--rf-shadow-sm);
}
&:disabled {
opacity: 0.6;
cursor: not-allowed;
background: var(--rf-color-primary-disabled);
}
}
</style>
|