mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-10-13 08:51:38 +08:00
provide id as ref object instead of string
This commit is contained in:
@@ -243,7 +243,7 @@ export default {
|
||||
const uid = unref(useUid("workflow-editor-"));
|
||||
const id = ref(props.workflowId || uid);
|
||||
|
||||
const { connectionStore, stepStore, stateStore, commentStore } = provideScopedWorkflowStores(id.value);
|
||||
const { connectionStore, stepStore, stateStore, commentStore } = provideScopedWorkflowStores(id);
|
||||
|
||||
const { comments } = storeToRefs(commentStore);
|
||||
const { getStepIndex, steps } = storeToRefs(stepStore);
|
||||
|
||||
@@ -46,7 +46,7 @@ const errorMessage = ref("");
|
||||
|
||||
const { datatypesMapper } = useDatatypesMapper();
|
||||
|
||||
const { stateStore } = provideScopedWorkflowStores(props.id);
|
||||
const { stateStore } = provideScopedWorkflowStores(ref(props.id));
|
||||
|
||||
stateStore.setScale(0.75);
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { inject, onScopeDispose, provide } from "vue";
|
||||
import { inject, onScopeDispose, provide, type Ref } from "vue";
|
||||
|
||||
import { useConnectionStore } from "@/stores/workflowConnectionStore";
|
||||
import { useWorkflowCommentStore } from "@/stores/workflowEditorCommentStore";
|
||||
@@ -15,14 +15,14 @@ import { useWorkflowStepStore } from "@/stores/workflowStepStore";
|
||||
* @param workflowId the workflow to scope to
|
||||
* @returns workflow Stores
|
||||
*/
|
||||
export function provideScopedWorkflowStores(workflowId: string) {
|
||||
export function provideScopedWorkflowStores(workflowId: Ref<string>) {
|
||||
provide("workflowId", workflowId);
|
||||
|
||||
const connectionStore = useConnectionStore(workflowId);
|
||||
const stateStore = useWorkflowStateStore(workflowId);
|
||||
const stepStore = useWorkflowStepStore(workflowId);
|
||||
const commentStore = useWorkflowCommentStore(workflowId);
|
||||
const toolbarStore = useWorkflowEditorToolbarStore(workflowId);
|
||||
const connectionStore = useConnectionStore(workflowId.value);
|
||||
const stateStore = useWorkflowStateStore(workflowId.value);
|
||||
const stepStore = useWorkflowStepStore(workflowId.value);
|
||||
const commentStore = useWorkflowCommentStore(workflowId.value);
|
||||
const toolbarStore = useWorkflowEditorToolbarStore(workflowId.value);
|
||||
|
||||
onScopeDispose(() => {
|
||||
connectionStore.$dispose();
|
||||
@@ -51,19 +51,19 @@ export function provideScopedWorkflowStores(workflowId: string) {
|
||||
* @returns workflow stores
|
||||
*/
|
||||
export function useWorkflowStores() {
|
||||
const workflowId = inject("workflowId");
|
||||
const workflowId = inject("workflowId") as Ref<string>;
|
||||
|
||||
if (typeof workflowId !== "string") {
|
||||
if (typeof workflowId?.value !== "string") {
|
||||
throw new Error(
|
||||
"Workflow ID not provided by parent component. Use `provideScopedWorkflowStores` on a parent component."
|
||||
);
|
||||
}
|
||||
|
||||
const connectionStore = useConnectionStore(workflowId);
|
||||
const stateStore = useWorkflowStateStore(workflowId);
|
||||
const stepStore = useWorkflowStepStore(workflowId);
|
||||
const commentStore = useWorkflowCommentStore(workflowId);
|
||||
const toolbarStore = useWorkflowEditorToolbarStore(workflowId);
|
||||
const connectionStore = useConnectionStore(workflowId.value);
|
||||
const stateStore = useWorkflowStateStore(workflowId.value);
|
||||
const stepStore = useWorkflowStepStore(workflowId.value);
|
||||
const commentStore = useWorkflowCommentStore(workflowId.value);
|
||||
const toolbarStore = useWorkflowEditorToolbarStore(workflowId.value);
|
||||
|
||||
return {
|
||||
connectionStore,
|
||||
|
||||
Reference in New Issue
Block a user