Skip to content

Commit

Permalink
EPMRPP-86766 || Code review fixes - 1
Browse files Browse the repository at this point in the history
  • Loading branch information
Dzmitry Kosarau authored and Dzmitry Kosarau committed Sep 29, 2023
1 parent b2b2883 commit b655953
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 8 deletions.
2 changes: 2 additions & 0 deletions app/localization/translated/be.json
Original file line number Diff line number Diff line change
Expand Up @@ -699,6 +699,8 @@
"EventActions.deletePattern": "Выдаленне шаблону",
"EventActions.deleteWidget": "Выдаленне віджэта",
"EventActions.import": "Імпарт",
"EventActions.startImport": "Пачаць імпарт",
"EventActions.finishImport": "Скончыць імпарт",
"EventActions.finishLaunch": "Канчатак запуску",
"EventActions.generateIndex": "Генерацыя індэкса",
"EventActions.linkIssue": "Прывязка праблемы",
Expand Down
2 changes: 2 additions & 0 deletions app/localization/translated/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -696,6 +696,8 @@
"EventActions.deletePattern": "Удаление шаблона",
"EventActions.deleteWidget": "Удаление виджета",
"EventActions.import": "Импорт",
"EventActions.startImport": "Начать импорт",
"EventActions.finishImport": "Закончить импорт",
"EventActions.finishLaunch": "Окончание запуска",
"EventActions.generateIndex": "Генерация индекса",
"EventActions.linkIssue": "Привязка ошибки",
Expand Down
2 changes: 2 additions & 0 deletions app/localization/translated/uk.json
Original file line number Diff line number Diff line change
Expand Up @@ -697,6 +697,8 @@
"EventActions.deletePattern": "Видалення шаблону",
"EventActions.deleteWidget": "Видалення міні-програми",
"EventActions.import": "Імпорт",
"EventActions.startImport": "Розпочати імпорт",
"EventActions.finishImport": "Завершити імпорт",
"EventActions.finishLaunch": "Закінчення запуску",
"EventActions.generateIndex": "Генерація індексу",
"EventActions.linkIssue": "Прив’язка помилки",
Expand Down
2 changes: 2 additions & 0 deletions app/localization/translated/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -693,6 +693,8 @@
"EventActions.deletePattern": "删除模板规则",
"EventActions.deleteWidget": "删除小部件",
"EventActions.import": "导入",
"EventActions.startImport": "Start import",
"EventActions.finishImport": "Finish import",
"EventActions.finishLaunch": "完成测试任务",
"EventActions.generateIndex": "生成索引",
"EventActions.linkIssue": "与问题关联",
Expand Down
1 change: 1 addition & 0 deletions app/src/common/constants/actionTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export const DELETE_PATTERN = 'deletePattern';
export const MATCHED_PATTERN = 'patternMatched';
export const CREATE_PROJECT = 'createProject';
export const CREATE_INVITATION_LINK = 'createInvitationLink';
export const EVENT_ACTIONS_IMPORT = 'import';

// grouped actions
export const ACTIONS_WITH_ISSUES = 'issuesActions';
Expand Down
14 changes: 12 additions & 2 deletions app/src/common/constants/localization/eventsLocalization.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ import {
START_LAUNCH,
FINISH_LAUNCH,
DELETE_LAUNCH,
ACTIONS_WITH_IMPORT,
UPDATE_PROJECT,
CREATE_DEFECT,
UPDATE_DEFECT,
Expand All @@ -71,6 +70,9 @@ import {
CREATE_PROJECT,
UPDATE_AUTO_PATTERN_ANALYSIS_SETTINGS,
CREATE_INVITATION_LINK,
FINISH_IMPORT,
START_IMPORT,
EVENT_ACTIONS_IMPORT,
} from 'common/constants/actionTypes';

export const actionMessages = defineMessages({
Expand Down Expand Up @@ -122,10 +124,18 @@ export const actionMessages = defineMessages({
id: 'EventActions.deleteLaunch',
defaultMessage: 'Delete launch',
},
[ACTIONS_WITH_IMPORT]: {
[EVENT_ACTIONS_IMPORT]: {
id: 'EventActions.import',
defaultMessage: 'Import',
},
[START_IMPORT]: {
id: 'EventActions.startImport',
defaultMessage: 'Start import',
},
[FINISH_IMPORT]: {
id: 'EventActions.finishImport',
defaultMessage: 'Finish import',
},
[ASSIGN_USER]: {
id: 'EventActions.assignUser',
defaultMessage: 'Assign user',
Expand Down
15 changes: 12 additions & 3 deletions app/src/components/filterEntities/entityDropdown.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ import PropTypes from 'prop-types';
import track from 'react-tracking';
import { InputDropdown } from 'components/inputs/inputDropdown';
import { FieldFilterEntity } from 'components/fields/fieldFilterEntity';
import { GROUP_TO_ACTION_MAP } from 'common/constants/actionTypes';
import { arrayRemoveDoubles } from 'common/utils';

@track()
export class EntityDropdown extends Component {
Expand Down Expand Up @@ -51,17 +53,23 @@ export class EntityDropdown extends Component {
events: {},
};

formatActionTypes = ({ value }, actionToGroup = {}) =>
arrayRemoveDoubles(value.split(',').map((action) => actionToGroup[action] || action));

parseActionTypes = (value) => value.map((group) => GROUP_TO_ACTION_MAP[group] || group).join(',');

getValue = () => {
const {
value,
customProps: { multiple },
customProps: { multiple, actionToGroup },
} = this.props;
if (!multiple) {
return value.value;
} else if (!value.value) {
return [];
}
return value.value.split(',');

return this.formatActionTypes(value, actionToGroup);
};

getOptionLabelByValue = (value) => {
Expand All @@ -83,9 +91,10 @@ export class EntityDropdown extends Component {
const label = this.getOptionLabelByValue(value);
tracking.trackEvent(events.getChangeFilterEvent(title, label));
}

this.props.onChange({
condition: this.props.value.condition,
value: multiple ? value.join(',') : value,
value: multiple ? this.parseActionTypes(value) : value,
});
};

Expand Down
12 changes: 9 additions & 3 deletions app/src/pages/admin/projectEventsPage/eventsEntities.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,9 @@ import {
CHANGE_ROLE,
UPDATE_AUTO_PATTERN_ANALYSIS_SETTINGS,
CREATE_PROJECT,
GROUP_TO_ACTION_MAP,
START_IMPORT,
FINISH_IMPORT,
EVENT_ACTIONS_IMPORT,
} from 'common/constants/actionTypes';
import {
DASHBOARD,
Expand Down Expand Up @@ -168,6 +170,10 @@ export class EventsEntities extends Component {
customProps: {
multiple: true,
selectAll: true,
actionToGroup: {
[START_IMPORT]: ACTIONS_WITH_IMPORT,
[FINISH_IMPORT]: ACTIONS_WITH_IMPORT,
},
options: [
{
label: intl.formatMessage(actionMessages[CREATE_DASHBOARD]),
Expand Down Expand Up @@ -286,8 +292,8 @@ export class EventsEntities extends Component {
value: DELETE_INDEX,
},
{
label: intl.formatMessage(actionMessages[ACTIONS_WITH_IMPORT]),
value: GROUP_TO_ACTION_MAP[ACTIONS_WITH_IMPORT],
label: intl.formatMessage(actionMessages[EVENT_ACTIONS_IMPORT]),
value: ACTIONS_WITH_IMPORT,
},
{
label: intl.formatMessage(actionMessages[UPDATE_ITEM]),
Expand Down

0 comments on commit b655953

Please sign in to comment.