Skip to content

Commit

Permalink
fix: do pagination in fleet free with correct query params (#24494) (#…
Browse files Browse the repository at this point in the history
…24525)

cherry-pick for #24494
  • Loading branch information
jahzielv authored Dec 9, 2024
1 parent a715a47 commit 4a262ca
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 12 deletions.
1 change: 1 addition & 0 deletions changes/23404-pagination
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Fixes a bug with pagination in the profiles and scripts lists.
Original file line number Diff line number Diff line change
Expand Up @@ -118,17 +118,16 @@ const CustomSettings = ({
};

// pagination controls
const path = PATHS.CONTROLS_CUSTOM_SETTINGS.concat(
`?team_id=${currentTeamId}`
);
const path = PATHS.CONTROLS_CUSTOM_SETTINGS;
const queryString = isPremiumTier ? `?team_id=${currentTeamId}&` : "?";

const onPrevPage = useCallback(() => {
router.push(path.concat(`&page=${currentPage - 1}`));
}, [router, path, currentPage]);
router.push(path.concat(`${queryString}page=${currentPage - 1}`));
}, [router, path, currentPage, queryString]);

const onNextPage = useCallback(() => {
router.push(path.concat(`&page=${currentPage + 1}`));
}, [router, path, currentPage]);
router.push(path.concat(`${queryString}page=${currentPage + 1}`));
}, [router, path, currentPage, queryString]);

const onClickDelete = (profile: IMdmProfile) => {
selectedProfile.current = profile;
Expand Down
12 changes: 7 additions & 5 deletions frontend/pages/ManageControlsPage/Scripts/Scripts.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ interface IScriptsProps {
}

const Scripts = ({ router, currentPage, teamIdForApi }: IScriptsProps) => {
const { isPremiumTier } = useContext(AppContext);
const [showDeleteScriptModal, setShowDeleteScriptModal] = useState(false);
const [showScriptDetailsModal, setShowScriptDetailsModal] = useState(false);
const [goBackToScriptDetails, setGoBackToScriptDetails] = useState(false); // Used for onCancel in delete modal
Expand Down Expand Up @@ -69,13 +70,14 @@ const Scripts = ({ router, currentPage, teamIdForApi }: IScriptsProps) => {
);

// pagination controls
const path = PATHS.CONTROLS_SCRIPTS.concat(`?team_id=${teamIdForApi}`);
const path = PATHS.CONTROLS_SCRIPTS;
const queryString = isPremiumTier ? `?team_id=${teamIdForApi}&` : "?";
const onPrevPage = useCallback(() => {
router.push(path.concat(`&page=${currentPage - 1}`));
}, [router, path, currentPage]);
router.push(path.concat(`${queryString}page=${currentPage - 1}`));
}, [router, path, currentPage, queryString]);
const onNextPage = useCallback(() => {
router.push(path.concat(`&page=${currentPage + 1}`));
}, [router, path, currentPage]);
router.push(path.concat(`${queryString}page=${currentPage + 1}`));
}, [router, path, currentPage, queryString]);

const { config } = useContext(AppContext);
if (!config) return null;
Expand Down

0 comments on commit 4a262ca

Please sign in to comment.