Skip to content

Commit

Permalink
refactor(editor): Migrate RunInfo.vue to composition API (#10721)
Browse files Browse the repository at this point in the history
  • Loading branch information
RicardoE105 authored and riascho committed Sep 23, 2024
1 parent cb08e76 commit 9825325
Showing 1 changed file with 34 additions and 35 deletions.
69 changes: 34 additions & 35 deletions packages/editor-ui/src/components/RunInfo.vue
Original file line number Diff line number Diff line change
@@ -1,33 +1,34 @@
<script lang="ts">
import { defineComponent } from 'vue';
<script setup lang="ts">
import type { ITaskData } from 'n8n-workflow';
import { convertToDisplayDateComponents } from '@/utils/formatters/dateFormatter';
import { computed } from 'vue';
import { useI18n } from '@/composables/useI18n';
export default defineComponent({
props: {
taskData: {}, // ITaskData
hasStaleData: Boolean,
hasPinData: Boolean,
},
const i18n = useI18n();
computed: {
theme(): string {
return this.runTaskData?.error ? 'danger' : 'success';
},
runTaskData(): ITaskData {
return this.taskData as ITaskData;
},
runMetadata(): { executionTime: number; startTime: string } | null {
if (!this.runTaskData) {
return null;
}
const { date, time } = convertToDisplayDateComponents(this.runTaskData.startTime);
return {
executionTime: this.runTaskData.executionTime,
startTime: `${date} at ${time}`,
};
},
},
const props = defineProps<{
taskData: ITaskData | null;
hasStaleData?: boolean;
hasPinData?: boolean;
}>();
const runTaskData = computed(() => {
return props.taskData;
});
const theme = computed(() => {
return props.taskData?.error ? 'danger' : 'success';
});
const runMetadata = computed(() => {
if (!runTaskData.value) {
return null;
}
const { date, time } = convertToDisplayDateComponents(runTaskData.value.startTime);
return {
executionTime: runTaskData.value.executionTime,
startTime: `${date} at ${time}`,
};
});
</script>

Expand All @@ -41,7 +42,7 @@ export default defineComponent({
>
<span
v-html="
$locale.baseText(
i18n.baseText(
hasPinData
? 'ndv.output.staleDataWarning.pinData'
: 'ndv.output.staleDataWarning.regular',
Expand All @@ -59,19 +60,17 @@ export default defineComponent({
<div>
<n8n-text :bold="true" size="small"
>{{
runTaskData.error
? $locale.baseText('runData.executionStatus.failed')
: $locale.baseText('runData.executionStatus.success')
runTaskData?.error
? i18n.baseText('runData.executionStatus.failed')
: i18n.baseText('runData.executionStatus.success')
}} </n8n-text
><br />
<n8n-text :bold="true" size="small">{{
$locale.baseText('runData.startTime') + ':'
}}</n8n-text>
<n8n-text :bold="true" size="small">{{ i18n.baseText('runData.startTime') + ':' }}</n8n-text>
{{ runMetadata.startTime }}<br />
<n8n-text :bold="true" size="small">{{
$locale.baseText('runData.executionTime') + ':'
i18n.baseText('runData.executionTime') + ':'
}}</n8n-text>
{{ runMetadata.executionTime }} {{ $locale.baseText('runData.ms') }}
{{ runMetadata.executionTime }} {{ i18n.baseText('runData.ms') }}
</div>
</n8n-info-tip>
</template>

0 comments on commit 9825325

Please sign in to comment.