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
> Related issue: #23404

# Checklist for submitter

If some of the following don't apply, delete the relevant line.

<!-- Note that API documentation changes are now addressed by the
product design team. -->

- [x] Changes file added for user-visible changes in `changes/`,
`orbit/changes/` or `ee/fleetd-chrome/changes`.
See [Changes
files](https://github.com/fleetdm/fleet/blob/main/docs/Contributing/Committing-Changes.md#changes-files)
for more information.
- [x] Manual QA for all new/changed functionality
  • Loading branch information
jahzielv committed Dec 9, 2024
1 parent a715a47 commit da95c83
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 da95c83

Please sign in to comment.