mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
[Workplace Search] Remove groups user management and filter (#104734)
* Remove TableFilterUsersDropdown * Update button to point to users and roles * Remove modal and group users logic * Remove route * Remove i18n translations
This commit is contained in:
parent
52d70fbc7c
commit
60a9eb9e84
17 changed files with 8 additions and 425 deletions
|
@ -10,13 +10,11 @@ import { GroupDetails, SourcePriority } from '../../../types';
|
|||
export const mockGroupValues = {
|
||||
group: {} as GroupDetails,
|
||||
dataLoading: true,
|
||||
manageUsersModalVisible: false,
|
||||
managerModalFormErrors: [],
|
||||
sharedSourcesModalVisible: false,
|
||||
confirmDeleteModalVisible: false,
|
||||
groupNameInputValue: '',
|
||||
selectedGroupSources: [],
|
||||
selectedGroupUsers: [],
|
||||
groupPrioritiesUnchanged: true,
|
||||
activeSourcePriorities: {} as SourcePriority,
|
||||
cachedSourcePriorities: {} as SourcePriority,
|
||||
|
|
|
@ -21,7 +21,6 @@ import { GroupOverview } from './group_overview';
|
|||
|
||||
const deleteGroup = jest.fn();
|
||||
const showSharedSourcesModal = jest.fn();
|
||||
const showManageUsersModal = jest.fn();
|
||||
const showConfirmDeleteModal = jest.fn();
|
||||
const hideConfirmDeleteModal = jest.fn();
|
||||
const updateGroupName = jest.fn();
|
||||
|
@ -39,7 +38,6 @@ describe('GroupOverview', () => {
|
|||
setMockActions({
|
||||
deleteGroup,
|
||||
showSharedSourcesModal,
|
||||
showManageUsersModal,
|
||||
showConfirmDeleteModal,
|
||||
hideConfirmDeleteModal,
|
||||
updateGroupName,
|
||||
|
|
|
@ -23,12 +23,14 @@ import {
|
|||
} from '@elastic/eui';
|
||||
import { i18n } from '@kbn/i18n';
|
||||
|
||||
import { EuiButtonTo } from '../../../../shared/react_router_helpers';
|
||||
import { TruncatedContent } from '../../../../shared/truncate';
|
||||
import noSharedSourcesIcon from '../../../assets/share_circle.svg';
|
||||
import { WorkplaceSearchPageTemplate } from '../../../components/layout';
|
||||
import { ContentSection } from '../../../components/shared/content_section';
|
||||
import { SourcesTable } from '../../../components/shared/sources_table';
|
||||
import { NAV, CANCEL_BUTTON } from '../../../constants';
|
||||
import { USERS_AND_ROLES_PATH } from '../../../routes';
|
||||
import { GroupLogic, MAX_NAME_LENGTH } from '../group_logic';
|
||||
|
||||
import { GroupUsersTable } from './group_users_table';
|
||||
|
@ -60,7 +62,7 @@ const MANAGE_SOURCES_BUTTON_TEXT = i18n.translate(
|
|||
const MANAGE_USERS_BUTTON_TEXT = i18n.translate(
|
||||
'xpack.enterpriseSearch.workplaceSearch.groups.overview.manageUsersButtonText',
|
||||
{
|
||||
defaultMessage: 'Manage users',
|
||||
defaultMessage: 'Manage users and roles',
|
||||
}
|
||||
);
|
||||
const NAME_SECTION_TITLE = i18n.translate(
|
||||
|
@ -110,7 +112,6 @@ export const GroupOverview: React.FC = () => {
|
|||
const {
|
||||
deleteGroup,
|
||||
showSharedSourcesModal,
|
||||
showManageUsersModal,
|
||||
showConfirmDeleteModal,
|
||||
hideConfirmDeleteModal,
|
||||
updateGroupName,
|
||||
|
@ -165,9 +166,9 @@ export const GroupOverview: React.FC = () => {
|
|||
</EuiButton>
|
||||
);
|
||||
const manageUsersButton = (
|
||||
<EuiButton color="primary" onClick={showManageUsersModal}>
|
||||
<EuiButtonTo color="primary" to={USERS_AND_ROLES_PATH}>
|
||||
{MANAGE_USERS_BUTTON_TEXT}
|
||||
</EuiButton>
|
||||
</EuiButtonTo>
|
||||
);
|
||||
const sourcesTable = <SourcesTable sources={contentSources} />;
|
||||
|
||||
|
|
|
@ -1,45 +0,0 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the Elastic License
|
||||
* 2.0; you may not use this file except in compliance with the Elastic License
|
||||
* 2.0.
|
||||
*/
|
||||
|
||||
import { setMockActions, setMockValues } from '../../../../__mocks__/kea_logic';
|
||||
import { users } from '../../../__mocks__/users.mock';
|
||||
|
||||
import React from 'react';
|
||||
|
||||
import { shallow } from 'enzyme';
|
||||
|
||||
import { FilterableUsersList } from './filterable_users_list';
|
||||
import { GroupManagerModal } from './group_manager_modal';
|
||||
import { ManageUsersModal } from './manage_users_modal';
|
||||
|
||||
const addGroupUser = jest.fn();
|
||||
const removeGroupUser = jest.fn();
|
||||
const selectAllUsers = jest.fn();
|
||||
const hideManageUsersModal = jest.fn();
|
||||
const saveGroupUsers = jest.fn();
|
||||
|
||||
describe('ManageUsersModal', () => {
|
||||
it('renders', () => {
|
||||
setMockActions({
|
||||
addGroupUser,
|
||||
removeGroupUser,
|
||||
selectAllUsers,
|
||||
hideManageUsersModal,
|
||||
saveGroupUsers,
|
||||
});
|
||||
|
||||
setMockValues({
|
||||
users,
|
||||
selectedGroupUsers: [],
|
||||
});
|
||||
|
||||
const wrapper = shallow(<ManageUsersModal />);
|
||||
|
||||
expect(wrapper.find(FilterableUsersList)).toHaveLength(1);
|
||||
expect(wrapper.find(GroupManagerModal)).toHaveLength(1);
|
||||
});
|
||||
});
|
|
@ -1,57 +0,0 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the Elastic License
|
||||
* 2.0; you may not use this file except in compliance with the Elastic License
|
||||
* 2.0.
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
|
||||
import { useActions, useValues } from 'kea';
|
||||
|
||||
import { i18n } from '@kbn/i18n';
|
||||
|
||||
import { GroupLogic } from '../group_logic';
|
||||
import { GroupsLogic } from '../groups_logic';
|
||||
|
||||
import { FilterableUsersList } from './filterable_users_list';
|
||||
import { GroupManagerModal } from './group_manager_modal';
|
||||
|
||||
const MODAL_LABEL = i18n.translate(
|
||||
'xpack.enterpriseSearch.workplaceSearch.groups.usersModalLabel',
|
||||
{
|
||||
defaultMessage: 'users',
|
||||
}
|
||||
);
|
||||
|
||||
export const ManageUsersModal: React.FC = () => {
|
||||
const {
|
||||
addGroupUser,
|
||||
removeGroupUser,
|
||||
selectAllUsers,
|
||||
hideManageUsersModal,
|
||||
saveGroupUsers,
|
||||
} = useActions(GroupLogic);
|
||||
|
||||
const { selectedGroupUsers } = useValues(GroupLogic);
|
||||
const { users } = useValues(GroupsLogic);
|
||||
|
||||
return (
|
||||
<GroupManagerModal
|
||||
label={MODAL_LABEL}
|
||||
allItems={users}
|
||||
numSelected={selectedGroupUsers.length}
|
||||
hideModal={hideManageUsersModal}
|
||||
selectAll={selectAllUsers}
|
||||
saveItems={saveGroupUsers}
|
||||
>
|
||||
<FilterableUsersList
|
||||
users={users}
|
||||
selectedOptions={selectedGroupUsers}
|
||||
itemsClickable
|
||||
addFilteredUser={addGroupUser}
|
||||
removeFilteredUser={removeGroupUser}
|
||||
/>
|
||||
</GroupManagerModal>
|
||||
);
|
||||
};
|
|
@ -1,30 +0,0 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the Elastic License
|
||||
* 2.0; you may not use this file except in compliance with the Elastic License
|
||||
* 2.0.
|
||||
*/
|
||||
|
||||
import { setMockActions, setMockValues } from '../../../../__mocks__/kea_logic';
|
||||
import { users } from '../../../__mocks__/users.mock';
|
||||
|
||||
import React from 'react';
|
||||
|
||||
import { shallow } from 'enzyme';
|
||||
|
||||
import { FilterableUsersPopover } from './filterable_users_popover';
|
||||
import { TableFilterUsersDropdown } from './table_filter_users_dropdown';
|
||||
|
||||
const closeFilterUsersDropdown = jest.fn();
|
||||
const toggleFilterUsersDropdown = jest.fn();
|
||||
|
||||
describe('TableFilterUsersDropdown', () => {
|
||||
it('renders', () => {
|
||||
setMockActions({ closeFilterUsersDropdown, toggleFilterUsersDropdown });
|
||||
setMockValues({ users, filteredUsers: [], filterUsersDropdownOpen: false });
|
||||
|
||||
const wrapper = shallow(<TableFilterUsersDropdown />);
|
||||
|
||||
expect(wrapper.find(FilterableUsersPopover)).toHaveLength(1);
|
||||
});
|
||||
});
|
|
@ -1,53 +0,0 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the Elastic License
|
||||
* 2.0; you may not use this file except in compliance with the Elastic License
|
||||
* 2.0.
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
|
||||
import { useActions, useValues } from 'kea';
|
||||
|
||||
import { EuiFilterButton } from '@elastic/eui';
|
||||
import { i18n } from '@kbn/i18n';
|
||||
|
||||
import { GroupsLogic } from '../groups_logic';
|
||||
|
||||
import { FilterableUsersPopover } from './filterable_users_popover';
|
||||
|
||||
const FILTER_USERS_BUTTON_TEXT = i18n.translate(
|
||||
'xpack.enterpriseSearch.workplaceSearch.groups.filterUsers.buttonText',
|
||||
{
|
||||
defaultMessage: 'Users',
|
||||
}
|
||||
);
|
||||
|
||||
export const TableFilterUsersDropdown: React.FC<{}> = () => {
|
||||
const { closeFilterUsersDropdown, toggleFilterUsersDropdown } = useActions(GroupsLogic);
|
||||
const { filteredUsers, filterUsersDropdownOpen, users } = useValues(GroupsLogic);
|
||||
|
||||
const filterButton = (
|
||||
<EuiFilterButton
|
||||
iconType="arrowDown"
|
||||
onClick={toggleFilterUsersDropdown}
|
||||
isSelected={filterUsersDropdownOpen}
|
||||
numFilters={users.length}
|
||||
hasActiveFilters={filteredUsers.length > 0}
|
||||
numActiveFilters={filteredUsers.length}
|
||||
>
|
||||
{FILTER_USERS_BUTTON_TEXT}
|
||||
</EuiFilterButton>
|
||||
);
|
||||
|
||||
return (
|
||||
<FilterableUsersPopover
|
||||
users={users}
|
||||
selectedOptions={filteredUsers}
|
||||
itemsClickable
|
||||
isPopoverOpen={filterUsersDropdownOpen}
|
||||
button={filterButton}
|
||||
closePopover={closeFilterUsersDropdown}
|
||||
/>
|
||||
);
|
||||
};
|
|
@ -14,7 +14,6 @@ import { shallow } from 'enzyme';
|
|||
import { EuiFieldSearch } from '@elastic/eui';
|
||||
|
||||
import { TableFilterSourcesDropdown } from './table_filter_sources_dropdown';
|
||||
import { TableFilterUsersDropdown } from './table_filter_users_dropdown';
|
||||
import { TableFilters } from './table_filters';
|
||||
|
||||
const setFilterValue = jest.fn();
|
||||
|
@ -29,7 +28,6 @@ describe('TableFilters', () => {
|
|||
|
||||
expect(wrapper.find(EuiFieldSearch)).toHaveLength(1);
|
||||
expect(wrapper.find(TableFilterSourcesDropdown)).toHaveLength(1);
|
||||
expect(wrapper.find(TableFilterUsersDropdown)).toHaveLength(1);
|
||||
});
|
||||
|
||||
it('handles search input value change', () => {
|
||||
|
|
|
@ -15,7 +15,6 @@ import { i18n } from '@kbn/i18n';
|
|||
import { GroupsLogic } from '../groups_logic';
|
||||
|
||||
import { TableFilterSourcesDropdown } from './table_filter_sources_dropdown';
|
||||
import { TableFilterUsersDropdown } from './table_filter_users_dropdown';
|
||||
|
||||
const FILTER_GROUPS_PLACEHOLDER = i18n.translate(
|
||||
'xpack.enterpriseSearch.workplaceSearch.groups.filterGroups.placeholder',
|
||||
|
@ -45,9 +44,6 @@ export const TableFilters: React.FC = () => {
|
|||
<EuiFlexItem className="user-groups-filters__filter-sources">
|
||||
<TableFilterSourcesDropdown />
|
||||
</EuiFlexItem>
|
||||
<EuiFlexItem>
|
||||
<TableFilterUsersDropdown />
|
||||
</EuiFlexItem>
|
||||
</EuiFlexGroup>
|
||||
</EuiFlexItem>
|
||||
</EuiFlexGroup>
|
||||
|
|
|
@ -34,7 +34,6 @@ describe('GroupLogic', () => {
|
|||
|
||||
const group = groups[0];
|
||||
const sourceIds = ['123', '124'];
|
||||
const userIds = ['1z1z'];
|
||||
const sourcePriorities = { [sourceIds[0]]: 1, [sourceIds[1]]: 0.5 };
|
||||
|
||||
beforeEach(() => {
|
||||
|
@ -55,7 +54,6 @@ describe('GroupLogic', () => {
|
|||
expect(GroupLogic.values.dataLoading).toEqual(false);
|
||||
expect(GroupLogic.values.groupNameInputValue).toEqual(group.name);
|
||||
expect(GroupLogic.values.selectedGroupSources).toEqual(sourceIds);
|
||||
expect(GroupLogic.values.selectedGroupUsers).toEqual(userIds);
|
||||
expect(GroupLogic.values.cachedSourcePriorities).toEqual(sourcePriorities);
|
||||
expect(GroupLogic.values.activeSourcePriorities).toEqual(sourcePriorities);
|
||||
expect(GroupLogic.values.groupPrioritiesUnchanged).toEqual(true);
|
||||
|
@ -112,24 +110,6 @@ describe('GroupLogic', () => {
|
|||
});
|
||||
});
|
||||
|
||||
describe('addGroupUser', () => {
|
||||
it('sets reducer', () => {
|
||||
GroupLogic.actions.addGroupUser(sourceIds[0]);
|
||||
|
||||
expect(GroupLogic.values.selectedGroupUsers).toEqual([sourceIds[0]]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('removeGroupUser', () => {
|
||||
it('sets reducers', () => {
|
||||
GroupLogic.actions.addGroupUser(sourceIds[0]);
|
||||
GroupLogic.actions.addGroupUser(sourceIds[1]);
|
||||
GroupLogic.actions.removeGroupUser(sourceIds[0]);
|
||||
|
||||
expect(GroupLogic.values.selectedGroupUsers).toEqual([sourceIds[1]]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('onGroupSourcesSaved', () => {
|
||||
it('sets reducers', () => {
|
||||
GroupLogic.actions.onGroupSourcesSaved(group);
|
||||
|
@ -142,16 +122,6 @@ describe('GroupLogic', () => {
|
|||
});
|
||||
});
|
||||
|
||||
describe('onGroupUsersSaved', () => {
|
||||
it('sets reducers', () => {
|
||||
GroupLogic.actions.onGroupUsersSaved(group);
|
||||
|
||||
expect(GroupLogic.values.group).toEqual(group);
|
||||
expect(GroupLogic.values.manageUsersModalVisible).toEqual(false);
|
||||
expect(GroupLogic.values.selectedGroupUsers).toEqual(userIds);
|
||||
});
|
||||
});
|
||||
|
||||
describe('setGroupModalErrors', () => {
|
||||
it('sets reducers', () => {
|
||||
const errors = ['this is an error'];
|
||||
|
@ -170,16 +140,6 @@ describe('GroupLogic', () => {
|
|||
});
|
||||
});
|
||||
|
||||
describe('hideManageUsersModal', () => {
|
||||
it('sets reducers', () => {
|
||||
GroupLogic.actions.hideManageUsersModal(group);
|
||||
|
||||
expect(GroupLogic.values.manageUsersModalVisible).toEqual(false);
|
||||
expect(GroupLogic.values.managerModalFormErrors).toEqual([]);
|
||||
expect(GroupLogic.values.selectedGroupUsers).toEqual(userIds);
|
||||
});
|
||||
});
|
||||
|
||||
describe('selectAllSources', () => {
|
||||
it('sets reducers', () => {
|
||||
GroupLogic.actions.selectAllSources(group.contentSources);
|
||||
|
@ -188,14 +148,6 @@ describe('GroupLogic', () => {
|
|||
});
|
||||
});
|
||||
|
||||
describe('selectAllUsers', () => {
|
||||
it('sets reducers', () => {
|
||||
GroupLogic.actions.selectAllUsers(group.users);
|
||||
|
||||
expect(GroupLogic.values.selectedGroupUsers).toEqual(userIds);
|
||||
});
|
||||
});
|
||||
|
||||
describe('updatePriority', () => {
|
||||
it('sets reducers', () => {
|
||||
const PRIORITY_VALUE = 4;
|
||||
|
@ -349,36 +301,6 @@ describe('GroupLogic', () => {
|
|||
});
|
||||
});
|
||||
|
||||
describe('saveGroupUsers', () => {
|
||||
beforeEach(() => {
|
||||
GroupLogic.actions.onInitializeGroup(group);
|
||||
});
|
||||
it('updates name', async () => {
|
||||
const onGroupUsersSavedSpy = jest.spyOn(GroupLogic.actions, 'onGroupUsersSaved');
|
||||
http.post.mockReturnValue(Promise.resolve(group));
|
||||
|
||||
GroupLogic.actions.saveGroupUsers();
|
||||
expect(http.post).toHaveBeenCalledWith('/api/workplace_search/groups/123/assign', {
|
||||
body: JSON.stringify({ user_ids: userIds }),
|
||||
});
|
||||
|
||||
await nextTick();
|
||||
expect(onGroupUsersSavedSpy).toHaveBeenCalledWith(group);
|
||||
expect(setSuccessMessage).toHaveBeenCalledWith(
|
||||
'Successfully updated the users of this group.'
|
||||
);
|
||||
});
|
||||
|
||||
it('handles error', async () => {
|
||||
http.post.mockReturnValue(Promise.reject('this is an error'));
|
||||
|
||||
GroupLogic.actions.saveGroupUsers();
|
||||
await nextTick();
|
||||
|
||||
expect(flashAPIErrors).toHaveBeenCalledWith('this is an error');
|
||||
});
|
||||
});
|
||||
|
||||
describe('saveGroupSourcePrioritization', () => {
|
||||
beforeEach(() => {
|
||||
GroupLogic.actions.onInitializeGroup(group);
|
||||
|
@ -435,15 +357,6 @@ describe('GroupLogic', () => {
|
|||
});
|
||||
});
|
||||
|
||||
describe('showManageUsersModal', () => {
|
||||
it('sets reducer and clears flash messages', () => {
|
||||
GroupLogic.actions.showManageUsersModal();
|
||||
|
||||
expect(GroupLogic.values.manageUsersModalVisible).toEqual(true);
|
||||
expect(clearFlashMessages).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
describe('resetFlashMessages', () => {
|
||||
it('clears flash messages', () => {
|
||||
GroupLogic.actions.resetFlashMessages();
|
||||
|
|
|
@ -20,7 +20,7 @@ import {
|
|||
import { HttpLogic } from '../../../shared/http';
|
||||
import { KibanaLogic } from '../../../shared/kibana';
|
||||
import { GROUPS_PATH } from '../../routes';
|
||||
import { ContentSourceDetails, GroupDetails, User, SourcePriority } from '../../types';
|
||||
import { ContentSourceDetails, GroupDetails, SourcePriority } from '../../types';
|
||||
|
||||
export const MAX_NAME_LENGTH = 40;
|
||||
|
||||
|
@ -31,40 +31,31 @@ interface GroupActions {
|
|||
onGroupNameInputChange(groupName: string): string;
|
||||
addGroupSource(sourceId: string): string;
|
||||
removeGroupSource(sourceId: string): string;
|
||||
addGroupUser(userId: string): string;
|
||||
removeGroupUser(userId: string): string;
|
||||
onGroupSourcesSaved(group: GroupDetails): GroupDetails;
|
||||
onGroupUsersSaved(group: GroupDetails): GroupDetails;
|
||||
setGroupModalErrors(errors: string[]): string[];
|
||||
hideSharedSourcesModal(group: GroupDetails): GroupDetails;
|
||||
hideManageUsersModal(group: GroupDetails): GroupDetails;
|
||||
selectAllSources(contentSources: ContentSourceDetails[]): ContentSourceDetails[];
|
||||
selectAllUsers(users: User[]): User[];
|
||||
updatePriority(id: string, boost: number): { id: string; boost: number };
|
||||
resetGroup(): void;
|
||||
showConfirmDeleteModal(): void;
|
||||
hideConfirmDeleteModal(): void;
|
||||
showSharedSourcesModal(): void;
|
||||
showManageUsersModal(): void;
|
||||
resetFlashMessages(): void;
|
||||
initializeGroup(groupId: string): { groupId: string };
|
||||
deleteGroup(): void;
|
||||
updateGroupName(): void;
|
||||
saveGroupSources(): void;
|
||||
saveGroupUsers(): void;
|
||||
saveGroupSourcePrioritization(): void;
|
||||
}
|
||||
|
||||
interface GroupValues {
|
||||
group: GroupDetails;
|
||||
dataLoading: boolean;
|
||||
manageUsersModalVisible: boolean;
|
||||
managerModalFormErrors: string[];
|
||||
sharedSourcesModalVisible: boolean;
|
||||
confirmDeleteModalVisible: boolean;
|
||||
groupNameInputValue: string;
|
||||
selectedGroupSources: string[];
|
||||
selectedGroupUsers: string[];
|
||||
groupPrioritiesUnchanged: boolean;
|
||||
activeSourcePriorities: SourcePriority;
|
||||
cachedSourcePriorities: SourcePriority;
|
||||
|
@ -79,27 +70,20 @@ export const GroupLogic = kea<MakeLogicType<GroupValues, GroupActions>>({
|
|||
onGroupNameInputChange: (groupName) => groupName,
|
||||
addGroupSource: (sourceId) => sourceId,
|
||||
removeGroupSource: (sourceId) => sourceId,
|
||||
addGroupUser: (userId) => userId,
|
||||
removeGroupUser: (userId) => userId,
|
||||
onGroupSourcesSaved: (group) => group,
|
||||
onGroupUsersSaved: (group) => group,
|
||||
setGroupModalErrors: (errors) => errors,
|
||||
hideSharedSourcesModal: (group) => group,
|
||||
hideManageUsersModal: (group) => group,
|
||||
selectAllSources: (contentSources) => contentSources,
|
||||
selectAllUsers: (users) => users,
|
||||
updatePriority: (id, boost) => ({ id, boost }),
|
||||
resetGroup: () => true,
|
||||
showConfirmDeleteModal: () => true,
|
||||
hideConfirmDeleteModal: () => true,
|
||||
showSharedSourcesModal: () => true,
|
||||
showManageUsersModal: () => true,
|
||||
resetFlashMessages: () => true,
|
||||
initializeGroup: (groupId) => ({ groupId }),
|
||||
deleteGroup: () => true,
|
||||
updateGroupName: () => true,
|
||||
saveGroupSources: () => true,
|
||||
saveGroupUsers: () => true,
|
||||
saveGroupSourcePrioritization: () => true,
|
||||
},
|
||||
reducers: {
|
||||
|
@ -109,7 +93,6 @@ export const GroupLogic = kea<MakeLogicType<GroupValues, GroupActions>>({
|
|||
onInitializeGroup: (_, group) => group,
|
||||
onGroupNameChanged: (_, group) => group,
|
||||
onGroupSourcesSaved: (_, group) => group,
|
||||
onGroupUsersSaved: (_, group) => group,
|
||||
resetGroup: () => ({} as GroupDetails),
|
||||
},
|
||||
],
|
||||
|
@ -121,19 +104,10 @@ export const GroupLogic = kea<MakeLogicType<GroupValues, GroupActions>>({
|
|||
resetGroup: () => true,
|
||||
},
|
||||
],
|
||||
manageUsersModalVisible: [
|
||||
false,
|
||||
{
|
||||
showManageUsersModal: () => true,
|
||||
hideManageUsersModal: () => false,
|
||||
onGroupUsersSaved: () => false,
|
||||
},
|
||||
],
|
||||
managerModalFormErrors: [
|
||||
[],
|
||||
{
|
||||
setGroupModalErrors: (_, errors) => errors,
|
||||
hideManageUsersModal: () => [],
|
||||
},
|
||||
],
|
||||
sharedSourcesModalVisible: [
|
||||
|
@ -170,17 +144,6 @@ export const GroupLogic = kea<MakeLogicType<GroupValues, GroupActions>>({
|
|||
removeGroupSource: (state, sourceId) => state.filter((id) => id !== sourceId),
|
||||
},
|
||||
],
|
||||
selectedGroupUsers: [
|
||||
[],
|
||||
{
|
||||
onInitializeGroup: (_, { users }) => users.map(({ id }) => id),
|
||||
onGroupUsersSaved: (_, { users }) => users.map(({ id }) => id),
|
||||
selectAllUsers: (_, users) => users.map(({ id }) => id),
|
||||
hideManageUsersModal: (_, { users }) => users.map(({ id }) => id),
|
||||
addGroupUser: (state, userId) => [...state, userId].sort(),
|
||||
removeGroupUser: (state, userId) => state.filter((id) => id !== userId),
|
||||
},
|
||||
],
|
||||
cachedSourcePriorities: [
|
||||
{},
|
||||
{
|
||||
|
@ -298,31 +261,6 @@ export const GroupLogic = kea<MakeLogicType<GroupValues, GroupActions>>({
|
|||
flashAPIErrors(e);
|
||||
}
|
||||
},
|
||||
saveGroupUsers: async () => {
|
||||
const {
|
||||
group: { id },
|
||||
selectedGroupUsers,
|
||||
} = values;
|
||||
|
||||
try {
|
||||
const response = await HttpLogic.values.http.post(
|
||||
`/api/workplace_search/groups/${id}/assign`,
|
||||
{
|
||||
body: JSON.stringify({ user_ids: selectedGroupUsers }),
|
||||
}
|
||||
);
|
||||
actions.onGroupUsersSaved(response);
|
||||
const GROUP_USERS_UPDATED_MESSAGE = i18n.translate(
|
||||
'xpack.enterpriseSearch.workplaceSearch.groups.groupUsersUpdated',
|
||||
{
|
||||
defaultMessage: 'Successfully updated the users of this group.',
|
||||
}
|
||||
);
|
||||
setSuccessMessage(GROUP_USERS_UPDATED_MESSAGE);
|
||||
} catch (e) {
|
||||
flashAPIErrors(e);
|
||||
}
|
||||
},
|
||||
saveGroupSourcePrioritization: async () => {
|
||||
const {
|
||||
group: { id },
|
||||
|
@ -360,9 +298,6 @@ export const GroupLogic = kea<MakeLogicType<GroupValues, GroupActions>>({
|
|||
showConfirmDeleteModal: () => {
|
||||
clearFlashMessages();
|
||||
},
|
||||
showManageUsersModal: () => {
|
||||
clearFlashMessages();
|
||||
},
|
||||
showSharedSourcesModal: () => {
|
||||
clearFlashMessages();
|
||||
},
|
||||
|
|
|
@ -17,7 +17,6 @@ import { shallow } from 'enzyme';
|
|||
|
||||
import { GroupOverview } from './components/group_overview';
|
||||
import { GroupSourcePrioritization } from './components/group_source_prioritization';
|
||||
import { ManageUsersModal } from './components/manage_users_modal';
|
||||
import { SharedSourcesModal } from './components/shared_sources_modal';
|
||||
import { GroupRouter } from './group_router';
|
||||
|
||||
|
@ -28,7 +27,6 @@ describe('GroupRouter', () => {
|
|||
beforeEach(() => {
|
||||
setMockValues({
|
||||
sharedSourcesModalVisible: false,
|
||||
manageUsersModalVisible: false,
|
||||
group: groups[0],
|
||||
});
|
||||
|
||||
|
@ -47,16 +45,14 @@ describe('GroupRouter', () => {
|
|||
expect(wrapper.find(GroupSourcePrioritization)).toHaveLength(1);
|
||||
});
|
||||
|
||||
it('renders modals', () => {
|
||||
it('renders modal', () => {
|
||||
setMockValues({
|
||||
sharedSourcesModalVisible: true,
|
||||
manageUsersModalVisible: true,
|
||||
group: groups[0],
|
||||
});
|
||||
|
||||
const wrapper = shallow(<GroupRouter />);
|
||||
|
||||
expect(wrapper.find(ManageUsersModal)).toHaveLength(1);
|
||||
expect(wrapper.find(SharedSourcesModal)).toHaveLength(1);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -14,7 +14,6 @@ import { GROUP_SOURCE_PRIORITIZATION_PATH, GROUP_PATH } from '../../routes';
|
|||
|
||||
import { GroupOverview } from './components/group_overview';
|
||||
import { GroupSourcePrioritization } from './components/group_source_prioritization';
|
||||
import { ManageUsersModal } from './components/manage_users_modal';
|
||||
import { SharedSourcesModal } from './components/shared_sources_modal';
|
||||
import { GroupLogic } from './group_logic';
|
||||
|
||||
|
@ -22,7 +21,7 @@ export const GroupRouter: React.FC = () => {
|
|||
const { groupId } = useParams() as { groupId: string };
|
||||
|
||||
const { initializeGroup, resetGroup } = useActions(GroupLogic);
|
||||
const { sharedSourcesModalVisible, manageUsersModalVisible } = useValues(GroupLogic);
|
||||
const { sharedSourcesModalVisible } = useValues(GroupLogic);
|
||||
|
||||
useEffect(() => {
|
||||
initializeGroup(groupId);
|
||||
|
@ -40,7 +39,6 @@ export const GroupRouter: React.FC = () => {
|
|||
</Route>
|
||||
</Switch>
|
||||
{sharedSourcesModalVisible && <SharedSourcesModal />}
|
||||
{manageUsersModalVisible && <ManageUsersModal />}
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
|
|
@ -13,7 +13,6 @@ import {
|
|||
registerGroupRoute,
|
||||
registerGroupUsersRoute,
|
||||
registerShareGroupRoute,
|
||||
registerAssignGroupRoute,
|
||||
registerBoostsGroupRoute,
|
||||
} from './groups';
|
||||
|
||||
|
@ -269,41 +268,6 @@ describe('groups routes', () => {
|
|||
});
|
||||
});
|
||||
|
||||
describe('POST /api/workplace_search/groups/{id}/assign', () => {
|
||||
let mockRouter: MockRouter;
|
||||
|
||||
beforeEach(() => {
|
||||
jest.clearAllMocks();
|
||||
mockRouter = new MockRouter({
|
||||
method: 'post',
|
||||
path: '/api/workplace_search/groups/{id}/assign',
|
||||
});
|
||||
|
||||
registerAssignGroupRoute({
|
||||
...mockDependencies,
|
||||
router: mockRouter.router,
|
||||
});
|
||||
});
|
||||
|
||||
it('creates a request handler', () => {
|
||||
expect(mockRequestHandler.createRequest).toHaveBeenCalledWith({
|
||||
path: '/ws/org/groups/:id/assign',
|
||||
});
|
||||
});
|
||||
|
||||
describe('validates', () => {
|
||||
it('correctly', () => {
|
||||
const request = {
|
||||
params: { id: '123' },
|
||||
body: {
|
||||
user_ids: ['123', '234'],
|
||||
},
|
||||
};
|
||||
mockRouter.shouldValidate(request);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('PUT /api/workplace_search/groups/{id}/boosts', () => {
|
||||
let mockRouter: MockRouter;
|
||||
|
||||
|
|
|
@ -152,28 +152,6 @@ export function registerShareGroupRoute({
|
|||
);
|
||||
}
|
||||
|
||||
export function registerAssignGroupRoute({
|
||||
router,
|
||||
enterpriseSearchRequestHandler,
|
||||
}: RouteDependencies) {
|
||||
router.post(
|
||||
{
|
||||
path: '/api/workplace_search/groups/{id}/assign',
|
||||
validate: {
|
||||
params: schema.object({
|
||||
id: schema.string(),
|
||||
}),
|
||||
body: schema.object({
|
||||
user_ids: schema.arrayOf(schema.string()),
|
||||
}),
|
||||
},
|
||||
},
|
||||
enterpriseSearchRequestHandler.createRequest({
|
||||
path: '/ws/org/groups/:id/assign',
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
export function registerBoostsGroupRoute({
|
||||
router,
|
||||
enterpriseSearchRequestHandler,
|
||||
|
@ -204,6 +182,5 @@ export const registerGroupsRoutes = (dependencies: RouteDependencies) => {
|
|||
registerGroupRoute(dependencies);
|
||||
registerGroupUsersRoute(dependencies);
|
||||
registerShareGroupRoute(dependencies);
|
||||
registerAssignGroupRoute(dependencies);
|
||||
registerBoostsGroupRoute(dependencies);
|
||||
};
|
||||
|
|
|
@ -8093,7 +8093,6 @@
|
|||
"xpack.enterpriseSearch.workplaceSearch.groups.description": "共有コンテンツソースとユーザーをグループに割り当て、さまざまな内部チーム向けに関連する検索エクスペリエンスを作成します。",
|
||||
"xpack.enterpriseSearch.workplaceSearch.groups.filterGroups.placeholder": "名前でグループをフィルター...",
|
||||
"xpack.enterpriseSearch.workplaceSearch.groups.filterSources.buttonText": "ソース",
|
||||
"xpack.enterpriseSearch.workplaceSearch.groups.filterUsers.buttonText": "ユーザー",
|
||||
"xpack.enterpriseSearch.workplaceSearch.groups.filterUsers.placeholder": "ユーザーをフィルター...",
|
||||
"xpack.enterpriseSearch.workplaceSearch.groups.groupDeleted": "グループ「{groupName}」が正常に削除されました。",
|
||||
"xpack.enterpriseSearch.workplaceSearch.groups.groupManagerHeaderTitle": "{label}を管理",
|
||||
|
@ -8109,7 +8108,6 @@
|
|||
"xpack.enterpriseSearch.workplaceSearch.groups.groupsTable.sourcesTableHeader": "コンテンツソース",
|
||||
"xpack.enterpriseSearch.workplaceSearch.groups.groupsTable.usersTableHeader": "ユーザー",
|
||||
"xpack.enterpriseSearch.workplaceSearch.groups.groupUpdatedText": "前回更新日時{updatedAt}。",
|
||||
"xpack.enterpriseSearch.workplaceSearch.groups.groupUsersUpdated": "このグループのユーザーが正常に更新されました。",
|
||||
"xpack.enterpriseSearch.workplaceSearch.groups.heading": "グループを管理",
|
||||
"xpack.enterpriseSearch.workplaceSearch.groups.inviteUsers.action": "ユーザーを招待",
|
||||
"xpack.enterpriseSearch.workplaceSearch.groups.newGroup.action": "グループを管理",
|
||||
|
@ -8144,7 +8142,6 @@
|
|||
"xpack.enterpriseSearch.workplaceSearch.groups.sourcesModalLabel": "共有コンテンツソース",
|
||||
"xpack.enterpriseSearch.workplaceSearch.groups.sourcesModalTitle": "{groupName}と共有するコンテンツソースを選択",
|
||||
"xpack.enterpriseSearch.workplaceSearch.groups.userListCount": "{maxVisibleUsers}/{numUsers}ユーザーを表示しています。",
|
||||
"xpack.enterpriseSearch.workplaceSearch.groups.usersModalLabel": "ユーザー",
|
||||
"xpack.enterpriseSearch.workplaceSearch.keepEditing.button": "編集を続行",
|
||||
"xpack.enterpriseSearch.workplaceSearch.name.label": "名前",
|
||||
"xpack.enterpriseSearch.workplaceSearch.nav.addSource": "ソースの追加",
|
||||
|
|
|
@ -8161,7 +8161,6 @@
|
|||
"xpack.enterpriseSearch.workplaceSearch.groups.description": "将共享内容源和用户分配到组,以便为各种内部团队打造相关搜索体验。",
|
||||
"xpack.enterpriseSearch.workplaceSearch.groups.filterGroups.placeholder": "按名称筛选组......",
|
||||
"xpack.enterpriseSearch.workplaceSearch.groups.filterSources.buttonText": "源",
|
||||
"xpack.enterpriseSearch.workplaceSearch.groups.filterUsers.buttonText": "用户",
|
||||
"xpack.enterpriseSearch.workplaceSearch.groups.filterUsers.placeholder": "筛选用户......",
|
||||
"xpack.enterpriseSearch.workplaceSearch.groups.groupDeleted": "组“{groupName}”已成功删除。",
|
||||
"xpack.enterpriseSearch.workplaceSearch.groups.groupManagerHeaderTitle": "管理 {label}",
|
||||
|
@ -8177,7 +8176,6 @@
|
|||
"xpack.enterpriseSearch.workplaceSearch.groups.groupsTable.sourcesTableHeader": "内容源",
|
||||
"xpack.enterpriseSearch.workplaceSearch.groups.groupsTable.usersTableHeader": "用户",
|
||||
"xpack.enterpriseSearch.workplaceSearch.groups.groupUpdatedText": "上次更新于 {updatedAt}。",
|
||||
"xpack.enterpriseSearch.workplaceSearch.groups.groupUsersUpdated": "已成功更新此组的用户",
|
||||
"xpack.enterpriseSearch.workplaceSearch.groups.heading": "管理组",
|
||||
"xpack.enterpriseSearch.workplaceSearch.groups.inviteUsers.action": "邀请用户",
|
||||
"xpack.enterpriseSearch.workplaceSearch.groups.newGroup.action": "管理组",
|
||||
|
@ -8212,7 +8210,6 @@
|
|||
"xpack.enterpriseSearch.workplaceSearch.groups.sourcesModalLabel": "共享内容源",
|
||||
"xpack.enterpriseSearch.workplaceSearch.groups.sourcesModalTitle": "选择要与 {groupName} 共享的内容源",
|
||||
"xpack.enterpriseSearch.workplaceSearch.groups.userListCount": "正在显示 {numUsers} 个用户中的 {maxVisibleUsers} 个。",
|
||||
"xpack.enterpriseSearch.workplaceSearch.groups.usersModalLabel": "用户",
|
||||
"xpack.enterpriseSearch.workplaceSearch.keepEditing.button": "继续编辑",
|
||||
"xpack.enterpriseSearch.workplaceSearch.name.label": "名称",
|
||||
"xpack.enterpriseSearch.workplaceSearch.nav.addSource": "添加源",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue