]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-21571 Update react-query
authorViktor Vorona <viktor.vorona@sonarsource.com>
Mon, 5 Feb 2024 13:21:28 +0000 (14:21 +0100)
committersonartech <sonartech@sonarsource.com>
Wed, 7 Feb 2024 20:02:50 +0000 (20:02 +0000)
41 files changed:
server/sonar-web/package.json
server/sonar-web/src/main/js/apps/coding-rules/components/ActivationFormModal.tsx
server/sonar-web/src/main/js/apps/coding-rules/components/CustomRuleFormModal.tsx
server/sonar-web/src/main/js/apps/coding-rules/components/RuleDetailsCustomRules.tsx
server/sonar-web/src/main/js/apps/coding-rules/components/RuleDetailsDescription.tsx
server/sonar-web/src/main/js/apps/groups/components/DeleteGroupForm.tsx
server/sonar-web/src/main/js/apps/groups/components/EditMembersModal.tsx
server/sonar-web/src/main/js/apps/groups/components/GroupForm.tsx
server/sonar-web/src/main/js/apps/overview/components/AnalysisWarningsModal.tsx
server/sonar-web/src/main/js/apps/projectBranches/components/BranchPurgeSetting.tsx
server/sonar-web/src/main/js/apps/projectBranches/components/DeleteBranchModal.tsx
server/sonar-web/src/main/js/apps/projectBranches/components/RenameBranchModal.tsx
server/sonar-web/src/main/js/apps/projectBranches/components/SetAsMainBranchModal.tsx
server/sonar-web/src/main/js/apps/projectInformation/badges/ProjectBadges.tsx
server/sonar-web/src/main/js/apps/projectNewCode/components/ProjectNewCodeDefinitionApp.tsx
server/sonar-web/src/main/js/apps/quality-profiles/details/ProfilePermissionsForm.tsx
server/sonar-web/src/main/js/apps/settings/components/NewCodeDefinition.tsx
server/sonar-web/src/main/js/apps/settings/components/authentication/GitHubMappingModal.tsx
server/sonar-web/src/main/js/apps/settings/components/authentication/GitLabAuthenticationTab.tsx
server/sonar-web/src/main/js/apps/settings/components/authentication/GitLabConfigurationForm.tsx
server/sonar-web/src/main/js/apps/settings/components/authentication/GithubAuthenticationTab.tsx
server/sonar-web/src/main/js/apps/settings/components/authentication/SamlAuthenticationTab.tsx
server/sonar-web/src/main/js/apps/settings/components/pullRequestDecorationBinding/PRDecorationBinding.tsx
server/sonar-web/src/main/js/apps/users/components/DeactivateForm.tsx
server/sonar-web/src/main/js/apps/users/components/TokensForm.tsx
server/sonar-web/src/main/js/apps/users/components/TokensFormItem.tsx
server/sonar-web/src/main/js/apps/users/components/UserForm.tsx
server/sonar-web/src/main/js/queries/badges.ts
server/sonar-web/src/main/js/queries/devops-integration.ts
server/sonar-web/src/main/js/queries/group-memberships.ts
server/sonar-web/src/main/js/queries/groups.ts
server/sonar-web/src/main/js/queries/identity-provider/common.ts
server/sonar-web/src/main/js/queries/identity-provider/github.ts
server/sonar-web/src/main/js/queries/identity-provider/gitlab.ts
server/sonar-web/src/main/js/queries/identity-provider/scim.ts
server/sonar-web/src/main/js/queries/newCodeDefinition.ts
server/sonar-web/src/main/js/queries/quality-gates.ts
server/sonar-web/src/main/js/queries/settings.ts
server/sonar-web/src/main/js/queries/users.ts
server/sonar-web/src/main/js/queries/web-api.ts
server/sonar-web/yarn.lock

index 58b852ef30385d9be5c93bf738167f94c3f7eddb..0e1280ba593ae3fd7012fcb6e53e5e6e9c83a2e3 100644 (file)
@@ -13,7 +13,7 @@
     "@primer/octicons-react": "19.8.0",
     "@react-spring/rafz": "9.7.3",
     "@react-spring/web": "9.7.3",
-    "@tanstack/react-query": "4.33.0",
+    "@tanstack/react-query": "5.18.1",
     "axios": "1.6.4",
     "classnames": "2.3.2",
     "clipboard": "2.0.11",
index 37ccc4cc98a1d7a2c4e8930700320f02dc8c6941..508eefcceb3201cdf858b167cadecbc02e0ffb25 100644 (file)
@@ -57,7 +57,7 @@ const FORM_ID = 'rule-activation-modal-form';
 
 export default function ActivationFormModal(props: Readonly<Props>) {
   const { activation, rule, profiles, modalHeader } = props;
-  const { mutate: activateRule, isLoading: submitting } = useActivateRuleMutation((data) => {
+  const { mutate: activateRule, isPending: submitting } = useActivateRuleMutation((data) => {
     props.onDone?.(data.severity as string);
     props.onClose();
   });
index d3d7951068339b7dae7b41474ee9e38fdbb39e23..035e0a6cac958ee0cc6b7e4bce2cd9a62fb163b5 100644 (file)
@@ -78,11 +78,11 @@ export default function CustomRuleFormModal(props: Readonly<Props>) {
     f: 'name,severity,params',
     template_key: templateRule.key,
   };
-  const { mutate: updateRule, isLoading: updatingRule } = useUpdateRuleMutation(
+  const { mutate: updateRule, isPending: updatingRule } = useUpdateRuleMutation(
     customRulesSearchParams,
     props.onClose,
   );
-  const { mutate: createRule, isLoading: creatingRule } = useCreateRuleMutation(
+  const { mutate: createRule, isPending: creatingRule } = useCreateRuleMutation(
     customRulesSearchParams,
     props.onClose,
     (response: Response) => {
index 7b545df9d309af833ed92e94d75fc53f1fbca6b4..0717e51856986136679249cc18a306de049c5128 100644 (file)
@@ -52,7 +52,7 @@ export default function RuleDetailsCustomRules(props: Readonly<Props>) {
     template_key: ruleDetails.key,
   };
   const { isLoading: loadingRules, data } = useSearchRulesQuery(rulesSearchParams);
-  const { mutate: deleteRules, isLoading: deletingRule } = useDeleteRuleMutation(rulesSearchParams);
+  const { mutate: deleteRules, isPending: deletingRule } = useDeleteRuleMutation(rulesSearchParams);
 
   const loading = loadingRules || deletingRule;
   const rules = data?.rules ?? [];
index 23077e42cd7679d9bec584c6a2e89899b53b5c4f..0728fe6a4214dda8d75f412d6d53ec854bd804e0 100644 (file)
@@ -46,7 +46,7 @@ export default function RuleDetailsDescription(props: Readonly<Props>) {
   const [descriptionForm, setDescriptionForm] = React.useState(false);
   const [removeDescriptionModal, setDescriptionModal] = React.useState(false);
 
-  const { mutate: updateRule, isLoading: updatingRule } = useUpdateRuleMutation(undefined, () =>
+  const { mutate: updateRule, isPending: updatingRule } = useUpdateRuleMutation(undefined, () =>
     setDescriptionForm(false),
   );
 
index 5b275c2589eca482174a56fe87182917991e8392..4abc6d4ab079540d08435184e4ece18e3ccbfa28 100644 (file)
@@ -31,7 +31,7 @@ interface Props {
 export default function DeleteGroupForm(props: Readonly<Props>) {
   const { group } = props;
 
-  const { mutate: deleteGroup, isLoading } = useDeleteGroupMutation();
+  const { mutate: deleteGroup, isPending } = useDeleteGroupMutation();
 
   const onSubmit = () => {
     deleteGroup(group.id, {
@@ -45,7 +45,7 @@ export default function DeleteGroupForm(props: Readonly<Props>) {
       onClose={props.onClose}
       body={translateWithParameters('groups.delete_group.confirmation', group.name)}
       primaryButton={
-        <DangerButtonPrimary autoFocus type="submit" onClick={onSubmit} disabled={isLoading}>
+        <DangerButtonPrimary autoFocus type="submit" onClick={onSubmit} disabled={isPending}>
           {translate('delete')}
         </DangerButtonPrimary>
       }
index fa75a1e993287720b3bfbfdb28977f40027d03f9..bcb718b48a6d76953953fb2ffd041721a9050344 100644 (file)
@@ -28,6 +28,7 @@ import { translate } from '../../../helpers/l10n';
 import {
   useAddGroupMembershipMutation,
   useGroupMembersQuery,
+  useRemoveGroupMembersQueryFromCache,
   useRemoveGroupMembershipMutation,
 } from '../../../queries/group-memberships';
 import { Group } from '../../../types/types';
@@ -46,16 +47,12 @@ export default function EditMembersModal(props: Readonly<Props>) {
   const [filter, setFilter] = React.useState<SelectListFilter>(SelectListFilter.Selected);
   const { mutateAsync: addUserToGroup } = useAddGroupMembershipMutation();
   const { mutateAsync: removeUserFromGroup } = useRemoveGroupMembershipMutation();
-  const {
-    data,
-    isLoading,
-    fetchNextPage,
-    remove: emptyQueryCache,
-  } = useGroupMembersQuery({
+  const { data, isLoading, fetchNextPage } = useGroupMembersQuery({
     q: query,
     groupId: group.id,
     filter,
   });
+  const emptyQueryCache = useRemoveGroupMembersQueryFromCache();
 
   const users: (RestUserBase & { selected?: boolean })[] =
     data?.pages.flatMap((page) => page.users) ?? [];
index 9865567daff0f3cbe4c0e13aa3c4ea1cf1a9c285..0b76702de2fd28c19a1dc722579b501e4d952b37 100644 (file)
@@ -43,8 +43,8 @@ export default function GroupForm(props: Props) {
   const [name, setName] = useState<string>(create ? '' : group.name);
   const [description, setDescription] = useState<string>(create ? '' : group.description ?? '');
 
-  const { mutate: createGroup, isLoading: isCreating } = useCreateGroupMutation();
-  const { mutate: updateGroup, isLoading: isUpdating } = useUpdateGroupMutation();
+  const { mutate: createGroup, isPending: isCreating } = useCreateGroupMutation();
+  const { mutate: updateGroup, isPending: isUpdating } = useUpdateGroupMutation();
 
   const handleCreateGroup = () => {
     createGroup({ name, description }, { onSuccess: props.onClose });
index d17e2f71782db0d13ded377497019d317bb9dd14..1847fee0f2bbf2f2102140535afa57f7a278c3a6 100644 (file)
@@ -37,7 +37,7 @@ interface Props {
 export function AnalysisWarningsModal(props: Props) {
   const { component, currentUser, warnings } = props;
 
-  const { mutate, isLoading, variables } = useDismissBranchWarningMutation();
+  const { mutate, isPending, variables } = useDismissBranchWarningMutation();
 
   const handleDismissMessage = (messageKey: string) => {
     mutate({ component, key: messageKey });
@@ -63,7 +63,7 @@ export function AnalysisWarningsModal(props: Props) {
             {dismissable && currentUser.isLoggedIn && (
               <div className="sw-mt-4">
                 <DangerButtonSecondary
-                  disabled={Boolean(isLoading)}
+                  disabled={Boolean(isPending)}
                   onClick={() => {
                     handleDismissMessage(key);
                   }}
@@ -71,7 +71,7 @@ export function AnalysisWarningsModal(props: Props) {
                   {translate('dismiss_permanently')}
                 </DangerButtonSecondary>
 
-                <Spinner className="sw-ml-2" loading={isLoading && variables?.key === key} />
+                <Spinner className="sw-ml-2" loading={isPending && variables?.key === key} />
               </div>
             )}
           </div>
index dbf6506da43e7c11d242778e3934b407e42747b7..dce0f7d4ef6b0582f8a114e367ede786ba82e997 100644 (file)
@@ -34,7 +34,7 @@ interface Props {
 
 export default function BranchPurgeSetting(props: Props) {
   const { branch, component } = props;
-  const { mutate: excludeFromPurge, isLoading } = useExcludeFromPurgeMutation();
+  const { mutate: excludeFromPurge, isPending } = useExcludeFromPurgeMutation();
 
   useEffect(() => {
     excludeFromPurge({ component, key: branch.name, exclude: branch.excludedFromPurge });
@@ -45,7 +45,7 @@ export default function BranchPurgeSetting(props: Props) {
   };
 
   const isTheMainBranch = isMainBranch(branch);
-  const disabled = isTheMainBranch || isLoading;
+  const disabled = isTheMainBranch || isPending;
 
   return (
     <>
@@ -58,7 +58,7 @@ export default function BranchPurgeSetting(props: Props) {
           off: translate('off'),
         }}
       />
-      <Spinner loading={isLoading} className="sw-ml-1" />
+      <Spinner loading={isPending} className="sw-ml-1" />
       {isTheMainBranch && (
         <HelpTooltip
           className="sw-ml-1"
index c7cde00368635ecb2a243d950fbeaa21eaecfa98..9fe48ecf412e452df90d67e722554a572f215d67 100644 (file)
@@ -35,7 +35,7 @@ const FORM_ID = 'confirm-branch-delete-form';
 
 export default function DeleteBranchModal(props: Props) {
   const { branchLike, component, onClose } = props;
-  const { mutate: deleteBranch, isLoading } = useDeletBranchMutation();
+  const { mutate: deleteBranch, isPending } = useDeletBranchMutation();
 
   const handleSubmit = React.useCallback(
     (event: React.SyntheticEvent<HTMLFormElement>) => {
@@ -73,7 +73,7 @@ export default function DeleteBranchModal(props: Props) {
           />
         </form>
       }
-      loading={isLoading}
+      loading={isPending}
       primaryButton={
         <DangerButtonPrimary type="submit" form={FORM_ID}>
           <FormattedMessage id="delete" />
index f2a58facc77162eab7ac42e90a1058a0c2863885..12ec89d966b7313325fe97a2a6b307ae6f36ba66 100644 (file)
@@ -38,7 +38,7 @@ export default function RenameBranchModal(props: Props) {
   const { branch, component, onClose } = props;
   const [name, setName] = useState<string>();
 
-  const { mutate: renameMainBranch, isLoading } = useRenameMainBranchMutation();
+  const { mutate: renameMainBranch, isPending } = useRenameMainBranchMutation();
 
   const handleSubmit = React.useCallback(
     (event: React.SyntheticEvent<HTMLFormElement>) => {
@@ -57,7 +57,7 @@ export default function RenameBranchModal(props: Props) {
   }, []);
 
   const header = translate('project_branch_pull_request.branch.rename');
-  const submitDisabled = isLoading || !name || name === branch.name;
+  const submitDisabled = isPending || !name || name === branch.name;
 
   return (
     <Modal
@@ -79,7 +79,7 @@ export default function RenameBranchModal(props: Props) {
           </FormField>
         </form>
       }
-      loading={isLoading}
+      loading={isPending}
       primaryButton={
         <ButtonPrimary disabled={submitDisabled} type="submit" form={FORM_ID}>
           <FormattedMessage id="rename" />
index 16aca54e6a37eaff30089e681c41b8764a46a956..e57ba4a2d10b262c3602b352c7187ea170c55990 100644 (file)
@@ -37,7 +37,7 @@ const FORM_ID = 'branch-setasmain-form';
 
 export default function SetAsMainBranchModal(props: SetAsMainBranchModalProps) {
   const { branch, component, onClose, onSetAsMain } = props;
-  const { mutate: setMainBranch, isLoading } = useSetMainBranchMutation();
+  const { mutate: setMainBranch, isPending } = useSetMainBranchMutation();
 
   const handleSubmit = React.useCallback(
     (e: React.SyntheticEvent<HTMLFormElement>) => {
@@ -55,7 +55,7 @@ export default function SetAsMainBranchModal(props: SetAsMainBranchModalProps) {
           values={{ branch: <span className="sw-break-all">{branch.name}</span> }}
         />
       }
-      loading={isLoading}
+      loading={isPending}
       onClose={onClose}
       body={
         <form id={FORM_ID} onSubmit={handleSubmit}>
@@ -83,7 +83,7 @@ export default function SetAsMainBranchModal(props: SetAsMainBranchModalProps) {
         </form>
       }
       primaryButton={
-        <ButtonPrimary disabled={isLoading} type="submit" form={FORM_ID}>
+        <ButtonPrimary disabled={isPending} type="submit" form={FORM_ID}>
           <FormattedMessage id="project_branch_pull_request.branch.set_main" />
         </ButtonPrimary>
       }
index 2acf1bdc8bcb1aecf8f19723e7c74c77bbc5c56e..e445738fe8d08bee582671767656907e63f1cba5 100644 (file)
@@ -65,7 +65,7 @@ export default function ProjectBadges(props: ProjectBadgesProps) {
     isFetching: isFetchingToken,
   } = useBadgeTokenQuery(project);
   const { data: metricOptions, isLoading: isLoadingMetrics } = useBadgeMetricsQuery();
-  const { mutate: renewToken, isLoading: isRenewing } = useRenewBagdeTokenMutation();
+  const { mutate: renewToken, isPending: isRenewing } = useRenewBagdeTokenMutation();
   const isLoading = isLoadingMetrics || isLoadingToken || isRenewing;
 
   const handleSelectType = (selectedType: BadgeType) => {
index 3301953b5b7435d4a6bf4e0404b85e8e03dfe33b..700a997d7716a2bfdbd1df58f5ffc63add123e8a 100644 (file)
@@ -73,7 +73,7 @@ function ProjectNewCodeDefinitionApp(props: Readonly<ProjectNewCodeDefinitionApp
       branchName: hasFeature(Feature.BranchSupport) ? undefined : branchLike?.name,
       projectKey: component.key,
     });
-  const { isLoading: isSaving, mutate: postNewCodeDefinition } = useNewCodeDefinitionMutation();
+  const { isPending: isSaving, mutate: postNewCodeDefinition } = useNewCodeDefinitionMutation();
 
   const branchList = useMemo(() => {
     return sortBranches(branchLikes.filter(isBranch));
index 90fc5ce672593cc1f4e8724096d097481b253e69..b7c40626aa9faf2a08d6aa733b69bcf16a85d40e 100644 (file)
@@ -36,10 +36,10 @@ export default function ProfilePermissionForm(props: Readonly<Props>) {
   const { profile } = props;
   const [selected, setSelected] = React.useState<UserSelected | Group>();
 
-  const { mutate: addUser, isLoading: addingUser } = useAddUserMutation(() =>
+  const { mutate: addUser, isPending: addingUser } = useAddUserMutation(() =>
     props.onUserAdd(selected as UserSelected),
   );
-  const { mutate: addGroup, isLoading: addingGroup } = useAddGroupMutation(() =>
+  const { mutate: addGroup, isPending: addingGroup } = useAddGroupMutation(() =>
     props.onGroupAdd(selected as Group),
   );
 
index 47920dde7fd1df75470bcea06485bc024d912bc0..64e9416c45eefe265042a6a3688dd23ad8fe4439 100644 (file)
@@ -44,7 +44,7 @@ export default function NewCodeDefinition() {
   >(undefined);
 
   const { data: newCodeDefinition, isLoading } = useNewCodeDefinitionQuery();
-  const { isLoading: isSaving, mutate: postNewCodeDefinition } = useNewCodeDefinitionMutation();
+  const { isPending: isSaving, mutate: postNewCodeDefinition } = useNewCodeDefinitionMutation();
 
   const resetNewCodeDefinition = useCallback(() => {
     setSelectedNewCodeDefinitionType(newCodeDefinition?.type);
index 6291b5d9410092bdfa5e329521024b73cc8aa3be..d22e7f0bf55cdef3e1eb66e39a21ca159eeb29ac 100644 (file)
@@ -114,7 +114,7 @@ function PermissionRow(props: Readonly<PermissionCellProps>) {
 }
 
 export default function GitHubMappingModal({ mapping, setMapping, onClose }: Readonly<Props>) {
-  const { data: roles, isLoading } = useGithubRolesMappingQuery();
+  const { data: roles, isPending } = useGithubRolesMappingQuery();
   const permissions = convertToPermissionDefinitions(
     PERMISSIONS_ORDER_FOR_PROJECT_TEMPLATE,
     'projects_role',
@@ -234,7 +234,7 @@ export default function GitHubMappingModal({ mapping, setMapping, onClose }: Rea
           'settings.authentication.github.configuration.roles_mapping.dialog.custom_roles_description',
         )}
       </FlagMessage>
-      <Spinner loading={isLoading} />
+      <Spinner loading={isPending} />
     </div>
   );
 
index 1de75c707cf7829bce5d1d0df3d4231abadf9065..e7e2b41e01e6ffe61601359463561b5d973144d9 100644 (file)
@@ -103,8 +103,8 @@ export default function GitLabAuthenticationTab() {
 
   const { canSyncNow, synchronizeNow } = useSyncWithGitLabNow();
 
-  const { mutate: updateConfig, isLoading: isUpdating } = useUpdateGitLabConfigurationMutation();
-  const { mutate: deleteConfig, isLoading: isDeleting } = useDeleteGitLabConfigurationMutation();
+  const { mutate: updateConfig, isPending: isUpdating } = useUpdateGitLabConfigurationMutation();
+  const { mutate: deleteConfig, isPending: isDeleting } = useDeleteGitLabConfigurationMutation();
 
   const definitions = getDefinitions(
     changes?.provisioningType ?? configuration?.provisioningType ?? ProvisioningType.jit,
index f17d87d5b4c63c36fc2f25099f4580ce948450b6..41845a5b896dd04f428efed3379566ff8125ef53 100644 (file)
@@ -55,8 +55,8 @@ export default function GitLabConfigurationForm(props: Readonly<Props>) {
   const { data } = props;
   const isCreate = data === null;
   const [errors, setErrors] = React.useState<Record<string, ErrorValue>>({});
-  const { mutate: createConfig, isLoading: createLoading } = useCreateGitLabConfigurationMutation();
-  const { mutate: updateConfig, isLoading: updateLoading } = useUpdateGitLabConfigurationMutation();
+  const { mutate: createConfig, isPending: createLoading } = useCreateGitLabConfigurationMutation();
+  const { mutate: updateConfig, isPending: updateLoading } = useUpdateGitLabConfigurationMutation();
 
   const [formData, setFormData] = React.useState<
     Record<keyof GitLabConfigurationCreateBody, FormData>
index 160285095023ac18348878315ec76b9b8579b5a9..d582ecd64a83b128f48f05c54a8e068629bebe00 100644 (file)
@@ -86,7 +86,7 @@ export default function GithubAuthenticationTab(props: GithubAuthenticationProps
     setRolesMapping,
     applyAdditionalOptions,
     hasLegacyConfiguration,
-    deleteMutation: { isLoading: isDeleting, mutate: deleteConfiguration },
+    deleteMutation: { isPending: isDeleting, mutate: deleteConfiguration },
   } = useGithubConfiguration(definitions);
 
   const provisioningStatus =
index b253dc807878e960464aa230a156c2912080d6f6..cb0c2b6c9eb9b13781836208892699cc1928cdbb 100644 (file)
@@ -68,7 +68,7 @@ export default function SamlAuthenticationTab(props: SamlAuthenticationProps) {
     newScimStatus,
     setNewScimStatus,
     setNewGroupSetting,
-    deleteMutation: { isLoading: isDeleting, mutate: deleteConfiguration },
+    deleteMutation: { isPending: isDeleting, mutate: deleteConfiguration },
   } = useSamlConfiguration(definitions);
   const toggleScim = useToggleScimMutation();
 
index 5da48c1bb73c456f853bfdf7b13142c6b9aa558e..a56bf2fcb1a7fe0e4b517f6974a079c07f429dea 100644 (file)
@@ -80,10 +80,10 @@ export function PRDecorationBinding(props: Props) {
   const [successfullyUpdated, setSuccessfullyUpdated] = React.useState(false);
   const [checkingConfiguration, setCheckingConfiguration] = React.useState(false);
   const { data: originalData } = useProjectBindingQuery(component.key);
-  const { mutateAsync: deleteMutation, isLoading: isDeleting } = useDeleteProjectAlmBindingMutation(
+  const { mutateAsync: deleteMutation, isPending: isDeleting } = useDeleteProjectAlmBindingMutation(
     component.key,
   );
-  const { mutateAsync: updateMutation, isLoading: isUpdating } = useSetProjectBindingMutation();
+  const { mutateAsync: updateMutation, isPending: isUpdating } = useSetProjectBindingMutation();
 
   const isConfigured = !!originalData;
   const updating = isDeleting || isUpdating;
index 40c4f688b6aa21d25b2392dffa17b36fecdeca40..c681a0dc0acfa5e4866eeb22f98c1c215497c837 100644 (file)
@@ -43,7 +43,7 @@ export default function DeactivateForm(props: Props) {
   const { user } = props;
   const [anonymize, setAnonymize] = React.useState(false);
 
-  const { mutate: deactivateUser, isLoading } = useDeactivateUserMutation();
+  const { mutate: deactivateUser, isPending } = useDeactivateUserMutation();
 
   const handleDeactivate = (event: React.SyntheticEvent<HTMLFormElement>) => {
     event.preventDefault();
@@ -88,9 +88,9 @@ export default function DeactivateForm(props: Props) {
         </form>
       }
       onClose={props.onClose}
-      loading={isLoading}
+      loading={isPending}
       primaryButton={
-        <DangerButtonPrimary form={DEACTIVATE_FORM_ID} disabled={isLoading} type="submit">
+        <DangerButtonPrimary form={DEACTIVATE_FORM_ID} disabled={isPending} type="submit">
           {translate('users.deactivate')}
         </DangerButtonPrimary>
       }
index 6961767c107c4542ab9ccc134e790852efbccf37..42b2cbaa6ae16d7d69f1847dbe4eac8291a64fcf 100644 (file)
@@ -73,7 +73,7 @@ export function TokensForm(props: Readonly<Props>) {
   const [tokenExpirationOptions, setTokenExpirationOptions] =
     React.useState<{ value: TokenExpiration; label: string }[]>(EXPIRATION_OPTIONS);
 
-  const { mutateAsync: generate, isLoading: generating } = useGenerateTokenMutation();
+  const { mutateAsync: generate, isPending: generating } = useGenerateTokenMutation();
 
   const tokenTypeOptions = React.useMemo(() => {
     const value = [{ label: translate('users.tokens', TokenType.User), value: TokenType.User }];
index 84e81312d0ad65030b5cc297414c341e6c4ab7ed..c6ec562dba385a70a15ebc6d1f487c1c5bcfd531 100644 (file)
@@ -48,7 +48,7 @@ interface Props {
 export default function TokensFormItem(props: Readonly<Props>) {
   const { token, deleteConfirmation, login } = props;
   const [showConfirmation, setShowConfirmation] = React.useState(false);
-  const { mutateAsync, isLoading } = useRevokeTokenMutation();
+  const { mutateAsync, isPending } = useRevokeTokenMutation();
 
   const handleRevoke = () => mutateAsync({ login, name: token.name });
 
@@ -116,11 +116,11 @@ export default function TokensFormItem(props: Readonly<Props>) {
       <ContentCell>
         {token.isExpired && (
           <DangerButtonSecondary
-            disabled={isLoading}
+            disabled={isPending}
             onClick={handleRevoke}
             aria-label={translateWithParameters('users.tokens.remove_label', token.name)}
           >
-            <Spinner className="sw-mr-1" loading={isLoading}>
+            <Spinner className="sw-mr-1" loading={isPending}>
               {translate('remove')}
             </Spinner>
           </DangerButtonSecondary>
@@ -142,7 +142,7 @@ export default function TokensFormItem(props: Readonly<Props>) {
           >
             {({ onClick }) => (
               <DangerButtonSecondary
-                disabled={isLoading}
+                disabled={isPending}
                 onClick={onClick}
                 aria-label={translateWithParameters('users.tokens.revoke_label', token.name)}
               >
@@ -159,10 +159,10 @@ export default function TokensFormItem(props: Readonly<Props>) {
                 ? translate('users.tokens.sure')
                 : translateWithParameters('users.tokens.revoke_label', token.name)
             }
-            disabled={isLoading}
+            disabled={isPending}
             onClick={handleClick}
           >
-            <Spinner className="sw-mr-1" loading={isLoading} />
+            <Spinner className="sw-mr-1" loading={isPending} />
 
             {showConfirmation ? translate('users.tokens.sure') : translate('users.tokens.revoke')}
           </DangerButtonSecondary>
index 21a167daa483b199e274e70ddb6bf45e13e4ba9b..8e572e5353ed2d7e109035ec450af5d34e5df068 100644 (file)
@@ -48,8 +48,8 @@ const INTERNAL_SERVER_ERROR = 500;
 export default function UserForm(props: Props) {
   const { user, isInstanceManaged } = props;
 
-  const { mutate: createUser, isLoading: isLoadingCreate } = usePostUserMutation();
-  const { mutate: updateUser, isLoading: isLoadingUserUpdate } = useUpdateUserMutation();
+  const { mutate: createUser, isPending: isLoadingCreate } = usePostUserMutation();
+  const { mutate: updateUser, isPending: isLoadingUserUpdate } = useUpdateUserMutation();
 
   const [email, setEmail] = React.useState<string>(user?.email ?? '');
   const [login, setLogin] = React.useState<string>(user?.login ?? '');
index f8346b94b08541fd2cf42689b80a3e7713e9f327..914ee8167aa5e6e609ba6634aa3a577a1b6288d3 100644 (file)
@@ -67,7 +67,8 @@ export function useBadgeMetricsQuery() {
 }
 
 export function useBadgeTokenQuery(componentKey: string) {
-  return useQuery(['badges-token', componentKey] as const, ({ queryKey: [_, key] }) =>
-    getProjectBadgesToken(key),
-  );
+  return useQuery({
+    queryKey: ['badges-token', componentKey] as const,
+    queryFn: ({ queryKey: [_, key] }) => getProjectBadgesToken(key),
+  });
 }
index 50e225fb5f27a44b9984c559f01ad52bfd5bb1b7..4620641a5cc75ce84d23322dd3f3c78413ba639c 100644 (file)
@@ -40,36 +40,39 @@ function useProjectKeyFromLocation() {
 
 export function useProjectBindingQuery<T = ProjectAlmBindingResponse>(
   project?: string,
-  options?: UseQueryOptions<
-    ProjectAlmBindingResponse,
-    unknown,
-    T,
-    ['devops_integration', string, 'binding']
+  options?: Omit<
+    UseQueryOptions<
+      ProjectAlmBindingResponse | null,
+      Error,
+      T,
+      ['devops_integration', string, 'binding']
+    >,
+    'queryKey' | 'queryFn'
   >,
 ) {
   const keyFromUrl = useProjectKeyFromLocation();
 
   const projectKey = project ?? keyFromUrl;
 
-  return useQuery(
-    ['devops_integration', projectKey, 'binding'],
-    ({ queryKey: [_, key] }) =>
+  return useQuery({
+    queryKey: ['devops_integration', projectKey, 'binding'],
+    queryFn: ({ queryKey: [_, key] }) =>
       getProjectAlmBinding(key).catch((e: Response) => {
         if (e.status === HttpStatus.NotFound) {
           return null;
         }
-        throw e;
+        return e;
       }),
-    {
-      staleTime: 60_000,
-      retry: false,
-      ...options,
-    },
-  );
+    staleTime: 60_000,
+    retry: false,
+    ...options,
+  });
 }
 
 export function useIsGitHubProjectQuery(project?: string) {
-  return useProjectBindingQuery(project, { select: (data) => data?.alm === AlmKeys.GitHub });
+  return useProjectBindingQuery<boolean>(project, {
+    select: (data) => data?.alm === AlmKeys.GitHub,
+  });
 }
 
 export function useDeleteProjectAlmBindingMutation(project?: string) {
@@ -78,7 +81,9 @@ export function useDeleteProjectAlmBindingMutation(project?: string) {
   return useMutation({
     mutationFn: () => deleteProjectAlmBinding(project ?? keyFromUrl),
     onSuccess: () => {
-      client.invalidateQueries(['devops_integration', project ?? keyFromUrl, 'binding']);
+      client.invalidateQueries({
+        queryKey: ['devops_integration', project ?? keyFromUrl, 'binding'],
+      });
     },
   });
 }
@@ -153,7 +158,7 @@ export function useSetProjectBindingMutation() {
   return useMutation({
     mutationFn: (data: SetBindingParams) => getSetProjectBindingFn(data),
     onSuccess: (_, variables) => {
-      client.invalidateQueries(['devops_integration', variables.project, 'binding']);
+      client.invalidateQueries({ queryKey: ['devops_integration', variables.project, 'binding'] });
     },
   });
 }
index a513895ca7ec3e6a059764e9109f25e113ecafad..457040f34cf8d0d5538307a9c25a0334fc7590a2 100644 (file)
@@ -41,8 +41,8 @@ export function useGroupMembersQuery(params: {
   pageIndex?: number;
 }) {
   return useInfiniteQuery({
-    queryKey: [DOMAIN, GROUP_SUB_DOMAIN, params],
-    queryFn: async ({ pageParam = 1 }) => {
+    queryKey: [DOMAIN, GROUP_SUB_DOMAIN, 'list', params],
+    queryFn: async ({ pageParam }) => {
       if (params.filter === SelectListFilter.All) {
         const result = await getUsers<RestUserDetailed>({
           q: params.q ?? '',
@@ -77,9 +77,17 @@ export function useGroupMembersQuery(params: {
     },
     getNextPageParam,
     getPreviousPageParam,
+    initialPageParam: 1,
   });
 }
 
+export function useRemoveGroupMembersQueryFromCache() {
+  const queryClient = useQueryClient();
+  return () => {
+    queryClient.removeQueries({ queryKey: [DOMAIN, GROUP_SUB_DOMAIN, 'list'] });
+  };
+}
+
 export function useUserGroupsQuery(params: {
   filter?: SelectListFilter;
   q?: string;
@@ -88,21 +96,22 @@ export function useUserGroupsQuery(params: {
   const { q, filter, userId } = params;
   const {
     data: groupsPages,
-    isLoading: loadingGroups,
+    isPending: loadingGroups,
     fetchNextPage: fetchNextPageGroups,
     hasNextPage: hasNextPageGroups,
   } = useGroupsQueries({});
   const {
     data: membershipsPages,
-    isLoading: loadingMemberships,
+    isPending: loadingMemberships,
     fetchNextPage: fetchNextPageMemberships,
     hasNextPage: hasNextPageMemberships,
   } = useInfiniteQuery({
     queryKey: [DOMAIN, USER_SUB_DOMAIN, 'memberships', userId],
-    queryFn: ({ pageParam = 1 }) =>
+    queryFn: ({ pageParam }) =>
       getGroupMemberships({ userId, pageSize: 100, pageIndex: pageParam }),
     getNextPageParam,
     getPreviousPageParam,
+    initialPageParam: 1,
   });
   if (hasNextPageGroups) {
     fetchNextPageGroups();
@@ -167,7 +176,9 @@ export function useAddGroupMembershipMutation() {
         [DOMAIN, USER_SUB_DOMAIN, 'count', data.userId],
         (oldData) => (oldData !== undefined ? oldData + 1 : undefined),
       );
-      queryClient.invalidateQueries([DOMAIN, USER_SUB_DOMAIN, 'memberships', data.userId]);
+      queryClient.invalidateQueries({
+        queryKey: [DOMAIN, USER_SUB_DOMAIN, 'memberships', data.userId],
+      });
     },
   });
 }
@@ -194,7 +205,9 @@ export function useRemoveGroupMembershipMutation() {
         [DOMAIN, USER_SUB_DOMAIN, 'count', data.userId],
         (oldData) => (oldData !== undefined ? oldData - 1 : undefined),
       );
-      queryClient.invalidateQueries([DOMAIN, USER_SUB_DOMAIN, 'memberships', data.userId]);
+      queryClient.invalidateQueries({
+        queryKey: [DOMAIN, USER_SUB_DOMAIN, 'memberships', data.userId],
+      });
     },
   });
 }
index ea96fa495e87f52a659d7038e437290ffe31be30..ac331a7047354fa2b6324a3dff9b327642e14c30 100644 (file)
@@ -26,9 +26,10 @@ export function useGroupsQueries(
 ) {
   return useInfiniteQuery({
     queryKey: ['group', 'list', getParams],
-    queryFn: ({ pageParam = 1 }) => getUsersGroups({ ...getParams, pageIndex: pageParam }),
+    queryFn: ({ pageParam }) => getUsersGroups({ ...getParams, pageIndex: pageParam }),
     getNextPageParam,
     getPreviousPageParam,
+    initialPageParam: 1,
   });
 }
 
index 4bba1554aa79813c8eb07374aeaf473c5982b7ef..fd080b4e28136b14bd0deecefceccf0bf507a8e4 100644 (file)
@@ -22,8 +22,11 @@ import { getSystemInfo } from '../../api/system';
 import { SysInfoCluster } from '../../types/types';
 
 export function useIdentityProviderQuery() {
-  return useQuery(['identity_provider', 'users_and_groups_provider'], async () => {
-    const info = (await getSystemInfo()) as SysInfoCluster;
-    return { provider: info.System['External Users and Groups Provisioning'] };
+  return useQuery({
+    queryKey: ['identity_provider', 'users_and_groups_provider'],
+    queryFn: async () => {
+      const info = (await getSystemInfo()) as SysInfoCluster;
+      return { provider: info.System['External Users and Groups Provisioning'] };
+    },
   });
 }
index d7b6152ec49a0aa1d12a2085cdf89c2f9a71748b..694ac7d5ff077059fe37a253dabf426264729e36 100644 (file)
@@ -52,7 +52,9 @@ export function useToggleGithubProvisioningMutation() {
 }
 
 export const useCheckGitHubConfigQuery = (githubEnabled: boolean) => {
-  return useQuery(['identity_provider', 'github_check'], checkConfigurationValidity, {
+  return useQuery({
+    queryKey: ['identity_provider', 'github_check'],
+    queryFn: checkConfigurationValidity,
     enabled: githubEnabled,
   });
 };
@@ -65,7 +67,9 @@ export function useGitHubSyncStatusQuery(options: GithubSyncStatusOptions = {})
   const hasGithubProvisioning = useContext(AvailableFeaturesContext).includes(
     Feature.GithubProvisioning,
   );
-  return useQuery(['identity_provider', 'github_sync', 'status'], fetchGithubProvisioningStatus, {
+  return useQuery({
+    queryKey: ['identity_provider', 'github_sync', 'status'],
+    queryFn: fetchGithubProvisioningStatus,
     enabled: hasGithubProvisioning,
     refetchInterval: options.noRefetch ? undefined : 10_000,
   });
@@ -80,15 +84,16 @@ export function useGithubProvisioningEnabledQuery() {
 export function useSyncWithGitHubNow() {
   const queryClient = useQueryClient();
   const { data } = useGitHubSyncStatusQuery();
-  const mutation = useMutation(syncNowGithubProvisioning, {
+  const mutation = useMutation({
+    mutationFn: syncNowGithubProvisioning,
     onSuccess: () => {
-      queryClient.invalidateQueries(['identity_provider', 'github_sync']);
+      queryClient.invalidateQueries({ queryKey: ['identity_provider', 'github_sync'] });
     },
   });
 
   return {
     synchronizeNow: mutation.mutate,
-    canSyncNow: data?.enabled && !data.nextSync && !mutation.isLoading,
+    canSyncNow: data?.enabled && !data.nextSync && !mutation.isPending,
   };
 }
 
@@ -96,7 +101,9 @@ export function useSyncWithGitHubNow() {
 const defaultRoleOrder = ['admin', 'maintain', 'write', 'triage', 'read'];
 
 export function useGithubRolesMappingQuery() {
-  return useQuery(['identity_provider', 'github_mapping'], fetchGithubRolesMapping, {
+  return useQuery({
+    queryKey: ['identity_provider', 'github_mapping'],
+    queryFn: fetchGithubRolesMapping,
     staleTime: MAPPING_STALE_TIME,
     select: (data) =>
       [...data].sort((a, b) => {
index 1169288650651021472ce8c93aea6cf0481b537d..4af3d08e2850bbd98dbce3b3002e7179844c7dd5 100644 (file)
@@ -32,7 +32,10 @@ import { AlmSyncStatus, ProvisioningType } from '../../types/provisioning';
 import { TaskStatuses, TaskTypes } from '../../types/tasks';
 
 export function useGitLabConfigurationsQuery() {
-  return useQuery(['identity_provider', 'gitlab_config', 'list'], fetchGitLabConfigurations);
+  return useQuery({
+    queryKey: ['identity_provider', 'gitlab_config', 'list'],
+    queryFn: fetchGitLabConfigurations,
+  });
 }
 
 export function useCreateGitLabConfigurationMutation() {
@@ -141,19 +144,17 @@ export function useGitLabSyncStatusQuery() {
     return { status: nextSync.status as TaskStatuses.Pending | TaskStatuses.InProgress };
   };
 
-  return useQuery(
-    ['identity_provider', 'gitlab_sync', 'status'],
-    async () => {
+  return useQuery({
+    queryKey: ['identity_provider', 'gitlab_sync', 'status'],
+    queryFn: async () => {
       const [lastSync, nextSync] = await Promise.all([getLastSync(), getNextSync()]);
       return {
         lastSync,
         nextSync,
       } as AlmSyncStatus;
     },
-    {
-      refetchInterval: 10_000,
-    },
-  );
+    refetchInterval: 10_000,
+  });
 }
 
 export function useSyncWithGitLabNow() {
@@ -164,14 +165,15 @@ export function useSyncWithGitLabNow() {
     (configuration) =>
       configuration.enabled && configuration.provisioningType === ProvisioningType.auto,
   );
-  const mutation = useMutation(syncNowGitLabProvisioning, {
+  const mutation = useMutation({
+    mutationFn: syncNowGitLabProvisioning,
     onSuccess: () => {
-      queryClient.invalidateQueries(['identity_provider', 'gitlab_sync']);
+      queryClient.invalidateQueries({ queryKey: ['identity_provider', 'gitlab_sync'] });
     },
   });
 
   return {
     synchronizeNow: mutation.mutate,
-    canSyncNow: autoProvisioningEnabled && !syncStatus?.nextSync && !mutation.isLoading,
+    canSyncNow: autoProvisioningEnabled && !syncStatus?.nextSync && !mutation.isPending,
   };
 }
index 16e2f3b60ebb258174c1b7b44448e1139e0d02b9..5ead680bd96700d23bc3a25e14995f35ffa1c873 100644 (file)
@@ -26,11 +26,14 @@ import { Feature } from '../../types/features';
 export function useScimStatusQuery() {
   const hasScim = useContext(AvailableFeaturesContext).includes(Feature.Scim);
 
-  return useQuery(['identity_provider', 'scim_status'], () => {
-    if (!hasScim) {
-      return false;
-    }
-    return fetchIsScimEnabled();
+  return useQuery({
+    queryKey: ['identity_provider', 'scim_status'],
+    queryFn: () => {
+      if (!hasScim) {
+        return false;
+      }
+      return fetchIsScimEnabled();
+    },
   });
 }
 
index 6642a6f4704a510633f25103e4fb906a19e874ff..cf00c317e0e850a87e94904d942f7770d090a1ac 100644 (file)
@@ -36,11 +36,13 @@ export function useNewCodeDefinitionQuery(params?: {
   enabled?: boolean;
   projectKey?: string;
 }) {
-  return useQuery(
-    getNewCodeDefinitionQueryKey(params?.projectKey, params?.branchName),
-    () => getNewCodeDefinition({ branch: params?.branchName, project: params?.projectKey }),
-    { enabled: params?.enabled ?? true, refetchOnWindowFocus: false },
-  );
+  return useQuery({
+    queryKey: getNewCodeDefinitionQueryKey(params?.projectKey, params?.branchName),
+    queryFn: () =>
+      getNewCodeDefinition({ branch: params?.branchName, project: params?.projectKey }),
+    enabled: params?.enabled ?? true,
+    refetchOnWindowFocus: false,
+  });
 }
 
 export function useNewCodeDefinitionMutation() {
index f73b05c7bd5b1aa203e63fa3e85ab694066701d8..7ef74ae3703d700ba60ca5b8cb6b4aa226151179 100644 (file)
@@ -80,7 +80,7 @@ export function useCreateQualityGateMutation() {
       return createQualityGate({ name });
     },
     onSuccess: () => {
-      queryClient.invalidateQueries(getQualityGateQueryKey());
+      queryClient.invalidateQueries({ queryKey: getQualityGateQueryKey() });
     },
   });
 }
@@ -93,8 +93,8 @@ export function useSetQualityGateAsDefaultMutation(gateName: string) {
       return setQualityGateAsDefault({ name: qualityGate.name });
     },
     onSuccess: () => {
-      queryClient.invalidateQueries(getQualityGateQueryKey());
-      queryClient.invalidateQueries(getQualityGateQueryKey('name', gateName));
+      queryClient.invalidateQueries({ queryKey: getQualityGateQueryKey() });
+      queryClient.invalidateQueries({ queryKey: getQualityGateQueryKey('name', gateName) });
     },
   });
 }
@@ -107,8 +107,8 @@ export function useRenameQualityGateMutation(currentName: string) {
       return renameQualityGate({ currentName, name: newName });
     },
     onSuccess: (_, newName: string) => {
-      queryClient.invalidateQueries(getQualityGateQueryKey());
-      queryClient.invalidateQueries(getQualityGateQueryKey('name', newName));
+      queryClient.invalidateQueries({ queryKey: getQualityGateQueryKey() });
+      queryClient.invalidateQueries({ queryKey: getQualityGateQueryKey('name', newName) });
     },
   });
 }
@@ -121,7 +121,7 @@ export function useCopyQualityGateMutation(sourceName: string) {
       return copyQualityGate({ sourceName, name: newName });
     },
     onSuccess: () => {
-      queryClient.invalidateQueries(getQualityGateQueryKey());
+      queryClient.invalidateQueries({ queryKey: getQualityGateQueryKey() });
     },
   });
 }
@@ -134,7 +134,7 @@ export function useDeleteQualityGateMutation(name: string) {
       return deleteQualityGate({ name });
     },
     onSuccess: () => {
-      queryClient.invalidateQueries(getQualityGateQueryKey());
+      queryClient.invalidateQueries({ queryKey: getQualityGateQueryKey() });
     },
   });
 }
@@ -169,8 +169,8 @@ export function useFixQualityGateMutation(gateName: string) {
       return Promise.all(promiseArr);
     },
     onSuccess: () => {
-      queryClient.invalidateQueries(getQualityGateQueryKey());
-      queryClient.invalidateQueries(getQualityGateQueryKey('name', gateName));
+      queryClient.invalidateQueries({ queryKey: getQualityGateQueryKey() });
+      queryClient.invalidateQueries({ queryKey: getQualityGateQueryKey('name', gateName) });
       addGlobalSuccessMessage(translate('quality_gates.conditions_updated'));
     },
   });
@@ -184,7 +184,7 @@ export function useCreateConditionMutation(gateName: string) {
       return createCondition({ ...condition, gateName });
     },
     onSuccess: (_, condition) => {
-      queryClient.invalidateQueries(getQualityGateQueryKey());
+      queryClient.invalidateQueries({ queryKey: getQualityGateQueryKey() });
       queryClient.setQueryData(
         getQualityGateQueryKey('name', gateName),
         (oldData?: QualityGate) => {
@@ -196,7 +196,7 @@ export function useCreateConditionMutation(gateName: string) {
             : undefined;
         },
       );
-      queryClient.invalidateQueries(getQualityGateQueryKey('name', gateName));
+      queryClient.invalidateQueries({ queryKey: getQualityGateQueryKey('name', gateName) });
       addGlobalSuccessMessage(translate('quality_gates.condition_added'));
     },
   });
@@ -210,8 +210,8 @@ export function useUpdateConditionMutation(gateName: string) {
       return updateCondition(condition);
     },
     onSuccess: () => {
-      queryClient.invalidateQueries(getQualityGateQueryKey());
-      queryClient.invalidateQueries(getQualityGateQueryKey('name', gateName));
+      queryClient.invalidateQueries({ queryKey: getQualityGateQueryKey() });
+      queryClient.invalidateQueries({ queryKey: getQualityGateQueryKey('name', gateName) });
       addGlobalSuccessMessage(translate('quality_gates.condition_updated'));
     },
   });
@@ -227,8 +227,8 @@ export function useDeleteConditionMutation(gateName: string) {
       });
     },
     onSuccess: () => {
-      queryClient.invalidateQueries(getQualityGateQueryKey());
-      queryClient.invalidateQueries(getQualityGateQueryKey('name', gateName));
+      queryClient.invalidateQueries({ queryKey: getQualityGateQueryKey() });
+      queryClient.invalidateQueries({ queryKey: getQualityGateQueryKey('name', gateName) });
       addGlobalSuccessMessage(translate('quality_gates.condition_deleted'));
     },
   });
index f61420dcbac428323810bccb770940d575b19e9f..225957e384f5bb06a2e21b909da3502a2c51723f 100644 (file)
@@ -26,14 +26,20 @@ import { ExtendedSettingDefinition } from '../types/settings';
 type SettingValue = string | boolean | string[];
 
 export function useGetValuesQuery(keys: string[]) {
-  return useQuery(['settings', 'values', keys] as const, ({ queryKey: [_a, _b, keys] }) => {
-    return getValues({ keys });
+  return useQuery({
+    queryKey: ['settings', 'values', keys] as const,
+    queryFn: ({ queryKey: [_a, _b, keys] }) => {
+      return getValues({ keys });
+    },
   });
 }
 
 export function useGetValueQuery(key: string, component?: string) {
-  return useQuery(['settings', 'details', key] as const, ({ queryKey: [_a, _b, key] }) => {
-    return getValue({ key, component }).then((v) => v ?? null);
+  return useQuery({
+    queryKey: ['settings', 'details', key] as const,
+    queryFn: ({ queryKey: [_a, _b, key] }) => {
+      return getValue({ key, component }).then((v) => v ?? null);
+    },
   });
 }
 
@@ -44,9 +50,9 @@ export function useResetSettingsMutation() {
       resetSettingValue({ keys: keys.join(','), component }),
     onSuccess: (_, { keys }) => {
       keys.forEach((key) => {
-        queryClient.invalidateQueries(['settings', 'details', key]);
+        queryClient.invalidateQueries({ queryKey: ['settings', 'details', key] });
       });
-      queryClient.invalidateQueries(['settings', 'values']);
+      queryClient.invalidateQueries({ queryKey: ['settings', 'values'] });
     },
   });
 }
@@ -80,9 +86,9 @@ export function useSaveValuesMutation() {
     onSuccess: (data) => {
       if (data.length > 0) {
         data.forEach(({ key }) => {
-          queryClient.invalidateQueries(['settings', 'details', key]);
+          queryClient.invalidateQueries({ queryKey: ['settings', 'details', key] });
         });
-        queryClient.invalidateQueries(['settings', 'values']);
+        queryClient.invalidateQueries({ queryKey: ['settings', 'values'] });
         addGlobalSuccessMessage(translate('settings.authentication.form.settings.save_success'));
       }
     },
@@ -107,8 +113,8 @@ export function useSaveValueMutation() {
       return setSettingValue(definition, newValue, component);
     },
     onSuccess: (_, { definition }) => {
-      queryClient.invalidateQueries(['settings', 'details', definition.key]);
-      queryClient.invalidateQueries(['settings', 'values']);
+      queryClient.invalidateQueries({ queryKey: ['settings', 'details', definition.key] });
+      queryClient.invalidateQueries({ queryKey: ['settings', 'values'] });
       addGlobalSuccessMessage(translate('settings.authentication.form.settings.save_success'));
     },
   });
index 3991572059db6515ff15aa1fd5da938fbeeb1b6d..c7391c0b002f967ebd94bbc4c7cb63f6b01e3662 100644 (file)
@@ -33,10 +33,11 @@ export function useUsersQueries<U extends RestUserBase>(
 ) {
   return useInfiniteQuery({
     queryKey: ['user', 'list', getParams],
-    queryFn: ({ pageParam = 1 }) => getUsers<U>({ ...getParams, pageIndex: pageParam }),
+    queryFn: ({ pageParam }) => getUsers<U>({ ...getParams, pageIndex: pageParam }),
     getNextPageParam,
     getPreviousPageParam,
     enabled,
+    initialPageParam: 1,
   });
 }
 
index de1f0291bedfe8b212bd706b3cddeea751fa7645..bbb1ff2086391b2193ab4d77c93e76b95ba6c06d 100644 (file)
@@ -21,9 +21,14 @@ import { useQuery } from '@tanstack/react-query';
 import { fetchOpenAPI, fetchWebApi } from '../api/web-api';
 
 export function useWebApiQuery() {
-  return useQuery(['web-api'], () => fetchWebApi(false));
+  return useQuery({ queryKey: ['web-api'], queryFn: () => fetchWebApi(false) });
 }
 
 export const useOpenAPI = () => {
-  return useQuery(['open_api'], fetchOpenAPI, { staleTime: Infinity, cacheTime: Infinity });
+  return useQuery({
+    queryKey: ['open_api'],
+    queryFn: fetchOpenAPI,
+    staleTime: Infinity,
+    gcTime: Infinity,
+  });
 };
index b07f184b41a24496213ea8fc34dfd4c44b5a0279..0338724de3bc8e4bd57ca8d79b8bdeab0d6afdd3 100644 (file)
@@ -4193,29 +4193,21 @@ __metadata:
   languageName: node
   linkType: hard
 
-"@tanstack/query-core@npm:4.33.0":
-  version: 4.33.0
-  resolution: "@tanstack/query-core@npm:4.33.0"
-  checksum: fae325f1d79b936435787797c32367331d5b8e9c5ced84852bf2085115e3aafef57a7ae530a6b0af46da4abafb4b0afaef885926b71715a0e6f166d74da61c7f
+"@tanstack/query-core@npm:5.18.1":
+  version: 5.18.1
+  resolution: "@tanstack/query-core@npm:5.18.1"
+  checksum: dd831e508fa4519a6e88af1f48e24c75f8c603d77dc603745c3f69ab6d650ba85b43041ab19572f20139dde13c56e6f477552228d469371b01ebe4268933a795
   languageName: node
   linkType: hard
 
-"@tanstack/react-query@npm:4.33.0":
-  version: 4.33.0
-  resolution: "@tanstack/react-query@npm:4.33.0"
+"@tanstack/react-query@npm:5.18.1":
+  version: 5.18.1
+  resolution: "@tanstack/react-query@npm:5.18.1"
   dependencies:
-    "@tanstack/query-core": 4.33.0
-    use-sync-external-store: ^1.2.0
+    "@tanstack/query-core": 5.18.1
   peerDependencies:
-    react: ^16.8.0 || ^17.0.0 || ^18.0.0
-    react-dom: ^16.8.0 || ^17.0.0 || ^18.0.0
-    react-native: "*"
-  peerDependenciesMeta:
-    react-dom:
-      optional: true
-    react-native:
-      optional: true
-  checksum: b3cf4afa427435e464e077b3f23c891e38e5f78873518f15c1d061ad55f1464d6241ecd92d796a5dbc9412b4fd7eb30b01f2a9cfc285ee9f30dfdd2ca0ecaf4b
+    react: ^18.0.0
+  checksum: d24d79b7bf464d0c80c72d6c93d5e51c7c400a0ed895f6bda9e6f53c3c576a08d7302193c70b6d5e2842981354a739ed9b12de9bb4e5fe35e8b41aa9e833f5af
   languageName: node
   linkType: hard
 
@@ -5229,7 +5221,7 @@ __metadata:
     "@react-spring/web": 9.7.3
     "@swc/core": 1.3.95
     "@swc/jest": 0.2.29
-    "@tanstack/react-query": 4.33.0
+    "@tanstack/react-query": 5.18.1
     "@testing-library/jest-dom": 6.1.4
     "@testing-library/react": 14.1.0
     "@testing-library/user-event": 14.5.1
@@ -13643,15 +13635,6 @@ __metadata:
   languageName: node
   linkType: hard
 
-"use-sync-external-store@npm:^1.2.0":
-  version: 1.2.0
-  resolution: "use-sync-external-store@npm:1.2.0"
-  peerDependencies:
-    react: ^16.8.0 || ^17.0.0 || ^18.0.0
-  checksum: 5c639e0f8da3521d605f59ce5be9e094ca772bd44a4ce7322b055a6f58eeed8dda3c94cabd90c7a41fb6fa852210092008afe48f7038792fd47501f33299116a
-  languageName: node
-  linkType: hard
-
 "util-deprecate@npm:^1.0.2, util-deprecate@npm:~1.0.1":
   version: 1.0.2
   resolution: "util-deprecate@npm:1.0.2"