From 5b30f1629114c67ee3be653cbe2f704f1f93681a Mon Sep 17 00:00:00 2001 From: Reinaldo Neto Date: Tue, 22 Jun 2021 18:42:10 -0300 Subject: [PATCH 01/10] [FIX] HEvaluating proper the error for channel, team and undefined --- app/sagas/createChannel.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/sagas/createChannel.js b/app/sagas/createChannel.js index a768916c8be..ced3244a51c 100644 --- a/app/sagas/createChannel.js +++ b/app/sagas/createChannel.js @@ -110,7 +110,9 @@ const handleSuccess = function* handleSuccess({ data }) { const handleFailure = function handleFailure({ err, isTeam }) { setTimeout(() => { - const msg = err.data.errorType ? I18n.t(err.data.errorType, { room_name: err.data.details.channel_name }) : err.reason || I18n.t('There_was_an_error_while_action', { action: isTeam ? I18n.t('creating_team') : I18n.t('creating_channel') }); + const msg = err?.data?.errorType + ? I18n.t(err?.data?.errorType, { room_name: err?.data?.details?.channel_name }) + : err?.reason || I18n.t(err?.data?.error || 'There_was_an_error_while_action', { action: isTeam ? I18n.t('creating_team') : I18n.t('creating_channel') }); showErrorAlert(msg, isTeam ? I18n.t('Create_Team') : I18n.t('Create_Channel')); }, 300); }; From 3e0c5bf7d661ebbd80b180734dabcaf00bbaada1 Mon Sep 17 00:00:00 2001 From: Reinaldo Neto Date: Tue, 22 Jun 2021 18:44:35 -0300 Subject: [PATCH 02/10] Added some team errors in i18n --- app/i18n/locales/en.json | 5 ++++- app/i18n/locales/pt-BR.json | 4 +++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/app/i18n/locales/en.json b/app/i18n/locales/en.json index 926b0c6746e..3960073dee6 100644 --- a/app/i18n/locales/en.json +++ b/app/i18n/locales/en.json @@ -762,5 +762,8 @@ "Move_to_Team_Warning": "After reading the previous intructions about this behavior, do you still want to move this channel to the selected team?", "Load_More": "Load More", "Load_Newer": "Load Newer", - "Load_Older": "Load Older" + "Load_Older": "Load Older", + "room-name-already-exists": "Room name already exists", + "error-team-creation": "Error team creation" + } \ No newline at end of file diff --git a/app/i18n/locales/pt-BR.json b/app/i18n/locales/pt-BR.json index 9b34d87d3f5..75380c5ffc4 100644 --- a/app/i18n/locales/pt-BR.json +++ b/app/i18n/locales/pt-BR.json @@ -665,5 +665,7 @@ "Team_not_found": "Time não encontrado", "Private_Team": "Equipe Privada", "Add_Existing_Channel": "Adicionar Canal Existente", - "invalid-room": "Sala inválida" + "invalid-room": "Sala inválida", + "room-name-already-exists": "Nome da sala já existe", + "error-team-creation": "Erro na criação do time" } \ No newline at end of file From ffdeb6c3c5a97a5eeefce0b744367b44cbdf28b1 Mon Sep 17 00:00:00 2001 From: Reinaldo Neto Date: Wed, 23 Jun 2021 11:04:10 -0300 Subject: [PATCH 03/10] Added unauthorized to i18n --- app/i18n/locales/en.json | 3 ++- app/i18n/locales/pt-BR.json | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/app/i18n/locales/en.json b/app/i18n/locales/en.json index 3960073dee6..0a9af40ac44 100644 --- a/app/i18n/locales/en.json +++ b/app/i18n/locales/en.json @@ -764,6 +764,7 @@ "Load_Newer": "Load Newer", "Load_Older": "Load Older", "room-name-already-exists": "Room name already exists", - "error-team-creation": "Error team creation" + "error-team-creation": "Error team creation", + "unauthorized": "Unauthorized" } \ No newline at end of file diff --git a/app/i18n/locales/pt-BR.json b/app/i18n/locales/pt-BR.json index 75380c5ffc4..b491b7c2e8f 100644 --- a/app/i18n/locales/pt-BR.json +++ b/app/i18n/locales/pt-BR.json @@ -667,5 +667,6 @@ "Add_Existing_Channel": "Adicionar Canal Existente", "invalid-room": "Sala inválida", "room-name-already-exists": "Nome da sala já existe", - "error-team-creation": "Erro na criação do time" + "error-team-creation": "Erro na criação do time", + "unauthorized": "Não autorizado" } \ No newline at end of file From 17efa73e92482de6899cfc09fac9142c4148b33b Mon Sep 17 00:00:00 2001 From: Reinaldo Neto Date: Wed, 23 Jun 2021 11:12:41 -0300 Subject: [PATCH 04/10] Test if there is channel name too, to prevent to show {missing roomName} --- app/sagas/createChannel.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/sagas/createChannel.js b/app/sagas/createChannel.js index ced3244a51c..2a0f342c28b 100644 --- a/app/sagas/createChannel.js +++ b/app/sagas/createChannel.js @@ -110,7 +110,7 @@ const handleSuccess = function* handleSuccess({ data }) { const handleFailure = function handleFailure({ err, isTeam }) { setTimeout(() => { - const msg = err?.data?.errorType + const msg = (err?.data?.errorType && err?.data?.details?.channel_name) ? I18n.t(err?.data?.errorType, { room_name: err?.data?.details?.channel_name }) : err?.reason || I18n.t(err?.data?.error || 'There_was_an_error_while_action', { action: isTeam ? I18n.t('creating_team') : I18n.t('creating_channel') }); showErrorAlert(msg, isTeam ? I18n.t('Create_Team') : I18n.t('Create_Channel')); From 2690ef1af5d7e3721a8e1067eda7e14e32f8ad1e Mon Sep 17 00:00:00 2001 From: Reinaldo Neto Date: Sun, 4 Jul 2021 23:36:06 -0300 Subject: [PATCH 05/10] Refactor the treatment error to check if exists before translate with i18n --- app/sagas/createChannel.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/app/sagas/createChannel.js b/app/sagas/createChannel.js index 2a0f342c28b..a5a81692cb3 100644 --- a/app/sagas/createChannel.js +++ b/app/sagas/createChannel.js @@ -12,6 +12,7 @@ import database from '../lib/database'; import I18n from '../i18n'; import { logEvent, events } from '../utils/log'; import { goRoom } from '../utils/goRoom'; +import i18nEnJson from '../i18n/locales/en.json'; const createChannel = function createChannel(data) { return RocketChat.createChannel(data); @@ -110,9 +111,12 @@ const handleSuccess = function* handleSuccess({ data }) { const handleFailure = function handleFailure({ err, isTeam }) { setTimeout(() => { - const msg = (err?.data?.errorType && err?.data?.details?.channel_name) - ? I18n.t(err?.data?.errorType, { room_name: err?.data?.details?.channel_name }) - : err?.reason || I18n.t(err?.data?.error || 'There_was_an_error_while_action', { action: isTeam ? I18n.t('creating_team') : I18n.t('creating_channel') }); + let msg = ''; + if (err?.data?.errorType && err?.data?.details?.channel_name) { + msg = i18nEnJson[err.data.errorType] ? I18n.t(err.data.errorType, { room_name: err.data.details.channel_name }) : err.data.errorType; + } else { + msg = err?.reason || (i18nEnJson[err?.data?.error] ? I18n.t(err?.data?.error) : err?.data?.error || I18n.t('There_was_an_error_while_action', { action: isTeam ? I18n.t('creating_team') : I18n.t('creating_channel') })); + } showErrorAlert(msg, isTeam ? I18n.t('Create_Team') : I18n.t('Create_Channel')); }, 300); }; From dbac8cc1c100791607782dbdcf7002c9686251f4 Mon Sep 17 00:00:00 2001 From: Reinaldo Neto Date: Tue, 13 Jul 2021 12:11:58 -0300 Subject: [PATCH 06/10] Remove some check conditional points --- app/sagas/createChannel.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/sagas/createChannel.js b/app/sagas/createChannel.js index 88393c600b9..6d6f3745cc0 100644 --- a/app/sagas/createChannel.js +++ b/app/sagas/createChannel.js @@ -115,7 +115,7 @@ const handleFailure = function handleFailure({ err, isTeam }) { if (err?.data?.errorType && err?.data?.details?.channel_name) { msg = i18nEnJson[err.data.errorType] ? I18n.t(err.data.errorType, { room_name: err.data.details.channel_name }) : err.data.errorType; } else { - msg = err?.reason || (i18nEnJson[err?.data?.error] ? I18n.t(err?.data?.error) : err?.data?.error || I18n.t('There_was_an_error_while_action', { action: isTeam ? I18n.t('creating_team') : I18n.t('creating_channel') })); + msg = err?.reason || (i18nEnJson[err?.data?.error] ? I18n.t(err.data.error) : err.data.error || I18n.t('There_was_an_error_while_action', { action: isTeam ? I18n.t('creating_team') : I18n.t('creating_channel') })); } showErrorAlert(msg, isTeam ? I18n.t('Create_Team') : I18n.t('Create_Channel')); }, 300); From 62ab637362f12024ddf191fc62034bca827e9334 Mon Sep 17 00:00:00 2001 From: Gerzon Z Date: Fri, 16 Jul 2021 10:09:11 -0400 Subject: [PATCH 07/10] Minor tweak --- app/sagas/createChannel.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/sagas/createChannel.js b/app/sagas/createChannel.js index 6d6f3745cc0..f36f2412bec 100644 --- a/app/sagas/createChannel.js +++ b/app/sagas/createChannel.js @@ -112,10 +112,11 @@ const handleSuccess = function* handleSuccess({ data }) { const handleFailure = function handleFailure({ err, isTeam }) { setTimeout(() => { let msg = ''; + const actionError = I18n.t('There_was_an_error_while_action', { action: isTeam ? I18n.t('creating_team') : I18n.t('creating_channel') }); if (err?.data?.errorType && err?.data?.details?.channel_name) { - msg = i18nEnJson[err.data.errorType] ? I18n.t(err.data.errorType, { room_name: err.data.details.channel_name }) : err.data.errorType; + msg = i18nEnJson[err.data.errorType] ? I18n.t(err.data.errorType, { room_name: err.data.details.channel_name }) : actionError; } else { - msg = err?.reason || (i18nEnJson[err?.data?.error] ? I18n.t(err.data.error) : err.data.error || I18n.t('There_was_an_error_while_action', { action: isTeam ? I18n.t('creating_team') : I18n.t('creating_channel') })); + msg = err?.reason || (i18nEnJson[err?.data?.error] ? I18n.t(err.data.error) : err.data.error || actionError); } showErrorAlert(msg, isTeam ? I18n.t('Create_Team') : I18n.t('Create_Channel')); }, 300); From 47acf5c60c1c65ca497b04d7be0476c8c7a677cf Mon Sep 17 00:00:00 2001 From: Reinaldo Neto Date: Tue, 27 Jul 2021 11:47:11 -0300 Subject: [PATCH 08/10] Added array with error inside the createChannel --- app/sagas/createChannel.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/app/sagas/createChannel.js b/app/sagas/createChannel.js index f36f2412bec..5ea0f12ba85 100644 --- a/app/sagas/createChannel.js +++ b/app/sagas/createChannel.js @@ -12,7 +12,15 @@ import database from '../lib/database'; import I18n from '../i18n'; import { logEvent, events } from '../utils/log'; import { goRoom } from '../utils/goRoom'; -import i18nEnJson from '../i18n/locales/en.json'; + +const errorArray = [ + 'room-name-already-exists', + 'error-team-creation', + 'unauthorized', + 'error-duplicate-channel-name', + 'error-invalid-room-name', + 'team-name-already-exists' +]; const createChannel = function createChannel(data) { return RocketChat.createChannel(data); @@ -114,9 +122,9 @@ const handleFailure = function handleFailure({ err, isTeam }) { let msg = ''; const actionError = I18n.t('There_was_an_error_while_action', { action: isTeam ? I18n.t('creating_team') : I18n.t('creating_channel') }); if (err?.data?.errorType && err?.data?.details?.channel_name) { - msg = i18nEnJson[err.data.errorType] ? I18n.t(err.data.errorType, { room_name: err.data.details.channel_name }) : actionError; + msg = errorArray.includes(err.data.errorType) ? I18n.t(err.data.errorType, { room_name: err.data.details.channel_name }) : actionError; } else { - msg = err?.reason || (i18nEnJson[err?.data?.error] ? I18n.t(err.data.error) : err.data.error || actionError); + msg = err?.reason || (errorArray.includes(err?.data?.error) ? I18n.t(err.data.error) : err.data.error || actionError); } showErrorAlert(msg, isTeam ? I18n.t('Create_Team') : I18n.t('Create_Channel')); }, 300); From fdf31e4d806c1d8ea3defcf705d2d594a75c85ae Mon Sep 17 00:00:00 2001 From: Reinaldo Neto Date: Wed, 11 Aug 2021 11:59:20 -0300 Subject: [PATCH 09/10] Moved error array to inside the handleFailure --- app/sagas/createChannel.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/app/sagas/createChannel.js b/app/sagas/createChannel.js index 5ea0f12ba85..6e244d9046a 100644 --- a/app/sagas/createChannel.js +++ b/app/sagas/createChannel.js @@ -13,15 +13,6 @@ import I18n from '../i18n'; import { logEvent, events } from '../utils/log'; import { goRoom } from '../utils/goRoom'; -const errorArray = [ - 'room-name-already-exists', - 'error-team-creation', - 'unauthorized', - 'error-duplicate-channel-name', - 'error-invalid-room-name', - 'team-name-already-exists' -]; - const createChannel = function createChannel(data) { return RocketChat.createChannel(data); }; @@ -118,6 +109,15 @@ const handleSuccess = function* handleSuccess({ data }) { }; const handleFailure = function handleFailure({ err, isTeam }) { + const errorArray = [ + 'room-name-already-exists', + 'error-team-creation', + 'unauthorized', + 'error-duplicate-channel-name', + 'error-invalid-room-name', + 'team-name-already-exists' + ]; + setTimeout(() => { let msg = ''; const actionError = I18n.t('There_was_an_error_while_action', { action: isTeam ? I18n.t('creating_team') : I18n.t('creating_channel') }); From b85ea7fd4eefb728b2d396bd7468c88d32544f08 Mon Sep 17 00:00:00 2001 From: Reinaldo Neto Date: Tue, 24 Aug 2021 17:21:20 -0300 Subject: [PATCH 10/10] added creating_discussion --- app/i18n/locales/en.json | 3 ++- app/views/CreateDiscussionView/index.js | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/app/i18n/locales/en.json b/app/i18n/locales/en.json index ece298f71c0..114478bb64c 100644 --- a/app/i18n/locales/en.json +++ b/app/i18n/locales/en.json @@ -771,5 +771,6 @@ "Convert_to_Channel": "Convert to Channel", "Converting_Team_To_Channel": "Converting Team to Channel", "Select_Team_Channels_To_Delete": "Select the Team’s Channels you would like to delete, the ones you do not select will be moved to the Workspace. \n\nNotice that public Channels will be public and visible to everyone.", - "You_are_converting_the_team": "You are converting this Team to a Channel" + "You_are_converting_the_team": "You are converting this Team to a Channel", + "creating_discussion": "creating discussion" } \ No newline at end of file diff --git a/app/views/CreateDiscussionView/index.js b/app/views/CreateDiscussionView/index.js index 46b2d6cde3b..a70caff9b17 100644 --- a/app/views/CreateDiscussionView/index.js +++ b/app/views/CreateDiscussionView/index.js @@ -74,7 +74,7 @@ class CreateChannelView extends React.Component { if (!loading && loading !== prevProps.loading) { setTimeout(() => { if (failure) { - const msg = error.reason || I18n.t('There_was_an_error_while_action', { action: I18n.t('creating_channel') }); + const msg = error.reason || I18n.t('There_was_an_error_while_action', { action: I18n.t('creating_discussion') }); showErrorAlert(msg); } else { const { rid, t, prid } = result;