-
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
app: Add simple new version notification
- Loading branch information
1 parent
f38c0be
commit 434a387
Showing
10 changed files
with
168 additions
and
118 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,34 @@ | ||
import styled from '@emotion/styled'; | ||
import {css} from '@emotion/core'; | ||
|
||
const primary = css` | ||
background: #28272b; | ||
color: #fff; | ||
&:hover { | ||
background: #000; | ||
} | ||
`; | ||
|
||
const muted = css` | ||
background: #eee; | ||
&:hover { | ||
background: #e5e5e5; | ||
} | ||
`; | ||
|
||
const ActionButton = styled('button')<{muted?: boolean}>` | ||
display: grid; | ||
grid-auto-flow: column; | ||
grid-auto-columns: max-content; | ||
grid-gap: 0.5rem; | ||
align-items: center; | ||
border: none; | ||
padding: 0.5rem 1rem; | ||
font-weight: bold; | ||
border-radius: 3px; | ||
${p => (p.muted ? muted : primary)} | ||
`; | ||
|
||
export default ActionButton; |
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,70 @@ | ||
import * as React from 'react'; | ||
import styled from '@emotion/styled'; | ||
import {Save} from 'react-feather'; | ||
import {shell} from 'electron'; | ||
|
||
import Logo from 'src/shared/components/Logo'; | ||
import ActionButton from './ActionButton'; | ||
import useRelease from 'src/utils/useLatestRelease'; | ||
|
||
const Footer = () => { | ||
const latestRelease = useRelease(); | ||
|
||
const hasNewVersion = | ||
latestRelease && | ||
process.env.RELEASE_CHANNEL === 'stable' && | ||
process.env.RELEASE !== latestRelease.name; | ||
|
||
const newVersion = latestRelease && hasNewVersion && ( | ||
<NewVersionButton onClick={() => shell.openExternal(latestRelease.html_url)}> | ||
<Save size="1rem" /> {latestRelease.name} available | ||
</NewVersionButton> | ||
); | ||
|
||
return ( | ||
<Wrapper> | ||
<Logo size={28} /> | ||
<div> | ||
<Title>prolink tools</Title> | ||
<Release>{process.env.RELEASE}</Release> | ||
</div> | ||
<Info>{newVersion}</Info> | ||
</Wrapper> | ||
); | ||
}; | ||
|
||
const Info = styled('div')` | ||
display: flex; | ||
gap: 0.5rem; | ||
align-items: center; | ||
justify-content: flex-end; | ||
`; | ||
|
||
const NewVersionButton = styled(ActionButton)` | ||
background: #ef5f73; | ||
color: #fff; | ||
padding: 0.375rem 0.5rem; | ||
font-size: 0.75rem; | ||
`; | ||
|
||
const Title = styled('h2')` | ||
display: flex; | ||
align-items: center; | ||
font-size: 0.8rem; | ||
margin: 0; | ||
`; | ||
|
||
const Release = styled('div')` | ||
font-size: 0.7rem; | ||
color: #777a7b; | ||
`; | ||
|
||
const Wrapper = styled('div')` | ||
padding: 0.5rem; | ||
display: grid; | ||
align-items: center; | ||
grid-template-columns: max-content max-content 1fr; | ||
grid-gap: 0.5rem; | ||
`; | ||
|
||
export default Footer; |
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,20 @@ | ||
import styled from '@emotion/styled'; | ||
|
||
const Header = styled('header')` | ||
display: flex; | ||
justify-content: space-between; | ||
align-items: center; | ||
padding: 1.5rem; | ||
border-bottom: 1px solid #eee; | ||
`; | ||
|
||
const HeaderInfo = styled('p')` | ||
font-family: Ubuntu; | ||
flex-grow: 1; | ||
margin-right: 1.5rem; | ||
font-size: 0.8rem; | ||
max-width: 450px; | ||
margin: 0; | ||
`; | ||
|
||
export {Header, HeaderInfo}; |
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,8 @@ | ||
export const GITHUB_REPO = { | ||
owner: 'evanpurkhiser', | ||
repo: 'prolink-tools', | ||
}; | ||
|
||
export const GITHUB_REPO_URL = `https://github.com/${GITHUB_REPO.owner}/${GITHUB_REPO.repo}`; | ||
|
||
export const WEBSERVER_PORT = 5152; |
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,21 @@ | ||
import * as React from 'react'; | ||
import {request} from '@octokit/request'; | ||
import {Endpoints} from '@octokit/types'; | ||
import {GITHUB_REPO} from 'src/shared/constants'; | ||
|
||
type Release = Endpoints['GET /repos/:owner/:repo/releases/latest']['response']; | ||
|
||
const useRelease = () => { | ||
const [release, setRelease] = React.useState<Release['data'] | null>(null); | ||
|
||
const getReleases = async () => { | ||
const release = await request('GET /repos/:owner/:repo/releases/latest', GITHUB_REPO); | ||
setRelease(release['data']); | ||
}; | ||
|
||
React.useEffect(() => void getReleases(), []); | ||
|
||
return release; | ||
}; | ||
|
||
export default useRelease; |
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 was deleted.
Oops, something went wrong.