@@ -3,6 +3,7 @@ import PropTypes from 'prop-types';
33import ky from 'ky/umd' ;
44import TimeAgo from 'react-timeago' ;
55import classNames from 'classnames' ;
6+ import { Link } from 'react-router-dom' ;
67
78import AutoProgressBar from './AutoProgressBar' ;
89import shortUrls from './shortUrls' ;
@@ -153,7 +154,7 @@ class DeployPage extends React.Component {
153154 return (
154155 < div >
155156 < h2 className = "text-center" >
156- What's Deployed
157+ < Link to = "/" > What's Deployed</ Link > { ' ' }
157158 { owner && repo && (
158159 < span >
159160 { ' ' }
@@ -188,7 +189,7 @@ class DeployPage extends React.Component {
188189 deployInfo = { deployInfo }
189190 commits = { commits }
190191 tags = { tags }
191- shortUrl = { `/s/ ${ code } ` }
192+ code = { code }
192193 owner = { owner }
193194 repo = { repo }
194195 />
@@ -215,23 +216,48 @@ class DeployTable extends React.Component {
215216 ) . isRequired ,
216217 commits : PropTypes . arrayOf ( PropTypes . shape ( { } ) ) . isRequired ,
217218 tags : PropTypes . object . isRequired ,
219+ code : PropTypes . string . isRequired ,
218220 owner : PropTypes . string . isRequired ,
219221 repo : PropTypes . string . isRequired
220222 } ;
223+ static prefBorsModeCacheKey = 'pref-bors-mode' ;
221224
222- constructor ( props ) {
223- super ( props ) ;
224- this . state = {
225- borsMode : false
226- } ;
225+ state = {
226+ borsMode : false
227+ } ;
228+
229+ componentDidMount ( ) {
230+ this . _restoreBorsModeChoice ( ) ;
227231 }
228232
229233 handleBorsCheckbox = ev => {
230- this . setState ( { borsMode : ev . target . checked } ) ;
234+ this . setState ( { borsMode : ev . target . checked } , this . _persistBorsModeChoice ) ;
235+ } ;
236+
237+ _restoreBorsModeChoice = ( ) => {
238+ const prefs = JSON . parse (
239+ localStorage . getItem ( this . prefBorsModeCacheKey ) || '{}'
240+ ) ;
241+ if (
242+ this . props . code in prefs &&
243+ prefs [ this . props . code ] !== this . state . borsMode
244+ ) {
245+ this . setState ( { borsMode : prefs [ this . props . code ] } ) ;
246+ }
247+ } ;
248+
249+ _persistBorsModeChoice = ( ) => {
250+ const prefs = JSON . parse (
251+ localStorage . getItem ( this . prefBorsModeCacheKey ) || '{}'
252+ ) ;
253+ prefs [ this . props . code ] = this . state . borsMode ;
254+ localStorage . setItem ( this . prefBorsModeCacheKey , JSON . stringify ( prefs ) ) ;
231255 } ;
232256
233257 render ( ) {
234- const { deployInfo, commits, tags, owner, repo, shortUrl } = this . props ;
258+ const { deployInfo, commits, tags, owner, repo, code } = this . props ;
259+ const shortUrl = `/s/${ code } ` ;
260+
235261 const { borsMode } = this . state ;
236262
237263 let hasBors = false ;
0 commit comments