Skip to content

Commit

Permalink
Fix administration page error for empty release feed url (#1667)
Browse files Browse the repository at this point in the history
  • Loading branch information
fscholdei committed May 31, 2021
1 parent a954e01 commit 9b7da23
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
2 changes: 2 additions & 0 deletions gradle/changelog/empty_release_feed_url.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- type: fixed
description: Fix administration page error for empty release feed url ([#1667](https://github.com/scm-manager/scm-manager/pull/1667))
15 changes: 11 additions & 4 deletions scm-ui/ui-api/src/admin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,21 @@
* SOFTWARE.
*/

import { ApiResult, useRequiredIndexLink } from "./base";
import { ApiResult, useIndexLink } from "./base";
import { UpdateInfo } from "@scm-manager/ui-types";
import { useQuery } from "react-query";
import { apiClient } from "@scm-manager/ui-components";

export const useUpdateInfo = (): ApiResult<UpdateInfo | null> => {
const indexLink = useRequiredIndexLink("updateInfo");
return useQuery<UpdateInfo | null, Error>("updateInfo", () =>
apiClient.get(indexLink).then(response => (response.status === 204 ? null : response.json()))
const indexLink = useIndexLink("updateInfo");
return useQuery<UpdateInfo | null, Error>(
"updateInfo",
() => {
if (!indexLink) {
throw new Error("could not find index data");
}
return apiClient.get(indexLink).then((response) => (response.status === 204 ? null : response.json()));
},
{ enabled: !!indexLink }
);
};

0 comments on commit 9b7da23

Please sign in to comment.