Skip to content

Commit

Permalink
Fix after review
Browse files Browse the repository at this point in the history
  • Loading branch information
gafetinov committed Dec 14, 2023
1 parent 76899eb commit 04c3bcf
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ interface RemoteTaskQueueApplicationProps {
customStateCaptions?: TaskStateDict;
customSearchHelp?: JSX.Element;
hideMissingMeta?: boolean;
isNotPagingOnBackend?: boolean;
useFrontPaging?: boolean;
}

export const RemoteTaskQueueApplication = ({
Expand All @@ -27,7 +27,7 @@ export const RemoteTaskQueueApplication = ({
customStateCaptions,
customSearchHelp,
hideMissingMeta,
isNotPagingOnBackend,
useFrontPaging,
}: RemoteTaskQueueApplicationProps): JSX.Element => (
<CustomSettingsProvider
customStateCaptions={customStateCaptions}
Expand All @@ -42,7 +42,7 @@ export const RemoteTaskQueueApplication = ({
isSuperUser={isSuperUser}
rtqMonitoringApi={rtqMonitoringApi}
useErrorHandlingContainer={useErrorHandlingContainer}
isNotPagingOnBackend={isNotPagingOnBackend}
useFrontPaging={useFrontPaging}
/>
}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,13 @@ export function TaskQueueFilter({
}
};

const onChangeTaskLimit = (value: string) => {
if (isNaN(Number(value)) || Number(value) > 9999) {
return;
}
onChange({ count: value === "" ? null : Number(value) });
};

const { enqueueTimestampRange, queryString, states, names, count } = value;
const defaultEnqueueDateTimeRange = {
lowerBound: null,
Expand Down Expand Up @@ -75,7 +82,7 @@ export function TaskQueueFilter({
data-tid="MaxInput"
placeholder="Max"
value={String(count || "")}
onValueChange={value => onChange({ count: Number(value) })}
onValueChange={onChangeTaskLimit}
onKeyDown={onKeyDown}
/>
</Fixed>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ interface TasksPageContainerProps {
rtqMonitoringApi: IRtqMonitoringApi;
isSuperUser: boolean;
useErrorHandlingContainer: boolean;
isNotPagingOnBackend?: boolean;
useFrontPaging?: boolean;
}

const maxTaskCountOnPage = 20;
Expand All @@ -45,7 +45,7 @@ export const TasksPageContainer = ({
rtqMonitoringApi,
isSuperUser,
useErrorHandlingContainer,
isNotPagingOnBackend,
useFrontPaging,
}: TasksPageContainerProps): JSX.Element => {
const navigate = useNavigate();
const { search, pathname } = useLocation();
Expand All @@ -64,14 +64,12 @@ export const TasksPageContainer = ({

useEffect(() => {
const newRequest = getRequestBySearchQuery(search);
if (isNotPagingOnBackend && request.offset !== newRequest.offset) {
if (useFrontPaging && request.offset !== newRequest.offset) {
const offset = newRequest.offset || 0;
setVisibleTasks(results.taskMetas.slice(offset, offset + maxTaskCountOnPage));
setLoading(false);
} else {
loadData(
isNotPagingOnBackend ? { ...newRequest, offset: 0 } : { ...newRequest, count: maxTaskCountOnPage }
);
loadData(useFrontPaging ? { ...newRequest, offset: 0 } : { ...newRequest, count: maxTaskCountOnPage });
}
setRequest(newRequest);
}, [search]);
Expand Down Expand Up @@ -172,7 +170,7 @@ export const TasksPageContainer = ({
const getRequestBySearchQuery = (searchQuery: string): RtqMonitoringSearchRequest => {
const request: RtqMonitoringSearchRequest = searchRequestMapping.parse(searchQuery);
request.offset ||= 0;
request.count = isNotPagingOnBackend ? request.count : request.count || maxTaskCountOnPage;
request.count = useFrontPaging ? request.count : request.count || maxTaskCountOnPage;
return request;
};

Expand Down Expand Up @@ -204,7 +202,7 @@ export const TasksPageContainer = ({
availableTaskTypes={availableTaskNames}
onChange={onChangeFilter}
onSearchButtonClick={handleSearch}
withTaskLimit={isNotPagingOnBackend}
withTaskLimit={useFrontPaging}
/>
</Fit>
<Fit>
Expand Down Expand Up @@ -297,7 +295,7 @@ export const TasksPageContainer = ({
const results = await rtqMonitoringApi.search(request);
setResults(results);
setVisibleTasks(
isNotPagingOnBackend ? results.taskMetas.slice(offset, offset + maxTaskCountOnPage) : results.taskMetas
useFrontPaging ? results.taskMetas.slice(offset, offset + maxTaskCountOnPage) : results.taskMetas
);
} finally {
setLoading(false);
Expand Down

0 comments on commit 04c3bcf

Please sign in to comment.