diff --git a/aleksis/core/assets/app.js b/aleksis/core/assets/app.js index 748747e09c8a6f05e460191e5182241c08d5cec1..54dc630204e04b85ef0151d9f12b8a594c9a6c91 100644 --- a/aleksis/core/assets/app.js +++ b/aleksis/core/assets/app.js @@ -67,7 +67,7 @@ Vue.use(VueRouter); export const typeDefs = gql` type snackbarItem { id: ID! - message: String! + messageKey: String! color: String! read: Boolean! } @@ -100,7 +100,7 @@ const resolvers = { }, }; -function addErrorSnackbarItem (error) { +function addErrorSnackbarItem (messageKey) { let uuid = crypto.randomUUID(); cache.writeQuery({ query: gqlSnackbarItems, @@ -109,7 +109,7 @@ function addErrorSnackbarItem (error) { { __typename: "snackbarItem", id: uuid, - message: error, + messageKey: messageKey, color: "red", read: false }, @@ -124,12 +124,9 @@ function addErrorSnackbarItem (error) { const retryLink = new RetryLink(); const errorLink = onError(({ graphQLErrors, networkError }) => { - if (graphQLErrors) - graphQLErrors.map(({ message, locations, path }) => - addErrorSnackbarItem(`[GraphQL error]: Message: ${message}, Location: ${locations}, Path: ${path}`), - ) + if (graphQLErrors) addErrorSnackbarItem("graphql_errors.snackbar_error_message") - if (networkError) addErrorSnackbarItem(`[Network error]: ${networkError}`) + if (networkError) addErrorSnackbarItem("network_errors.snackbar_error_message") }); const httpLink = new HttpLink({ diff --git a/aleksis/core/assets/components/SnackbarItem.vue b/aleksis/core/assets/components/SnackbarItem.vue index b7b496d73dc6a0715082bb63a77ff97bd3ea8dd5..f80fb4cc7c2de8a269ab0fc73e15caad01dbfe10 100644 --- a/aleksis/core/assets/components/SnackbarItem.vue +++ b/aleksis/core/assets/components/SnackbarItem.vue @@ -1,6 +1,6 @@ <template> <v-snackbar v-model="!snackbarItem.read" :color="snackbarItem.color"> - {{ snackbarItem.message }} + {{ $t(snackbarItem.messageKey) }} <template v-slot:action="{ attrs }"> <v-btn icon @click="checkSnackbarItem(snackbarItem.id)" ><v-icon>mdi-close</v-icon></v-btn> </template> diff --git a/aleksis/core/assets/messages.json b/aleksis/core/assets/messages.json index 5bfa70fb7e8b180fc08179930e7f53733b94bf72..64cc329345330a10a03af4bb985258eda1d4316a 100644 --- a/aleksis/core/assets/messages.json +++ b/aleksis/core/assets/messages.json @@ -239,7 +239,11 @@ "network_errors": { "error_404": "404", "page_not_found": "The requested page or resource could not be found.", - "take_me_back": "Take me back" + "take_me_back": "Take me back", + "snackbar_error_message": "There was an error with your network. Please try again." + }, + "graphql_errors": { + "snackbar_error_message": "There was an error accessing the page data. Please try again." }, "service_worker": { "new_version_available": "A new version of the app is available", diff --git a/aleksis/core/assets/snackbarItems.graphql b/aleksis/core/assets/snackbarItems.graphql index 28f5034a332705f844d03ee6aaedd4a1994cb788..c31423e87179649f7d29e80edc32c84e54490ee1 100644 --- a/aleksis/core/assets/snackbarItems.graphql +++ b/aleksis/core/assets/snackbarItems.graphql @@ -1,7 +1,7 @@ { snackbarItems @client { id - message + messageKey color read }