-
Notifications
You must be signed in to change notification settings - Fork 106
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BED-4541: Add server version to profile page (#696)
* add version to profile page * included in error-state * add optional chaining to display * WIP * updated version content * remove y padding on page * Add test mock for api version
- Loading branch information
1 parent
09e66d6
commit 68ac15e
Showing
5 changed files
with
155 additions
and
81 deletions.
There are no files selected for viewing
42 changes: 42 additions & 0 deletions
42
packages/javascript/bh-shared-ui/src/components/ApiVersion.tsx
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,42 @@ | ||
// Copyright 2024 Specter Ops, Inc. | ||
// | ||
// Licensed under the Apache License, Version 2.0 | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
import { Box, Skeleton, Typography } from '@mui/material'; | ||
import { apiClient } from '../utils'; | ||
import React from 'react'; | ||
import { useQuery } from 'react-query'; | ||
|
||
const ApiVersion: React.FC = () => { | ||
const getVersionQuery = useQuery(['Version'], ({ signal }) => | ||
apiClient.version({ signal }).then((res) => res.data.data) | ||
); | ||
|
||
const version = getVersionQuery; | ||
|
||
if (getVersionQuery.isLoading) | ||
return ( | ||
<Box paddingX={2}> | ||
<Skeleton variant='text' /> | ||
</Box> | ||
); | ||
|
||
if (getVersionQuery.isError) | ||
return <Typography variant='body2'>API Version: Unknown, please refresh the page or report a bug.</Typography>; | ||
|
||
return <Typography variant='body2'>API Version: {version.data.server_version}</Typography>; | ||
}; | ||
|
||
export default ApiVersion; |
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
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
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
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