UI: Changed default page size for tables from 10 to 15 (#7256)

* - Default page size for tables changed from 10 to 15
- Code optimization and bug fixes

* worked on comments
This commit is contained in:
Aniket Katkar 2022-09-06 22:01:38 +05:30 committed by GitHub
parent be553eb017
commit 0f2b81f503
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
16 changed files with 109 additions and 85 deletions

View File

@ -11,13 +11,20 @@
* limitations under the License. * limitations under the License.
*/ */
import { CreateWebhook } from '../generated/api/events/createWebhook'; import {
CreateWebhook,
WebhookType,
} from '../generated/api/events/createWebhook';
import { Webhook } from '../generated/entity/events/webhook'; import { Webhook } from '../generated/entity/events/webhook';
import { Paging } from '../generated/type/paging'; import { Paging } from '../generated/type/paging';
import { getURLWithQueryFields } from '../utils/APIUtils'; import { getURLWithQueryFields } from '../utils/APIUtils';
import APIClient from './index'; import APIClient from './index';
export const getWebhooks = async (paging?: string, arrQueryFields?: string) => { export const getWebhooks = async (
paging?: string,
arrQueryFields?: string,
params?: { limit: number; webhookType?: WebhookType }
) => {
const url = getURLWithQueryFields( const url = getURLWithQueryFields(
'/webhook', '/webhook',
arrQueryFields, arrQueryFields,
@ -25,7 +32,10 @@ export const getWebhooks = async (paging?: string, arrQueryFields?: string) => {
); );
const response = await APIClient.get<{ data: Webhook[]; paging: Paging }>( const response = await APIClient.get<{ data: Webhook[]; paging: Paging }>(
url url,
{
params,
}
); );
return response.data; return response.data;

View File

@ -21,7 +21,7 @@ import { getBots } from '../../axiosAPIs/botsAPI';
import { import {
getBotsPath, getBotsPath,
INITIAL_PAGING_VALUE, INITIAL_PAGING_VALUE,
PAGE_SIZE, PAGE_SIZE_MEDIUM,
} from '../../constants/constants'; } from '../../constants/constants';
import { BOTS_DOCS } from '../../constants/docs.constants'; import { BOTS_DOCS } from '../../constants/docs.constants';
import { NO_PERMISSION_FOR_ACTION } from '../../constants/HelperTextUtil'; import { NO_PERMISSION_FOR_ACTION } from '../../constants/HelperTextUtil';
@ -76,7 +76,7 @@ const BotListV1 = ({
setLoading(true); setLoading(true);
const { data, paging } = await getBots({ const { data, paging } = await getBots({
after, after,
limit: PAGE_SIZE, limit: PAGE_SIZE_MEDIUM,
include: showDeleted ? Include.Deleted : Include.NonDeleted, include: showDeleted ? Include.Deleted : Include.NonDeleted,
}); });
setPaging(paging); setPaging(paging);
@ -232,10 +232,10 @@ const BotListV1 = ({
/> />
</Col> </Col>
<Col span={24}> <Col span={24}>
{paging.total > PAGE_SIZE && ( {paging.total > PAGE_SIZE_MEDIUM && (
<NextPrevious <NextPrevious
currentPage={currentPage} currentPage={currentPage}
pageSize={PAGE_SIZE} pageSize={PAGE_SIZE_MEDIUM}
paging={paging} paging={paging}
pagingHandler={handlePageChange} pagingHandler={handlePageChange}
totalCount={paging.total} totalCount={paging.total}

View File

@ -37,7 +37,7 @@ import AppState from '../../AppState';
import { import {
getTeamAndUserDetailsPath, getTeamAndUserDetailsPath,
getUserPath, getUserPath,
PAGE_SIZE, PAGE_SIZE_MEDIUM,
} from '../../constants/constants'; } from '../../constants/constants';
import { TEAMS_DOCS } from '../../constants/docs.constants'; import { TEAMS_DOCS } from '../../constants/docs.constants';
import { import {
@ -114,6 +114,7 @@ const TeamDetailsV1 = ({
onDescriptionUpdate, onDescriptionUpdate,
descriptionHandler, descriptionHandler,
handleTeamUsersSearchAction, handleTeamUsersSearchAction,
handleCurrentUserPage,
teamUserPaginHandler, teamUserPaginHandler,
handleJoinTeamClick, handleJoinTeamClick,
handleLeaveTeamClick, handleLeaveTeamClick,
@ -483,8 +484,12 @@ const TeamDetailsV1 = ({
}, [currentTeam, AppState.userDetails, AppState.nonSecureUserDetails]); }, [currentTeam, AppState.userDetails, AppState.nonSecureUserDetails]);
useEffect(() => { useEffect(() => {
setCurrentTab(tabs[0].position); isGroupType && setCurrentTab(2);
}, [tabs]); }, [isGroupType]);
useEffect(() => {
handleCurrentUserPage();
}, []);
const removeUserBodyText = (leave: boolean) => { const removeUserBodyText = (leave: boolean) => {
const text = leave const text = leave
@ -621,11 +626,11 @@ const TeamDetailsV1 = ({
pagination={false} pagination={false}
size="small" size="small"
/> />
{teamUserPagin.total > PAGE_SIZE && ( {teamUserPagin.total > PAGE_SIZE_MEDIUM && (
<NextPrevious <NextPrevious
currentPage={currentTeamUserPage} currentPage={currentTeamUserPage}
isNumberBased={Boolean(teamUsersSearchText)} isNumberBased={Boolean(teamUsersSearchText)}
pageSize={PAGE_SIZE} pageSize={PAGE_SIZE_MEDIUM}
paging={teamUserPagin} paging={teamUserPagin}
pagingHandler={teamUserPaginHandler} pagingHandler={teamUserPaginHandler}
totalCount={teamUserPagin.total} totalCount={teamUserPagin.total}

View File

@ -18,7 +18,7 @@ import { isUndefined } from 'lodash';
import React, { FC, useMemo, useState } from 'react'; import React, { FC, useMemo, useState } from 'react';
import { useHistory } from 'react-router-dom'; import { useHistory } from 'react-router-dom';
import { updateUser } from '../../axiosAPIs/userAPI'; import { updateUser } from '../../axiosAPIs/userAPI';
import { PAGE_SIZE, ROUTES } from '../../constants/constants'; import { PAGE_SIZE_MEDIUM, ROUTES } from '../../constants/constants';
import { NO_PERMISSION_FOR_ACTION } from '../../constants/HelperTextUtil'; import { NO_PERMISSION_FOR_ACTION } from '../../constants/HelperTextUtil';
import { CreateUser } from '../../generated/api/teams/createUser'; import { CreateUser } from '../../generated/api/teams/createUser';
import { Operation } from '../../generated/entity/policies/policy'; import { Operation } from '../../generated/entity/policies/policy';
@ -225,11 +225,11 @@ const UserListV1: FC<UserListV1Props> = ({
/> />
</Col> </Col>
<Col span={24}> <Col span={24}>
{paging.total > PAGE_SIZE && ( {paging.total > PAGE_SIZE_MEDIUM && (
<NextPrevious <NextPrevious
currentPage={currentPage} currentPage={currentPage}
isNumberBased={Boolean(searchTerm)} isNumberBased={Boolean(searchTerm)}
pageSize={PAGE_SIZE} pageSize={PAGE_SIZE_MEDIUM}
paging={paging} paging={paging}
pagingHandler={onPagingChange} pagingHandler={onPagingChange}
totalCount={paging.total} totalCount={paging.total}

View File

@ -126,12 +126,12 @@ const WebhookTable: FC<Props> = ({ onEdit, webhookList, onDelete }) => {
title: 'Description', title: 'Description',
dataIndex: 'description', dataIndex: 'description',
key: 'description', key: 'description',
render: (_, record) => ( render: (value) =>
<RichTextEditorPreviewer value ? (
markdown={record?.description || ''} <RichTextEditorPreviewer markdown={value || ''} maxLength={100} />
maxLength={100} ) : (
/> '--'
), ),
}, },
{ {
title: 'Actions', title: 'Actions',

View File

@ -17,7 +17,7 @@ import classNames from 'classnames';
import { isEmpty, isNil } from 'lodash'; import { isEmpty, isNil } from 'lodash';
import React, { FC, useEffect, useMemo, useState } from 'react'; import React, { FC, useEffect, useMemo, useState } from 'react';
import { deleteWebhook } from '../../axiosAPIs/webhookAPI'; import { deleteWebhook } from '../../axiosAPIs/webhookAPI';
import { PAGE_SIZE } from '../../constants/constants'; import { PAGE_SIZE_MEDIUM } from '../../constants/constants';
import { WEBHOOK_DOCS } from '../../constants/docs.constants'; import { WEBHOOK_DOCS } from '../../constants/docs.constants';
import { NO_PERMISSION_FOR_ACTION } from '../../constants/HelperTextUtil'; import { NO_PERMISSION_FOR_ACTION } from '../../constants/HelperTextUtil';
import { WebhookType } from '../../generated/api/events/createWebhook'; import { WebhookType } from '../../generated/api/events/createWebhook';
@ -175,7 +175,7 @@ const WebhooksV1: FC<WebhooksV1Props> = ({
{Boolean(!isNil(paging.after) || !isNil(paging.before)) && ( {Boolean(!isNil(paging.after) || !isNil(paging.before)) && (
<NextPrevious <NextPrevious
currentPage={currentPage} currentPage={currentPage}
pageSize={PAGE_SIZE} pageSize={PAGE_SIZE_MEDIUM}
paging={paging} paging={paging}
pagingHandler={onPageChange} pagingHandler={onPageChange}
totalCount={paging.total} totalCount={paging.total}

View File

@ -33,7 +33,7 @@ export const INITIAL_PAGING_VALUE = 1;
export const JSON_TAB_SIZE = 2; export const JSON_TAB_SIZE = 2;
export const PAGE_SIZE = 10; export const PAGE_SIZE = 10;
export const PAGE_SIZE_BASE = 12; export const PAGE_SIZE_BASE = 12;
export const PAGE_SIZE_MEDIUM = 16; export const PAGE_SIZE_MEDIUM = 15;
export const API_RES_MAX_SIZE = 100000; export const API_RES_MAX_SIZE = 100000;
export const LIST_SIZE = 5; export const LIST_SIZE = 5;
export const SIDEBAR_WIDTH_COLLAPSED = 290; export const SIDEBAR_WIDTH_COLLAPSED = 290;

View File

@ -102,6 +102,7 @@ export interface TeamDetailsProp {
onDescriptionUpdate: (value: string) => Promise<void>; onDescriptionUpdate: (value: string) => Promise<void>;
handleTeamUsersSearchAction: (text: string) => void; handleTeamUsersSearchAction: (text: string) => void;
updateTeamHandler: (data: Team) => Promise<void>; updateTeamHandler: (data: Team) => Promise<void>;
handleCurrentUserPage: (value?: number) => void;
teamUserPaginHandler: ( teamUserPaginHandler: (
cursorValue: string | number, cursorValue: string | number,
activePage?: number activePage?: number

View File

@ -49,20 +49,37 @@ const AddWebhookPage: FunctionComponent = () => {
const [status, setStatus] = useState<LoadingState>('initial'); const [status, setStatus] = useState<LoadingState>('initial');
const goToWebhooks = () => { const goToWebhooks = () => {
if (webhookType === WebhookType.Slack) { switch (webhookType) {
history.push( case WebhookType.Slack: {
getSettingPath( history.push(
GlobalSettingsMenuCategory.INTEGRATIONS, getSettingPath(
GlobalSettingOptions.SLACK GlobalSettingsMenuCategory.INTEGRATIONS,
) GlobalSettingOptions.SLACK
); )
} else { );
history.push(
getSettingPath( break;
GlobalSettingsMenuCategory.INTEGRATIONS, }
GlobalSettingOptions.WEBHOOK
) case WebhookType.Msteams: {
); history.push(
getSettingPath(
GlobalSettingsMenuCategory.INTEGRATIONS,
GlobalSettingOptions.MSTEAMS
)
);
break;
}
default: {
history.push(
getSettingPath(
GlobalSettingsMenuCategory.INTEGRATIONS,
GlobalSettingOptions.WEBHOOK
)
);
}
} }
}; };

View File

@ -21,6 +21,7 @@ import WebhooksV1 from '../../components/Webhooks/WebhooksV1';
import { import {
getAddWebhookPath, getAddWebhookPath,
getEditWebhookPath, getEditWebhookPath,
PAGE_SIZE_MEDIUM,
pagingObject, pagingObject,
} from '../../constants/constants'; } from '../../constants/constants';
import { import {
@ -42,13 +43,13 @@ const MsTeamsPage = () => {
const fetchData = (paging?: string) => { const fetchData = (paging?: string) => {
setIsLoading(true); setIsLoading(true);
getWebhooks(paging) getWebhooks(paging, undefined, {
limit: PAGE_SIZE_MEDIUM,
webhookType: WebhookType.Msteams,
})
.then((res) => { .then((res) => {
if (res.data) { if (res.data) {
const genericWebhooks = res.data.filter( setData(res.data);
(d) => d.webhookType === WebhookType.Msteams
);
setData(genericWebhooks);
setPaging(res.paging); setPaging(res.paging);
} else { } else {
setData([]); setData([]);

View File

@ -23,7 +23,7 @@ import { usePermissionProvider } from '../../../components/PermissionProvider/Pe
import { ResourceEntity } from '../../../components/PermissionProvider/PermissionProvider.interface'; import { ResourceEntity } from '../../../components/PermissionProvider/PermissionProvider.interface';
import { import {
INITIAL_PAGING_VALUE, INITIAL_PAGING_VALUE,
PAGE_SIZE, PAGE_SIZE_MEDIUM,
ROUTES, ROUTES,
} from '../../../constants/constants'; } from '../../../constants/constants';
import { NO_PERMISSION_FOR_ACTION } from '../../../constants/HelperTextUtil'; import { NO_PERMISSION_FOR_ACTION } from '../../../constants/HelperTextUtil';
@ -56,7 +56,8 @@ const PoliciesListPage = () => {
const data = await getPolicies( const data = await getPolicies(
'owner,location,roles,teams', 'owner,location,roles,teams',
paging?.after, paging?.after,
paging?.before paging?.before,
PAGE_SIZE_MEDIUM
); );
setPolicies(data.data || []); setPolicies(data.data || []);
@ -106,10 +107,10 @@ const PoliciesListPage = () => {
<PoliciesList fetchPolicies={fetchPolicies} policies={policies} /> <PoliciesList fetchPolicies={fetchPolicies} policies={policies} />
</Col> </Col>
<Col span={24}> <Col span={24}>
{paging && paging.total > PAGE_SIZE && ( {paging && paging.total > PAGE_SIZE_MEDIUM && (
<NextPrevious <NextPrevious
currentPage={currentPage} currentPage={currentPage}
pageSize={PAGE_SIZE} pageSize={PAGE_SIZE_MEDIUM}
paging={paging} paging={paging}
pagingHandler={handlePaging} pagingHandler={handlePaging}
totalCount={paging.total} totalCount={paging.total}

View File

@ -23,7 +23,7 @@ import { usePermissionProvider } from '../../../components/PermissionProvider/Pe
import { ResourceEntity } from '../../../components/PermissionProvider/PermissionProvider.interface'; import { ResourceEntity } from '../../../components/PermissionProvider/PermissionProvider.interface';
import { import {
INITIAL_PAGING_VALUE, INITIAL_PAGING_VALUE,
PAGE_SIZE, PAGE_SIZE_MEDIUM,
ROUTES, ROUTES,
} from '../../../constants/constants'; } from '../../../constants/constants';
import { NO_PERMISSION_FOR_ACTION } from '../../../constants/HelperTextUtil'; import { NO_PERMISSION_FOR_ACTION } from '../../../constants/HelperTextUtil';
@ -58,7 +58,9 @@ const RolesListPage = () => {
const data = await getRoles( const data = await getRoles(
'policies,teams,users', 'policies,teams,users',
paging?.after, paging?.after,
paging?.before paging?.before,
undefined,
PAGE_SIZE_MEDIUM
); );
setRoles(data.data || []); setRoles(data.data || []);
@ -109,10 +111,10 @@ const RolesListPage = () => {
<RolesList fetchRoles={fetchRoles} roles={roles} /> <RolesList fetchRoles={fetchRoles} roles={roles} />
</Col> </Col>
<Col span={24}> <Col span={24}>
{paging && paging.total > PAGE_SIZE && ( {paging && paging.total > PAGE_SIZE_MEDIUM && (
<NextPrevious <NextPrevious
currentPage={currentPage} currentPage={currentPage}
pageSize={PAGE_SIZE} pageSize={PAGE_SIZE_MEDIUM}
paging={paging} paging={paging}
pagingHandler={handlePaging} pagingHandler={handlePaging}
totalCount={paging.total} totalCount={paging.total}

View File

@ -21,6 +21,7 @@ import WebhooksV1 from '../../components/Webhooks/WebhooksV1';
import { import {
getAddWebhookPath, getAddWebhookPath,
getEditWebhookPath, getEditWebhookPath,
PAGE_SIZE_MEDIUM,
} from '../../constants/constants'; } from '../../constants/constants';
import { WebhookType } from '../../generated/api/events/createWebhook'; import { WebhookType } from '../../generated/api/events/createWebhook';
import { Status, Webhook } from '../../generated/entity/events/webhook'; import { Status, Webhook } from '../../generated/entity/events/webhook';
@ -40,16 +41,13 @@ export const SlackSettingsPage = () => {
const fetchData = (paging?: string) => { const fetchData = (paging?: string) => {
setIsLoading(true); setIsLoading(true);
getWebhooks(paging) getWebhooks(paging, undefined, {
limit: PAGE_SIZE_MEDIUM,
webhookType: WebhookType.Slack,
})
.then((response) => { .then((response) => {
if (response.data) { if (response.data) {
// TODO: We are expecting filter support from BE (backend) setData(response.data);
// Once we got it remove below lines and provide filter API calls
const slackData = response.data.filter(
(res) => res.webhookType === 'slack'
);
setData(slackData);
setData(slackData);
setPaging(response.paging); setPaging(response.paging);
} else { } else {
setData([]); setData([]);
@ -92,25 +90,8 @@ export const SlackSettingsPage = () => {
history.push(getAddWebhookPath(WebhookType.Slack)); history.push(getAddWebhookPath(WebhookType.Slack));
}; };
const fetchSlackData = async () => {
try {
const response = await getWebhooks();
if (response.data) {
const slackData = response.data.filter(
(res) => res.webhookType === 'slack'
);
setData(slackData);
}
setIsLoading(false);
} catch (error) {
setData([]);
setIsLoading(false);
}
};
useEffect(() => { useEffect(() => {
fetchSlackData(); fetchData();
}, []); }, []);
return ( return (

View File

@ -20,7 +20,7 @@ import Ellipses from '../../components/common/Ellipses/Ellipses';
import NextPrevious from '../../components/common/next-previous/NextPrevious'; import NextPrevious from '../../components/common/next-previous/NextPrevious';
import { import {
INITIAL_PAGING_VALUE, INITIAL_PAGING_VALUE,
PAGE_SIZE, PAGE_SIZE_MEDIUM,
pagingObject, pagingObject,
} from '../../constants/constants'; } from '../../constants/constants';
import { TestSuite } from '../../generated/tests/testSuite'; import { TestSuite } from '../../generated/tests/testSuite';
@ -39,7 +39,7 @@ const TestSuitePage = () => {
setIsLoading(true); setIsLoading(true);
const response = await getListTestSuites({ const response = await getListTestSuites({
fields: 'owner,tests', fields: 'owner,tests',
limit: PAGE_SIZE, limit: PAGE_SIZE_MEDIUM,
before: param && param.before, before: param && param.before,
after: param && param.after, after: param && param.after,
}); });
@ -116,11 +116,11 @@ const TestSuitePage = () => {
size="small" size="small"
/> />
</Col> </Col>
{testSuites.length > PAGE_SIZE && ( {testSuites.length > PAGE_SIZE_MEDIUM && (
<Col span={24}> <Col span={24}>
<NextPrevious <NextPrevious
currentPage={testSuitePage} currentPage={testSuitePage}
pageSize={PAGE_SIZE} pageSize={PAGE_SIZE_MEDIUM}
paging={testSuitePaging} paging={testSuitePaging}
pagingHandler={testSuitePagingHandler} pagingHandler={testSuitePagingHandler}
totalCount={testSuitePaging.total} totalCount={testSuitePaging.total}

View File

@ -19,6 +19,7 @@ import Loader from '../../components/Loader/Loader';
import WebhooksV1 from '../../components/Webhooks/WebhooksV1'; import WebhooksV1 from '../../components/Webhooks/WebhooksV1';
import { import {
getEditWebhookPath, getEditWebhookPath,
PAGE_SIZE_MEDIUM,
pagingObject, pagingObject,
ROUTES, ROUTES,
} from '../../constants/constants'; } from '../../constants/constants';
@ -41,7 +42,7 @@ const WebhooksPageV1 = () => {
const fetchData = (paging?: string) => { const fetchData = (paging?: string) => {
setIsLoading(true); setIsLoading(true);
getWebhooks(paging) getWebhooks(paging, undefined, { limit: PAGE_SIZE_MEDIUM })
.then((res) => { .then((res) => {
if (res.data) { if (res.data) {
const genericWebhooks = res.data.filter( const genericWebhooks = res.data.filter(

View File

@ -32,7 +32,7 @@ import TeamDetailsV1 from '../../components/TeamDetails/TeamDetailsV1';
import Teams from '../../components/TeamDetails/Teams'; import Teams from '../../components/TeamDetails/Teams';
import { import {
INITIAL_PAGING_VALUE, INITIAL_PAGING_VALUE,
PAGE_SIZE, PAGE_SIZE_MEDIUM,
pagingObject, pagingObject,
} from '../../constants/constants'; } from '../../constants/constants';
import { SearchIndex } from '../../enums/search.enum'; import { SearchIndex } from '../../enums/search.enum';
@ -169,7 +169,7 @@ const TeamsPage = () => {
paging = {} as { [key: string]: string } paging = {} as { [key: string]: string }
) => { ) => {
setIsDataLoading(true); setIsDataLoading(true);
getUsers('teams,roles', PAGE_SIZE, { team, ...paging }) getUsers('teams,roles', PAGE_SIZE_MEDIUM, { team, ...paging })
.then((res) => { .then((res) => {
if (res.data) { if (res.data) {
setUsers(res.data); setUsers(res.data);
@ -220,7 +220,7 @@ const TeamsPage = () => {
searchData( searchData(
text, text,
currentPage, currentPage,
PAGE_SIZE, PAGE_SIZE_MEDIUM,
`(teams.id:${selectedTeam?.id})`, `(teams.id:${selectedTeam?.id})`,
'', '',
'', '',
@ -393,6 +393,10 @@ const TeamsPage = () => {
}); });
}; };
const handleCurrentUserPage = (value?: number) => {
setCurrentUserPage(value ?? INITIAL_PAGING_VALUE);
};
const handleUsersSearchAction = (text: string) => { const handleUsersSearchAction = (text: string) => {
setUserSearchValue(text); setUserSearchValue(text);
setCurrentUserPage(INITIAL_PAGING_VALUE); setCurrentUserPage(INITIAL_PAGING_VALUE);
@ -463,6 +467,7 @@ const TeamsPage = () => {
descriptionHandler={descriptionHandler} descriptionHandler={descriptionHandler}
handleAddTeam={handleAddTeam} handleAddTeam={handleAddTeam}
handleAddUser={handleAddUsers} handleAddUser={handleAddUsers}
handleCurrentUserPage={handleCurrentUserPage}
handleJoinTeamClick={handleJoinTeamClick} handleJoinTeamClick={handleJoinTeamClick}
handleLeaveTeamClick={handleLeaveTeamClick} handleLeaveTeamClick={handleLeaveTeamClick}
handleTeamUsersSearchAction={handleUsersSearchAction} handleTeamUsersSearchAction={handleUsersSearchAction}