Skip to content

Commit

Permalink
fix(ui): fix blueprints use button
Browse files Browse the repository at this point in the history
  • Loading branch information
fhussonnois committed Jan 23, 2025
1 parent 2045635 commit 8e5ffe8
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 23 deletions.
13 changes: 4 additions & 9 deletions ui/src/components/flows/FlowCreate.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import {mapGetters, mapMutations, mapState} from "vuex";
import RouteContext from "../../mixins/routeContext";
import TopNavBar from "../../components/layout/TopNavBar.vue";
import {apiUrl} from "override/utils/route";
export default {
mixins: [RouteContext],
Expand Down Expand Up @@ -51,14 +50,13 @@
methods: {
...mapMutations("editor", ["closeAllTabs"]),
async queryBlueprint(blueprintId) {
return (await this.$http.get(`${this.blueprintUri}/${blueprintId}/flow`)).data;
},
async setupFlow() {
const blueprintId = this.$route.query.blueprintId;
const blueprintSource = this.$route.query.blueprintSource;
if (this.$route.query.copy && this.flow){
this.source = this.flow.source;
} else if (this.$route.query.blueprintId && this.$route.query.blueprintSource) {
this.source = await this.queryBlueprint(this.$route.query.blueprintId)
} else if (blueprintId && blueprintSource) {
this.source = await this.$store.dispatch("blueprints/getBlueprintSource", {type: blueprintSource, kind: "flow", id: blueprintId});
} else {
const selectedNamespace = this.$route.query.namespace || "company.team";
this.source = `id: myflow
Expand All @@ -85,9 +83,6 @@ tasks:
title: this.$t("flows")
};
},
blueprintUri() {
return `${apiUrl(this.$store)}/blueprints/${this.$route.query.blueprintSource}`
},
flowParsed() {
return YamlUtils.parse(this.source);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
{{ $t('copy') }}
</el-button>
</el-tooltip>
<el-button v-else-if="blueprintKind === 'flow'" type="primary" size="default" @click.prevent.stop="blueprintToEditor(blueprint.id)">
<el-button v-else type="primary" size="default" @click.prevent.stop="blueprintToEditor(blueprint.id)">
{{ $t('use') }}
</el-button>
</div>
Expand Down Expand Up @@ -157,25 +157,25 @@
}
},
methods: {
kind() {
return this.blueprintType === "community" ? this.blueprintKind : undefined;
},
initSelectedTag() {
return this.$route?.query?.selectedTag ?? 0
},
async copy(id) {
await Utils.copy(
(await this.$store.dispatch("blueprints/getBlueprintSource", {type: this.blueprintType, kind: this.kind(), id: id}))
(await this.$store.dispatch("blueprints/getBlueprintSource", {type: this.blueprintType, kind: this.blueprintKind, id: id}))
);
},
async blueprintToEditor(blueprintId) {
localStorage.setItem(editorViewTypes.STORAGE_KEY, editorViewTypes.SOURCE_TOPOLOGY);
const query = this.blueprintKind === "flow" ?
{blueprintId: blueprintId, blueprintSource: this.embedFriendlyBlueprintBaseUri.includes("community") ? "community" : "custom"} :
{blueprintId: blueprintId};
this.$router.push({
name: "flows/create",
name: `${this.blueprintKind}s/create`,
params: {
tenant: this.$route.params.tenant
},
query: {blueprintId: blueprintId, blueprintSource: this.embedFriendlyBlueprintBaseUri.includes("community") ? "community" : "custom"}
query: query
});
},
goToDetail(blueprintId) {
Expand All @@ -188,7 +188,7 @@
if (this.$route.query.q || this.q) {
query.q = this.$route.query.q || this.q;
}
return this.$store.dispatch("blueprints/getBlueprintTagsForQuery", {type: this.blueprintType, kind: this.kind(), ...query})
return this.$store.dispatch("blueprints/getBlueprintTagsForQuery", {type: this.blueprintType, kind: this.blueprintKind, ...query})
.then(data => {
// Handle switch tab while fetching data
if (this.embedFriendlyBlueprintBaseUri === beforeLoadBlueprintBaseUri) {
Expand Down Expand Up @@ -218,7 +218,7 @@
}
return this.$store
.dispatch("blueprints/getBlueprintsForQuery", {type: this.blueprintType, kind: this.kind(), params: query})
.dispatch("blueprints/getBlueprintsForQuery", {type: this.blueprintType, kind: this.blueprintKind, params: query})
.then(data => {
// Handle switch tab while fetching data
if (this.embedFriendlyBlueprintBaseUri === beforeLoadBlueprintBaseUri) {
Expand Down
10 changes: 5 additions & 5 deletions ui/src/stores/blueprints.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export default {

actions: {
getBlueprint({commit}, options) {
const kind = options.kind ? `/${options.kind}` : "";
const kind = options.kind && options.type !== "custom" ? `/${options.kind}` : "";
return this.$http.get(
`${apiUrl(this)}/blueprints/${options.type}${kind}/${options.id}`
)
Expand All @@ -20,7 +20,7 @@ export default {
});
},
getBlueprintSource({commit}, options) {
const kind = options.kind ? `/${options.kind}` : "";
const kind = options.kind && options.type !== "custom" ? `/${options.kind}` : "";
return this.$http.get(
`${apiUrl(this)}/blueprints/${options.type}${kind}/${options.id}/source`
)
Expand All @@ -30,7 +30,7 @@ export default {
});
},
getBlueprintGraph({commit}, options) {
const kind = options.kind ? `/${options.kind}` : "";
const kind = options.kind && options.type !== "custom" ? `/${options.kind}` : "";
return this.$http.get(
`${apiUrl(this)}/blueprints/${options.type}${kind}/${options.id}/graph`
)
Expand All @@ -40,7 +40,7 @@ export default {
});
},
getBlueprintsForQuery({commit}, options) {
const kind = options.kind ? `/${options.kind}` : "";
const kind = options.kind && options.type !== "custom" ? `/${options.kind}` : "";
return this.$http.get(
`${apiUrl(this)}/blueprints/${options.type}${kind}`,
{params: options.params}
Expand All @@ -51,7 +51,7 @@ export default {
});
},
getBlueprintTagsForQuery(_, options) {
const kind = options.kind ? `/${options.kind}` : "";
const kind = options.kind && options.type !== "custom" ? `/${options.kind}` : "";
return this.$http.get(
`${apiUrl(this)}/blueprints/${options.type}${kind}/tags`,
{params: options.params}
Expand Down

0 comments on commit 8e5ffe8

Please sign in to comment.