Skip to content

Commit

Permalink
EPMRPP-92028 || fix conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
BlazarQSO committed Sep 17, 2024
2 parents 91fa9ec + aed053b commit 818e3bf
Show file tree
Hide file tree
Showing 33 changed files with 1,567 additions and 1,512 deletions.
1 change: 1 addition & 0 deletions app/localization/translated/be.json
Original file line number Diff line number Diff line change
Expand Up @@ -1771,6 +1771,7 @@
"ProjectsPage.deleteProjectsCount": "{count} элементаў абрана",
"ProjectsPage.deleteSuccess": "Праект быў паспяхова выдалены",
"ProjectsPage.deleteSuccessMultiple": "Праекты быў паспяхова выдалены",
"ProjectsPage.noResultsDescription": "Вашым крытэрам пошуку або фільтра не знойдзена ніводнага выніку. Калі ласка, паспрабуйце іншыя ключавыя словы або змяніце налады фільтра.",
"ProjectsPage.projectDuplicateHint": "Праект з дадзеным найменнем ўжо існуе ў сістэме",
"ProjectsPage.projectExists": "Праект ''{name}'' ўжо існуе",
"ProjectsPage.projectLengthHint": "Назва праекта",
Expand Down
1 change: 1 addition & 0 deletions app/localization/translated/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -1758,6 +1758,7 @@
"ProjectsPage.deleteProjectsCount": "{count} elementos seleccionados",
"ProjectsPage.deleteSuccess": "El proyecto ha sido eliminado exitosamente",
"ProjectsPage.deleteSuccessMultiple": "Los proyectos han sido eliminados exitosamente",
"ProjectsPage.noResultsDescription": "Your search or filter criteria didn't match any results. Please try different keywords or adjust your filter settings.",
"ProjectsPage.projectDuplicateHint": "Ya existe un proyecto con este nombre en el esta organización",
"ProjectsPage.projectExists": "El proyecto ''{name}'' ya existe",
"ProjectsPage.projectLengthHint": "Nombre del proyecto",
Expand Down
1 change: 1 addition & 0 deletions app/localization/translated/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -1771,6 +1771,7 @@
"ProjectsPage.deleteProjectsCount": "{count} элементов выбрано",
"ProjectsPage.deleteSuccess": "Проект был успешно удалён",
"ProjectsPage.deleteSuccessMultiple": "Проекты были успешно удалены",
"ProjectsPage.noResultsDescription": "Ваши критерии поиска или фильтра не дали никаких результатов. Попробуйте другие ключевые слова или измените настройки фильтра.",
"ProjectsPage.projectDuplicateHint": "Проект с данным наименованием уже существует в этой организации",
"ProjectsPage.projectExists": "Проект ''{name}'' уже существует",
"ProjectsPage.projectLengthHint": "Имя проекта",
Expand Down
1 change: 1 addition & 0 deletions app/localization/translated/uk.json
Original file line number Diff line number Diff line change
Expand Up @@ -1771,6 +1771,7 @@
"ProjectsPage.deleteProjectsCount": "{count} елементів вибрано",
"ProjectsPage.deleteSuccess": "Проект був успішно видалений",
"ProjectsPage.deleteSuccessMultiple": "Проекти були успішно видалені",
"ProjectsPage.noResultsDescription": "Ваші критерії пошуку чи фільтра не відповідають жодному результату. Будь ласка, спробуйте інші ключові слова або змініть налаштування фільтра.",
"ProjectsPage.projectDuplicateHint": "Проект з таким найменуванням вже існує в цій організації",
"ProjectsPage.projectExists": "Проект ''{name}'' вже існує",
"ProjectsPage.projectLengthHint": "Ім’я проекту",
Expand Down
1 change: 1 addition & 0 deletions app/localization/translated/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -1771,6 +1771,7 @@
"ProjectsPage.deleteProjectsCount": "已选择{count}项",
"ProjectsPage.deleteSuccess": "项目删除成功",
"ProjectsPage.deleteSuccessMultiple": "已选项目删除成功",
"ProjectsPage.noResultsDescription": "Your search or filter criteria didn't match any results. Please try different keywords or adjust your filter settings.",
"ProjectsPage.projectDuplicateHint": "Project with the same name already exists in this organization",
"ProjectsPage.projectExists": "项目“{name}”已存在",
"ProjectsPage.projectLengthHint": "项目名称",
Expand Down
9 changes: 9 additions & 0 deletions app/src/common/constants/permissions.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ export const ACTIONS = {
FORCE_FINISH_RERUN_LAUNCH: 'FORCE_FINISH_RERUN_LAUNCH',
START_ANALYSIS: 'START_ANALYSIS',
DELETE_TEST_ITEM: 'DELETE_TEST_ITEM',
MAKE_DECISION: 'MAKE_DECISION',
CHANGE_TEST_ITEM_STATUS: 'CHANGE_TEST_ITEM_STATUS',
MANAGE_BTS_ISSUES: 'MANAGE_BTS_ISSUES',
MOVE_TO_DEBUG: 'MOVE_TO_DEBUG',
MERGE_LAUNCHES: 'MERGE_LAUNCHES',
WORK_WITH_FILTERS: 'WORK_WITH_FILTERS',
Expand Down Expand Up @@ -80,7 +83,10 @@ export const PERMISSIONS_MAP = {
[ACTIONS.START_ANALYSIS]: true,
[ACTIONS.BULK_EDIT_ITEMS]: true,
[ACTIONS.FORCE_FINISH_RERUN_LAUNCH]: true,
[ACTIONS.CHANGE_TEST_ITEM_STATUS]: true,
[ACTIONS.DELETE_TEST_ITEM]: true,
[ACTIONS.MAKE_DECISION]: true,
[ACTIONS.MANAGE_BTS_ISSUES]: true,
[ACTIONS.WORK_WITH_FILTERS]: true,
[ACTIONS.WORK_WITH_WIDGETS]: true,
[ACTIONS.SEE_ORGANIZATION_SETTINGS]: true,
Expand Down Expand Up @@ -120,6 +126,9 @@ export const PERMISSIONS_MAP = {
[ACTIONS.FORCE_FINISH_RERUN_LAUNCH]: true,
[ACTIONS.BULK_EDIT_ITEMS]: true,
[ACTIONS.DELETE_TEST_ITEM]: true,
[ACTIONS.CHANGE_TEST_ITEM_STATUS]: true,
[ACTIONS.MAKE_DECISION]: true,
[ACTIONS.MANAGE_BTS_ISSUES]: true,
[ACTIONS.WORK_WITH_FILTERS]: true,
[ACTIONS.WORK_WITH_WIDGETS]: true,
[ACTIONS.RENAME_PROJECT]: true,
Expand Down
3 changes: 3 additions & 0 deletions app/src/common/utils/permissions/permissions.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ export const canForceFinishRerunLaunch = checkPermission(ACTIONS.FORCE_FINISH_RE
export const canStartAnalysis = checkPermission(ACTIONS.START_ANALYSIS);
export const canDeleteTestItem = checkPermission(ACTIONS.DELETE_TEST_ITEM);
export const canMoveToDebug = checkPermission(ACTIONS.MOVE_TO_DEBUG);
export const canChangeTestItemStatus = checkPermission(ACTIONS.CHANGE_TEST_ITEM_STATUS);
export const canMakeDecision = checkPermission(ACTIONS.MAKE_DECISION);
export const canManageBTSIssues = checkPermission(ACTIONS.MANAGE_BTS_ISSUES);
export const canMergeLaunches = checkPermission(ACTIONS.MERGE_LAUNCHES);
export const canWorkWithFilters = checkPermission(ACTIONS.WORK_WITH_FILTERS);
export const canReadData = checkPermission(ACTIONS.READ_DATA);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,54 +14,65 @@
* limitations under the License.
*/

import { Component } from 'react';
import { useCallback } from 'react';
import PropTypes from 'prop-types';
import isEqual from 'fast-deep-equal';
import { connectRouter, debounce, isEmptyObject } from 'common/utils';
import { defaultPaginationSelector, PAGE_KEY } from 'controllers/pagination';
import { collectFilterEntities, createFilterQuery } from './utils';

@connectRouter(
(query) => ({
entities: collectFilterEntities(query),
defaultPagination: defaultPaginationSelector(),
}),
{
updateFilters: (query, page) => ({ ...query, [PAGE_KEY]: page }),
},
)
export class FilterEntitiesURLContainer extends Component {
static propTypes = {
entities: PropTypes.object,
updateFilters: PropTypes.func,
render: PropTypes.func.isRequired,
debounced: PropTypes.bool,
defaultPagination: PropTypes.any.isRequired,
};
const FilterEntitiesURL = ({
entities = {},
updateFilters = () => {},
render,
debounced = true,
debounceTime = 1000,
defaultPagination,
prefixQueryKey,
}) => {
const handleChange = useCallback(
(newEntities) => {
if (isEqual(newEntities, entities)) {
return;
}
const filterQuery = createFilterQuery(newEntities, entities, prefixQueryKey);
if (!isEmptyObject(filterQuery)) {
updateFilters(filterQuery, defaultPagination[PAGE_KEY]);
}
},
[entities, defaultPagination, prefixQueryKey, updateFilters],
);

static defaultProps = {
entities: {},
updateFilters: () => {},
debounced: true,
};
handleChange = (entities) => {
if (isEqual(entities, this.props.entities)) {
return;
}
const { defaultPagination } = this.props;
const filterQuery = createFilterQuery(entities, this.props.entities);
if (!isEmptyObject(filterQuery)) {
this.props.updateFilters(filterQuery, defaultPagination[PAGE_KEY]);
}
};
const debouncedHandleChange = useCallback(debounce(handleChange, debounceTime), [

Check warning on line 46 in app/src/components/filterEntities/containers/filterEntitiesURLContainer.jsx

View workflow job for this annotation

GitHub Actions / build (20)

React Hook useCallback received a function whose dependencies are unknown. Pass an inline function instead
handleChange,
debounceTime,
]);

debouncedHandleChange = debounce(this.handleChange, 1000);
return render({
entities,
onChange: debounced ? debouncedHandleChange : handleChange,
});
};

render() {
const { render, entities, debounced } = this.props;
return render({
entities,
onChange: debounced ? this.debouncedHandleChange : this.handleChange,
});
}
}
FilterEntitiesURL.propTypes = {
entities: PropTypes.object,
updateFilters: PropTypes.func,
render: PropTypes.func.isRequired,
debounced: PropTypes.bool,
debounceTime: PropTypes.number,
defaultPagination: PropTypes.any.isRequired,
prefixQueryKey: PropTypes.string,
};

const createFilterEntitiesURLContainer = (prefixQueryKey) =>
connectRouter(
(query) => ({
entities: collectFilterEntities(query, prefixQueryKey),
defaultPagination: defaultPaginationSelector(),
}),
{
updateFilters: (query, page) => ({ ...query, [PAGE_KEY]: page }),
},
)(FilterEntitiesURL);

export const FilterEntitiesURLContainer = createFilterEntitiesURLContainer();
26 changes: 14 additions & 12 deletions app/src/components/filterEntities/containers/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,30 +19,28 @@ import { isEmptyValue } from 'common/utils/isEmptyValue';
const FILTER_PREFIX = 'filter.';
const PREDEFINED_FILTER_PREFIX = 'predefinedFilter.';

const getFilterKey = (entity, key) =>
entity.condition
? `${FILTER_PREFIX}${entity.condition}.${key}`
: `${PREDEFINED_FILTER_PREFIX}${key}`;
const getFilterKey = (entity, key, predefinedPrefixKey = PREDEFINED_FILTER_PREFIX) =>
entity.condition ? `${FILTER_PREFIX}${entity.condition}.${key}` : `${predefinedPrefixKey}${key}`;

export const resetOldCondition = (entity, oldEntity, key) => {
export const resetOldCondition = (entity, oldEntity, key, predefinedPrefixKey) => {
if (entity && oldEntity) {
if (entity.condition !== oldEntity.condition) {
return { [getFilterKey(oldEntity, key)]: null };
return { [getFilterKey(oldEntity, key, predefinedPrefixKey)]: null };
}
}
return {};
};

export const collectFilterEntities = (query = {}) =>
export const collectFilterEntities = (query = {}, predefinedPrefixKey = PREDEFINED_FILTER_PREFIX) =>
Object.keys(query).reduce((result, key) => {
if (key.indexOf(PREDEFINED_FILTER_PREFIX) === 0) {
if (key.startsWith(predefinedPrefixKey)) {
const [, filterName] = key.split('.');
return {
...result,
[filterName]: { value: query[key] || null },
};
}
if (key.indexOf(FILTER_PREFIX) !== 0) {
if (!key.startsWith(FILTER_PREFIX)) {
return result;
}
const [, condition, filterName] = key.split('.');
Expand All @@ -61,7 +59,11 @@ const isConditionChangeWithEmptyValue = (entity = {}, oldEntity = {}) => {
return isEmptyValue(entityValue) && isEmptyValue(oldEntityValue);
};

export const createFilterQuery = (entities = {}, oldEntities = {}) => {
export const createFilterQuery = (
entities = {},
oldEntities = {},
predefinedPrefixKey = PREDEFINED_FILTER_PREFIX,
) => {
const mergedEntities = { ...oldEntities, ...entities };
const keys = Object.keys(mergedEntities);
const initialQuery = {};
Expand All @@ -72,14 +74,14 @@ export const createFilterQuery = (entities = {}, oldEntities = {}) => {
return res;
}
if (!entity && oldEntity) {
return { ...res, [getFilterKey(oldEntity, key)]: null };
return { ...res, [getFilterKey(oldEntity, key, predefinedPrefixKey)]: null };
}

const resetOldConditions = resetOldCondition(entity, oldEntity, key);
const filterValue = !isEmptyValue(entity.value) ? entity.value : null;
return {
...res,
[getFilterKey(entity, key)]: filterValue,
[getFilterKey(entity, key, predefinedPrefixKey)]: filterValue,
...resetOldConditions,
};
}, initialQuery);
Expand Down
75 changes: 40 additions & 35 deletions app/src/components/inputs/inputDropdown/inputDropdown.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export class InputDropdown extends Component {
independentGroupSelection: PropTypes.bool,
customClasses: PropTypes.object,
title: PropTypes.string,
readOnly: PropTypes.bool,
};

static defaultProps = {
Expand All @@ -70,6 +71,7 @@ export class InputDropdown extends Component {
opened: '',
},
title: '',
readOnly: false,
};
state = {
opened: false,
Expand Down Expand Up @@ -233,48 +235,51 @@ export class InputDropdown extends Component {
error,
touched,
'mobile-disabled': mobileDisabled,
readonly: this.props.readOnly,
})}
onClick={this.onClickSelectBlock}
onClick={this.props.readOnly ? () => {} : this.onClickSelectBlock}
>
<span className={cx('value', customClasses.value)}>{this.displayedValue()}</span>
<span className={cx('arrow', customClasses.arrow)} />
{!this.props.readOnly && <span className={cx('arrow', customClasses.arrow)} />}
</div>
</div>
)}
</Reference>
<Popper
placement="bottom-start"
eventsEnabled={false}
modifiers={{
preventOverflow: { enabled: true },
flip: {
enabled: true,
},
}}
>
{({ placement, ref, style, scheduleUpdate }) => {
this.updatePosition = scheduleUpdate;
return (
<div
ref={ref}
style={style}
data-placement={placement}
className={cx('select-list', customClasses.selectList, {
opened: this.state.opened,
})}
>
{multiple && selectAll && (
<div className={cx('select-all-block')} onClick={this.handleAllClick}>
<span className={cx('select-all')}>All</span>
</div>
)}
<ScrollWrapper autoHeight autoHeightMax={300}>
{this.renderOptions()}
</ScrollWrapper>
</div>
);
}}
</Popper>
{!this.props.readOnly && (
<Popper
placement="bottom-start"
eventsEnabled={false}
modifiers={{
preventOverflow: { enabled: true },
flip: {
enabled: true,
},
}}
>
{({ placement, ref, style, scheduleUpdate }) => {
this.updatePosition = scheduleUpdate;
return (
<div
ref={ref}
style={style}
data-placement={placement}
className={cx('select-list', customClasses.selectList, {
opened: this.state.opened,
})}
>
{multiple && selectAll && (
<div className={cx('select-all-block')} onClick={this.handleAllClick}>
<span className={cx('select-all')}>All</span>
</div>
)}
<ScrollWrapper autoHeight autoHeightMax={300}>
{this.renderOptions()}
</ScrollWrapper>
</div>
);
}}
</Popper>
)}
</div>
</Manager>
);
Expand Down
Loading

0 comments on commit 818e3bf

Please sign in to comment.