-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replacing use of store with
useQuery
for content packs.
- Loading branch information
1 parent
2b4b6ca
commit 914ce4d
Showing
3 changed files
with
66 additions
and
33 deletions.
There are no files selected for viewing
9 changes: 9 additions & 0 deletions
9
graylog2-web-interface/src/components/content-packs/hooks/useContentPackInstallations.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { useQuery } from '@tanstack/react-query'; | ||
|
||
import { SystemContentPacks } from '@graylog/server-api'; | ||
|
||
const useContentPackInstallations = (id: string) => useQuery( | ||
['content-packs', 'installations', id], | ||
() => SystemContentPacks.listContentPackInstallationsById(id), | ||
); | ||
export default useContentPackInstallations; |
24 changes: 24 additions & 0 deletions
24
graylog2-web-interface/src/components/content-packs/hooks/useContentPackRevisions.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { useQuery } from '@tanstack/react-query'; | ||
|
||
import { SystemContentPacks } from '@graylog/server-api'; | ||
|
||
import ContentPackRevisions from 'logic/content-packs/ContentPackRevisions'; | ||
import { onError } from 'util/conditional/onError'; | ||
|
||
const fetchContentPackRevisions = async (id: string) => { | ||
const response = await SystemContentPacks.listContentPackRevisions(id); | ||
const contentPackRevision = new ContentPackRevisions(response.content_pack_revisions); | ||
const constraints = response.constraints_result; | ||
|
||
return { | ||
contentPackRevisions: contentPackRevision, | ||
selectedVersion: contentPackRevision.latestRevision, | ||
constraints: constraints, | ||
}; | ||
}; | ||
|
||
const useContentPackRevisions = (id: string, onFetchError: (e: Error) => void) => useQuery( | ||
['content-packs', 'revisions', id], | ||
() => onError(fetchContentPackRevisions(id), onFetchError), | ||
); | ||
export default useContentPackRevisions; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters