Skip to content

Commit e0e2481

Browse files
authored
Merge pull request #71 from mythmon/title
Include owner and repo in more places, to make pages easier to read
2 parents 987c7c8 + def67d4 commit e0e2481

File tree

6 files changed

+74
-70
lines changed

6 files changed

+74
-70
lines changed

src/App.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,3 +145,7 @@ th > .column-extra {
145145
font-weight: normal;
146146
margin-right: 20px;
147147
}
148+
149+
h2 .reponame {
150+
color: #666;
151+
}

src/App.js

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from 'react';
2-
import { BrowserRouter as Router, Link } from 'react-router-dom';
2+
import { BrowserRouter as Router } from 'react-router-dom';
33
import 'bootstrap/dist/css/bootstrap.min.css';
44

55
import Routes from './Routes';
@@ -10,7 +10,6 @@ export default class App extends React.Component {
1010
return (
1111
<Router>
1212
<div className="App container">
13-
<Header />
1413
<Routes />
1514
<Footer />
1615
</div>
@@ -19,16 +18,6 @@ export default class App extends React.Component {
1918
}
2019
}
2120

22-
class Header extends React.Component {
23-
render() {
24-
return (
25-
<h2 className="text-center">
26-
<Link to="/">What's Deployed?</Link>
27-
</h2>
28-
);
29-
}
30-
}
31-
3221
class Footer extends React.Component {
3322
render() {
3423
let versionData;

src/DeployPage.js

Lines changed: 64 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,16 @@ class DeployPage extends React.Component {
1616
shortCode: PropTypes.string.isRequired
1717
};
1818

19-
constructor(props) {
20-
super(props);
21-
this.state = {
22-
owner: null,
23-
repo: null,
24-
deployments: null,
25-
commits: null,
26-
deployInfo: null,
27-
error: null,
28-
loading: null,
29-
tags: null
30-
};
31-
}
19+
state = {
20+
owner: null,
21+
repo: null,
22+
deployments: null,
23+
commits: null,
24+
deployInfo: null,
25+
error: null,
26+
loading: null,
27+
tags: null
28+
};
3229

3330
isLoading() {
3431
if (this.state.loading === null) {
@@ -53,14 +50,17 @@ class DeployPage extends React.Component {
5350

5451
async decodeShortCode() {
5552
const {
56-
match: {
57-
params: { code }
58-
}
53+
history,
54+
match: { params }
5955
} = this.props;
6056
this.startLoad('parameters');
6157
try {
62-
let { owner, repo, deployments } = await shortUrls.decode(code);
58+
let { owner, repo, deployments } = await shortUrls.decode(params.code);
6359
this.setState({ owner, repo, deployments });
60+
if (params.owner !== owner || params.repo !== repo) {
61+
history.replace(`/s/${params.code}/${owner}/${repo}`);
62+
}
63+
6464
this.fetchShas();
6565
this.fetchCommits();
6666
this.finishLoad('parameters');
@@ -144,46 +144,55 @@ class DeployPage extends React.Component {
144144

145145
document.title = `What's Deployed on ${owner}/${repo}?`;
146146

147-
if (error) {
148-
return <div className="alert alert-danger">{error.toString()}</div>;
149-
}
150-
151-
if (this.isLoading()) {
152-
return (
153-
<div>
154-
<span>Loading {Array.from(loading || '...').join(' and ')}</span>
155-
<AutoProgressBar
156-
count={loading ? loading.size : 0}
157-
total={3}
158-
targetTime={5000}
159-
/>
160-
</div>
161-
);
162-
}
163-
164-
if (!deployInfo) {
165-
return (
166-
<div className="alert alert-danger">
167-
No Deployment info could be found
168-
</div>
169-
);
170-
}
171-
172147
return (
173148
<div>
174-
<DeployTable
175-
deployInfo={deployInfo}
176-
commits={commits}
177-
tags={tags}
178-
shortUrl={`/s/${code}`}
179-
/>
180-
<RepoSummary
181-
deployInfo={deployInfo}
182-
tags={tags}
183-
owner={owner}
184-
repo={repo}
185-
/>
186-
<Culprits deployInfo={deployInfo} owner={owner} repo={repo} />
149+
<h2 className="text-center">
150+
What's Deployed
151+
{owner && repo && (
152+
<span>
153+
{' '}
154+
on{' '}
155+
<a
156+
href={`https://github.com/${owner}/${repo}`}
157+
className="reponame"
158+
>
159+
{owner}/{repo}
160+
</a>
161+
</span>
162+
)}
163+
?
164+
</h2>
165+
{error && <div className="alert alert-danger">{error.toString()}</div>}
166+
{this.isLoading() ? (
167+
<>
168+
<span>Loading {Array.from(loading || '...').join(' and ')}</span>
169+
<AutoProgressBar
170+
count={loading ? loading.size : 0}
171+
total={3}
172+
targetTime={5000}
173+
/>
174+
</>
175+
) : !deployInfo ? (
176+
<div className="alert alert-danger">
177+
No Deployment info could be found
178+
</div>
179+
) : (
180+
<>
181+
<DeployTable
182+
deployInfo={deployInfo}
183+
commits={commits}
184+
tags={tags}
185+
shortUrl={`/s/${code}`}
186+
/>
187+
<RepoSummary
188+
deployInfo={deployInfo}
189+
tags={tags}
190+
owner={owner}
191+
repo={repo}
192+
/>
193+
<Culprits deployInfo={deployInfo} owner={owner} repo={repo} />
194+
</>
195+
)}
187196
</div>
188197
);
189198
}

src/LongUrlRedirect.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ class LongUrlRedirect extends React.Component {
5959
const { owner, repo } = this.props;
6060
const { error } = this.state;
6161

62-
document.title = `What's deployed on ${owner}/${repo}?`;
62+
document.title = `What's Deployed on ${owner}/${repo}?`;
6363

6464
if (error) {
6565
return <div className="alert alert-danger">{error.toString()}</div>;

src/Routes.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ const Routes = withRouter(({ location }) => {
1818
return (
1919
<Switch>
2020
<Redirect from="/s-:code(.*)" to="/s/:code" />
21+
<Route path="/s/:code/:owner/:repo" component={DeployPage} />
2122
<Route path="/s/:code" component={DeployPage} />
2223
<Route path="/" exact component={SetupPage} />
2324
</Switch>

src/SetupPage.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export default class SetupPage extends React.Component {
88
render() {
99
return (
1010
<div>
11+
<h2 className="text-center">What's Deployed</h2>
1112
<SetupFormWithRouter />
1213
<PreviousEnvironments />
1314
<WhatIsIt />
@@ -76,7 +77,7 @@ class SetupForm extends React.Component {
7677

7778
render() {
7879
const { owner, repository, rows } = this.state;
79-
document.title = "What's deployed?";
80+
document.title = "What's Deployed?";
8081

8182
return (
8283
<form>
@@ -173,7 +174,7 @@ class PreviousEnvironments extends React.Component {
173174
<ul>
174175
{environments.map(env => (
175176
<li key={env.shortlink}>
176-
<Link to={`/s/${env.shortlink}`}>
177+
<Link to={`/s/${env.shortlink}/${env.owner}/${env.repo}`}>
177178
{env.owner}/{env.repo}
178179
</Link>
179180
<span className="names">

0 commit comments

Comments
 (0)