Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EPMRPP-96257 || Search for users on Project team page #4099

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions app/localization/translated/be.json
Original file line number Diff line number Diff line change
Expand Up @@ -1776,10 +1776,12 @@
"ProjectStatusPage.oneMonth": "1 месяц",
"ProjectStatusPage.sixMonths": "6 месяцаў",
"ProjectStatusPage.threeMonths": "3 месяца",
"ProjectTeamPage.title": "Праектная група",
"ProjectTeamPage.noUsers": "Карыстальнікаў пакуль не дададзена",
"ProjectTeamPage.description": "Спіс карыстальнікаў у дадзены момант пусты. Каб атрымаць максімальную аддачу ад свайго праекта, Запрасіце членаў сваёй каманды і эфектыўна супрацоўнічайце.",
"ProjectTeamPage.inviteUser": "Запрасіць карыстальніка",
"ProjectTeamPage.noResultsDescription": "Вынікі пошуку або фільтрацыі не супалі ні з адным з крытэраў. Калі ласка, паспрабуйце выкарыстоўваць іншыя ключавыя словы або змяніць налады фільтра.",
"ProjectTeamPage.noUsers": "Карыстальнікаў пакуль не дададзена",
"ProjectTeamPage.searchPlaceholder": "Пошук па назве",
"ProjectTeamPage.title": "Праектная група",
AmsterGet marked this conversation as resolved.
Show resolved Hide resolved
"ProjectsAndRolesColumn.more": "яшчэ",
"ProjectsGrid.lastLaunchCol": "Дата апошняга запуску",
"ProjectsGrid.lastLaunchColShort": "Дата зпск",
Expand Down
6 changes: 6 additions & 0 deletions app/localization/translated/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -1774,6 +1774,12 @@
"ProjectStatusPage.oneMonth": "1 mes",
"ProjectStatusPage.sixMonths": "6 meses",
"ProjectStatusPage.threeMonths": "3 meses",
"ProjectTeamPage.description": "User list is currently empty. To make the most out of your project, invite your team members and collaborate efficiently.",
"ProjectTeamPage.inviteUser": "Invite user",
"ProjectTeamPage.noResultsDescription": "Your search or filter criteria didn't match any results. Please try different keywords or adjust your filter settings.",
"ProjectTeamPage.noUsers": "No users added yet",
"ProjectTeamPage.searchPlaceholder": "Type to search by name",
"ProjectTeamPage.title": "Project team",
"ProjectsAndRolesColumn.more": "más",
"ProjectsGrid.lastLaunchCol": "Fecha de la última ejecución",
"ProjectsGrid.lastLaunchColShort": "Fecha ejc",
Expand Down
6 changes: 4 additions & 2 deletions app/localization/translated/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -1771,10 +1771,12 @@
"ProjectStatusPage.oneMonth": "1 месяц",
"ProjectStatusPage.sixMonths": "6 месяцев",
"ProjectStatusPage.threeMonths": "3 месяца",
"ProjectTeamPage.title": "Проектная группа",
"ProjectTeamPage.noUsers": "Пользователей пока не добавлено",
"ProjectTeamPage.description": "Список пользователей в данный момент пуст. Чтобы получить максимальную отдачу от своего проекта, пригласите членов своей команды и эффективно сотрудничайте.",
"ProjectTeamPage.inviteUser": "Пригласить пользователя",
"ProjectTeamPage.noResultsDescription": "Результаты поиска или фильтрации не совпали ни с одним из критериев. Пожалуйста, попробуйте использовать другие ключевые слова или измените настройки фильтра.",
"ProjectTeamPage.noUsers": "Пользователей пока не добавлено",
"ProjectTeamPage.searchPlaceholder": "Поиск по названию",
"ProjectTeamPage.title": "Проектная группа",
"ProjectsAndRolesColumn.more": "еще",
"ProjectsGrid.lastLaunchCol": "Дата последнего запуска",
"ProjectsGrid.lastLaunchColShort": "Дата зпск",
Expand Down
6 changes: 4 additions & 2 deletions app/localization/translated/uk.json
Original file line number Diff line number Diff line change
Expand Up @@ -1773,10 +1773,12 @@
"ProjectStatusPage.oneMonth": "1 місяць",
"ProjectStatusPage.sixMonths": "6 місяців",
"ProjectStatusPage.threeMonths": "3 місяці",
"ProjectTeamPage.title": "Проектна група",
"ProjectTeamPage.noUsers": "Користувачів поки не додано",
"ProjectTeamPage.description": "Список користувачів на даний момент порожній. Щоб отримати максимальну віддачу від свого проекту, запросіть членів своєї команди та ефективно співпрацюйте.",
"ProjectTeamPage.inviteUser": "Запросити користувача",
"ProjectTeamPage.noResultsDescription": "Результати пошуку або фільтрації не співпали з жодним із критеріїв. Будь ласка, спробуйте використовувати інші ключові слова або змініть налаштування фільтра.",
"ProjectTeamPage.noUsers": "Користувачів поки не додано",
"ProjectTeamPage.searchPlaceholder": "Пошук по назві",
"ProjectTeamPage.title": "Проектна група",
"ProjectsAndRolesColumn.more": "ще",
"ProjectsGrid.lastLaunchCol": "Дата останнього запуску",
"ProjectsGrid.lastLaunchColShort": "Дата зпск",
Expand Down
6 changes: 4 additions & 2 deletions app/localization/translated/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -1773,10 +1773,12 @@
"ProjectStatusPage.oneMonth": "1个月",
"ProjectStatusPage.sixMonths": "6个月",
"ProjectStatusPage.threeMonths": "3个月",
"ProjectTeamPage.title": "Project team",
"ProjectTeamPage.noUsers": "No users added yet",
"ProjectTeamPage.description": "User list is currently empty. To make the most out of your project, invite your team members and collaborate efficiently.",
"ProjectTeamPage.inviteUser": "Invite user",
"ProjectTeamPage.noResultsDescription": "Your search or filter criteria didn't match any results. Please try different keywords or adjust your filter settings.",
"ProjectTeamPage.noUsers": "No users added yet",
"ProjectTeamPage.searchPlaceholder": "Type to search by name",
"ProjectTeamPage.title": "Project team",
"ProjectsAndRolesColumn.more": "更多",
"ProjectsGrid.lastLaunchCol": "上个测试任务日期",
"ProjectsGrid.lastLaunchColShort": "测试任务日期",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* Copyright 2024 EPAM Systems
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import { getBasicClickEventParameters } from '../common/ga4Utils';

const PROJECT_PAGE = 'project';

const BASIC_EVENT_PARAMETERS = getBasicClickEventParameters(PROJECT_PAGE);

export const PROJECT_PAGE_EVENTS = {
SEARCH_PROJECT_TEAM_FIELD: {
...BASIC_EVENT_PARAMETERS,
place: 'project_team',
element_name: 'search',
},
};
2 changes: 1 addition & 1 deletion app/src/controllers/instance/organizations/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@ export const querySelector = createAlternativeQueryParametersSelector({
defaultPagination: DEFAULT_PAGINATION,
defaultSorting: SORTING_ASC,
sortingKey: SORTING_KEY,
alternativeNamespace: NAMESPACE,
namespace: NAMESPACE,
});
1 change: 1 addition & 0 deletions app/src/controllers/members/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,5 @@ export const FETCH_MEMBERS = 'fetchMembers';
export const NAMESPACE = 'members';
export const DEFAULT_SORTING = formatSortingString([USER], SORTING_ASC);
export const DEFAULT_SORT_COLUMN = 'fullName';
export const SEARCH_KEY = 'filter.cnt.fullName';
export const DEFAULT_PAGE_SIZE_OPTIONS = [20, 50, 100, 300];
2 changes: 1 addition & 1 deletion app/src/controllers/organization/projects/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@ export const querySelector = createAlternativeQueryParametersSelector({
defaultPagination: DEFAULT_PAGINATION,
defaultSorting: SORTING_ASC,
sortingKey: SORTING_KEY,
alternativeNamespace: NAMESPACE,
namespace: NAMESPACE,
});
2 changes: 1 addition & 1 deletion app/src/controllers/organization/users/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,5 @@ export const querySelector = createAlternativeQueryParametersSelector({
defaultPagination: DEFAULT_PAGINATION,
defaultSorting: SORTING_ASC,
sortingKey: SORTING_KEY,
alternativeNamespace: NAMESPACE,
namespace: NAMESPACE,
});
12 changes: 5 additions & 7 deletions app/src/controllers/pages/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,16 +107,13 @@ export const prevPagePropertiesSelector = (

export const createQueryParametersSelector = ({
namespace: staticNamespace,
alternativeNamespace,
defaultPagination,
defaultSorting,
sortingKey = SORTING_KEY,
} = {}) => (state, namespace) => {
const calculatedNamespace = staticNamespace || namespace || alternativeNamespace;
const calculatedNamespace = staticNamespace || namespace;
const calculatedPagination = defaultPagination || DEFAULT_PAGINATION;
const query = alternativeNamespace
? querySelector(state)
: pagePropertiesSelector(state, calculatedNamespace);
const query = pagePropertiesSelector(state, calculatedNamespace);
const queryParameters = {
...calculatedPagination,
[sortingKey]: defaultSorting || '',
Expand All @@ -134,21 +131,22 @@ export const createQueryParametersSelector = ({
const userSettings = getStorageItem(`${userId}_settings`) || {};
queryParameters[SIZE_KEY] = userSettings[`${calculatedNamespace}PageSize`] || defaultPageSize;
}

return queryParameters;
};

export const createAlternativeQueryParametersSelector = ({
defaultPagination,
defaultSorting,
sortingKey,
alternativeNamespace,
namespace,
} = {}) =>
createSelector(
createQueryParametersSelector({
defaultPagination,
defaultSorting,
sortingKey,
alternativeNamespace,
namespace,
}),
({ [SIZE_KEY]: limit, [SORTING_KEY]: sort, [PAGE_KEY]: pageNumber, ...rest }) => {
return { ...getAlternativePaginationAndSortParams(sort, limit, pageNumber), ...rest };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { useIntl } from 'react-intl';
import { SearchField } from 'components/fields/searchField';
import { SEARCH_KEY } from 'controllers/organization/projects/constants';
import { withFilter } from 'controllers/filter';
import { NAMESPACE } from 'controllers/instance/organizations/constants';
import { useSelector } from 'react-redux';
import { organizationsListLoadingSelector } from 'controllers/instance/organizations';
import { ORGANIZATION_PAGE_EVENTS } from 'components/main/analytics/events/ga4Events/organizationsPageEvents';
Expand All @@ -34,7 +35,9 @@ import styles from './organizationsPageHeader.scss';

const cx = classNames.bind(styles);

const SearchFieldWithFilter = withFilter({ filterKey: SEARCH_KEY })(SearchField);
const SearchFieldWithFilter = withFilter({ filterKey: SEARCH_KEY, namespace: NAMESPACE })(
SearchField,
);

export const OrganizationsPageHeader = ({
isEmpty,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ export const OrganizationsPanelView = withSortingURL({
defaultDirection: SORTING_ASC,
defaultFields: [DEFAULT_SORT_COLUMN],
sortingKey: SORTING_KEY,
namespace: NAMESPACE,
})(
withPagination({
paginationSelector: organizationsListPaginationSelector,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,13 @@ export const messages = defineMessages({
id: 'ProjectTeamPage.inviteUser',
defaultMessage: 'Invite user',
},
searchPlaceholder: {
id: 'ProjectTeamPage.searchPlaceholder',
defaultMessage: 'Type to search by name',
},
noResultsDescription: {
id: 'ProjectTeamPage.noResultsDescription',
defaultMessage:
"Your search or filter criteria didn't match any results. Please try different keywords or adjust your filter settings.",
},
});
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ export const ProjectsListTableWrapper = withSortingURL({
defaultFields: [DEFAULT_SORT_COLUMN],
defaultDirection: SORTING_ASC,
sortingKey: SORTING_KEY,
namespace: NAMESPACE,
})(
withPagination({
paginationSelector: projectsPaginationSelector,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import { Breadcrumbs } from 'componentLibrary/breadcrumbs';
import { activeOrganizationSelector } from 'controllers/organization';
import { loadingSelector } from 'controllers/organization/projects';
import { SearchField } from 'components/fields/searchField';
import { SEARCH_KEY } from 'controllers/organization/projects/constants';
import { SEARCH_KEY, NAMESPACE } from 'controllers/organization/projects/constants';
import { withFilter } from 'controllers/filter';
import projectsIcon from './img/projects-inline.svg';
import styles from './projectsPageHeader.scss';
Expand All @@ -35,7 +35,9 @@ import userIcon from './img/user-inline.svg';

const cx = classNames.bind(styles);

const SearchFieldWithFilter = withFilter({ filterKey: SEARCH_KEY })(SearchField);
const SearchFieldWithFilter = withFilter({ filterKey: SEARCH_KEY, namespace: NAMESPACE })(
SearchField,
);

export const ProjectsPageHeader = ({
hasPermission,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ ProjectTeamListTableWrapped.defaultProps = {
export const ProjectTeamListTable = withSortingURL({
defaultFields: [DEFAULT_SORT_COLUMN],
defaultDirection: SORTING_ASC,
namespace: NAMESPACE,
})(
withPagination({
paginationSelector: membersPaginationSelector,
Expand Down
39 changes: 29 additions & 10 deletions app/src/pages/organization/projectTeamPage/projectTeamPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,19 @@
* limitations under the License.
*/

import { useState } from 'react';
import { useSelector, useDispatch } from 'react-redux';
import { useIntl } from 'react-intl';
import { userRolesSelector } from 'controllers/pages';
import { canInviteInternalUser } from 'common/utils/permissions';
import classNames from 'classnames/bind';
import { loadingSelector, membersSelector, fetchMembersAction } from 'controllers/members';
import { ScrollWrapper } from 'components/main/scrollWrapper';
import { showModalAction } from 'controllers/modal';
import { EmptyPageState } from 'pages/common';
import NoResultsIcon from 'common/img/newIcons/no-results-icon-inline.svg';
import { COMMON_LOCALE_KEYS } from 'common/constants/localization';
import { messages } from '../common/membersPage/membersPageHeader/messages';
import { EmptyMembersPageState } from '../common/membersPage/emptyMembersPageState';
import { ProjectTeamPageHeader } from './projectTeamPageHeader';
import { ProjectTeamListTable } from './projectTeamListTable';
Expand All @@ -29,11 +35,13 @@ import styles from './projectTeamPage.scss';
const cx = classNames.bind(styles);

export const ProjectTeamPage = () => {
const { formatMessage } = useIntl();
const dispatch = useDispatch();
const userRoles = useSelector(userRolesSelector);
const hasPermission = canInviteInternalUser(userRoles);
const members = useSelector(membersSelector);
const isMembersLoading = useSelector(loadingSelector);
const [searchValue, setSearchValue] = useState(null);
const isEmptyMembers = members.length === 0;

const onInvite = () => {
Expand All @@ -49,23 +57,34 @@ export const ProjectTeamPage = () => {
);
};

const getEmptyPageState = () => {
return searchValue === null ? (
<EmptyMembersPageState
isLoading={isMembersLoading}
hasPermission={hasPermission}
showInviteUserModal={showInviteUserModal}
/>
) : (
<EmptyPageState
label={formatMessage(COMMON_LOCALE_KEYS.NO_RESULTS)}
description={formatMessage(messages.noResultsDescription)}
emptyIcon={NoResultsIcon}
hasPermission={false}
/>
);
};

return (
<ScrollWrapper>
<div className={cx('project-team-page')}>
<ProjectTeamPageHeader
hasPermission={hasPermission}
isNotEmpty={!isEmptyMembers}
onInvite={showInviteUserModal}
isMembersLoading={isMembersLoading}
searchValue={searchValue}
setSearchValue={setSearchValue}
/>
{isEmptyMembers ? (
<EmptyMembersPageState
isLoading={isMembersLoading}
hasPermission={hasPermission}
showInviteUserModal={showInviteUserModal}
/>
) : (
<ProjectTeamListTable members={members} />
)}
{isEmptyMembers ? getEmptyPageState() : <ProjectTeamListTable members={members} />}
</div>
</ScrollWrapper>
);
Expand Down
Loading
Loading