Compare commits

...

9 commits

Author SHA1 Message Date
Danny Martini 662d2d2a03
Merge d61d563f48 into fdef6c9f0d 2024-09-19 17:34:03 +02:00
कारतोफ्फेलस्क्रिप्ट™ fdef6c9f0d
ci: Remove eslint-plugin-prettier again (no-changelog) (#10876) 2024-09-19 16:29:04 +02:00
Tomi Turtiainen 8fb31e8459
fix(benchmark): Simplify binary data scenario setup and use larger binary file (#10879) 2024-09-19 16:21:55 +03:00
Ricardo Espinoza cee57b6504
refactor(editor): Migrate LogStreaming.store.ts to composition API (#10719)
Some checks are pending
Test Master / install-and-build (push) Waiting to run
Test Master / Unit tests (18.x) (push) Blocked by required conditions
Test Master / Unit tests (20.x) (push) Blocked by required conditions
Test Master / Unit tests (22.4) (push) Blocked by required conditions
Test Master / Lint (push) Blocked by required conditions
Test Master / Notify Slack on failure (push) Blocked by required conditions
Benchmark Docker Image CI / build (push) Waiting to run
2024-09-19 09:15:01 -04:00
Ricardo Espinoza f5474ff791
perf(editor): Use virtual scrolling in RunDataJson.vue (#10838) 2024-09-19 08:43:09 -04:00
Milorad FIlipović b86fd80fc9
fix(editor): Update gird size when opening credentials support chat (#10882) 2024-09-19 14:06:14 +02:00
कारतोफ्फेलस्क्रिप्ट™ aa6cfa07ef
ci: Upgrade storybook and chromatic (no-changelog) (#10878) 2024-09-19 10:57:41 +02:00
Danny Martini d61d563f48
take shutdown and worfklow timeouts into account 2024-09-12 15:40:58 +02:00
Danny Martini d3b8776f20
fix(core): fix lifecycle issue when cancelling manual executions 2024-09-12 15:13:32 +02:00
29 changed files with 1529 additions and 4603 deletions

View file

@ -72,7 +72,6 @@
"chokidar": "3.5.2",
"esbuild": "^0.20.2",
"formidable": "3.5.1",
"prettier": "^3.2.5",
"pug": "^3.0.3",
"semver": "^7.5.4",
"tslib": "^2.6.2",

View file

@ -3,8 +3,9 @@ import { check } from 'k6';
const apiBaseUrl = __ENV.API_BASE_URL;
const file = open(__ENV.SCRIPT_FILE_PATH, 'b');
const filename = String(__ENV.SCRIPT_FILE_PATH).split('/').pop();
// This creates a 2MB file (16 * 128 * 1024 = 2 * 1024 * 1024 = 2MB)
const file = Array.from({ length: 128 * 1024 }, () => Math.random().toString().slice(2)).join('');
const filename = 'test.bin';
export default function () {
const data = {

View file

@ -77,7 +77,6 @@ export function handleSummary(data) {
env: {
API_BASE_URL: this.opts.n8nApiBaseUrl,
K6_CLOUD_TOKEN: this.opts.k6ApiToken,
SCRIPT_FILE_PATH: augmentedTestScriptPath,
},
stdio: 'inherit',
})`${k6ExecutablePath} run ${flattedFlags} ${augmentedTestScriptPath}`;

View file

@ -3,19 +3,19 @@
"private": true,
"version": "0.0.1",
"devDependencies": {
"@chromatic-com/storybook": "^1.5.0",
"@storybook/addon-a11y": "^8.1.4",
"@storybook/addon-actions": "^8.1.4",
"@storybook/addon-docs": "^8.1.4",
"@storybook/addon-essentials": "^8.1.4",
"@storybook/addon-interactions": "^8.1.4",
"@storybook/addon-links": "^8.1.4",
"@storybook/addon-themes": "^8.1.4",
"@storybook/blocks": "^8.1.4",
"@storybook/test": "^8.1.4",
"@storybook/vue3": "^8.1.4",
"@storybook/vue3-vite": "^8.1.4",
"chromatic": "^11.4.1",
"storybook": "^8.1.4"
"@chromatic-com/storybook": "^2.0.2",
"@storybook/addon-a11y": "^8.3.1",
"@storybook/addon-actions": "^8.3.1",
"@storybook/addon-docs": "^8.3.1",
"@storybook/addon-essentials": "^8.3.1",
"@storybook/addon-interactions": "^8.3.1",
"@storybook/addon-links": "^8.3.1",
"@storybook/addon-themes": "^8.3.1",
"@storybook/blocks": "^8.3.1",
"@storybook/test": "^8.3.1",
"@storybook/vue3": "^8.3.1",
"@storybook/vue3-vite": "^8.3.1",
"chromatic": "^11.10.2",
"storybook": "^8.3.1"
}
}

View file

@ -25,7 +25,6 @@ module.exports = {
},
{
files: ['**/*.vue'],
plugins: isCI ? [] : ['eslint-plugin-prettier'],
rules: {
'vue/no-deprecated-slot-attribute': 'error',
'vue/no-deprecated-slot-scope-attribute': 'error',
@ -68,14 +67,6 @@ module.exports = {
],
'vue/no-v-html': 'error',
...(isCI
? {}
: {
'prettier/prettier': ['error', { endOfLine: 'auto' }],
'arrow-body-style': 'off',
'prefer-arrow-callback': 'off',
}),
// TODO: remove these
'vue/no-mutating-props': 'warn',
'vue/no-side-effects-in-computed-properties': 'warn',

View file

@ -6,7 +6,6 @@
"@types/eslint": "^8.56.5",
"@typescript-eslint/eslint-plugin": "^7.2.0",
"@typescript-eslint/parser": "^7.2.0",
"@vue/eslint-config-prettier": "^9.0.0",
"@vue/eslint-config-typescript": "^13.0.0",
"eslint": "^8.57.0",
"eslint-config-airbnb-typescript": "^18.0.0",
@ -15,7 +14,6 @@
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-lodash": "^7.4.0",
"eslint-plugin-n8n-local-rules": "^1.0.0",
"eslint-plugin-prettier": "^5.1.3",
"eslint-plugin-unicorn": "^51.0.1",
"eslint-plugin-unused-imports": "^3.1.0",
"eslint-plugin-vue": "^9.23.0",

View file

@ -146,6 +146,18 @@ export class ActiveExecutions {
this.postExecuteCleanup(executionId);
}
cancelExecution(executionId: string): void {
const execution = this.activeExecutions[executionId];
if (execution === undefined) {
// There is no execution running with that id
return;
}
console.log(new Date().toISOString(), 'cancel execution');
execution.workflowExecution!.cancel();
console.log(new Date().toISOString(), 'cancelled execution');
}
/**
* Forces an execution to stop
*/
@ -164,6 +176,12 @@ export class ActiveExecutions {
promise.reject(reason);
}
// FIXME: Option 2: Don't clean up the execution. Because we cancelled it
// above, which means the time a node finishes the execution will stop and
// the WorkflowRunner will remove it from the active executions.
// Given that this function is called from many places this is probably not
// a good fix.
//
this.postExecuteCleanup(executionId);
}
@ -235,7 +253,7 @@ export class ActiveExecutions {
await this.concurrencyControl.removeAll(this.activeExecutions);
}
executionIds.forEach((executionId) => this.stopExecution(executionId));
executionIds.forEach((executionId) => this.cancelExecution(executionId));
}
let count = 0;

View file

@ -452,8 +452,19 @@ export class ExecutionService {
return await this.executionRepository.stopBeforeRun(execution);
}
// NOTE: old code
// NOTE: Should this actually stop the execution?
// Maybe this should just get the execution from the active executions,
// then cancel it and then let the workflow execute and workflow runner
// take care of the rest?
//if (this.activeExecutions.has(execution.id)) {
// this.activeExecutions.stopExecution(execution.id);
//}
// NOTE: new code
// FIXME: Option 3
if (this.activeExecutions.has(execution.id)) {
this.activeExecutions.stopExecution(execution.id);
this.activeExecutions.cancelExecution(execution.id);
}
if (this.waitTracker.has(execution.id)) {

View file

@ -325,18 +325,30 @@ export class WorkflowRunner {
if (workflowTimeout > 0) {
const timeout = Math.min(workflowTimeout, config.getEnv('executions.maxTimeout')) * 1000; // as seconds
executionTimeout = setTimeout(() => {
void this.activeExecutions.stopExecution(executionId);
void this.activeExecutions.cancelExecution(executionId);
}, timeout);
}
workflowExecution
.then((fullRunData) => {
clearTimeout(executionTimeout);
// NOTE: old code
if (workflowExecution.isCanceled) {
fullRunData.finished = false;
}
fullRunData.status = this.activeExecutions.getStatus(executionId);
this.activeExecutions.remove(executionId, fullRunData);
// NOTE: new code
// FIXME: Option 1: Don't call `getStatus` if the execution was
// already cancelled.
//if (workflowExecution.isCanceled) {
// fullRunData.finished = false;
// this.activeExecutions.remove(executionId, fullRunData);
//} else {
// // if the execution was canceled it was already removed from the active executions
// fullRunData.status = this.activeExecutions.getStatus(executionId);
//}
})
.catch(
async (error) =>

View file

@ -63,7 +63,7 @@
"n8n-design-system": "workspace:*",
"n8n-workflow": "workspace:*",
"pinia": "^2.1.6",
"prettier": "^3.1.0",
"prettier": "^3.3.3",
"qrcode.vue": "^3.3.4",
"stream-browserify": "^3.0.0",
"timeago.js": "^4.0.2",

View file

@ -77,7 +77,7 @@ const onDrag = (event: MouseEvent) => {
if (!isDragging.value && draggingElement.value) {
isDragging.value = true;
const data = props.targetDataKey ? draggingElement.value.dataset.value : props.data ?? '';
const data = props.targetDataKey ? draggingElement.value.dataset.value : (props.data ?? '');
ndvStore.draggableStartDragging({
type: props.type,

View file

@ -417,7 +417,7 @@ export default defineComponent({
type="secondary"
hide-icon
:transparent="true"
:node-name="isActiveNodeConfig ? rootNode : currentNodeName ?? ''"
:node-name="isActiveNodeConfig ? rootNode : (currentNodeName ?? '')"
:label="$locale.baseText('ndv.input.noOutputData.executePrevious')"
telemetry-source="inputs"
data-test-id="execute-previous-node"

View file

@ -26,7 +26,7 @@ const emit = defineEmits<{
projectRemoved: [value: ProjectSharingData];
}>();
const selectedProject = ref(Array.isArray(model.value) ? '' : model.value?.id ?? '');
const selectedProject = ref(Array.isArray(model.value) ? '' : (model.value?.id ?? ''));
const filter = ref('');
const selectPlaceholder = computed(
() => props.placeholder ?? locale.baseText('projects.sharing.select.placeholder'),

View file

@ -41,7 +41,7 @@ export default defineComponent({
const projectId = props.projectId ?? inferProjectIdFromRoute(route);
const resourceType = props.resourceType ?? inferResourceTypeFromRoute(route);
const resourceId = resourceType
? props.resourceId ?? inferResourceIdFromRoute(route)
? (props.resourceId ?? inferResourceIdFromRoute(route))
: undefined;
return rbacStore.hasScope(

View file

@ -14,6 +14,7 @@ import { nonExistingJsonPath } from '@/constants';
import { useExternalHooks } from '@/composables/useExternalHooks';
import TextWithHighlights from './TextWithHighlights.vue';
import { useTelemetry } from '@/composables/useTelemetry';
import { useElementSize } from '@vueuse/core';
const LazyRunDataJsonActions = defineAsyncComponent(
async () => await import('@/components/RunDataJsonActions.vue'),
@ -45,6 +46,9 @@ const telemetry = useTelemetry();
const selectedJsonPath = ref(nonExistingJsonPath);
const draggingPath = ref<null | string>(null);
const displayMode = ref('json');
const jsonDataContainer = ref(null);
const { height } = useElementSize(jsonDataContainer);
const jsonData = computed(() => executionDataToJson(props.inputData));
@ -110,7 +114,7 @@ const getListItemName = (path: string) => {
</script>
<template>
<div :class="[$style.jsonDisplay, { [$style.highlight]: highlight }]">
<div ref="jsonDataContainer" :class="[$style.jsonDisplay, { [$style.highlight]: highlight }]">
<Suspense>
<LazyRunDataJsonActions
v-if="!editMode.enabled"
@ -141,6 +145,8 @@ const getListItemName = (path: string) => {
root-path=""
selectable-type="single"
class="json-data"
:virtual="true"
:height="height"
@update:selected-value="selectedJsonPath = $event"
>
<template #renderNodeKey="{ node }">
@ -192,11 +198,10 @@ const getListItemName = (path: string) => {
left: 0;
padding-left: var(--spacing-s);
right: 0;
overflow-y: auto;
overflow-y: hidden;
line-height: 1.5;
word-break: normal;
height: 100%;
padding-bottom: var(--spacing-3xl);
&:hover {
/* Shows .actionsGroup element from <run-data-json-actions /> child component */
@ -299,4 +304,8 @@ const getListItemName = (path: string) => {
.vjs-tree .vjs-tree__content.has-line {
border-left: 1px dotted var(--color-json-line);
}
.vjs-tree .vjs-tree-list-holder-inner {
padding-bottom: var(--spacing-3xl);
}
</style>

View file

@ -25,7 +25,7 @@ const i18n = useI18n();
const saveButtonLabel = computed(() => {
return props.isSaving
? props.savingLabel ?? i18n.baseText('saveButton.saving')
? (props.savingLabel ?? i18n.baseText('saveButton.saving'))
: i18n.baseText('saveButton.save');
});

View file

@ -87,7 +87,7 @@ const valueToDisplay = computed<NodeParameterValue>(() => {
}
if (isListMode.value) {
return props.modelValue ? props.modelValue.cachedResultName ?? props.modelValue.value : '';
return props.modelValue ? (props.modelValue.cachedResultName ?? props.modelValue.value) : '';
}
return props.modelValue ? props.modelValue.value : '';

View file

@ -2,6 +2,22 @@ import { createTestingPinia } from '@pinia/testing';
import { screen, cleanup } from '@testing-library/vue';
import RunDataJson from '@/components/RunDataJson.vue';
import { createComponentRenderer } from '@/__tests__/render';
import { useElementSize } from '@vueuse/core'; // Import the composable to mock
vi.mock('@vueuse/core', async () => {
// eslint-disable-next-line @typescript-eslint/consistent-type-imports
const originalModule = await vi.importActual<typeof import('@vueuse/core')>('@vueuse/core');
return {
...originalModule, // Keep all original exports
useElementSize: vi.fn(), // Mock useElementSize
};
});
(useElementSize as jest.Mock).mockReturnValue({
height: 500, // Mocked height value
width: 300, // Mocked width value
});
const renderComponent = createComponentRenderer(RunDataJson, {
props: {
@ -34,18 +50,6 @@ const renderComponent = createComponentRenderer(RunDataJson, {
disabled: false,
},
},
global: {
mocks: {
$locale: {
baseText() {
return '';
},
},
$store: {
getters: {},
},
},
},
});
describe('RunDataJson.vue', () => {

View file

@ -37,7 +37,7 @@ const plusLineSize = computed(
small: 46,
medium: 66,
large: 80,
})[renderOptions.value.outputs?.labelSize ?? runData.value ? 'large' : 'small'],
})[(renderOptions.value.outputs?.labelSize ?? runData.value) ? 'large' : 'small'],
);
function onMouseEnter() {

View file

@ -39,7 +39,7 @@ const router = useRouter();
const temporaryExecution = computed<ExecutionSummary | undefined>(() =>
props.executions.find((execution) => execution.id === props.execution?.id)
? undefined
: props.execution ?? undefined,
: (props.execution ?? undefined),
);
const hidePreview = computed(() => {

View file

@ -356,9 +356,9 @@ export const useAssistantStore = defineStore(STORES.ASSISTANT, () => {
resetAssistantChat();
chatSessionTask.value = credentialType ? 'credentials' : 'support';
chatSessionCredType.value = credentialType;
chatWindowOpen.value = true;
addUserMessage(userMessage, id);
addLoadingAssistantMessage(locale.baseText('aiAssistant.thinkingSteps.thinking'));
openChat();
streaming.value = true;
let payload: ChatRequest.InitSupportChat | ChatRequest.InitCredHelp = {

View file

@ -7,8 +7,9 @@ import {
hasDestinationId,
saveDestinationToDb,
sendTestMessageToDestination,
} from '../api/eventbus.ee';
} from '@/api/eventbus.ee';
import { useRootStore } from './root.store';
import { ref } from 'vue';
export interface EventSelectionItem {
selected: boolean;
@ -32,221 +33,242 @@ export interface DestinationSettingsStore {
[key: string]: DestinationStoreItem;
}
export const useLogStreamingStore = defineStore('logStreaming', {
state: () => ({
items: {} as DestinationSettingsStore,
eventNames: new Set<string>(),
}),
getters: {},
actions: {
addDestination(destination: MessageEventBusDestinationOptions) {
if (destination.id && this.items[destination.id]) {
this.items[destination.id].destination = destination;
} else {
this.setSelectionAndBuildItems(destination);
export const useLogStreamingStore = defineStore('logStreaming', () => {
const items = ref<DestinationSettingsStore>({});
const eventNames = ref(new Set<string>());
const rootStore = useRootStore();
const addDestination = (destination: MessageEventBusDestinationOptions) => {
if (destination.id && items.value[destination.id]) {
items.value[destination.id].destination = destination;
} else {
setSelectionAndBuildItems(destination);
}
};
const setSelectionAndBuildItems = (destination: MessageEventBusDestinationOptions) => {
if (destination.id) {
if (!items.value[destination.id]) {
items.value[destination.id] = {
destination,
selectedEvents: new Set<string>(),
eventGroups: [],
isNew: false,
} as DestinationStoreItem;
}
},
getDestination(destinationId: string): MessageEventBusDestinationOptions | undefined {
if (this.items[destinationId]) {
return this.items[destinationId].destination;
} else {
return;
items.value[destination.id]?.selectedEvents?.clear();
if (destination.subscribedEvents) {
for (const eventName of destination.subscribedEvents) {
items.value[destination.id]?.selectedEvents?.add(eventName);
}
}
},
getAllDestinations(): MessageEventBusDestinationOptions[] {
const destinations: MessageEventBusDestinationOptions[] = [];
for (const key of Object.keys(this.items)) {
destinations.push(this.items[key].destination);
}
return destinations;
},
updateDestination(destination: MessageEventBusDestinationOptions) {
if (destination.id && this.items[destination.id]) {
this.$patch((state) => {
if (destination.id && this.items[destination.id]) {
state.items[destination.id].destination = destination;
}
// to trigger refresh
state.items = { ...state.items };
});
}
},
removeDestination(destinationId: string) {
if (!destinationId) return;
delete this.items[destinationId];
if (this.items[destinationId]) {
this.$patch({
items: {
...this.items,
},
});
}
},
clearDestinations() {
this.items = {};
},
addEventName(name: string) {
this.eventNames.add(name);
},
removeEventName(name: string) {
this.eventNames.delete(name);
},
clearEventNames() {
this.eventNames.clear();
},
addSelectedEvent(id: string, name: string) {
this.items[id]?.selectedEvents?.add(name);
this.setSelectedInGroup(id, name, true);
},
removeSelectedEvent(id: string, name: string) {
this.items[id]?.selectedEvents?.delete(name);
this.setSelectedInGroup(id, name, false);
},
getSelectedEvents(destinationId: string): string[] {
const selectedEvents: string[] = [];
if (this.items[destinationId]) {
for (const group of this.items[destinationId].eventGroups) {
if (group.selected) {
selectedEvents.push(group.name);
}
for (const event of group.children) {
if (event.selected) {
selectedEvents.push(event.name);
items.value[destination.id].eventGroups = eventGroupsFromStringList(
eventNames.value,
items.value[destination.id]?.selectedEvents,
);
}
};
const getDestination = (destinationId: string) => {
if (items.value[destinationId]) {
return items.value[destinationId].destination;
} else {
return;
}
};
const getAllDestinations = () => {
const destinations: MessageEventBusDestinationOptions[] = [];
for (const key of Object.keys(items)) {
destinations.push(items.value[key].destination);
}
return destinations;
};
const clearDestinations = () => {
items.value = {};
};
const addEventName = (name: string) => {
eventNames.value.add(name);
};
const removeEventName = (name: string) => {
eventNames.value.delete(name);
};
const clearEventNames = () => {
eventNames.value.clear();
};
const addSelectedEvent = (id: string, name: string) => {
items.value[id]?.selectedEvents?.add(name);
setSelectedInGroup(id, name, true);
};
const removeSelectedEvent = (id: string, name: string) => {
items.value[id]?.selectedEvents?.delete(name);
setSelectedInGroup(id, name, false);
};
const setSelectedInGroup = (destinationId: string, name: string, isSelected: boolean) => {
if (items.value[destinationId]) {
const groupName = eventGroupFromEventName(name);
const groupIndex = items.value[destinationId].eventGroups.findIndex(
(e) => e.name === groupName,
);
if (groupIndex > -1) {
if (groupName === name) {
items.value[destinationId].eventGroups[groupIndex].selected = isSelected;
} else {
const eventIndex = items.value[destinationId].eventGroups[groupIndex].children.findIndex(
(e) => e.name === name,
);
if (eventIndex > -1) {
items.value[destinationId].eventGroups[groupIndex].children[eventIndex].selected =
isSelected;
if (isSelected) {
items.value[destinationId].eventGroups[groupIndex].indeterminate = isSelected;
} else {
let anySelected = false;
for (
let i = 0;
i < items.value[destinationId].eventGroups[groupIndex].children.length;
i++
) {
anySelected =
anySelected ||
items.value[destinationId].eventGroups[groupIndex].children[i].selected;
}
items.value[destinationId].eventGroups[groupIndex].indeterminate = anySelected;
}
}
}
}
return selectedEvents;
},
setSelectedInGroup(destinationId: string, name: string, isSelected: boolean) {
if (this.items[destinationId]) {
const groupName = eventGroupFromEventName(name);
const groupIndex = this.items[destinationId].eventGroups.findIndex(
(e) => e.name === groupName,
);
if (groupIndex > -1) {
if (groupName === name) {
this.$patch((state) => {
state.items[destinationId].eventGroups[groupIndex].selected = isSelected;
});
} else {
const eventIndex = this.items[destinationId].eventGroups[groupIndex].children.findIndex(
(e) => e.name === name,
);
if (eventIndex > -1) {
this.$patch((state) => {
state.items[destinationId].eventGroups[groupIndex].children[eventIndex].selected =
isSelected;
if (isSelected) {
state.items[destinationId].eventGroups[groupIndex].indeterminate = isSelected;
} else {
let anySelected = false;
for (
let i = 0;
i < state.items[destinationId].eventGroups[groupIndex].children.length;
i++
) {
anySelected =
anySelected ||
state.items[destinationId].eventGroups[groupIndex].children[i].selected;
}
state.items[destinationId].eventGroups[groupIndex].indeterminate = anySelected;
}
});
}
}
};
const removeDestinationItemTree = (id: string) => {
delete items.value[id];
};
const updateDestination = (destination: MessageEventBusDestinationOptions) => {
if (destination.id && items.value[destination.id]) {
items.value[destination.id].destination = destination;
}
};
const removeDestination = (destinationId: string) => {
if (!destinationId) return;
delete items.value[destinationId];
};
const getSelectedEvents = (destinationId: string): string[] => {
const selectedEvents: string[] = [];
if (items.value[destinationId]) {
for (const group of items.value[destinationId].eventGroups) {
if (group.selected) {
selectedEvents.push(group.name);
}
for (const event of group.children) {
if (event.selected) {
selectedEvents.push(event.name);
}
}
}
},
removeDestinationItemTree(id: string) {
delete this.items[id];
},
clearDestinationItemTrees() {
this.items = {} as DestinationSettingsStore;
},
setSelectionAndBuildItems(destination: MessageEventBusDestinationOptions) {
if (destination.id) {
if (!this.items[destination.id]) {
this.items[destination.id] = {
destination,
selectedEvents: new Set<string>(),
eventGroups: [],
isNew: false,
} as DestinationStoreItem;
}
this.items[destination.id]?.selectedEvents?.clear();
if (destination.subscribedEvents) {
for (const eventName of destination.subscribedEvents) {
this.items[destination.id]?.selectedEvents?.add(eventName);
}
}
this.items[destination.id].eventGroups = eventGroupsFromStringList(
this.eventNames,
this.items[destination.id]?.selectedEvents,
);
}
},
async saveDestination(destination: MessageEventBusDestinationOptions): Promise<boolean> {
if (!hasDestinationId(destination)) {
return false;
}
}
return selectedEvents;
};
const rootStore = useRootStore();
const selectedEvents = this.getSelectedEvents(destination.id);
try {
await saveDestinationToDb(rootStore.restApiContext, destination, selectedEvents);
this.updateDestination(destination);
return true;
} catch (e) {
return false;
}
},
async sendTestMessage(destination: MessageEventBusDestinationOptions): Promise<boolean> {
if (!hasDestinationId(destination)) {
return false;
}
const saveDestination = async (
destination: MessageEventBusDestinationOptions,
): Promise<boolean> => {
if (!hasDestinationId(destination)) {
return false;
}
const rootStore = useRootStore();
const testResult = await sendTestMessageToDestination(rootStore.restApiContext, destination);
return testResult;
},
async fetchEventNames(): Promise<string[]> {
const rootStore = useRootStore();
return await getEventNamesFromBackend(rootStore.restApiContext);
},
async fetchDestinations(): Promise<MessageEventBusDestinationOptions[]> {
const rootStore = useRootStore();
return await getDestinationsFromBackend(rootStore.restApiContext);
},
async deleteDestination(destinationId: string) {
const rootStore = useRootStore();
await deleteDestinationFromDb(rootStore.restApiContext, destinationId);
this.removeDestination(destinationId);
},
},
const selectedEvents = getSelectedEvents(destination.id);
try {
await saveDestinationToDb(rootStore.restApiContext, destination, selectedEvents);
updateDestination(destination);
return true;
} catch (e) {
return false;
}
};
const sendTestMessage = async (
destination: MessageEventBusDestinationOptions,
): Promise<boolean> => {
if (!hasDestinationId(destination)) {
return false;
}
const testResult = await sendTestMessageToDestination(rootStore.restApiContext, destination);
return testResult;
};
const fetchEventNames = async () => {
return await getEventNamesFromBackend(rootStore.restApiContext);
};
const fetchDestinations = async (): Promise<MessageEventBusDestinationOptions[]> => {
return await getDestinationsFromBackend(rootStore.restApiContext);
};
const deleteDestination = async (destinationId: string) => {
await deleteDestinationFromDb(rootStore.restApiContext, destinationId);
removeDestination(destinationId);
};
return {
addDestination,
setSelectionAndBuildItems,
getDestination,
getAllDestinations,
clearDestinations,
addEventName,
removeEventName,
clearEventNames,
addSelectedEvent,
removeSelectedEvent,
setSelectedInGroup,
removeDestinationItemTree,
updateDestination,
removeDestination,
getSelectedEvents,
saveDestination,
sendTestMessage,
fetchEventNames,
fetchDestinations,
deleteDestination,
items,
};
});
export function eventGroupFromEventName(eventName: string): string | undefined {
export const eventGroupFromEventName = (eventName: string): string | undefined => {
const matches = eventName.match(/^[\w\s]+\.[\w\s]+/);
if (matches && matches?.length > 0) {
return matches[0];
}
return undefined;
}
};
function prettifyEventName(label: string, group = ''): string {
const prettifyEventName = (label: string, group = ''): string => {
label = label.replace(group + '.', '');
if (label.length > 0) {
label = label[0].toUpperCase() + label.substring(1);
label = label.replaceAll('.', ' ');
}
return label;
}
};
export function eventGroupsFromStringList(
export const eventGroupsFromStringList = (
dottedList: Set<string>,
selectionList: Set<string> = new Set(),
) {
) => {
const result = [] as EventSelectionGroup[];
const eventNameArray = Array.from(dottedList.values());
@ -287,4 +309,4 @@ export function eventGroupsFromStringList(
result.push(collection);
}
return result;
}
};

View file

@ -935,7 +935,7 @@ const workflowPermissions = computed(() => {
const projectPermissions = computed(() => {
const project = route.query?.projectId
? projectsStore.myProjects.find((p) => p.id === route.query.projectId)
: projectsStore.currentProject ?? projectsStore.personalProject;
: (projectsStore.currentProject ?? projectsStore.personalProject);
return getResourcePermissions(project?.scopes);
});

View file

@ -507,7 +507,7 @@ export default defineComponent({
projectPermissions() {
const project = this.$route.query?.projectId
? this.projectsStore.myProjects.find((p) => p.id === this.$route.query.projectId)
: this.projectsStore.currentProject ?? this.projectsStore.personalProject;
: (this.projectsStore.currentProject ?? this.projectsStore.personalProject);
return getResourcePermissions(project?.scopes);
},
},

View file

@ -95,7 +95,7 @@ export default defineComponent({
},
async getDestinationDataFromBackend(): Promise<void> {
this.logStreamingStore.clearEventNames();
this.logStreamingStore.clearDestinationItemTrees();
this.logStreamingStore.clearDestinations();
this.allDestinations = [];
const eventNamesData = await this.logStreamingStore.fetchEventNames();
if (eventNamesData) {

View file

@ -124,7 +124,7 @@ function resetNewVariablesList() {
const resourceToEnvironmentVariable = (data: IResource): EnvironmentVariable => ({
id: data.id,
key: data.name,
value: 'value' in data ? data.value ?? '' : '',
value: 'value' in data ? (data.value ?? '') : '',
});
const environmentVariableToResource = (data: EnvironmentVariable): IResource => ({

View file

@ -515,7 +515,11 @@ export class Wait extends Webhook {
// we just check the database every 60 seconds.
return await new Promise((resolve) => {
const timer = setTimeout(() => resolve([context.getInputData()]), waitValue);
context.onExecutionCancellation(() => clearTimeout(timer));
context.onExecutionCancellation(() => {
clearTimeout(timer);
// FIXME: Don't let the promise dangle
resolve([context.getInputData()]);
});
});
}

File diff suppressed because it is too large Load diff