Skip to content

Commit c3ef5a7

Browse files
hbishwardpeet
authored andcommitted
fix(www): hide feedback and edit on github for remote packages (#9678)
For plugins not hosted in gatsby/package, the 2 features (feedback and edit in github) in the footer does not work as intended. This PR removes edit in github from the footer for remote packages. <img width="1217" alt="screen shot 2018-11-03 at 8 24 14 pm" src="https://user-images.githubusercontent.com/1014413/47950452-b344dd00-dfa6-11e8-88be-99e07a18cb8f.png">
1 parent 1daf73d commit c3ef5a7

File tree

2 files changed

+53
-103
lines changed

2 files changed

+53
-103
lines changed

www/src/components/markdown-page-footer.js

+30-88
Original file line numberDiff line numberDiff line change
@@ -1,106 +1,48 @@
11
import React from "react"
22
import { graphql } from "gatsby"
33
import EditIcon from "react-icons/lib/md/create"
4-
import CheckIcon from "react-icons/lib/md/thumb-up"
5-
import CrossIcon from "react-icons/lib/md/thumb-down"
6-
import { GraphQLClient } from "graphql-request"
74

85
import { rhythm, scale } from "../utils/typography"
96
import { colors } from "../utils/presets"
107

11-
const client = new GraphQLClient(
12-
`https://api.graph.cool/relay/v1/cj8xuo77f0a3a0164y7jketkr`
13-
)
14-
15-
function sendReview(thumbsUp, relativePath) {
16-
return client.request(`
17-
mutation {
18-
createReview(input: {thumbsUp: ${thumbsUp}, relativePath: "${relativePath}", clientMutationId: "1"}) {
19-
review {
20-
id
21-
}
22-
}
23-
}
24-
`)
25-
}
26-
278
export default class MarkdownPageFooter extends React.Component {
289
constructor() {
2910
super()
3011
this.state = { feedbackSubmitted: false }
3112
}
3213
render() {
33-
return [
34-
<hr css={{ marginTop: rhythm(2) }} key="hr" />,
35-
<div
36-
css={{
37-
marginBottom: rhythm(1),
38-
}}
39-
key="div"
40-
>
41-
{this.state.feedbackSubmitted ? (
42-
<span css={{ lineHeight: rhythm(2) }}>Thank you!</span>
43-
) : (
44-
<span css={{ lineHeight: rhythm(2) }}>
45-
Was this helpful?
46-
{` `}
47-
<CheckIcon
48-
onClick={() => {
49-
sendReview(true, this.props.page.parent.relativePath)
50-
this.setState({ feedbackSubmitted: true })
51-
}}
52-
css={{
53-
color: colors.success,
54-
fontSize: rhythm(1.3),
55-
padding: rhythm(0.2),
56-
position: `relative`,
57-
top: -3,
58-
marginLeft: rhythm(1 / 4),
59-
cursor: `pointer`,
60-
}}
61-
/>
14+
return (
15+
<>
16+
<hr css={{ marginTop: rhythm(2) }} />
17+
18+
{this.props.page && (
19+
<a
20+
css={{
21+
"&&": {
22+
display: `block`,
23+
color: colors.gray.calm,
24+
fontSize: scale(-1 / 5).fontSize,
25+
fontWeight: `normal`,
26+
border: `none`,
27+
boxShadow: `none`,
28+
padding: rhythm(1 / 2),
29+
"&:hover": {
30+
background: `transparent`,
31+
color: colors.gatsby,
32+
},
33+
},
34+
}}
35+
href={`https://github.com/gatsbyjs/gatsby/blob/master/${
36+
this.props.packagePage ? `packages` : `docs`
37+
}/${this.props.page ? this.props.page.parent.relativePath : ``}`}
38+
>
39+
<EditIcon css={{ fontSize: 20, position: `relative`, top: -2 }} />
6240
{` `}
63-
<CrossIcon
64-
onClick={() => {
65-
sendReview(false, this.props.page.parent.relativePath)
66-
this.setState({ feedbackSubmitted: true })
67-
}}
68-
css={{
69-
color: colors.warning,
70-
fontSize: rhythm(1.3),
71-
padding: rhythm(0.2),
72-
cursor: `pointer`,
73-
}}
74-
/>
75-
</span>
41+
edit this page on GitHub
42+
</a>
7643
)}
77-
<a
78-
css={{
79-
"&&": {
80-
float: `right`,
81-
display: `block`,
82-
color: colors.gray.calm,
83-
fontSize: scale(-1 / 5).fontSize,
84-
fontWeight: `normal`,
85-
border: `none`,
86-
boxShadow: `none`,
87-
padding: rhythm(1 / 2),
88-
"&:hover": {
89-
background: `transparent`,
90-
color: colors.gatsby,
91-
},
92-
},
93-
}}
94-
href={`https://github.com/gatsbyjs/gatsby/blob/master/${
95-
this.props.packagePage ? `packages` : `docs`
96-
}/${this.props.page ? this.props.page.parent.relativePath : ``}`}
97-
>
98-
<EditIcon css={{ fontSize: 20, position: `relative`, top: -2 }} />
99-
{` `}
100-
edit this page on GitHub
101-
</a>
102-
</div>,
103-
]
44+
</>
45+
)
10446
}
10547
}
10648

www/src/templates/template-docs-remote-packages.js

+23-15
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,36 @@ import React from "react"
22
import { graphql } from "gatsby"
33

44
import PackageReadme from "../components/package-readme"
5+
import Unbird from "../components/unbird"
56

67
class DocsRemotePackagesTemplate extends React.Component {
78
render() {
89
const {
910
data: { npmPackage, markdownRemark },
1011
} = this.props
1112
return (
12-
<PackageReadme
13-
page={markdownRemark}
14-
packageName={npmPackage.name}
15-
excerpt={npmPackage.readme.childMarkdownRemark.excerpt}
16-
html={npmPackage.readme.childMarkdownRemark.html}
17-
githubUrl={
18-
npmPackage.repository !== null
19-
? npmPackage.repository.url
20-
: `https://github.com/search?q=${npmPackage.name}`
21-
}
22-
modified={npmPackage.modified}
23-
timeToRead={npmPackage.readme.childMarkdownRemark.timeToRead}
24-
keywords={npmPackage.keywords}
25-
lastPublisher={npmPackage.lastPublisher}
26-
/>
13+
<>
14+
<PackageReadme
15+
page={markdownRemark}
16+
packageName={npmPackage.name}
17+
excerpt={npmPackage.readme.childMarkdownRemark.excerpt}
18+
html={npmPackage.readme.childMarkdownRemark.html}
19+
githubUrl={
20+
npmPackage.repository !== null
21+
? npmPackage.repository.url
22+
: `https://github.com/search?q=${npmPackage.name}`
23+
}
24+
modified={npmPackage.modified}
25+
timeToRead={npmPackage.readme.childMarkdownRemark.timeToRead}
26+
keywords={npmPackage.keywords}
27+
lastPublisher={npmPackage.lastPublisher}
28+
/>
29+
<Unbird
30+
dataSetId="5c1ac24b4a828a169b6c235c"
31+
publicKey={process.env.UNBIRD_FEEDBACK_KEY_PLUGINLIB}
32+
feedbackPrompt="Have feedback on the Plugin Library?"
33+
/>
34+
</>
2735
)
2836
}
2937
}

0 commit comments

Comments
 (0)