-
Notifications
You must be signed in to change notification settings - Fork 833
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add releases page It lists available documentation websites for v3+ versions * Use constant for the latest url link * Make releases table horisontally scrollable on mobile
- Loading branch information
1 parent
41fa537
commit c4c9f80
Showing
7 changed files
with
176 additions
and
11 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
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 |
---|---|---|
@@ -0,0 +1,126 @@ | ||
import * as React from 'react'; | ||
import { NextFC } from 'next'; | ||
import { PageMeta } from '_shared/PageMeta'; | ||
import { fetchGithubData } from 'utils/github-api'; | ||
import { DOMAIN, GITHUB_URL, HOST_URL } from '_constants'; | ||
import { | ||
Paper, | ||
Table, | ||
TableBody, | ||
TableHead, | ||
TableCell, | ||
TableRow, | ||
Typography, | ||
makeStyles, | ||
} from '@material-ui/core'; | ||
|
||
interface ReleasesProps { | ||
tags: string[]; | ||
} | ||
|
||
const ExternalLink: React.FC<React.HTMLProps<HTMLLinkElement>> = ({ href }) => { | ||
return ( | ||
<a href={href} rel="noopener noreferrer"> | ||
{href} | ||
</a> | ||
); | ||
}; | ||
|
||
const useStyles = makeStyles({ | ||
scrollableTable: { | ||
overflowX: 'auto', | ||
}, | ||
}); | ||
|
||
const Releases: NextFC<ReleasesProps> = ({ tags }) => { | ||
const classes = useStyles(); | ||
|
||
return ( | ||
<> | ||
<PageMeta | ||
title="Releases - @material-ui/pickers" | ||
description="List of @material-ui/pickers releases with a link to per-release documentation site." | ||
/> | ||
|
||
<Typography variant="h2" gutterBottom> | ||
Releases | ||
</Typography> | ||
<Typography gutterBottom> | ||
We are using semver strategy for making releases. Here you can find documentation for some | ||
of previous material-ui-picker's releases. Please note that our versions is not synced with | ||
@material-ui/core versions | ||
</Typography> | ||
|
||
<Paper className={classes.scrollableTable}> | ||
<Table> | ||
<TableHead> | ||
<TableRow> | ||
<TableCell>Version</TableCell> | ||
<TableCell>Documentation Url</TableCell> | ||
<TableCell>Release notes</TableCell> | ||
</TableRow> | ||
</TableHead> | ||
|
||
<TableBody> | ||
<TableRow> | ||
<TableCell> | ||
<strong> Unpublished </strong> | ||
</TableCell> | ||
<TableCell> | ||
<ExternalLink href="https://material-ui-pickers.mui-org.now.sh/" /> | ||
</TableCell> | ||
<TableCell> | ||
This is unpublished <b> future in-development </b> version. | ||
</TableCell> | ||
</TableRow> | ||
|
||
<TableRow> | ||
<TableCell> | ||
<strong> Latest </strong> | ||
</TableCell> | ||
<TableCell> | ||
<ExternalLink href={HOST_URL} /> | ||
</TableCell> | ||
<TableCell>Latest stable published release</TableCell> | ||
</TableRow> | ||
|
||
{tags.map(version => { | ||
const docsLink = `https://${version.replace(/\./g, '-')}.${DOMAIN}`; | ||
const releaseNotesLink = `${GITHUB_URL}/releases/tag/${version}`; | ||
|
||
return ( | ||
<TableRow> | ||
<TableCell>{version}</TableCell> | ||
<TableCell> | ||
<ExternalLink href={docsLink} /> | ||
</TableCell> | ||
<TableCell> | ||
<ExternalLink href={releaseNotesLink} /> | ||
</TableCell> | ||
</TableRow> | ||
); | ||
})} | ||
|
||
<TableRow> | ||
<TableCell>v2</TableCell> | ||
<TableCell> | ||
<ExternalLink href="https://material-ui-pickers-v2.dmtr-kovalenko.now.sh/" /> | ||
</TableCell> | ||
<TableCell> | ||
<ExternalLink href="https://github.com/mui-org/material-ui-pickers/releases/tag/v2.2.4" /> | ||
</TableCell> | ||
</TableRow> | ||
</TableBody> | ||
</Table> | ||
</Paper> | ||
</> | ||
); | ||
}; | ||
|
||
Releases.getInitialProps = () => { | ||
return fetchGithubData('tags').then(data => ({ | ||
tags: data.map(tagObject => tagObject.name).filter(tag => Number(tag.charAt(1)) > 2), | ||
})); | ||
}; | ||
|
||
export default Releases; |
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,36 @@ | ||
import fetch from 'isomorphic-fetch'; | ||
|
||
let cacheRemaining = 0; | ||
const cache = { | ||
tags: null as { name: string }[] | null, | ||
}; | ||
|
||
type CacheType = typeof cache; | ||
|
||
export function fetchGithubData<T extends keyof CacheType>( | ||
path: T | ||
): Promise<NonNullable<CacheType[T]>> { | ||
if (cache[path] && new Date().getTime() < cacheRemaining) { | ||
return Promise.resolve(cache[path] || ([] as any)); | ||
} | ||
|
||
return fetch('https://api.github.com/repos/mui-org/material-ui-pickers/' + path, { | ||
headers: { | ||
// just a super basic readonly token, that makes api rate limit = 5000/hour | ||
Authorization: 'token 14ef125b9fbcf138ff9042b45f89f8b3c28f510a', | ||
}, | ||
}) | ||
.then(res => { | ||
cacheRemaining = Number(res.headers.get('X-RateLimit-Reset')) * 1000; | ||
if (res.status > 400) { | ||
// We cannot update the cache on this step | ||
throw new Error('Could not fetch the data'); | ||
} | ||
|
||
return res.json(); | ||
}) | ||
.then((data: NonNullable<CacheType[T]>) => { | ||
cache[path] = data; | ||
return data; | ||
}); | ||
} |
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