Implemented error notice

This commit is contained in:
Milorad Filipovic 2025-03-04 14:54:21 +01:00
parent 891ecb798f
commit 8c6a5eed8e
No known key found for this signature in database
3 changed files with 53 additions and 23 deletions

View file

@ -53,11 +53,17 @@ import {
updateFromAIOverrideValues, updateFromAIOverrideValues,
type FromAIOverride, type FromAIOverride,
} from '../../utils/fromAIOverrideUtils'; } from '../../utils/fromAIOverrideUtils';
import { N8nNotice } from '@n8n/design-system';
interface IResourceLocatorQuery { interface IResourceLocatorQuery {
results: INodeListSearchItems[]; results: INodeListSearchItems[];
nextPageToken: unknown; nextPageToken: unknown;
error: boolean; error: boolean;
errorDetails?: {
message?: string;
description?: string;
httpCode?: string;
};
loading: boolean; loading: boolean;
} }
@ -148,13 +154,9 @@ const selectedMode = computed(() => {
const isListMode = computed(() => selectedMode.value === 'list'); const isListMode = computed(() => selectedMode.value === 'list');
const hasCredential = computed(() => { const hasPermissionError = computed(() =>
const node = ndvStore.activeNode; ['401', '403'].includes(currentResponse.value?.errorDetails?.httpCode ?? ''),
if (!node) { );
return false;
}
return !!(node?.credentials && Object.keys(node.credentials).length === 1);
});
const credentialsNotSet = computed(() => { const credentialsNotSet = computed(() => {
if (!props.node) return false; if (!props.node) return false;
@ -643,6 +645,11 @@ async function loadResources() {
setResponse(paramsKey, { setResponse(paramsKey, {
loading: false, loading: false,
error: true, error: true,
errorDetails: {
message: e.message,
description: e.description,
httpCode: e.httpCode,
},
}); });
} }
} }
@ -777,19 +784,37 @@ function removeOverride() {
@load-more="loadResourcesDebounced" @load-more="loadResourcesDebounced"
> >
<template #error> <template #error>
<div :class="$style.error" data-test-id="rlc-error-container"> <div
<n8n-text color="text-dark" align="center" tag="div"> v-if="currentResponse.errorDetails"
{{ i18n.baseText('resourceLocator.mode.list.error.title') }} :class="$style.error"
</n8n-text> data-test-id="rlc-error-container"
<n8n-text v-if="hasCredential || credentialsNotSet" size="small" color="text-base"> >
{{ i18n.baseText('resourceLocator.mode.list.error.description.part1') }} <n8n-text bold size="small">
<a v-if="credentialsNotSet" @click="createNewCredential">{{ {{ i18n.baseText('resourceLocator.mode.list.error.title') }} -
i18n.baseText('resourceLocator.mode.list.error.description.part2.noCredentials') <span v-if="currentResponse.errorDetails.httpCode">
}}</a> {{ currentResponse.errorDetails.httpCode }}
<a v-else-if="hasCredential" @click="openCredential">{{ </span>
i18n.baseText('resourceLocator.mode.list.error.description.part2.hasCredentials') {{ currentResponse.errorDetails.message?.split('-')[0]?.trim() }}
}}</a>
</n8n-text> </n8n-text>
<N8nNotice
v-if="currentResponse.errorDetails.description"
theme="warning"
class="mt-s mb-s text-left"
>
{{ currentResponse.errorDetails.description }}
</N8nNotice>
<div v-if="hasPermissionError" data-test-id="permission-error-link">
<a
v-if="credentialsNotSet"
:class="$style['credential-link']"
@click="createNewCredential"
>
{{ i18n.baseText('resourceLocator.mode.list.error.description.noCredentials') }}
</a>
<a v-else :class="$style['credential-link']" @click="openCredential">
{{ i18n.baseText('resourceLocator.mode.list.error.description.checkCredentials') }}
</a>
</div>
</div> </div>
</template> </template>
<div <div
@ -820,6 +845,7 @@ function removeOverride() {
<n8n-option <n8n-option
v-for="mode in parameter.modes" v-for="mode in parameter.modes"
:key="mode.name" :key="mode.name"
:data-test-id="`mode-${mode.name}`"
:value="mode.name" :value="mode.name"
:label="getModeLabel(mode)" :label="getModeLabel(mode)"
:disabled="isValueExpression && mode.name === 'list'" :disabled="isValueExpression && mode.name === 'list'"

View file

@ -141,9 +141,14 @@ $--mode-selector-width: 92px;
} }
.error { .error {
max-width: 170px; width: 80%;
word-break: normal; word-break: normal;
text-align: center; text-align: center;
color: var(--color-text-base);
}
.credential-link {
font-size: 12px;
} }
.openResourceLink { .openResourceLink {

View file

@ -1589,9 +1589,8 @@
"resourceLocator.mode.list": "From list", "resourceLocator.mode.list": "From list",
"resourceLocator.mode.list.disabled.title": "Change to Fixed mode to choose From List", "resourceLocator.mode.list.disabled.title": "Change to Fixed mode to choose From List",
"resourceLocator.mode.list.error.title": "Could not load list", "resourceLocator.mode.list.error.title": "Could not load list",
"resourceLocator.mode.list.error.description.part1": "Please", "resourceLocator.mode.list.error.description.checkCredentials": "Check your credential",
"resourceLocator.mode.list.error.description.part2.hasCredentials": "check your credential", "resourceLocator.mode.list.error.description.noCredentials": "Add your credential",
"resourceLocator.mode.list.error.description.part2.noCredentials": "add your credential",
"resourceLocator.mode.list.noResults": "No results", "resourceLocator.mode.list.noResults": "No results",
"resourceLocator.mode.list.openUrl": "Open URL", "resourceLocator.mode.list.openUrl": "Open URL",
"resourceLocator.mode.list.placeholder": "Choose...", "resourceLocator.mode.list.placeholder": "Choose...",