Skip to content

Commit 88ac670

Browse files
authored
refactor(UI-1398): always open first session on Sessions page (#1077)
1 parent dae1751 commit 88ac670

File tree

5 files changed

+9
-10
lines changed

5 files changed

+9
-10
lines changed

src/components/organisms/deployments/sessions/table/table.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { useTranslation } from "react-i18next";
55
import { Outlet, useNavigate, useParams, useSearchParams } from "react-router-dom";
66
import { ListOnItemsRenderedProps } from "react-window";
77

8-
import { defaultSplitFrameSize, namespaces, sessionRowHeight } from "@constants";
8+
import { defaultSplitFrameSize, namespaces } from "@constants";
99
import { ModalName } from "@enums/components";
1010
import { reverseSessionStateConverter } from "@models/utils";
1111
import { LoggerService, SessionsService } from "@services";
@@ -176,8 +176,7 @@ export const SessionsTable = () => {
176176
{
177177
stateType: reverseSessionStateConverter(urlSessionStateFilter as SessionStateKeyType),
178178
},
179-
nextPageToken,
180-
sessionRowHeight
179+
nextPageToken
181180
);
182181

183182
if (error) {
@@ -211,6 +210,10 @@ export const SessionsTable = () => {
211210
setSessionsNextPageToken(data.nextPageToken);
212211
setIsLoading(false);
213212
setIsInitialLoad(false);
213+
214+
if (!nextPageToken && data.sessions.length > 0) {
215+
navigateInSessions("", data.sessions[0].sessionId);
216+
}
214217
},
215218
// eslint-disable-next-line react-hooks/exhaustive-deps
216219
[deploymentId, urlSessionStateFilter]

src/constants/global.constants.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ export const version = packageJson.version;
1616

1717
export const fetchProjectsMenuItemsInterval = 60000;
1818
export const fetchSessionsInterval = 10000;
19-
export const defaultSessionsVisiblePageSize = 10;
2019
export const maxLogs = 20;
2120
export const fileSizeUploadLimit = 50 * 1024; // 50KB
2221
export const apiRequestTimeout = isDevelopment ? 1000 * 60 : 1000 * 10; // 1 minute in development, 10 seconds in production

src/constants/index.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
export { featureFlags } from "@constants/featureFlags.constants";
22
export {
3-
defaultSessionsVisiblePageSize,
43
descopeProjectId,
54
fetchProjectsMenuItemsInterval,
65
fetchSessionsInterval,
@@ -57,7 +56,6 @@ export {
5756
standardScreenHeightFallback,
5857
sessionsEditorLineHeight,
5958
sessionLogRowHeight,
60-
sessionRowHeight,
6159
} from "@constants/sessions.constants";
6260
export { initialSortConfig } from "@constants/sortConfig.constants";
6361
export { infoCronExpressionsLinks, extraTriggerTypes } from "@constants/triggers.constants";

src/constants/sessions.constants.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,3 @@ export const sessionTabs = [
1111
export const sessionLogRowHeight = Math.ceil(
1212
(standardScreenHeightFallback / defaultSessionLogRecordsListRowHeight) * 1.5
1313
);
14-
export const sessionRowHeight = Math.ceil((standardScreenHeightFallback / defaultSessionsListRowHeight) * 1.5);

src/services/sessions.service.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
} from "@ak-proto-ts/sessions/v1/session_pb";
99
import { StartRequest } from "@ak-proto-ts/sessions/v1/svc_pb";
1010
import { sessionsClient } from "@api/grpc/clients.grpc.api";
11-
import { defaultSessionsVisiblePageSize, namespaces } from "@constants";
11+
import { namespaces } from "@constants";
1212
import { convertSessionLogProtoToModel, convertSessionProtoToModel, convertSessionProtoToViewerModel } from "@models";
1313
import { LoggerService } from "@services";
1414
import { SessionLogType } from "@src/enums";
@@ -133,7 +133,7 @@ export class SessionsService {
133133
try {
134134
const { nextPageToken, sessions: sessionsResponse } = await sessionsClient.list({
135135
deploymentId,
136-
pageSize: pageSize || defaultSessionsVisiblePageSize,
136+
pageSize: pageSize,
137137
pageToken,
138138
stateType: filter?.stateType,
139139
});
@@ -157,7 +157,7 @@ export class SessionsService {
157157
try {
158158
const { nextPageToken, sessions: sessionsResponse } = await sessionsClient.list({
159159
projectId,
160-
pageSize: pageSize || defaultSessionsVisiblePageSize,
160+
pageSize: pageSize,
161161
pageToken,
162162
stateType: filter?.stateType,
163163
});

0 commit comments

Comments
 (0)