@scm-manager/ui-api 2.27.3-20211113-092021 → 2.27.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scm-manager/ui-api",
3
- "version": "2.27.3-20211113-092021",
3
+ "version": "2.27.3",
4
4
  "description": "React hook api for the SCM-Manager backend",
5
5
  "main": "src/index.ts",
6
6
  "files": [
@@ -25,10 +25,10 @@
25
25
  "react-test-renderer": "^17.0.1"
26
26
  },
27
27
  "dependencies": {
28
- "@scm-manager/ui-types": "^2.27.3-20211113-092021",
28
+ "@scm-manager/ui-types": "^2.27.3",
29
29
  "fetch-mock-jest": "^1.5.1",
30
30
  "gitdiff-parser": "^0.1.2",
31
- "query-string": "6.14.1",
31
+ "query-string": "5",
32
32
  "react": "^17.0.1",
33
33
  "react-query": "^3.25.1"
34
34
  },
@@ -36,38 +36,36 @@ describe("Test branches hooks", () => {
36
36
  type: "hg",
37
37
  _links: {
38
38
  branches: {
39
- href: "/hog/branches"
40
- }
41
- }
39
+ href: "/hog/branches",
40
+ },
41
+ },
42
42
  };
43
43
 
44
44
  const develop: Branch = {
45
45
  name: "develop",
46
46
  revision: "42",
47
- lastCommitter: { name: "trillian" },
48
47
  _links: {
49
48
  delete: {
50
- href: "/hog/branches/develop"
51
- }
52
- }
49
+ href: "/hog/branches/develop",
50
+ },
51
+ },
53
52
  };
54
53
 
55
54
  const feature: Branch = {
56
55
  name: "feature/something-special",
57
56
  revision: "42",
58
- lastCommitter: { name: "trillian" },
59
57
  _links: {
60
58
  delete: {
61
- href: "/hog/branches/feature%2Fsomething-special"
62
- }
63
- }
59
+ href: "/hog/branches/feature%2Fsomething-special",
60
+ },
61
+ },
64
62
  };
65
63
 
66
64
  const branches: BranchCollection = {
67
65
  _embedded: {
68
- branches: [develop]
66
+ branches: [develop],
69
67
  },
70
- _links: {}
68
+ _links: {},
71
69
  };
72
70
 
73
71
  const queryClient = createInfiniteCachingClient();
@@ -85,7 +83,7 @@ describe("Test branches hooks", () => {
85
83
  fetchMock.getOnce("/api/v2/hog/branches", branches);
86
84
 
87
85
  const { result, waitFor } = renderHook(() => useBranches(repository), {
88
- wrapper: createWrapper(undefined, queryClient)
86
+ wrapper: createWrapper(undefined, queryClient),
89
87
  });
90
88
  await waitFor(() => {
91
89
  return !!result.current.data;
@@ -106,7 +104,7 @@ describe("Test branches hooks", () => {
106
104
  "repository",
107
105
  "hitchhiker",
108
106
  "heart-of-gold",
109
- "branches"
107
+ "branches",
110
108
  ]);
111
109
  expect(data).toEqual(branches);
112
110
  });
@@ -117,7 +115,7 @@ describe("Test branches hooks", () => {
117
115
  fetchMock.getOnce("/api/v2/hog/branches/" + encodeURIComponent(name), branch);
118
116
 
119
117
  const { result, waitFor } = renderHook(() => useBranch(repository, name), {
120
- wrapper: createWrapper(undefined, queryClient)
118
+ wrapper: createWrapper(undefined, queryClient),
121
119
  });
122
120
 
123
121
  expect(result.error).toBeUndefined();
@@ -145,14 +143,14 @@ describe("Test branches hooks", () => {
145
143
  fetchMock.postOnce("/api/v2/hog/branches", {
146
144
  status: 201,
147
145
  headers: {
148
- Location: "/hog/branches/develop"
149
- }
146
+ Location: "/hog/branches/develop",
147
+ },
150
148
  });
151
149
 
152
150
  fetchMock.getOnce("/api/v2/hog/branches/develop", develop);
153
151
 
154
152
  const { result, waitForNextUpdate } = renderHook(() => useCreateBranch(repository), {
155
- wrapper: createWrapper(undefined, queryClient)
153
+ wrapper: createWrapper(undefined, queryClient),
156
154
  });
157
155
 
158
156
  await act(() => {
@@ -177,7 +175,7 @@ describe("Test branches hooks", () => {
177
175
  "hitchhiker",
178
176
  "heart-of-gold",
179
177
  "branch",
180
- "develop"
178
+ "develop",
181
179
  ]);
182
180
  expect(branch).toEqual(develop);
183
181
  });
@@ -194,11 +192,11 @@ describe("Test branches hooks", () => {
194
192
  describe("useDeleteBranch tests", () => {
195
193
  const deleteBranch = async () => {
196
194
  fetchMock.deleteOnce("/api/v2/hog/branches/develop", {
197
- status: 204
195
+ status: 204,
198
196
  });
199
197
 
200
198
  const { result, waitForNextUpdate } = renderHook(() => useDeleteBranch(repository), {
201
- wrapper: createWrapper(undefined, queryClient)
199
+ wrapper: createWrapper(undefined, queryClient),
202
200
  });
203
201
 
204
202
  await act(() => {
package/src/branches.ts CHANGED
@@ -21,33 +21,19 @@
21
21
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
22
  * SOFTWARE.
23
23
  */
24
- import {
25
- Branch,
26
- BranchCollection,
27
- BranchCreation,
28
- BranchDetailsCollection,
29
- Link, NamespaceAndName,
30
- Repository
31
- } from "@scm-manager/ui-types";
24
+ import { Branch, BranchCollection, BranchCreation, Link, Repository } from "@scm-manager/ui-types";
32
25
  import { requiredLink } from "./links";
33
- import { useInfiniteQuery, useMutation, useQuery, useQueryClient } from "react-query";
26
+ import { useMutation, useQuery, useQueryClient } from "react-query";
34
27
  import { ApiResult, ApiResultWithFetching } from "./base";
35
28
  import { branchQueryKey, repoQueryKey } from "./keys";
36
29
  import { apiClient } from "./apiclient";
37
30
  import { concat } from "./urls";
38
- import { useEffect } from "react";
39
31
 
40
32
  export const useBranches = (repository: Repository): ApiResult<BranchCollection> => {
41
- const queryClient = useQueryClient();
42
33
  const link = requiredLink(repository, "branches");
43
34
  return useQuery<BranchCollection, Error>(
44
35
  repoQueryKey(repository, "branches"),
45
- () => apiClient.get(link).then(response => response.json()),
46
- {
47
- onSuccess: () => {
48
- return queryClient.invalidateQueries(branchQueryKey(repository, "details"));
49
- }
50
- }
36
+ () => apiClient.get(link).then((response) => response.json())
51
37
  // we do not populate the cache for a single branch,
52
38
  // because we have no pagination for branches and if we have a lot of them
53
39
  // the population slows us down
@@ -57,87 +43,22 @@ export const useBranches = (repository: Repository): ApiResult<BranchCollection>
57
43
  export const useBranch = (repository: Repository, name: string): ApiResultWithFetching<Branch> => {
58
44
  const link = requiredLink(repository, "branches");
59
45
  return useQuery<Branch, Error>(branchQueryKey(repository, name), () =>
60
- apiClient.get(concat(link, encodeURIComponent(name))).then(response => response.json())
46
+ apiClient.get(concat(link, encodeURIComponent(name))).then((response) => response.json())
61
47
  );
62
48
  };
63
49
 
64
- function chunkBranches(branches: Branch[]) {
65
- const chunks: Branch[][] = [];
66
- const chunkSize = 5;
67
- let chunkIndex = 0;
68
- for (const branch of branches) {
69
- if (!chunks[chunkIndex]) {
70
- chunks[chunkIndex] = [];
71
- }
72
- chunks[chunkIndex].push(branch);
73
- if (chunks[chunkIndex].length >= chunkSize) {
74
- chunkIndex = chunkIndex + 1;
75
- }
76
- }
77
- return chunks;
78
- }
79
-
80
- const branchDetailsQueryKey = (
81
- repository: NamespaceAndName,
82
- branch: string | undefined = undefined,
83
- ...values: unknown[]
84
- ) => {
85
- let branchName;
86
- if (!branch) {
87
- branchName = "_";
88
- } else {
89
- branchName = branch;
90
- }
91
- return [...repoQueryKey(repository), "branch-details", branchName, ...values];
92
- };
93
-
94
- export const useBranchDetailsCollection = (repository: Repository, branches: Branch[]) => {
95
- const link = requiredLink(repository, "branchDetailsCollection");
96
- const chunks = chunkBranches(branches);
97
-
98
- const { data, isLoading, error, fetchNextPage } = useInfiniteQuery<
99
- BranchDetailsCollection,
100
- Error,
101
- BranchDetailsCollection
102
- >(
103
- branchDetailsQueryKey(repository),
104
- ({ pageParam = 0 }) => {
105
- const encodedBranches = chunks[pageParam]?.map(b => encodeURIComponent(b.name)).join("&branches=");
106
- return apiClient.get(concat(link, `?branches=${encodedBranches}`)).then(response => response.json());
107
- },
108
- {
109
- getNextPageParam: (lastPage, allPages) => {
110
- if (allPages.length >= chunks.length) {
111
- return undefined;
112
- }
113
- return allPages.length;
114
- }
115
- }
116
- );
117
-
118
- useEffect(() => {
119
- fetchNextPage();
120
- }, [data, fetchNextPage]);
121
-
122
- return {
123
- data: data?.pages?.map(d => d._embedded?.branchDetails).flat(1),
124
- isLoading,
125
- error
126
- };
127
- };
128
-
129
50
  const createBranch = (link: string) => {
130
51
  return (branch: BranchCreation) => {
131
52
  return apiClient
132
53
  .post(link, branch, "application/vnd.scmm-branchRequest+json;v=2")
133
- .then(response => {
54
+ .then((response) => {
134
55
  const location = response.headers.get("Location");
135
56
  if (!location) {
136
57
  throw new Error("Server does not return required Location header");
137
58
  }
138
59
  return apiClient.get(location);
139
60
  })
140
- .then(response => response.json());
61
+ .then((response) => response.json());
141
62
  };
142
63
  };
143
64
 
@@ -145,23 +66,23 @@ export const useCreateBranch = (repository: Repository) => {
145
66
  const queryClient = useQueryClient();
146
67
  const link = requiredLink(repository, "branches");
147
68
  const { mutate, isLoading, error, data } = useMutation<Branch, Error, BranchCreation>(createBranch(link), {
148
- onSuccess: async branch => {
69
+ onSuccess: async (branch) => {
149
70
  queryClient.setQueryData(branchQueryKey(repository, branch), branch);
150
71
  await queryClient.invalidateQueries(repoQueryKey(repository, "branches"));
151
- }
72
+ },
152
73
  });
153
74
  return {
154
75
  create: (branch: BranchCreation) => mutate(branch),
155
76
  isLoading,
156
77
  error,
157
- branch: data
78
+ branch: data,
158
79
  };
159
80
  };
160
81
 
161
82
  export const useDeleteBranch = (repository: Repository) => {
162
83
  const queryClient = useQueryClient();
163
84
  const { mutate, isLoading, error, data } = useMutation<unknown, Error, Branch>(
164
- branch => {
85
+ (branch) => {
165
86
  const deleteUrl = (branch._links.delete as Link).href;
166
87
  return apiClient.delete(deleteUrl);
167
88
  },
@@ -169,14 +90,14 @@ export const useDeleteBranch = (repository: Repository) => {
169
90
  onSuccess: async (_, branch) => {
170
91
  queryClient.removeQueries(branchQueryKey(repository, branch));
171
92
  await queryClient.invalidateQueries(repoQueryKey(repository, "branches"));
172
- }
93
+ },
173
94
  }
174
95
  );
175
96
  return {
176
97
  remove: (branch: Branch) => mutate(branch),
177
98
  isLoading,
178
99
  error,
179
- isDeleted: !!data
100
+ isDeleted: !!data,
180
101
  };
181
102
  };
182
103
 
@@ -185,6 +106,6 @@ type DefaultBranch = { defaultBranch: string };
185
106
  export const useDefaultBranch = (repository: Repository): ApiResult<DefaultBranch> => {
186
107
  const link = requiredLink(repository, "defaultBranch");
187
108
  return useQuery<DefaultBranch, Error>(branchQueryKey(repository, "__default-branch"), () =>
188
- apiClient.get(link).then(response => response.json())
109
+ apiClient.get(link).then((response) => response.json())
189
110
  );
190
111
  };
@@ -35,20 +35,19 @@ describe("Test changeset hooks", () => {
35
35
  type: "hg",
36
36
  _links: {
37
37
  changesets: {
38
- href: "/r/c"
39
- }
40
- }
38
+ href: "/r/c",
39
+ },
40
+ },
41
41
  };
42
42
 
43
43
  const develop: Branch = {
44
44
  name: "develop",
45
45
  revision: "42",
46
- lastCommitter: { name: "trillian" },
47
46
  _links: {
48
47
  history: {
49
- href: "/r/b/c"
50
- }
51
- }
48
+ href: "/r/b/c",
49
+ },
50
+ },
52
51
  };
53
52
 
54
53
  const changeset: Changeset = {
@@ -56,19 +55,19 @@ describe("Test changeset hooks", () => {
56
55
  description: "Awesome change",
57
56
  date: new Date(),
58
57
  author: {
59
- name: "Arthur Dent"
58
+ name: "Arthur Dent",
60
59
  },
61
60
  _embedded: {},
62
- _links: {}
61
+ _links: {},
63
62
  };
64
63
 
65
64
  const changesets: ChangesetCollection = {
66
65
  page: 1,
67
66
  pageTotal: 1,
68
67
  _embedded: {
69
- changesets: [changeset]
68
+ changesets: [changeset],
70
69
  },
71
- _links: {}
70
+ _links: {},
72
71
  };
73
72
 
74
73
  const expectChangesetCollection = (result?: ChangesetCollection) => {
@@ -86,7 +85,7 @@ describe("Test changeset hooks", () => {
86
85
  const queryClient = createInfiniteCachingClient();
87
86
 
88
87
  const { result, waitFor } = renderHook(() => useChangesets(repository), {
89
- wrapper: createWrapper(undefined, queryClient)
88
+ wrapper: createWrapper(undefined, queryClient),
90
89
  });
91
90
 
92
91
  await waitFor(() => {
@@ -99,14 +98,14 @@ describe("Test changeset hooks", () => {
99
98
  it("should return changesets for page", async () => {
100
99
  fetchMock.getOnce("/api/v2/r/c", changesets, {
101
100
  query: {
102
- page: 42
103
- }
101
+ page: 42,
102
+ },
104
103
  });
105
104
 
106
105
  const queryClient = createInfiniteCachingClient();
107
106
 
108
107
  const { result, waitFor } = renderHook(() => useChangesets(repository, { page: 42 }), {
109
- wrapper: createWrapper(undefined, queryClient)
108
+ wrapper: createWrapper(undefined, queryClient),
110
109
  });
111
110
 
112
111
  await waitFor(() => {
@@ -122,7 +121,7 @@ describe("Test changeset hooks", () => {
122
121
  const queryClient = createInfiniteCachingClient();
123
122
 
124
123
  const { result, waitFor } = renderHook(() => useChangesets(repository, { branch: develop }), {
125
- wrapper: createWrapper(undefined, queryClient)
124
+ wrapper: createWrapper(undefined, queryClient),
126
125
  });
127
126
 
128
127
  await waitFor(() => {
@@ -138,7 +137,7 @@ describe("Test changeset hooks", () => {
138
137
  const queryClient = createInfiniteCachingClient();
139
138
 
140
139
  const { result, waitFor } = renderHook(() => useChangesets(repository), {
141
- wrapper: createWrapper(undefined, queryClient)
140
+ wrapper: createWrapper(undefined, queryClient),
142
141
  });
143
142
 
144
143
  await waitFor(() => {
@@ -150,7 +149,7 @@ describe("Test changeset hooks", () => {
150
149
  "hitchhiker",
151
150
  "heart-of-gold",
152
151
  "changeset",
153
- "42"
152
+ "42",
154
153
  ]);
155
154
 
156
155
  expect(changeset?.id).toBe("42");
@@ -164,7 +163,7 @@ describe("Test changeset hooks", () => {
164
163
  const queryClient = createInfiniteCachingClient();
165
164
 
166
165
  const { result, waitFor } = renderHook(() => useChangeset(repository, "42"), {
167
- wrapper: createWrapper(undefined, queryClient)
166
+ wrapper: createWrapper(undefined, queryClient),
168
167
  });
169
168
 
170
169
  await waitFor(() => {
package/src/import.ts CHANGED
@@ -30,12 +30,12 @@ import { requiredLink } from "./links";
30
30
 
31
31
  export const useImportLog = (logId: string): ApiResult<string> => {
32
32
  const link = useRequiredIndexLink("importLog").replace("{logId}", logId);
33
- return useQuery<string, Error>(["importLog", logId], () => apiClient.get(link).then(response => response.text()));
33
+ return useQuery<string, Error>(["importLog", logId], () => apiClient.get(link).then((response) => response.text()));
34
34
  };
35
35
 
36
36
  export const useImportRepositoryFromUrl = (repositoryType: RepositoryType) => {
37
37
  const url = requiredLink(repositoryType, "import", "url");
38
- const { isLoading, error, data, mutate } = useMutation<Repository, Error, RepositoryUrlImport>(repo =>
38
+ const { isLoading, error, data, mutate } = useMutation<Repository, Error, RepositoryUrlImport>((repo) =>
39
39
  apiClient
40
40
  .post(url, repo, "application/vnd.scmm-repository+json;v=2")
41
41
  .then(fetchResourceFromLocationHeader)
@@ -46,14 +46,14 @@ export const useImportRepositoryFromUrl = (repositoryType: RepositoryType) => {
46
46
  isLoading,
47
47
  error,
48
48
  importRepositoryFromUrl: (repository: RepositoryUrlImport) => mutate(repository),
49
- importedRepository: data
49
+ importedRepository: data,
50
50
  };
51
51
  };
52
52
 
53
53
  const importRepository = (url: string, repository: RepositoryCreation, file: File, password?: string) => {
54
54
  return apiClient
55
- .postBinary(url, formData => {
56
- formData.append("bundle", file, file.name);
55
+ .postBinary(url, (formData) => {
56
+ formData.append("bundle", file, file?.name);
57
57
  formData.append("repository", JSON.stringify({ ...repository, password }));
58
58
  })
59
59
  .then(fetchResourceFromLocationHeader)
@@ -82,9 +82,9 @@ export const useImportRepositoryFromBundle = (repositoryType: RepositoryType) =>
82
82
  repository,
83
83
  file,
84
84
  compressed,
85
- password
85
+ password,
86
86
  }),
87
- importedRepository: data
87
+ importedRepository: data,
88
88
  };
89
89
  };
90
90
 
@@ -107,8 +107,8 @@ export const useImportFullRepository = (repositoryType: RepositoryType) => {
107
107
  mutate({
108
108
  repository,
109
109
  file,
110
- password
110
+ password,
111
111
  }),
112
- importedRepository: data
112
+ importedRepository: data,
113
113
  };
114
114
  };
package/src/index.ts CHANGED
@@ -58,7 +58,6 @@ export * from "./history";
58
58
  export * from "./contentType";
59
59
  export * from "./annotations";
60
60
  export * from "./search";
61
- export * from "./loginInfo";
62
61
 
63
62
  export { default as ApiProvider } from "./ApiProvider";
64
63
  export * from "./ApiProvider";
@@ -37,7 +37,7 @@ import {
37
37
  useRepository,
38
38
  useRepositoryTypes,
39
39
  useUnarchiveRepository,
40
- useUpdateRepository
40
+ useUpdateRepository,
41
41
  } from "./repositories";
42
42
  import { Repository } from "@scm-manager/ui-types";
43
43
  import { QueryClient } from "react-query";
@@ -50,25 +50,25 @@ describe("Test repository hooks", () => {
50
50
  type: "git",
51
51
  _links: {
52
52
  delete: {
53
- href: "/r/spaceships/heartOfGold"
53
+ href: "/r/spaceships/heartOfGold",
54
54
  },
55
55
  update: {
56
- href: "/r/spaceships/heartOfGold"
56
+ href: "/r/spaceships/heartOfGold",
57
57
  },
58
58
  archive: {
59
- href: "/r/spaceships/heartOfGold/archive"
59
+ href: "/r/spaceships/heartOfGold/archive",
60
60
  },
61
61
  unarchive: {
62
- href: "/r/spaceships/heartOfGold/unarchive"
63
- }
64
- }
62
+ href: "/r/spaceships/heartOfGold/unarchive",
63
+ },
64
+ },
65
65
  };
66
66
 
67
67
  const repositoryCollection = {
68
68
  _embedded: {
69
- repositories: [heartOfGold]
69
+ repositories: [heartOfGold],
70
70
  },
71
- _links: {}
71
+ _links: {},
72
72
  };
73
73
 
74
74
  afterEach(() => {
@@ -78,7 +78,7 @@ describe("Test repository hooks", () => {
78
78
  describe("useRepositories tests", () => {
79
79
  const expectCollection = async (queryClient: QueryClient, request?: UseRepositoriesRequest) => {
80
80
  const { result, waitFor } = renderHook(() => useRepositories(request), {
81
- wrapper: createWrapper(undefined, queryClient)
81
+ wrapper: createWrapper(undefined, queryClient),
82
82
  });
83
83
  await waitFor(() => {
84
84
  return !!result.current.data;
@@ -91,8 +91,8 @@ describe("Test repository hooks", () => {
91
91
  setIndexLink(queryClient, "repositories", "/repos");
92
92
  fetchMock.get("/api/v2/repos", repositoryCollection, {
93
93
  query: {
94
- sortBy: "namespaceAndName"
95
- }
94
+ sortBy: "namespaceAndName",
95
+ },
96
96
  });
97
97
 
98
98
  await expectCollection(queryClient);
@@ -104,12 +104,12 @@ describe("Test repository hooks", () => {
104
104
  fetchMock.get("/api/v2/repos", repositoryCollection, {
105
105
  query: {
106
106
  sortBy: "namespaceAndName",
107
- page: "42"
108
- }
107
+ page: "42",
108
+ },
109
109
  });
110
110
 
111
111
  await expectCollection(queryClient, {
112
- page: 42
112
+ page: 42,
113
113
  });
114
114
  });
115
115
 
@@ -118,8 +118,8 @@ describe("Test repository hooks", () => {
118
118
  setIndexLink(queryClient, "repositories", "/repos");
119
119
  fetchMock.get("/api/v2/spaceships", repositoryCollection, {
120
120
  query: {
121
- sortBy: "namespaceAndName"
122
- }
121
+ sortBy: "namespaceAndName",
122
+ },
123
123
  });
124
124
 
125
125
  await expectCollection(queryClient, {
@@ -127,10 +127,10 @@ describe("Test repository hooks", () => {
127
127
  namespace: "spaceships",
128
128
  _links: {
129
129
  repositories: {
130
- href: "/spaceships"
131
- }
132
- }
133
- }
130
+ href: "/spaceships",
131
+ },
132
+ },
133
+ },
134
134
  });
135
135
  });
136
136
 
@@ -140,12 +140,12 @@ describe("Test repository hooks", () => {
140
140
  fetchMock.get("/api/v2/repos", repositoryCollection, {
141
141
  query: {
142
142
  sortBy: "namespaceAndName",
143
- q: "heart"
144
- }
143
+ q: "heart",
144
+ },
145
145
  });
146
146
 
147
147
  await expectCollection(queryClient, {
148
- search: "heart"
148
+ search: "heart",
149
149
  });
150
150
  });
151
151
 
@@ -154,8 +154,8 @@ describe("Test repository hooks", () => {
154
154
  setIndexLink(queryClient, "repositories", "/repos");
155
155
  fetchMock.get("/api/v2/repos", repositoryCollection, {
156
156
  query: {
157
- sortBy: "namespaceAndName"
158
- }
157
+ sortBy: "namespaceAndName",
158
+ },
159
159
  });
160
160
 
161
161
  await expectCollection(queryClient);
@@ -168,7 +168,7 @@ describe("Test repository hooks", () => {
168
168
  const queryClient = createInfiniteCachingClient();
169
169
  setIndexLink(queryClient, "repositories", "/repos");
170
170
  const { result } = renderHook(() => useRepositories({ disabled: true }), {
171
- wrapper: createWrapper(undefined, queryClient)
171
+ wrapper: createWrapper(undefined, queryClient),
172
172
  });
173
173
 
174
174
  expect(result.current.isLoading).toBe(false);
@@ -185,18 +185,19 @@ describe("Test repository hooks", () => {
185
185
  fetchMock.postOnce("/api/v2/r", {
186
186
  status: 201,
187
187
  headers: {
188
- Location: "/r/spaceships/heartOfGold"
189
- }
188
+ Location: "/r/spaceships/heartOfGold",
189
+ },
190
190
  });
191
191
 
192
192
  fetchMock.getOnce("/api/v2/r/spaceships/heartOfGold", heartOfGold);
193
193
 
194
194
  const { result, waitForNextUpdate } = renderHook(() => useCreateRepository(), {
195
- wrapper: createWrapper(undefined, queryClient)
195
+ wrapper: createWrapper(undefined, queryClient),
196
196
  });
197
197
 
198
198
  const repository = {
199
- ...heartOfGold
199
+ ...heartOfGold,
200
+ contextEntries: [],
200
201
  };
201
202
 
202
203
  await act(() => {
@@ -215,18 +216,19 @@ describe("Test repository hooks", () => {
215
216
  fetchMock.postOnce("/api/v2/r?initialize=true", {
216
217
  status: 201,
217
218
  headers: {
218
- Location: "/r/spaceships/heartOfGold"
219
- }
219
+ Location: "/r/spaceships/heartOfGold",
220
+ },
220
221
  });
221
222
 
222
223
  fetchMock.getOnce("/api/v2/r/spaceships/heartOfGold", heartOfGold);
223
224
 
224
225
  const { result, waitForNextUpdate } = renderHook(() => useCreateRepository(), {
225
- wrapper: createWrapper(undefined, queryClient)
226
+ wrapper: createWrapper(undefined, queryClient),
226
227
  });
227
228
 
228
229
  const repository = {
229
- ...heartOfGold
230
+ ...heartOfGold,
231
+ contextEntries: [],
230
232
  };
231
233
 
232
234
  await act(() => {
@@ -243,15 +245,16 @@ describe("Test repository hooks", () => {
243
245
  setIndexLink(queryClient, "repositories", "/r");
244
246
 
245
247
  fetchMock.postOnce("/api/v2/r", {
246
- status: 201
248
+ status: 201,
247
249
  });
248
250
 
249
251
  const { result, waitForNextUpdate } = renderHook(() => useCreateRepository(), {
250
- wrapper: createWrapper(undefined, queryClient)
252
+ wrapper: createWrapper(undefined, queryClient),
251
253
  });
252
254
 
253
255
  const repository = {
254
- ...heartOfGold
256
+ ...heartOfGold,
257
+ contextEntries: [],
255
258
  };
256
259
 
257
260
  await act(() => {
@@ -271,7 +274,7 @@ describe("Test repository hooks", () => {
271
274
  fetchMock.get("/api/v2/r/spaceships/heartOfGold", heartOfGold);
272
275
 
273
276
  const { result, waitFor } = renderHook(() => useRepository("spaceships", "heartOfGold"), {
274
- wrapper: createWrapper(undefined, queryClient)
277
+ wrapper: createWrapper(undefined, queryClient),
275
278
  });
276
279
  await waitFor(() => {
277
280
  return !!result.current.data;
@@ -290,15 +293,15 @@ describe("Test repository hooks", () => {
290
293
  {
291
294
  name: "git",
292
295
  displayName: "Git",
293
- _links: {}
294
- }
295
- ]
296
+ _links: {},
297
+ },
298
+ ],
296
299
  },
297
- _links: {}
300
+ _links: {},
298
301
  });
299
302
 
300
303
  const { result, waitFor } = renderHook(() => useRepositoryTypes(), {
301
- wrapper: createWrapper(undefined, queryClient)
304
+ wrapper: createWrapper(undefined, queryClient),
302
305
  });
303
306
  await waitFor(() => {
304
307
  return !!result.current.data;
@@ -319,11 +322,11 @@ describe("Test repository hooks", () => {
319
322
 
320
323
  const deleteRepository = async (options?: UseDeleteRepositoryOptions) => {
321
324
  fetchMock.deleteOnce("/api/v2/r/spaceships/heartOfGold", {
322
- status: 204
325
+ status: 204,
323
326
  });
324
327
 
325
328
  const { result, waitForNextUpdate } = renderHook(() => useDeleteRepository(options), {
326
- wrapper: createWrapper(undefined, queryClient)
329
+ wrapper: createWrapper(undefined, queryClient),
327
330
  });
328
331
 
329
332
  await act(() => {
@@ -368,9 +371,9 @@ describe("Test repository hooks", () => {
368
371
  it("should call onSuccess callback", async () => {
369
372
  let repo;
370
373
  await deleteRepository({
371
- onSuccess: repository => {
374
+ onSuccess: (repository) => {
372
375
  repo = repository;
373
- }
376
+ },
374
377
  });
375
378
  expect(repo).toEqual(heartOfGold);
376
379
  });
@@ -385,11 +388,11 @@ describe("Test repository hooks", () => {
385
388
 
386
389
  const updateRepository = async () => {
387
390
  fetchMock.putOnce("/api/v2/r/spaceships/heartOfGold", {
388
- status: 204
391
+ status: 204,
389
392
  });
390
393
 
391
394
  const { result, waitForNextUpdate } = renderHook(() => useUpdateRepository(), {
392
- wrapper: createWrapper(undefined, queryClient)
395
+ wrapper: createWrapper(undefined, queryClient),
393
396
  });
394
397
 
395
398
  await act(() => {
@@ -433,11 +436,11 @@ describe("Test repository hooks", () => {
433
436
 
434
437
  const archiveRepository = async () => {
435
438
  fetchMock.postOnce("/api/v2/r/spaceships/heartOfGold/archive", {
436
- status: 204
439
+ status: 204,
437
440
  });
438
441
 
439
442
  const { result, waitForNextUpdate } = renderHook(() => useArchiveRepository(), {
440
- wrapper: createWrapper(undefined, queryClient)
443
+ wrapper: createWrapper(undefined, queryClient),
441
444
  });
442
445
 
443
446
  await act(() => {
@@ -481,11 +484,11 @@ describe("Test repository hooks", () => {
481
484
 
482
485
  const unarchiveRepository = async () => {
483
486
  fetchMock.postOnce("/api/v2/r/spaceships/heartOfGold/unarchive", {
484
- status: 204
487
+ status: 204,
485
488
  });
486
489
 
487
490
  const { result, waitForNextUpdate } = renderHook(() => useUnarchiveRepository(), {
488
- wrapper: createWrapper(undefined, queryClient)
491
+ wrapper: createWrapper(undefined, queryClient),
489
492
  });
490
493
 
491
494
  await act(() => {
package/src/urls.ts CHANGED
@@ -84,13 +84,8 @@ function parsePageNumber(pageAsString: string) {
84
84
  return page;
85
85
  }
86
86
 
87
- export function getQueryStringFromLocation(location: { search?: string }): string | undefined {
88
- if (location.search) {
89
- const query = queryString.parse(location.search).q;
90
- if (query && !Array.isArray(query)) {
91
- return query;
92
- }
93
- }
87
+ export function getQueryStringFromLocation(location: any) {
88
+ return location.search ? queryString.parse(location.search).q : undefined;
94
89
  }
95
90
 
96
91
  export function stripEndingSlash(url: string) {
package/src/loginInfo.ts DELETED
@@ -1,43 +0,0 @@
1
- /*
2
- * MIT License
3
- *
4
- * Copyright (c) 2020-present Cloudogu GmbH and Contributors
5
- *
6
- * Permission is hereby granted, free of charge, to any person obtaining a copy
7
- * of this software and associated documentation files (the "Software"), to deal
8
- * in the Software without restriction, including without limitation the rights
9
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
- * copies of the Software, and to permit persons to whom the Software is
11
- * furnished to do so, subject to the following conditions:
12
- *
13
- * The above copyright notice and this permission notice shall be included in all
14
- * copies or substantial portions of the Software.
15
- *
16
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
- * SOFTWARE.
23
- */
24
- import { ApiResult, useIndexLink } from "./base";
25
- import { useQuery } from "react-query";
26
- import { LoginInfo } from "@scm-manager/ui-types";
27
-
28
- export const useLoginInfo = (disabled = false): ApiResult<LoginInfo> => {
29
- const loginInfoLink = useIndexLink("loginInfo");
30
- const { error, isLoading, data } = useQuery<LoginInfo, Error>(
31
- ["loginInfo"],
32
- () => fetch(loginInfoLink!).then(response => response.json()),
33
- {
34
- enabled: !disabled && !!loginInfoLink,
35
- refetchOnWindowFocus: false
36
- }
37
- );
38
- return {
39
- data,
40
- error,
41
- isLoading
42
- };
43
- };