Skip to content

Commit ddfc9d8

Browse files
author
Peter Bengtsson
authored
PreviousEnvironments and the long link (#62)
* PreviousEnvironments and the long link Fixes #61 * correct key usage * console.log leftovere
1 parent a8ee744 commit ddfc9d8

File tree

3 files changed

+12
-25
lines changed

3 files changed

+12
-25
lines changed

app.py

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -326,22 +326,12 @@ def get(self):
326326
environments = []
327327
shortlinks = Shortlink.query.filter(Shortlink.link.in_(ids)).all()
328328
for shortlink in shortlinks:
329-
qs = {
330-
"repo": shortlink.repo,
331-
"owner": shortlink.owner,
332-
"name[]": [],
333-
"url[]": [],
334-
}
335-
for k, v in json.loads(shortlink.revisions):
336-
qs["name[]"].append(k)
337-
qs["url[]"].append(v)
338-
url = "/?" + urlencode(qs, True)
339329
environments.append(
340330
{
331+
"shortlink": shortlink.link,
341332
"owner": shortlink.owner,
342333
"repo": shortlink.repo,
343334
"revisions": json.loads(shortlink.revisions),
344-
"url": url,
345335
}
346336
)
347337

src/App.js

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

55
import Routes from './Routes';
@@ -23,7 +23,7 @@ class Header extends React.Component {
2323
render() {
2424
return (
2525
<h2 className="text-center">
26-
<NavLink to="/">What's Deployed?</NavLink>
26+
<Link to="/">What's Deployed?</Link>
2727
</h2>
2828
);
2929
}

src/SetupPage.js

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from 'react';
2-
import { withRouter } from 'react-router-dom';
2+
import { withRouter, Link } from 'react-router-dom';
33

44
import shortUrls from './shortUrls';
55

@@ -144,13 +144,10 @@ class SetupForm extends React.Component {
144144
const SetupFormWithRouter = withRouter(SetupForm);
145145

146146
class PreviousEnvironments extends React.Component {
147-
constructor(props) {
148-
super(props);
149-
this.state = {
150-
environments: [],
151-
loading: false
152-
};
153-
}
147+
state = {
148+
environments: [],
149+
loading: false
150+
};
154151

155152
componentWillUnmount() {
156153
this.dismounted = true;
@@ -177,13 +174,13 @@ class PreviousEnvironments extends React.Component {
177174

178175
return (
179176
<div id="previous">
180-
<h3>PreviousEnvironments</h3>
177+
<h3>Previous Environments</h3>
181178
<ul>
182179
{environments.map(env => (
183-
<li key={env.revisions[0]}>
184-
<a href={env.url}>
180+
<li key={env.shortlink}>
181+
<Link to={`/s/${env.shortlink}`}>
185182
{env.owner}/{env.repo}
186-
</a>
183+
</Link>
187184
<span className="names">
188185
{env.revisions.map(r => r[0]).join(', ')}
189186
</span>

0 commit comments

Comments
 (0)