Fix issue 6105 (#6156)

* fix(ui): teams & user page layout fixes
Fixed - filters not added for User profile page
Fix issue for longer text
Fix all the teams not showing up

* update team selectable

* revert getUserSuggestions function

* fix elipsis issue

* fix lint issue

* address comments
This commit is contained in:
Chirag Madlani 2022-07-19 10:37:25 +05:30 committed by GitHub
parent 8c9dc91ccf
commit 2e3b062e44
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 57 additions and 21 deletions

View File

@ -143,6 +143,20 @@ export const getUserSuggestions: Function = (
return APIClient.get(`/search/suggest`, { params }); return APIClient.get(`/search/suggest`, { params });
}; };
export const getTeamsByQuery = async (params: {
q: string;
from?: number;
size?: number;
isJoinable?: boolean;
}) => {
const response = await APIClient.get(`/search/query`, {
params: { index: SearchIndex.TEAM, ...params },
});
return response.data;
};
export const getTagSuggestions: Function = ( export const getTagSuggestions: Function = (
term: string term: string
): Promise<AxiosResponse> => { ): Promise<AxiosResponse> => {

View File

@ -18,6 +18,7 @@ import { Link } from 'react-router-dom';
import { EntityReference } from '../../generated/type/entityReference'; import { EntityReference } from '../../generated/type/entityReference';
import { getEntityName } from '../../utils/CommonUtils'; import { getEntityName } from '../../utils/CommonUtils';
import { getEntityIcon, getEntityLink } from '../../utils/TableUtils'; import { getEntityIcon, getEntityLink } from '../../utils/TableUtils';
import Ellipses from '../common/Ellipses/Ellipses';
import { leftPanelAntCardStyle } from '../containers/PageLayout'; import { leftPanelAntCardStyle } from '../containers/PageLayout';
interface Prop { interface Prop {
entityList: Array<FormattedTableData>; entityList: Array<FormattedTableData>;
@ -113,7 +114,9 @@ export const EntityListWithAntd: FunctionComponent<AntdEntityListProp> = ({
className="tw-text-grey-body hover:tw-text-primary-hover hover:tw-underline" className="tw-text-grey-body hover:tw-text-primary-hover hover:tw-underline"
title={getEntityName(item as unknown as EntityReference)} title={getEntityName(item as unknown as EntityReference)}
type="text"> type="text">
<Ellipses className="tw-w-48 tw-text-left">
{getEntityName(item as unknown as EntityReference)} {getEntityName(item as unknown as EntityReference)}
</Ellipses>
</Button> </Button>
</Link> </Link>
</div> </div>

View File

@ -547,7 +547,7 @@ const TeamDetails = ({
</div> </div>
) : ( ) : (
<div className="tw-flex tw-group" data-testid="team-heading"> <div className="tw-flex tw-group" data-testid="team-heading">
<Ellipses tooltip className="tw-w-120" rows={1}> <Ellipses tooltip rows={1}>
{heading} {heading}
</Ellipses> </Ellipses>
{isActionAllowed() && ( {isActionAllowed() && (

View File

@ -96,18 +96,19 @@ const TeamsAndUsers = ({
<> <>
<Card <Card
data-testid="data-summary-container" data-testid="data-summary-container"
size="small"
style={leftPanelAntCardStyle} style={leftPanelAntCardStyle}
title={ title={
<div <div
className="tw-flex tw-justify-between tw-items-center" className="tw-flex tw-justify-between tw-items-center"
data-testid="add-team-container"> data-testid="add-team-container">
<p className="tw-heading tw-my-2">Teams</p> <p className="tw-heading tw-mb-0">Teams</p>
{hasAccess && ( {hasAccess && (
<NonAdminAction <NonAdminAction
position="bottom" position="bottom"
title={TITLE_FOR_NON_ADMIN_ACTION}> title={TITLE_FOR_NON_ADMIN_ACTION}>
<Button <Button
className="tw-h-7 tw-px-2" className="tw-px-2"
data-testid="add-team-button" data-testid="add-team-button"
size="small" size="small"
theme="primary" theme="primary"
@ -156,16 +157,17 @@ const TeamsAndUsers = ({
{hasAccess && ( {hasAccess && (
<Card <Card
data-testid="data-summary-container" data-testid="data-summary-container"
size="small"
style={{ ...leftPanelAntCardStyle, marginTop: '10px' }} style={{ ...leftPanelAntCardStyle, marginTop: '10px' }}
title={ title={
<div className="tw-flex tw-justify-between tw-items-center"> <div className="tw-flex tw-justify-between tw-items-center">
<p className="tw-heading tw-heading tw-my-2">All Users</p> <p className="tw-heading tw-mb-0">All Users</p>
{hasAccess && ( {hasAccess && (
<NonAdminAction <NonAdminAction
position="bottom" position="bottom"
title={TITLE_FOR_NON_ADMIN_ACTION}> title={TITLE_FOR_NON_ADMIN_ACTION}>
<Button <Button
className="tw-h-7 tw-px-2" className="tw-px-2"
data-testid="add-user-button" data-testid="add-user-button"
size="small" size="small"
theme="primary" theme="primary"

View File

@ -14,8 +14,7 @@
import { SelectableOption } from 'Models'; import { SelectableOption } from 'Models';
import React, { useState } from 'react'; import React, { useState } from 'react';
import AsyncSelect from 'react-select/async'; import AsyncSelect from 'react-select/async';
import { getSuggestedTeams } from '../../axiosAPIs/miscAPI'; import { getSuggestedTeams, getTeamsByQuery } from '../../axiosAPIs/miscAPI';
import { getTeams } from '../../axiosAPIs/teamsAPI';
import { PAGE_SIZE } from '../../constants/constants'; import { PAGE_SIZE } from '../../constants/constants';
import { Team } from '../../generated/entity/teams/team'; import { Team } from '../../generated/entity/teams/team';
import { EntityReference } from '../../generated/type/entityReference'; import { EntityReference } from '../../generated/type/entityReference';
@ -29,9 +28,15 @@ interface CustomOption extends SelectableOption {
interface Props { interface Props {
onSelectionChange: (teams: string[]) => void; onSelectionChange: (teams: string[]) => void;
filterJoinable?: boolean;
placeholder?: string;
} }
const TeamsSelectable = ({ onSelectionChange }: Props) => { const TeamsSelectable = ({
onSelectionChange,
filterJoinable,
placeholder = 'Start typing the name of team...',
}: Props) => {
const [teamSearchText, setTeamSearchText] = useState<string>(''); const [teamSearchText, setTeamSearchText] = useState<string>('');
const handleSelectionChange = (selectedOptions: SelectableOption[]) => { const handleSelectionChange = (selectedOptions: SelectableOption[]) => {
@ -39,9 +44,11 @@ const TeamsSelectable = ({ onSelectionChange }: Props) => {
}; };
const getOptions = (teams: Team[]) => { const getOptions = (teams: Team[]) => {
return teams const filteredTeams = filterJoinable
.filter((team) => team.isJoinable) ? teams.filter((team) => team.isJoinable)
.map((team) => ({ : teams;
return filteredTeams.map((team) => ({
label: getEntityName(team as EntityReference), label: getEntityName(team as EntityReference),
value: team.id, value: team.id,
})); }));
@ -57,8 +64,14 @@ const TeamsSelectable = ({ onSelectionChange }: Props) => {
resolve(getOptions(teams)); resolve(getOptions(teams));
}); });
} else { } else {
getTeams('', PAGE_SIZE).then((res) => { getTeamsByQuery({
const teams: Team[] = res.data.data || []; q: '*',
from: 0,
size: PAGE_SIZE,
isJoinable: filterJoinable,
}).then((res) => {
const teams: Team[] =
res.hits.hits.map((t: { _source: Team }) => t._source) || [];
resolve(getOptions(teams)); resolve(getOptions(teams));
}); });
} }
@ -79,7 +92,7 @@ const TeamsSelectable = ({ onSelectionChange }: Props) => {
isOptionDisabled={(option) => !!(option as CustomOption).isDisabled} isOptionDisabled={(option) => !!(option as CustomOption).isDisabled}
loadOptions={loadOptions} loadOptions={loadOptions}
maxMenuHeight={200} maxMenuHeight={200}
placeholder="Teams..." placeholder={placeholder}
styles={reactSingleSelectCustomStyle} styles={reactSingleSelectCustomStyle}
onChange={(value) => handleSelectionChange(value as SelectableOption[])} onChange={(value) => handleSelectionChange(value as SelectableOption[])}
onInputChange={(newText) => { onInputChange={(newText) => {

View File

@ -141,7 +141,7 @@ const UserPage = () => {
setIsFeedLoading(false); setIsFeedLoading(false);
}); });
}, },
[taskStatus] [taskStatus, userData]
); );
const handleFeedFetchFromFeedList = useCallback( const handleFeedFetchFromFeedList = useCallback(

View File

@ -220,7 +220,10 @@ const Signup = () => {
<label className="tw-block tw-text-body tw-text-grey-body tw-mb-2"> <label className="tw-block tw-text-body tw-text-grey-body tw-mb-2">
Select teams Select teams
</label> </label>
<TeamsSelectable onSelectionChange={setSelectedTeams} /> <TeamsSelectable
filterJoinable
onSelectionChange={setSelectedTeams}
/>
{countTeams === 0 ? ( {countTeams === 0 ? (
<div <div

View File

@ -407,6 +407,7 @@ const TagsPage = () => {
return ( return (
<Card <Card
data-testid="data-summary-container" data-testid="data-summary-container"
size="small"
style={leftPanelAntCardStyle} style={leftPanelAntCardStyle}
title={ title={
<div className="tw-flex tw-justify-between tw-items-center"> <div className="tw-flex tw-justify-between tw-items-center">
@ -419,7 +420,7 @@ const TagsPage = () => {
position="bottom" position="bottom"
title={TITLE_FOR_NON_ADMIN_ACTION}> title={TITLE_FOR_NON_ADMIN_ACTION}>
<Button <Button
className={classNames('tw-h-7 tw-px-2 tw-my-2', { className={classNames('tw-px-2 ', {
'tw-opacity-40': !isAdminUser && !isAuthDisabled, 'tw-opacity-40': !isAdminUser && !isAuthDisabled,
})} })}
data-testid="add-category" data-testid="add-category"