Skip to content

Commit

Permalink
EPMRPP-96901 || Merge develop to org
Browse files Browse the repository at this point in the history
  • Loading branch information
BlazarQSO committed Nov 25, 2024
2 parents e95e8cc + 239ba94 commit dd49e48
Show file tree
Hide file tree
Showing 29 changed files with 449 additions and 52 deletions.
7 changes: 6 additions & 1 deletion app/localization/translated/be.json
Original file line number Diff line number Diff line change
Expand Up @@ -647,7 +647,8 @@
"EditWidgetModal.editWidgetSuccess": "Віджэт абноўлены!",
"EditWidgetModal.headerText": "Рэдагаваць віджэт",
"EmailFormFields.authLabel": "Аўтарызацыя",
"EmailFormFields.fromLabel": "Імя адпраўніка па змаўчанні",
"EmailFormFields.fromEmailLabel": "From Email",
"EmailFormFields.fromNameLabel": "From name",
"EmailFormFields.hostLabel": "Хост",
"EmailFormFields.passwordLabel": "Пароль",
"EmailFormFields.portFieldHint": "Магчымы толькі лічбы ад '1' да '65535'",
Expand Down Expand Up @@ -1944,6 +1945,10 @@
"SortingControl.sortByFailedItems": "Няўдалыя пункты",
"SortingControl.sortByPassingRate": "Прахадны бал",
"SortingControl.sortByTotal": "Агульная колькасць",
"SsoUsersForm.formHeader": "Instance Invitations",
"SsoUsersForm.manualInvitesDescription": "Карыстальнікі могуць адпраўляць запрашэнні іншым карыстальнікам. Калі ўключана, новыя карыстальнікі могуць быць ствараны толькі праз SSO.",
"SsoUsersForm.ssoOnlyDescription": "Новыя карыстальнікі могуць быць створаны толькі праз SSO.",
"SsoUsersForm.switcherLabel": "Толькі SSO карыстальнікі",
"StackTrace.jumpTo": "Перайсці",
"StackTrace.linkText": "Адкрыць логі",
"StackTrace.loadLabel": "Загрузіць яшчэ",
Expand Down
7 changes: 6 additions & 1 deletion app/localization/translated/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -646,7 +646,8 @@
"EditWidgetModal.editWidgetSuccess": "¡Widget actualizado!",
"EditWidgetModal.headerText": "Editar widget",
"EmailFormFields.authLabel": "Autorización",
"EmailFormFields.fromLabel": "Nombre del remitente predeterminado",
"EmailFormFields.fromEmailLabel": "From Email",
"EmailFormFields.fromNameLabel": "From name",
"EmailFormFields.hostLabel": "Host",
"EmailFormFields.passwordLabel": "Contraseña",
"EmailFormFields.portFieldHint": "Solo se permiten números del '1' al '65535'",
Expand Down Expand Up @@ -1922,6 +1923,10 @@
"SortingControl.sortByFailedItems": "Elementos fallidos",
"SortingControl.sortByPassingRate": "Porcentaje de aprobados",
"SortingControl.sortByTotal": "Cantidad total",
"SsoUsersForm.formHeader": "Instance Invitations",
"SsoUsersForm.manualInvitesDescription": "Users can manually send invitations for other users. If enabled new users can be created via SSO only.",
"SsoUsersForm.ssoOnlyDescription": "New users can be created via SSO only.",
"SsoUsersForm.switcherLabel": "SSO users only",
"StackTrace.jumpTo": "Ir a",
"StackTrace.linkText": "Abrir registros",
"StackTrace.loadLabel": "Cargar más",
Expand Down
7 changes: 6 additions & 1 deletion app/localization/translated/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -647,7 +647,8 @@
"EditWidgetModal.editWidgetSuccess": "Виджет обновлен!",
"EditWidgetModal.headerText": "Редактировать виджет",
"EmailFormFields.authLabel": "Авторизация",
"EmailFormFields.fromLabel": "Имя отправителя по умолчанию",
"EmailFormFields.fromEmailLabel": "From Email",
"EmailFormFields.fromNameLabel": "From name",
"EmailFormFields.hostLabel": "Хост",
"EmailFormFields.passwordLabel": "Пароль",
"EmailFormFields.portFieldHint": "Возможны только цифры от '1' до '65535'",
Expand Down Expand Up @@ -1941,6 +1942,10 @@
"SortingControl.sortByFailedItems": "Неудачные пункты",
"SortingControl.sortByPassingRate": "Проходной балл",
"SortingControl.sortByTotal": "Общее количество",
"SsoUsersForm.formHeader": "Instance Invitations",
"SsoUsersForm.manualInvitesDescription": "Пользователи могут вручную отправлять приглашения другим пользователям. Если включено, новых пользователей можно создавать только через SSO.",
"SsoUsersForm.ssoOnlyDescription": "Новых пользователей можно создавать только через SSO.",
"SsoUsersForm.switcherLabel": "Только SSO пользователи",
"StackTrace.jumpTo": "Перейти",
"StackTrace.linkText": "Открыть логи",
"StackTrace.loadLabel": "Загрузить еще",
Expand Down
7 changes: 6 additions & 1 deletion app/localization/translated/uk.json
Original file line number Diff line number Diff line change
Expand Up @@ -647,7 +647,8 @@
"EditWidgetModal.editWidgetSuccess": "Оновлений Віджет!",
"EditWidgetModal.headerText": "Віджет Редагувати",
"EmailFormFields.authLabel": "Авторизація",
"EmailFormFields.fromLabel": "Ім’я відправника за замовчуванням",
"EmailFormFields.fromEmailLabel": "From Email",
"EmailFormFields.fromNameLabel": "From name",
"EmailFormFields.hostLabel": "Хост",
"EmailFormFields.passwordLabel": "Пароль",
"EmailFormFields.portFieldHint": "Можливі тільки цифри від '1' до '65535'",
Expand Down Expand Up @@ -1943,6 +1944,10 @@
"SortingControl.sortByFailedItems": "Невдалі пункти",
"SortingControl.sortByPassingRate": "Прохідний бал",
"SortingControl.sortByTotal": "Загальна кількість",
"SsoUsersForm.formHeader": "Instance Invitations",
"SsoUsersForm.manualInvitesDescription": "Користувачі можуть самостійно надсилати запрошення іншим користувачам. Якщо ввімкнено, нові користувачі створюються виключно через SSO.",
"SsoUsersForm.ssoOnlyDescription": "Користувачі створюються виключно через SSO.",
"SsoUsersForm.switcherLabel": "SSO users only",
"StackTrace.jumpTo": "Перейти",
"StackTrace.linkText": "Логи Відкрити",
"StackTrace.loadLabel": "Завантажити",
Expand Down
7 changes: 6 additions & 1 deletion app/localization/translated/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -647,7 +647,8 @@
"EditWidgetModal.editWidgetSuccess": "小部件已更新",
"EditWidgetModal.headerText": "编辑小部件",
"EmailFormFields.authLabel": "授权",
"EmailFormFields.fromLabel": "默认发件人姓名",
"EmailFormFields.fromEmailLabel": "From Email",
"EmailFormFields.fromNameLabel": "From name",
"EmailFormFields.hostLabel": "服务器(Host)",
"EmailFormFields.passwordLabel": "密码",
"EmailFormFields.portFieldHint": "只允许输入从“1”到“65535”的数字",
Expand Down Expand Up @@ -1943,6 +1944,10 @@
"SortingControl.sortByFailedItems": "失败的测试项",
"SortingControl.sortByPassingRate": "通过率",
"SortingControl.sortByTotal": "全部",
"SsoUsersForm.formHeader": "Instance Invitations",
"SsoUsersForm.manualInvitesDescription": "Users can manually send invitations for other users. If enabled new users can be created via SSO only.",
"SsoUsersForm.ssoOnlyDescription": "New users can be created via SSO only.",
"SsoUsersForm.switcherLabel": "SSO users only",
"StackTrace.jumpTo": "跳转至",
"StackTrace.linkText": "在日志视图中打开",
"StackTrace.loadLabel": "加载更多",
Expand Down
35 changes: 35 additions & 0 deletions app/src/common/utils/fieldTransformer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
export function combineNameAndEmailToFrom(inputObj) {
const obj = { ...inputObj };
if (obj.fromName && obj.fromEmail) {
obj.from = `${obj.fromName} <${obj.fromEmail}>`;
delete obj.fromName;
delete obj.fromEmail;
} else {
obj.from = obj.fromName || obj.fromEmail;
delete obj.fromName;
delete obj.fromEmail;
}
return obj;
}

export function separateFromIntoNameAndEmail(inputObj) {
const obj = { ...inputObj };
if (obj.from) {
const match = obj.from.match(/^(.*) <(.*)>$/);
if (match) {
obj.fromName = match[1];
obj.fromEmail = match[2];
} else if (obj.from.includes('@')) {
obj.fromName = '';
obj.fromEmail = obj.from;
} else {
obj.fromName = obj.from;
obj.fromEmail = '';
}
delete obj.from;
} else {
obj.fromName = '';
obj.fromEmail = '';
}
return obj;
}
73 changes: 73 additions & 0 deletions app/src/common/utils/fieldTransformer.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
import { separateFromIntoNameAndEmail, combineNameAndEmailToFrom } from './fieldTransformer';

describe('separateFromIntoNameAndEmail', () => {
it('should split "from" into "fromName" and "fromEmail" when valid format is provided', () => {
const input = { from: 'John Doe <[email protected]>' };
const result = separateFromIntoNameAndEmail(input);
expect(result).toEqual({
fromName: 'John Doe',
fromEmail: '[email protected]',
});
});

it('should set "fromName" and empty "fromEmail" when "from" does not include <email>', () => {
const input = { from: 'John Doe' };
const result = separateFromIntoNameAndEmail(input);
expect(result).toEqual({
fromName: 'John Doe',
fromEmail: '',
});
});

it('should set "fromName" and "fromEmail" to empty strings when "from" is not provided', () => {
const input = {};
const result = separateFromIntoNameAndEmail(input);
expect(result).toEqual({
fromName: '',
fromEmail: '',
});
});

it('should leave unrelated fields in the object unchanged', () => {
const input = { from: 'John Doe <[email protected]>', otherField: 'value' };
const result = separateFromIntoNameAndEmail(input);
expect(result).toEqual({
fromName: 'John Doe',
fromEmail: '[email protected]',
otherField: 'value',
});
});
});

describe('combineNameAndEmailToFrom', () => {
it('should combine "fromName" and "fromEmail" into "from"', () => {
const input = { fromName: 'John Doe', fromEmail: '[email protected]' };
const result = combineNameAndEmailToFrom(input);
expect(result).toEqual({
from: 'John Doe <[email protected]>',
});
});

it('should leave unrelated fields in the object unchanged', () => {
const input = { fromName: 'John Doe', fromEmail: '[email protected]', otherField: 'value' };
const result = combineNameAndEmailToFrom(input);
expect(result).toEqual({
from: 'John Doe <[email protected]>',
otherField: 'value',
});
});

it('should set "from" to "fromName" or "fromEmail" if only one is provided', () => {
const input1 = { fromName: 'John Doe' };
const input2 = { fromEmail: '[email protected]' };
const input3 = {};

const result1 = combineNameAndEmailToFrom(input1);
const result2 = combineNameAndEmailToFrom(input2);
const result3 = combineNameAndEmailToFrom(input3);

expect(result1).toEqual({ from: 'John Doe' });
expect(result2).toEqual({ from: '[email protected]' });
expect(result3).toEqual({});
});
});
1 change: 1 addition & 0 deletions app/src/common/utils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,4 @@ export { omit } from './omit';
export { calculateFontColor } from './calculateFontColor';
export { createExternalLink } from './createExternalLink';
export { findAssignedProjectByOrganization } from './findAssignedProjectByOrganization';
export { combineNameAndEmailToFrom, separateFromIntoNameAndEmail } from './fieldTransformer';
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ import {
isPluginBuiltin,
} from 'components/integrations/utils';
import { PLUGIN_NAME_TITLES } from 'components/integrations/constants';
import { LDAP } from 'common/constants/pluginNames';
import { EMAIL, LDAP } from 'common/constants/pluginNames';
import { combineNameAndEmailToFrom } from 'common/utils';
import { InstancesList } from './instancesList';
import styles from './instancesSection.scss';

Expand Down Expand Up @@ -188,10 +189,11 @@ export class InstancesSection extends Component {

createIntegration = (formData, metaData) => {
const { isGlobal, instanceType } = this.props;
const updatedFormData = instanceType === EMAIL ? combineNameAndEmailToFrom(formData) : formData;
const data = {
enabled: true,
integrationParameters: formData,
name: formData.integrationName || PLUGIN_NAME_TITLES[instanceType],
integrationParameters: updatedFormData,
name: updatedFormData.integrationName || PLUGIN_NAME_TITLES[instanceType],
};

this.props.addIntegrationAction(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ import { updateIntegrationAction } from 'controllers/plugins';
import { uiExtensionIntegrationSettingsSelector } from 'controllers/plugins/uiExtensions/selectors';
import { INTEGRATIONS_SETTINGS_COMPONENTS_MAP } from 'components/integrations/settingsComponentsMap';
import { ExtensionLoader, extensionType } from 'components/extensionLoader';
import { EMAIL } from 'common/constants/pluginNames';
import { combineNameAndEmailToFrom } from 'common/utils';
import styles from './integrationSettingsContainer.scss';

const cx = classNames.bind(styles);
Expand Down Expand Up @@ -61,13 +63,14 @@ export class IntegrationSettingsContainer extends Component {
},
isGlobal,
} = this.props;
const updatedFormData = pluginName === EMAIL ? combineNameAndEmailToFrom(formData) : formData;
const data = {
enabled: true,
integrationParameters: formData,
integrationParameters: updatedFormData,
};

if (formData.integrationName) {
data.name = formData.integrationName;
if (updatedFormData.integrationName) {
data.name = updatedFormData.integrationName;
}

this.props.updateIntegrationAction(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ export const AUTH_ENABLED_KEY = 'authEnabled';
export const PROTOCOL_KEY = 'protocol';
export const SSL_KEY = 'sslEnabled';
export const TLS_KEY = 'starTlsEnabled';
export const FROM_KEY = 'from';
export const FROM_NAME_KEY = 'fromName';
export const FROM_EMAIL_KEY = 'fromEmail';
export const HOST_KEY = 'host';
export const PORT_KEY = 'port';
export const USERNAME_KEY = 'username';
Expand Down
Loading

0 comments on commit dd49e48

Please sign in to comment.