mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-21 20:00:02 +00:00
fix(editor): Source control workflow diff release (#17974)
Co-authored-by: r00gm <raul00gm@gmail.com>
This commit is contained in:
@@ -1,34 +1,21 @@
|
||||
<script lang="ts" setup>
|
||||
import { computed, ref } from 'vue';
|
||||
import { createEventBus } from '@n8n/utils/event-bus';
|
||||
import { useI18n } from '@n8n/i18n';
|
||||
import { hasPermission } from '@/utils/rbac/permissions';
|
||||
import { getResourcePermissions } from '@n8n/permissions';
|
||||
import { useToast } from '@/composables/useToast';
|
||||
import { useLoadingService } from '@/composables/useLoadingService';
|
||||
import { useUIStore } from '@/stores/ui.store';
|
||||
import { useSourceControlStore } from '@/stores/sourceControl.store';
|
||||
import { SOURCE_CONTROL_PULL_MODAL_KEY, SOURCE_CONTROL_PUSH_MODAL_KEY } from '@/constants';
|
||||
import { sourceControlEventBus } from '@/event-bus/source-control';
|
||||
import { notifyUserAboutPullWorkFolderOutcome } from '@/utils/sourceControlUtils';
|
||||
import { useProjectsStore } from '@/stores/projects.store';
|
||||
import { useRoute, useRouter } from 'vue-router';
|
||||
|
||||
defineProps<{
|
||||
isCollapsed: boolean;
|
||||
}>();
|
||||
|
||||
const responseStatuses = {
|
||||
CONFLICT: 409,
|
||||
};
|
||||
|
||||
const loadingService = useLoadingService();
|
||||
const uiStore = useUIStore();
|
||||
const sourceControlStore = useSourceControlStore();
|
||||
const projectStore = useProjectsStore();
|
||||
const toast = useToast();
|
||||
const i18n = useI18n();
|
||||
|
||||
const eventBus = createEventBus();
|
||||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
const tooltipOpenDelay = ref(300);
|
||||
|
||||
const currentBranch = computed(() => {
|
||||
@@ -57,57 +44,23 @@ const sourceControlAvailable = computed(
|
||||
);
|
||||
|
||||
async function pushWorkfolder() {
|
||||
loadingService.startLoading();
|
||||
loadingService.setLoadingText(i18n.baseText('settings.sourceControl.loading.checkingForChanges'));
|
||||
try {
|
||||
const status = await sourceControlStore.getAggregatedStatus();
|
||||
|
||||
if (!status.length) {
|
||||
toast.showMessage({
|
||||
title: 'No changes to commit',
|
||||
message: 'Everything is up to date',
|
||||
type: 'info',
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
uiStore.openModalWithData({
|
||||
name: SOURCE_CONTROL_PUSH_MODAL_KEY,
|
||||
data: { eventBus, status },
|
||||
});
|
||||
} catch (error) {
|
||||
toast.showError(error, i18n.baseText('error'));
|
||||
} finally {
|
||||
loadingService.stopLoading();
|
||||
loadingService.setLoadingText(i18n.baseText('genericHelpers.loading'));
|
||||
}
|
||||
// Navigate to route with sourceControl param - modal will handle data loading and loading states
|
||||
void router.push({
|
||||
query: {
|
||||
...route.query,
|
||||
sourceControl: 'push',
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
async function pullWorkfolder() {
|
||||
loadingService.startLoading();
|
||||
loadingService.setLoadingText(i18n.baseText('settings.sourceControl.loading.pull'));
|
||||
|
||||
try {
|
||||
const status = await sourceControlStore.pullWorkfolder(false);
|
||||
|
||||
await notifyUserAboutPullWorkFolderOutcome(status, toast);
|
||||
|
||||
sourceControlEventBus.emit('pull');
|
||||
} catch (error) {
|
||||
const errorResponse = error.response;
|
||||
|
||||
if (errorResponse?.status === responseStatuses.CONFLICT) {
|
||||
uiStore.openModalWithData({
|
||||
name: SOURCE_CONTROL_PULL_MODAL_KEY,
|
||||
data: { eventBus, status: errorResponse.data.data },
|
||||
});
|
||||
} else {
|
||||
toast.showError(error, 'Error');
|
||||
}
|
||||
} finally {
|
||||
loadingService.stopLoading();
|
||||
loadingService.setLoadingText(i18n.baseText('genericHelpers.loading'));
|
||||
}
|
||||
function pullWorkfolder() {
|
||||
// Navigate to route with sourceControl param - modal will handle the pull operation
|
||||
void router.push({
|
||||
query: {
|
||||
...route.query,
|
||||
sourceControl: 'pull',
|
||||
},
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user