Skip to content

Commit

Permalink
Merge pull request #582 from Gencaster/577-creating-new-graph-in-edit…
Browse files Browse the repository at this point in the history
…or-doesnt-show-up

Forward to new graph on create
  • Loading branch information
vin-ni authored Sep 23, 2023
2 parents 5972680 + c0ed64a commit 344106a
Showing 1 changed file with 38 additions and 33 deletions.
71 changes: 38 additions & 33 deletions caster-editor/src/components/DialogAddGraph.vue
Original file line number Diff line number Diff line change
@@ -1,34 +1,6 @@
<template>
<div>
<ElDialog
v-model="showDialog"
title="Create graph"
:show-close="false"
align-center
>
<ElInput
id="graphNameInput"
v-model="newGraphDialogName"
placeholder="Name of graph"
/>
<template #footer>
<span class="dialog-footer">
<ElButton
type="danger"
@click="() => emit('aborted')"
>Cancel</ElButton>
<ElButton
type="primary"
@click="createGraph()"
> Confirm </ElButton>
</span>
</template>
</ElDialog>
</div>
</template>

<script setup lang="ts">
import { ref, type Ref } from "vue";
import { useRouter } from "vue-router";
import {
useCreateGraphMutation,
StreamAssignmentPolicy,
Expand All @@ -40,6 +12,7 @@ const emit = defineEmits<{
(e: "created"): void;
}>();
const router = useRouter();
const newGraphDialogName: Ref<string> = ref("");
const showDialog: Ref<boolean> = ref(true);
const createGraphMutation = useCreateGraphMutation();
Expand All @@ -55,8 +28,8 @@ const slugify = (str: string): string => {
};
const createGraph = async () => {
const { error: createGraphError } = await createGraphMutation.executeMutation(
{
const { error: createGraphError, data } =
await createGraphMutation.executeMutation({
graphInput: {
name: newGraphDialogName.value,
displayName: newGraphDialogName.value,
Expand All @@ -65,14 +38,46 @@ const createGraph = async () => {
streamAssignmentPolicy: StreamAssignmentPolicy.OneUserOneStream,
templateName: GraphDetailTemplate.Default,
},
},
);
});
if (createGraphError) {
alert("Could not create graph: " + createGraphError.message);
return;
}
// route to graph
router.push({ name: "graph", params: { uuid: data?.addGraph.uuid } });
newGraphDialogName.value = "";
emit("created");
};
</script>

<template>
<div>
<ElDialog
v-model="showDialog"
title="Create graph"
:show-close="false"
align-center
>
<ElInput
id="graphNameInput"
v-model="newGraphDialogName"
placeholder="Name of graph"
/>
<template #footer>
<span class="dialog-footer">
<ElButton
type="danger"
@click="() => emit('aborted')"
>Cancel</ElButton>
<ElButton
type="primary"
@click="createGraph()"
> Confirm </ElButton>
</span>
</template>
</ElDialog>
</div>
</template>

0 comments on commit 344106a

Please sign in to comment.