-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[WKP-2269] Adds server/ui version to the UI (#30)
* Adds server/ui version to the UI * Fix ui linting * Moves help/version outside the white content boxes
- Loading branch information
Showing
6 changed files
with
64 additions
and
9 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
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 |
---|---|---|
@@ -1,6 +1,7 @@ | ||
import { FC } from 'react'; | ||
import styled, { css } from 'styled-components'; | ||
import { spacing } from 'weaveworks-ui-components/lib/theme/selectors'; | ||
import useVersions from '../../contexts/Versions'; | ||
|
||
export const pageDimensionsCss = css` | ||
width: 100%; | ||
|
@@ -16,7 +17,7 @@ const medium = spacing('medium'); | |
const large = spacing('large'); | ||
|
||
export const contentCss = css` | ||
margin: ${medium} ${small} ${small} ${small}; | ||
margin: ${medium} ${small} 0 ${small}; | ||
padding: ${large} ${medium} ${medium} ${medium}; | ||
background-color: white; | ||
border-radius: ${spacing('xs')}; | ||
|
@@ -27,9 +28,11 @@ export const Content = styled.div` | |
`; | ||
|
||
const HelpLinkWrapper = styled.div` | ||
margin: 0 ${small}; | ||
padding: ${small} ${small}; | ||
display: flex; | ||
justify-content: flex-end; | ||
margin-top: ${large}; | ||
flex-direction: column; | ||
align-items: flex-end; | ||
color: ${({ theme }) => theme.colors.gray600}; | ||
white-space: nowrap; | ||
line-height: 1.5em; | ||
|
@@ -39,13 +42,17 @@ const HelpLinkWrapper = styled.div` | |
`; | ||
|
||
export const ContentWrapper: FC = ({ children }) => { | ||
const versions = useVersions(); | ||
return ( | ||
<Content> | ||
{children} | ||
<> | ||
<Content>{children}</Content> | ||
<HelpLinkWrapper> | ||
Need help? Contact us at | ||
<a href="mailto:[email protected]">[email protected]</a> | ||
<div> | ||
Need help? Contact us at{' '} | ||
<a href="mailto:[email protected]">[email protected]</a> | ||
</div> | ||
<div>Version {versions.versions?.capiServer}</div> | ||
</HelpLinkWrapper> | ||
</Content> | ||
</> | ||
); | ||
}; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import React, { FC, useCallback, useEffect, useState } from 'react'; | ||
import { ClustersService } from '../../capi-server/capi_server.pb'; | ||
import { Versions, VersionData } from './index'; | ||
|
||
const VersionsProvider: FC = ({ children }) => { | ||
const [versions, setVersions] = useState<VersionData>({ | ||
ui: process.env.REACT_APP_VERSION || 'no version specified', | ||
}); | ||
|
||
const getVersions = useCallback(() => { | ||
ClustersService.GetEnterpriseVersion({}).then(res => { | ||
console.log('weave-gitops-enterprise capiServer:', res.version); | ||
setVersions(s => ({ ...s, capiServer: res.version })); | ||
}); | ||
}, []); | ||
|
||
useEffect(() => getVersions(), [getVersions]); | ||
|
||
return ( | ||
<Versions.Provider | ||
value={{ | ||
versions, | ||
}} | ||
> | ||
{children} | ||
</Versions.Provider> | ||
); | ||
}; | ||
|
||
export default VersionsProvider; |
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,14 @@ | ||
import { createContext, useContext } from 'react'; | ||
|
||
export interface VersionData { | ||
ui: string; | ||
capiServer?: string; | ||
} | ||
|
||
type VersionsContext = { | ||
versions: VersionData | null; | ||
}; | ||
|
||
export const Versions = createContext<VersionsContext | null>(null); | ||
|
||
export default () => useContext(Versions) as VersionsContext; |
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