Skip to content

Commit

Permalink
Fix "Copy To" action for Flow operations (#21566)
Browse files Browse the repository at this point in the history
  • Loading branch information
paescuj committed Feb 26, 2024
1 parent 920942a commit 3e9e5ec
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 18 deletions.
5 changes: 5 additions & 0 deletions .changeset/bright-eagles-fix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@directus/app': patch
---

Fixed an issue where "Copy To" action on Flow operations failed when connected to subsequent operations
36 changes: 18 additions & 18 deletions app/src/modules/settings/routes/flows/flow.vue
Original file line number Diff line number Diff line change
Expand Up @@ -390,32 +390,32 @@ function editPanel(panel: AppTile) {
else router.push(`/settings/flows/${props.primaryKey}/${panel.id}`);
}
// ------------- Move Panel To ------------- //
// ------------- Copy Panel To ------------- //
const movePanelID = ref<string | undefined>();
const movePanelTo = ref<string | undefined>();
const movePanelLoading = ref(false);
const copyPanelId = ref<string | undefined>();
const copyPanelTo = ref<string | undefined>();
const copyPanelLoading = ref(false);
const movePanelChoices = computed(() => flowsStore.flows.filter((flow) => flow.id !== props.primaryKey));
const copyPanelChoices = computed(() => flowsStore.flows.filter((flow) => flow.id !== props.primaryKey));
async function movePanel() {
movePanelLoading.value = true;
async function copyPanel() {
copyPanelLoading.value = true;
const currentPanel = panels.value.find((panel) => panel.id === movePanelID.value);
const currentPanel = panels.value.find((panel) => panel.id === copyPanelId.value);
try {
await api.post(`/operations`, {
...omit(currentPanel, ['id']),
flow: movePanelTo.value,
...omit(currentPanel, ['id', 'date_created', 'user_created', 'resolve', 'reject']),
flow: copyPanelTo.value,
});
await flowsStore.hydrate();
movePanelID.value = undefined;
copyPanelId.value = undefined;
} catch (error) {
unexpectedError(error);
} finally {
movePanelLoading.value = false;
copyPanelLoading.value = false;
}
}
Expand Down Expand Up @@ -623,7 +623,7 @@ function discardAndLeave() {
:subdued="flow.status === 'inactive'"
@create="createPanel"
@edit="editPanel"
@move="movePanelID = $event"
@move="copyPanelId = $event"
@update="stageOperationEdits"
@delete="deletePanel"
@duplicate="duplicatePanel"
Expand Down Expand Up @@ -679,22 +679,22 @@ function discardAndLeave() {
</v-card>
</v-dialog>
<v-dialog :model-value="!!movePanelID" @update:model-value="movePanelID = undefined" @esc="movePanelID = undefined">
<v-dialog :model-value="!!copyPanelId" @update:model-value="copyPanelId = undefined" @esc="copyPanelId = undefined">
<v-card>
<v-card-title>{{ t('copy_to') }}</v-card-title>
<v-card-text>
<v-notice v-if="movePanelChoices.length === 0">
<v-notice v-if="copyPanelChoices.length === 0">
{{ t('no_other_flows_copy') }}
</v-notice>
<v-select v-else v-model="movePanelTo" :items="movePanelChoices" item-text="name" item-value="id" />
<v-select v-else v-model="copyPanelTo" :items="copyPanelChoices" item-text="name" item-value="id" />
</v-card-text>
<v-card-actions>
<v-button secondary @click="movePanelID = undefined">
<v-button secondary @click="copyPanelId = undefined">
{{ t('cancel') }}
</v-button>
<v-button :loading="movePanelLoading" :disabled="movePanelChoices.length === 0" @click="movePanel">
<v-button :loading="copyPanelLoading" :disabled="copyPanelChoices.length === 0" @click="copyPanel">
{{ t('copy') }}
</v-button>
</v-card-actions>
Expand Down

0 comments on commit 3e9e5ec

Please sign in to comment.