Skip to content

Commit

Permalink
feat(ui): add a button to export all flow & templates
Browse files Browse the repository at this point in the history
close #1010
  • Loading branch information
tchiotludo committed Feb 24, 2023
1 parent 53b84c6 commit 21db60b
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 1 deletion.
39 changes: 38 additions & 1 deletion ui/src/components/settings/Settings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,30 @@
<el-form-item :label="$t('Default log level')">
<log-level-selector clearable :value="defaultLogLevel" @update:model-value="onLevelChange" />
</el-form-item>

<el-form-item v-if="canReadFlows || canReadTemplates" :label="$t('exports')">
<el-button v-if="canReadFlows" :icon="Download" size="large" @click="exportFlows()">
{{ $t('export all flows') }}
</el-button>
<el-button v-if="canReadTemplates" :icon="Download" size="large" @click="exportTemplates()">
{{ $t('export all templates') }}
</el-button>
</el-form-item>
</el-form>
</div>
</template>

<script setup>
import Download from "vue-material-design-icons/Download.vue";
</script>

<script>
import RouteContext from "../../mixins/routeContext";
import NamespaceSelect from "../../components/namespace/NamespaceSelect.vue";
import LogLevelSelector from "../../components/logs/LogLevelSelector.vue";
import permission from "../../models/permission";
import action from "../../models/action";
import {mapState} from "vuex";
export default {
mixins: [RouteContext],
Expand Down Expand Up @@ -125,6 +141,7 @@
},
},
computed: {
...mapState("auth", ["user"]),
routeInfo() {
return {
title: this.$t("settings")
Expand All @@ -147,7 +164,27 @@
{value: "vs", text: "Light"},
{value: "dark", text: "Dark"}
]
}
},
canReadFlows() {
return this.user && this.user.isAllowed(permission.FLOW, action.READ);
},
canReadTemplates() {
return this.user && this.user.isAllowed(permission.TEMPLATE, action.READ);
},
exportFlows() {
return this.$store
.dispatch("flow/exportFlowByQuery", {})
.then(_ => {
this.$toast().success(this.$t("flows exported"));
})
},
exportTemplates() {
return this.$store
.dispatch("template/exportTemplateByQuery", {})
.then(_ => {
this.$toast().success(this.$t("templates exported"));
})
},
}
};
</script>
8 changes: 8 additions & 0 deletions ui/src/translations.json
Original file line number Diff line number Diff line change
Expand Up @@ -274,10 +274,13 @@
"execution already finished": "Execution <code>{executionId}</code> already finished",
"seeing old revision": "You are seeing an old revision: {revision}",
"export": "Export",
"exports": "Exports",
"template export": "Are you sure you want to export <code>{templateCount}</code> template(s)?",
"templates exported": "Templates exported",
"export all templates": "Export all templates",
"flow export": "Are you sure you want to export <code>{flowCount}</code> flow(s)?",
"flows exported": "Flows exported",
"export all flows": "Export all flows",
"import": "Import",
"dependencies": "Dependencies",
"see dependencies": "See dependencies",
Expand Down Expand Up @@ -561,10 +564,12 @@
"restore revision": "Êtes-vous sur de vouloir restaurer la revision <code>{revision}</code> ?",
"seeing old revision": "Vous visualisez une ancienne revision : {revision}",
"export": "Exporter",
"exports": "Exporter",
"template export": "Êtes vous sûr de vouloir exporter <code>{templateCount}</code> template(s)?",
"templates exported": "Templates exportés",
"flow export": "Êtes vous sûr de vouloir exporter <code>{flowCount}</code> flow(s)?",
"flows exported": "Flows exportés",
"export all flows": "Exporter tous les flows",
"import": "Importer",
"dependencies": "Dépendances",
"see dependencies": "Voir les dépendances",
Expand Down Expand Up @@ -846,10 +851,13 @@
"execution already finished": "Ausführung <code>{executionId}</code> bereits abgeschlossen",
"seeing old revision": "Sie sehen eine alte Revision: {revision}",
"export": "Export",
"exports": "Exports",
"template export": "Sind Sie sicher, dass Sie <code>{templateCount}</code> Template(n) exportieren möchten?",
"templates exported": "Template exportiert",
"export all templates": "Exportieren Sie alle Template",
"flow export": "Sind Sie sicher, dass Sie <code>{flowCount}</code> Flows exportieren möchten?",
"flows exported": "Flows exportiert",
"export all flows": "Exportieren Sie alle Flows",
"import": "Importieren",
"dependencies": "Abhängigkeiten",
"see dependencies": "Siehe Abhängigkeiten",
Expand Down

0 comments on commit 21db60b

Please sign in to comment.