Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(ui): Add "Export" action allowing to download the flow source code. #6610

Merged
merged 3 commits into from
Jan 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion ui/src/components/inputs/EditorButtons.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@
</el-button>
<template #dropdown>
<el-dropdown-menu class="m-dropdown-menu">
<el-dropdown-item
v-if="isAllowedEdit"
:icon="Download"
size="large"
@click="forwardEvent('export-yaml')"
>
{{ $t("export_to_file") }}
</el-dropdown-item>
<el-dropdown-item
v-if="!isCreating && canDelete"
:icon="Delete"
Expand Down Expand Up @@ -75,6 +83,7 @@
import LightningBolt from "vue-material-design-icons/LightningBolt.vue";
import FileEdit from "vue-material-design-icons/FileEdit.vue";
import ContentSave from "vue-material-design-icons/ContentSave.vue";
import Download from "vue-material-design-icons/Download.vue";
</script>
<script>
import {defineComponent} from "vue";
Expand All @@ -86,7 +95,8 @@
"open-new-error",
"open-new-trigger",
"open-edit-metadata",
"save"
"save",
"export-yaml"
],
props: {
isCreating: {
Expand Down
16 changes: 16 additions & 0 deletions ui/src/components/inputs/EditorView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,13 @@
:infos="flowInfos"
/>

<el-button
v-if="!isNamespace"
:icon="Download"
@click="exportYaml"
class="ms-2 me-0"
/>

<EditorButtons
v-if="isCreating || openedTabs.length"
:is-creating="props.isCreating"
Expand All @@ -111,6 +118,7 @@
@open-new-error="isNewErrorOpen = true"
@open-new-trigger="isNewTriggerOpen = true"
@open-edit-metadata="isEditMetadataOpen = true"
@export-yaml="exportYaml"
:is-namespace="isNamespace"
/>
</div>
Expand Down Expand Up @@ -316,6 +324,7 @@
import MenuClose from "vue-material-design-icons/MenuClose.vue";
import Close from "vue-material-design-icons/Close.vue";
import CircleMedium from "vue-material-design-icons/CircleMedium.vue";
import Download from "vue-material-design-icons/Download.vue";

import TypeIcon from "../utils/icons/Type.vue"

Expand All @@ -338,6 +347,8 @@
import Drawer from "../Drawer.vue";
import {ElMessageBox} from "element-plus";

import localUtils from "../../utils/utils";

import NoCode from "../code/NoCode.vue";

const store = useStore();
Expand Down Expand Up @@ -1315,6 +1326,11 @@
const closeTabsToRight = (index) => {
closeTabs(openedTabs.value.slice(index + 1).filter(tab => tab !== FLOW_TAB.value), openedTabs.value[index]);
};

const exportYaml = () => {
const blob = new Blob([flowYaml.value], {type: "text/yaml"});
localUtils.downloadUrl(blob, "flow.yaml");
};
</script>

<style lang="scss" scoped>
Expand Down
1 change: 1 addition & 0 deletions ui/src/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,7 @@
"add global error handler": "Add global error handler",
"add error handler": "Add an error handler",
"add trigger": "Add trigger",
"export_to_file": "Export to file",
"edit metadata": "Edit Metadata",
"taskDefaults": "Task Defaults",
"disabled": "Disabled",
Expand Down
Loading