"@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",
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();
});
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) => {
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 ?? [];
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),
);
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, {
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>
}
import {
useAddGroupMembershipMutation,
useGroupMembersQuery,
+ useRemoveGroupMembersQueryFromCache,
useRemoveGroupMembershipMutation,
} from '../../../queries/group-memberships';
import { Group } from '../../../types/types';
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) ?? [];
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 });
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 });
{dismissable && currentUser.isLoggedIn && (
<div className="sw-mt-4">
<DangerButtonSecondary
- disabled={Boolean(isLoading)}
+ disabled={Boolean(isPending)}
onClick={() => {
handleDismissMessage(key);
}}
{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>
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 });
};
const isTheMainBranch = isMainBranch(branch);
- const disabled = isTheMainBranch || isLoading;
+ const disabled = isTheMainBranch || isPending;
return (
<>
off: translate('off'),
}}
/>
- <Spinner loading={isLoading} className="sw-ml-1" />
+ <Spinner loading={isPending} className="sw-ml-1" />
{isTheMainBranch && (
<HelpTooltip
className="sw-ml-1"
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>) => {
/>
</form>
}
- loading={isLoading}
+ loading={isPending}
primaryButton={
<DangerButtonPrimary type="submit" form={FORM_ID}>
<FormattedMessage id="delete" />
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>) => {
}, []);
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
</FormField>
</form>
}
- loading={isLoading}
+ loading={isPending}
primaryButton={
<ButtonPrimary disabled={submitDisabled} type="submit" form={FORM_ID}>
<FormattedMessage id="rename" />
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>) => {
values={{ branch: <span className="sw-break-all">{branch.name}</span> }}
/>
}
- loading={isLoading}
+ loading={isPending}
onClose={onClose}
body={
<form id={FORM_ID} onSubmit={handleSubmit}>
</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>
}
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) => {
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));
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),
);
>(undefined);
const { data: newCodeDefinition, isLoading } = useNewCodeDefinitionQuery();
- const { isLoading: isSaving, mutate: postNewCodeDefinition } = useNewCodeDefinitionMutation();
+ const { isPending: isSaving, mutate: postNewCodeDefinition } = useNewCodeDefinitionMutation();
const resetNewCodeDefinition = useCallback(() => {
setSelectedNewCodeDefinitionType(newCodeDefinition?.type);
}
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',
'settings.authentication.github.configuration.roles_mapping.dialog.custom_roles_description',
)}
</FlagMessage>
- <Spinner loading={isLoading} />
+ <Spinner loading={isPending} />
</div>
);
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,
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>
setRolesMapping,
applyAdditionalOptions,
hasLegacyConfiguration,
- deleteMutation: { isLoading: isDeleting, mutate: deleteConfiguration },
+ deleteMutation: { isPending: isDeleting, mutate: deleteConfiguration },
} = useGithubConfiguration(definitions);
const provisioningStatus =
newScimStatus,
setNewScimStatus,
setNewGroupSetting,
- deleteMutation: { isLoading: isDeleting, mutate: deleteConfiguration },
+ deleteMutation: { isPending: isDeleting, mutate: deleteConfiguration },
} = useSamlConfiguration(definitions);
const toggleScim = useToggleScimMutation();
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;
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();
</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>
}
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 }];
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 });
<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>
>
{({ onClick }) => (
<DangerButtonSecondary
- disabled={isLoading}
+ disabled={isPending}
onClick={onClick}
aria-label={translateWithParameters('users.tokens.revoke_label', token.name)}
>
? 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>
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 ?? '');
}
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),
+ });
}
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) {
return useMutation({
mutationFn: () => deleteProjectAlmBinding(project ?? keyFromUrl),
onSuccess: () => {
- client.invalidateQueries(['devops_integration', project ?? keyFromUrl, 'binding']);
+ client.invalidateQueries({
+ queryKey: ['devops_integration', project ?? keyFromUrl, 'binding'],
+ });
},
});
}
return useMutation({
mutationFn: (data: SetBindingParams) => getSetProjectBindingFn(data),
onSuccess: (_, variables) => {
- client.invalidateQueries(['devops_integration', variables.project, 'binding']);
+ client.invalidateQueries({ queryKey: ['devops_integration', variables.project, 'binding'] });
},
});
}
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 ?? '',
},
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;
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();
[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],
+ });
},
});
}
[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],
+ });
},
});
}
) {
return useInfiniteQuery({
queryKey: ['group', 'list', getParams],
- queryFn: ({ pageParam = 1 }) => getUsersGroups({ ...getParams, pageIndex: pageParam }),
+ queryFn: ({ pageParam }) => getUsersGroups({ ...getParams, pageIndex: pageParam }),
getNextPageParam,
getPreviousPageParam,
+ initialPageParam: 1,
});
}
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'] };
+ },
});
}
}
export const useCheckGitHubConfigQuery = (githubEnabled: boolean) => {
- return useQuery(['identity_provider', 'github_check'], checkConfigurationValidity, {
+ return useQuery({
+ queryKey: ['identity_provider', 'github_check'],
+ queryFn: checkConfigurationValidity,
enabled: githubEnabled,
});
};
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,
});
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,
};
}
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) => {
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() {
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() {
(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,
};
}
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();
+ },
});
}
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() {
return createQualityGate({ name });
},
onSuccess: () => {
- queryClient.invalidateQueries(getQualityGateQueryKey());
+ queryClient.invalidateQueries({ queryKey: getQualityGateQueryKey() });
},
});
}
return setQualityGateAsDefault({ name: qualityGate.name });
},
onSuccess: () => {
- queryClient.invalidateQueries(getQualityGateQueryKey());
- queryClient.invalidateQueries(getQualityGateQueryKey('name', gateName));
+ queryClient.invalidateQueries({ queryKey: getQualityGateQueryKey() });
+ queryClient.invalidateQueries({ queryKey: getQualityGateQueryKey('name', gateName) });
},
});
}
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) });
},
});
}
return copyQualityGate({ sourceName, name: newName });
},
onSuccess: () => {
- queryClient.invalidateQueries(getQualityGateQueryKey());
+ queryClient.invalidateQueries({ queryKey: getQualityGateQueryKey() });
},
});
}
return deleteQualityGate({ name });
},
onSuccess: () => {
- queryClient.invalidateQueries(getQualityGateQueryKey());
+ queryClient.invalidateQueries({ queryKey: getQualityGateQueryKey() });
},
});
}
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'));
},
});
return createCondition({ ...condition, gateName });
},
onSuccess: (_, condition) => {
- queryClient.invalidateQueries(getQualityGateQueryKey());
+ queryClient.invalidateQueries({ queryKey: getQualityGateQueryKey() });
queryClient.setQueryData(
getQualityGateQueryKey('name', gateName),
(oldData?: QualityGate) => {
: undefined;
},
);
- queryClient.invalidateQueries(getQualityGateQueryKey('name', gateName));
+ queryClient.invalidateQueries({ queryKey: getQualityGateQueryKey('name', gateName) });
addGlobalSuccessMessage(translate('quality_gates.condition_added'));
},
});
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'));
},
});
});
},
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'));
},
});
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);
+ },
});
}
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'] });
},
});
}
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'));
}
},
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'));
},
});
) {
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,
});
}
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,
+ });
};
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
"@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
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"