Skip to content

Commit

Permalink
FIX: #14486 filter current user from reviewer list (#14495)
Browse files Browse the repository at this point in the history
  • Loading branch information
chirag-madlani authored Dec 26, 2023
1 parent f6b72d2 commit 8746058
Show file tree
Hide file tree
Showing 16 changed files with 176 additions and 67 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1241,7 +1241,7 @@ export const removeOwner = (entity, isGlossaryPage) => {
cy.get('[data-testid="edit-owner"]').click();
verifyResponseStatusCode('@getUsers', 200);
cy.get("[data-testid='select-owner-tabs']").should('be.visible');
cy.get('[data-testid="remove-owner"]').click();
cy.get('[data-testid="remove-owner"]').scrollIntoView().click();
verifyResponseStatusCode('@patchOwner', 200);
if (isGlossaryPage) {
cy.get('[data-testid="glossary-owner-name"] > [data-testid="Add"]').should(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,34 +28,6 @@ describe('Data Insight settings page should work properly', () => {
verifyResponseStatusCode('@getApplications', 200);
});

it('Deploy & run application', () => {
interceptURL(
'GET',
'/api/v1/apps/name/DataInsightsApplication?fields=*',
'getDataInsightDetails'
);
interceptURL(
'POST',
'/api/v1/apps/deploy/DataInsightsApplication',
'deploy'
);
interceptURL(
'POST',
'/api/v1/apps/trigger/DataInsightsApplication',
'triggerPipeline'
);
cy.get(
'[data-testid="data-insights-application-card"] [data-testid="config-btn"]'
).click();
verifyResponseStatusCode('@getDataInsightDetails', 200);
cy.get('[data-testid="deploy-button"]').click();
verifyResponseStatusCode('@deploy', 200);
cy.reload();
verifyResponseStatusCode('@getDataInsightDetails', 200);
cy.get('[data-testid="run-now-button"]').click();
verifyResponseStatusCode('@triggerPipeline', 200);
});

it('Edit data insight application', () => {
interceptURL(
'GET',
Expand Down Expand Up @@ -115,11 +87,40 @@ describe('Data Insight settings page should work properly', () => {
cy.get('[data-testid="save-button"]').click();
cy.get('#cronType').click();
cy.get('[title="Day"]').click();
cy.get('[data-testid="cron-type"]').should('contain', 'Day');
cy.get('[data-testid="deploy-button"]').click();
verifyResponseStatusCode('@installApplication', 201);
verifyResponseStatusCode('@getApplications', 200);
cy.get('[data-testid="data-insights-application-card"]').should(
'be.visible'
);
});

it('Deploy & run application', () => {
interceptURL(
'GET',
'/api/v1/apps/name/DataInsightsApplication?fields=*',
'getDataInsightDetails'
);
interceptURL(
'POST',
'/api/v1/apps/deploy/DataInsightsApplication',
'deploy'
);
interceptURL(
'POST',
'/api/v1/apps/trigger/DataInsightsApplication',
'triggerPipeline'
);
cy.get(
'[data-testid="data-insights-application-card"] [data-testid="config-btn"]'
).click();
verifyResponseStatusCode('@getDataInsightDetails', 200);
cy.get('[data-testid="deploy-button"]').click();
verifyResponseStatusCode('@deploy', 200);
cy.reload();
verifyResponseStatusCode('@getDataInsightDetails', 200);
cy.get('[data-testid="run-now-button"]').click();
verifyResponseStatusCode('@triggerPipeline', 200);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import { domainTypeTooltipDataRender } from '../../../utils/DomainUtils';
import { getEntityName } from '../../../utils/EntityUtils';
import { generateFormFields, getField } from '../../../utils/formUtils';
import { checkPermission } from '../../../utils/PermissionsUtils';
import { UserTeam } from '../../common/AssigneeList/AssigneeList.interface';
import '../domain.less';
import { DomainFormType } from '../DomainPage.interface';
import { AddDomainFormProps } from './AddDomainForm.interface';
Expand Down Expand Up @@ -243,7 +244,8 @@ const AddDomainForm = ({
{selectedOwner && (
<div className="m-b-sm" data-testid="owner-container">
<UserTag
id={selectedOwner.id}
id={selectedOwner.name ?? selectedOwner.id}
isTeam={selectedOwner.type === UserTeam.Team}
name={getEntityName(selectedOwner)}
size={UserTagSize.small}
/>
Expand All @@ -260,7 +262,7 @@ const AddDomainForm = ({
size={[8, 8]}>
{expertsList.map((d) => (
<UserTag
id={d.id}
id={d.name ?? d.id}
key={'expert' + d.id}
name={getEntityName(d)}
size={UserTagSize.small}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import {
import { getEntityName } from '../../../utils/EntityUtils';
import { generateFormFields, getField } from '../../../utils/formUtils';
import { useAuthContext } from '../../Auth/AuthProviders/AuthProvider';
import { UserTeam } from '../../common/AssigneeList/AssigneeList.interface';
import ResizablePanels from '../../common/ResizablePanels/ResizablePanels';
import TitleBreadcrumb from '../../common/TitleBreadcrumb/TitleBreadcrumb.component';
import { UserTag } from '../../common/UserTag/UserTag.component';
Expand Down Expand Up @@ -241,7 +242,8 @@ const AddGlossary = ({
{selectedOwner && (
<div className="m-y-xs" data-testid="owner-container">
<UserTag
id={selectedOwner.id}
id={selectedOwner.name ?? selectedOwner.id}
isTeam={selectedOwner.type === UserTeam.Team}
name={getEntityName(selectedOwner)}
size={UserTagSize.small}
/>
Expand All @@ -258,7 +260,7 @@ const AddGlossary = ({
size={[8, 8]}>
{reviewersList.map((d, index) => (
<UserTag
id={d.id}
id={d.name ?? d.id}
key={index}
name={getEntityName(d)}
size={UserTagSize.small}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import { getEntityName } from '../../../utils/EntityUtils';
import { generateFormFields, getField } from '../../../utils/formUtils';
import { fetchGlossaryList } from '../../../utils/TagsUtils';
import { useAuthContext } from '../../Auth/AuthProviders/AuthProvider';
import { UserTeam } from '../../common/AssigneeList/AssigneeList.interface';
import { UserTag } from '../../common/UserTag/UserTag.component';
import { UserTagSize } from '../../common/UserTag/UserTag.interface';
import { AddGlossaryTermFormProps } from './AddGlossaryTermForm.interface';
Expand Down Expand Up @@ -326,6 +327,7 @@ const AddGlossaryTermForm = ({
type: FieldTypes.USER_MULTI_SELECT,
props: {
hasPermission: true,
filterCurrentUser: true,
popoverProps: { placement: 'topLeft' },
children: (
<Button
Expand Down Expand Up @@ -432,7 +434,8 @@ const AddGlossaryTermForm = ({
{owner && (
<div className="m-y-sm" data-testid="owner-container">
<UserTag
id={owner.id}
id={owner.name ?? owner.id}
isTeam={owner.type === UserTeam.Team}
name={getEntityName(owner)}
size={UserTagSize.small}
/>
Expand All @@ -445,7 +448,7 @@ const AddGlossaryTermForm = ({
<Space wrap data-testid="reviewers-container" size={[8, 8]}>
{reviewersList.map((d) => (
<UserTag
id={d.id}
id={d.name ?? d.id}
key={d.id}
name={getEntityName(d)}
size={UserTagSize.small}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,14 @@ const GlossaryDetails = ({
const [isDescriptionEditable, setIsDescriptionEditable] =
useState<boolean>(false);

const getEntityFeedCount = () => {
getFeedCounts(
EntityType.GLOSSARY,
glossary.fullyQualifiedName ?? '',
setFeedCount
);
};

const handleGlossaryUpdate = async (updatedGlossary: Glossary) => {
await updateGlossary(updatedGlossary);
getEntityFeedCount();
Expand Down Expand Up @@ -114,14 +122,6 @@ const GlossaryDetails = ({
[glossary, isVersionView]
);

const getEntityFeedCount = () => {
getFeedCounts(
EntityType.GLOSSARY,
glossary.fullyQualifiedName ?? '',
setFeedCount
);
};

const handleTabChange = (activeKey: string) => {
if (activeKey !== activeTab) {
history.push(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ import { useEntityExportModalProvider } from '../../../components/Entity/EntityE
import { EntityHeader } from '../../../components/Entity/EntityHeader/EntityHeader.component';
import EntityDeleteModal from '../../../components/Modals/EntityDeleteModal/EntityDeleteModal';
import EntityNameModal from '../../../components/Modals/EntityNameModal/EntityNameModal.component';
import { OperationPermission } from '../../../components/PermissionProvider/PermissionProvider.interface';
import Voting from '../../../components/Voting/Voting.component';
import { VotingDataProps } from '../../../components/Voting/voting.interface';
import { FQN_SEPARATOR_CHAR } from '../../../constants/char.constants';
Expand Down Expand Up @@ -76,19 +75,7 @@ import { showErrorToast } from '../../../utils/ToastUtils';
import { useAuthContext } from '../../Auth/AuthProviders/AuthProvider';
import { TitleBreadcrumbProps } from '../../common/TitleBreadcrumb/TitleBreadcrumb.interface';
import StyleModal from '../../Modals/StyleModal/StyleModal.component';

export interface GlossaryHeaderProps {
isVersionView?: boolean;
supportAddOwner?: boolean;
selectedData: Glossary | GlossaryTerm;
permissions: OperationPermission;
isGlossary: boolean;
onUpdate: (data: GlossaryTerm | Glossary) => void;
onDelete: (id: string) => void;
onAssetAdd?: () => void;
updateVote?: (data: VotingDataProps) => Promise<void>;
onAddGlossaryTerm: (glossaryTerm: GlossaryTerm | undefined) => void;
}
import { GlossaryHeaderProps } from './GlossaryHeader.interface';

const GlossaryHeader = ({
selectedData,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* Copyright 2023 Collate.
* 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 { Glossary } from '../../../generated/entity/data/glossary';
import { GlossaryTerm } from '../../../generated/entity/data/glossaryTerm';
import { OperationPermission } from '../../PermissionProvider/PermissionProvider.interface';
import { VotingDataProps } from '../../Voting/voting.interface';

export interface GlossaryHeaderProps {
isVersionView?: boolean;
supportAddOwner?: boolean;
permissions: OperationPermission;
selectedData: Glossary | GlossaryTerm;
isGlossary: boolean;
onUpdate: (data: GlossaryTerm | Glossary) => void;
onDelete: (id: string) => void;
onAssetAdd?: () => void;
updateVote?: (data: VotingDataProps) => Promise<void>;
onAddGlossaryTerm: (glossaryTerm: GlossaryTerm | undefined) => void;
}
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ export const AddEditPersonaForm = ({
size={[8, 8]}>
{usersList.map((d) => (
<UserTag
id={d.id}
id={d.name ?? d.id}
key={d.id}
name={getEntityName(d)}
size={UserTagSize.small}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,6 @@ export const SelectableList = ({
removeMargin
placeholder={searchPlaceholder ?? t('label.search')}
searchBarDataTestId={searchBarDataTestId}
searchValue={searchText}
typingInterval={500}
onSearch={handleSearch}
/>
Expand Down Expand Up @@ -279,10 +278,7 @@ export const SelectableList = ({
{customTagRenderer ? (
customTagRenderer(item)
) : (
<UserTag
id={item.name ?? ''}
name={item.displayName ?? item.name ?? ''}
/>
<UserTag id={item.name ?? ''} name={getEntityName(item)} />
)}
</List.Item>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import { searchData } from '../../../rest/miscAPI';
import { getUsers } from '../../../rest/userAPI';
import { formatUsersResponse } from '../../../utils/APIUtils';
import { getEntityReferenceListFromEntities } from '../../../utils/EntityUtils';
import { useAuthContext } from '../../Auth/AuthProviders/AuthProvider';
import { SelectableList } from '../SelectableList/SelectableList.component';
import './user-select-dropdown.less';
import { UserSelectableListProps } from './UserSelectableList.interface';
Expand All @@ -38,9 +39,11 @@ export const UserSelectableList = ({
children,
popoverProps,
multiSelect = true,
filterCurrentUser = false,
}: UserSelectableListProps) => {
const [popupVisible, setPopupVisible] = useState(false);
const { t } = useTranslation();
const { currentUser } = useAuthContext();

const fetchOptions = async (searchText: string, after?: string) => {
if (searchText) {
Expand All @@ -60,6 +63,13 @@ export const UserSelectableList = ({
EntityType.USER
);

if (filterCurrentUser) {
const user = data.find((user) => user.id === currentUser?.id);
if (user) {
data.splice(data.indexOf(user), 1);
}
}

return { data, paging: { total: res.data.hits.total.value } };
} catch (error) {
return { data: [], paging: { total: 0 } };
Expand All @@ -75,6 +85,12 @@ export const UserSelectableList = ({
data,
EntityType.USER
);
if (filterCurrentUser) {
const user = filterData.find((user) => user.id === currentUser?.id);
if (user) {
filterData.splice(filterData.indexOf(user), 1);
}
}

return { data: filterData, paging };
} catch (error) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export type UserSelectableListProps =
selectedUsers: EntityReference[];
children?: ReactNode;
popoverProps?: PopoverProps;
filterCurrentUser?: boolean;
} & (
| {
multiSelect?: true;
Expand Down
Loading

0 comments on commit 8746058

Please sign in to comment.