-
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.
added actions on datanode datails page (#17840)
* added actions on datanode datails page * changelog file * use fetchDataNode instead of the list api call for details page * reuse DataNodeActions component * defaultProp displayAs: 'dropdown' --------- Co-authored-by: Ousmane SAMBA <ousmane@graylog.com>
- Loading branch information
Showing
4 changed files
with
111 additions
and
25 deletions.
There are no files selected for viewing
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,5 @@ | ||
type = "fixed" | ||
message = "added actions on datanode datails page" | ||
|
||
issues = ["17705"] | ||
pulls = ["17840"] |
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
53 changes: 53 additions & 0 deletions
53
graylog2-web-interface/src/components/datanode/hooks/useDataNode.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,53 @@ | ||
/* | ||
* Copyright (C) 2020 Graylog, Inc. | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the Server Side Public License, version 1, | ||
* as published by MongoDB, Inc. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* Server Side Public License for more details. | ||
* | ||
* You should have received a copy of the Server Side Public License | ||
* along with this program. If not, see | ||
* <http://www.mongodb.com/licensing/server-side-public-license>. | ||
*/ | ||
import { useQuery } from '@tanstack/react-query'; | ||
|
||
import { qualifyUrl } from 'util/URLUtils'; | ||
import type { DataNode } from 'preflight/types'; | ||
import UserNotification from 'util/UserNotification'; | ||
import fetch from 'logic/rest/FetchProvider'; | ||
|
||
const fetchDataNode = async (datanodeId: string) => fetch('GET', qualifyUrl(`/datanode/${datanodeId}`)); | ||
|
||
const useDataNode = (datanodeId: string) : { | ||
data: DataNode, | ||
refetch: () => void, | ||
isInitialLoading: boolean, | ||
error: any, | ||
} => { | ||
const { data, refetch, isInitialLoading, error } = useQuery( | ||
['datanode'], | ||
() => fetchDataNode(datanodeId), | ||
{ | ||
onError: (errorThrown) => { | ||
UserNotification.error(`Loading Data Node failed with status: ${errorThrown}`, | ||
'Could not load Data Node'); | ||
}, | ||
notifyOnChangeProps: ['data', 'error'], | ||
refetchInterval: 5000, | ||
}, | ||
); | ||
|
||
return ({ | ||
data, | ||
refetch, | ||
isInitialLoading, | ||
error, | ||
}); | ||
}; | ||
|
||
export default useDataNode; |
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