Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use mutations in Gatsby Admin #23337

Merged
merged 48 commits into from
Apr 22, 2020
Merged
Changes from 3 commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
3def3a7
fix(gatsby): Throw error on default export in gatsby-ssr/brows… (#23133)
LekoArts Apr 20, 2020
2f353f1
chore(release): Publish
LekoArts Apr 20, 2020
3dcff0c
fix(docs): Using-MDX link (#23288)
LekoArts Apr 20, 2020
5cd1d61
fix(docs): Link to apollo blog (#23290)
LekoArts Apr 20, 2020
fae27a8
fix(docs): change gatsby-config mention for global CSS import (#23245)
Js-Brecht Apr 20, 2020
85cf630
docs: added details signifying that node fields can be arbitra… (#23106)
ElijahCano33 Apr 20, 2020
5975874
chore(gatsby): drop the the (#23295)
pvdz Apr 20, 2020
0fe8008
chore(showcase): Add new sites built by Bejamas to showcase; c… (#23125)
zielinsm Apr 20, 2020
c29c6ee
chore(showcase):Add SofaScore Corporate web to showcase sites (#23128)
mnikolaus Apr 20, 2020
0dcc20a
fix local links (#23149)
muescha Apr 20, 2020
e095119
chore(docs): Reference new ComponentModel component rather than gener…
Apr 20, 2020
d69b217
fix(www): fix sidebar (#23301)
wardpeet Apr 20, 2020
d8fdee6
fix(recipes): Fix shadow-file resource for scoped NPM packages & re-e…
KyleAMathews Apr 20, 2020
c8d86ae
chore(release): Publish
KyleAMathews Apr 20, 2020
c681ccd
chore(starters): add gatsby-starter-ecommerce (#23037)
Apr 20, 2020
a9d1e94
Add site Interficie Internet Services (#23130)
aperacaula Apr 20, 2020
b333083
fix brand names (#23142)
muescha Apr 20, 2020
ab48677
fix(blog): remove local domain (#23141)
muescha Apr 20, 2020
92fee49
Create paul scanlon 100 days of Gatsby blog post and add assets (#23…
mgienow Apr 20, 2020
da93096
Clarify prefix-paths variable. (#23309)
alexfornuto Apr 20, 2020
5f1e42d
chore(showcase):Add shreysachdeva.tech to showchase (#23032)
sachdeva-shrey Apr 20, 2020
3c123c7
fix(www): Fix sidebar expansion behavior (#23325)
tesseralis Apr 21, 2020
8cfe41b
[gatsby-plugin-manifest] Generate a 32x32 favicon instead of generati…
Apr 21, 2020
442b7e5
Use mutations in Gatsby Admin
mxstbr Apr 21, 2020
435baa7
Remove stray console.logs
mxstbr Apr 21, 2020
c45b0ba
chore(gatsby-recipes): Update README typo (#23333)
marcuslyons Apr 21, 2020
ea7160d
fix(gatsby): Check for files before delete action when using GATSBY_E…
StuartRayson Apr 21, 2020
4a4d5fa
Install plugins as prod dependencies
mxstbr Apr 21, 2020
4f045c6
chore(release): Publish
pieh Apr 21, 2020
b9a28f7
Add Besoegsvenner site to showcase (#23172)
jacobpackert Apr 21, 2020
b349a04
chore(benchmarks): Add Drupal data updater script to update benchmark…
smthomas Apr 21, 2020
8a0f9c4
Make TypeScript happy
mxstbr Apr 21, 2020
da535a8
fix(gatsby): fix Uncaught TypeError in navigation.js (#23196)
shicholas Apr 21, 2020
67730fd
Add support for file argument in remark plugins for gatsby-plugin-mdx…
kevin940726 Apr 21, 2020
8ee74c1
chore(gatsby-cli) Migrate remaining files in reporters/logger/ink to …
arthurjdam Apr 21, 2020
ca3f76e
Fix Drupal data update script (#23349)
duffn Apr 21, 2020
372c843
Add noop data update scripts for all benchmarks (#23352)
duffn Apr 21, 2020
59992b7
chore(babel-preset-gatsby): Convert dependencies to TS (#22038)
MichaelDeBoey Apr 21, 2020
6a079fb
fix(gatsby): Improve error message when calling useStaticQuery withou…
blainekasten Apr 21, 2020
8b180da
Add warning message for a long queries (#23261)
AlexRAV Apr 21, 2020
ac8db6a
refactor(gatsby): Convert inference metadata to TypeScript (#23264)
chooban Apr 21, 2020
3beca2e
Update README.md (#23357)
Khaledgarbaya Apr 21, 2020
82c05aa
feat(gatsby-remark-images): support markdownCaptions in mdx + fix for…
mathieudutour Apr 22, 2020
12eaaa0
chore(release): Publish
vladar Apr 22, 2020
18de9f8
Fix lint errors
mxstbr Apr 22, 2020
9c01fb2
Fix TypeScript unused declaration error
mxstbr Apr 22, 2020
c8da75e
Fix linting
sidharthachatterjee Apr 22, 2020
ef8346f
Merge branch 'master' into feat/phpMyAdmin-mutations
mxstbr Apr 22, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 77 additions & 3 deletions packages/gatsby-admin/src/pages/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,72 @@
import React from "react"
import { useQuery } from "urql"
import { useQuery, useMutation } from "urql"

const InstallInput = () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The linter is complaining about missing return values, which is why it's failing tests. Type them as React.FC and you'll get that for free

const [value, setValue] = React.useState("")

const [_, installGatbyPlugin] = useMutation(`
mutation installGatsbyPlugin($name: String!) {
createNpmPackage(npmPackage: {
name: $name,
dependencyType: "production"
}) {
id
name
}
createGatsbyPlugin(gatsbyPlugin: {
name: $name
}) {
id
name
}
}
`)

return (
<form
onSubmit={evt => {
evt.preventDefault()
installGatbyPlugin({
name: value,
})
}}
>
<label>
Install:
<input
value={value}
onChange={evt => setValue(evt.target.value)}
type="text"
placeholder="gatsby-plugin-cool"
/>
</label>
</form>
)
}

const DestroyButton = ({ name }) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You'll need to use an interface to type the props here. Make it React.FC<ButtonProps> or similar

const [_, deleteGatsbyPlugin] = useMutation(`
mutation destroyGatsbyPlugin($name: String!) {
destroyNpmPackage(npmPackage: {
name: $name,
id: $name,
dependencyType: "production"
}) {
id
name
}
destroyGatsbyPlugin(gatsbyPlugin: {
name: $name,
id: $name
}) {
id
name
}
}
`)

return <button onClick={() => deleteGatsbyPlugin({ name })}>X</button>
}

export default (): React.ReactElement => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you give this a name and export that as default afterwards it should show up properly in devtools. As above, typing it as React.FC will give correct return and props values

const [{ data, fetching, error }] = useQuery({
Expand Down Expand Up @@ -33,17 +100,22 @@ export default (): React.ReactElement => {
{data.allGatsbyPlugin.nodes
.filter(plugin => plugin.name.indexOf(`gatsby-plugin`) === 0)
.map(plugin => (
<li key={plugin.id}>{plugin.name}</li>
<li key={plugin.id}>
{plugin.name} <DestroyButton name={plugin.name} />
</li>
))}
</ul>
<InstallInput />
<h2>Themes</h2>
<ul>
{data.allGatsbyPlugin.nodes
.filter(plugin => plugin.name.indexOf(`gatsby-theme`) === 0)
.map(plugin => (
<li key={plugin.id}>
<details>
<summary>{plugin.name}</summary>
<summary>
{plugin.name} <DestroyButton name={plugin.name} />
</summary>
<ul>
{plugin.shadowedFiles.map(file => (
<li key={file} style={{ opacity: 0.6 }}>
Expand All @@ -58,6 +130,8 @@ export default (): React.ReactElement => {
</li>
))}
</ul>

<InstallInput />
</>
)
}