-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: Workshop documentation updates
- Loading branch information
Showing
11 changed files
with
171 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
# Part 3: Code - React Cat Preview Field Extension | ||
|
||
Below is the code for the React component that we will be creating in this exercise. This component will display a random cat picture from the Cat API. | ||
|
||
```typescript | ||
import React, { useEffect, useState } from 'react'; | ||
import { FieldExtensionComponentProps } from '@backstage/plugin-scaffolder-react'; | ||
import FormControl from '@material-ui/core/FormControl'; | ||
import { Button, FormHelperText, FormLabel } from '@material-ui/core'; | ||
|
||
export interface CatResult { | ||
id: string; | ||
url: string; | ||
width: number; | ||
height: number; | ||
} | ||
|
||
/* | ||
This is the actual component that will get rendered in the form | ||
*/ | ||
export const RandomCatPixExtension = ({ | ||
onChange, | ||
rawErrors, | ||
required, | ||
formData, | ||
}: FieldExtensionComponentProps<string>) => { | ||
const [catPic, setCatPic] = useState(''); | ||
|
||
const refreshPic = async () => { | ||
const catResult = await fetch('https://api.thecatapi.com/v1/images/search'); | ||
const catData: Record<string, CatResult> = await catResult.json(); | ||
setCatPic(catData[0].url); | ||
onChange(catData[0].url); | ||
}; | ||
|
||
useEffect(() => { | ||
refreshPic(); | ||
}, []); | ||
|
||
return ( | ||
<FormControl | ||
margin="normal" | ||
required={required} | ||
error={rawErrors?.length > 0 && !formData} | ||
> | ||
<FormLabel>Random Cat Picture</FormLabel> | ||
<Button variant="contained" color="primary" onClick={() => refreshPic()}> | ||
Refresh 😻 | ||
</Button> | ||
|
||
<img src={catPic} alt="Random Cat" width={'500px'} /> | ||
|
||
<FormHelperText id="entityName"> | ||
Giving you a random cat picture, all day, every day. | ||
</FormHelperText> | ||
</FormControl> | ||
); | ||
}; | ||
``` |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# Clean up | ||
|
||
??? Info "Pro tip" | ||
|
||
You can delete via the `gh cli` as well. Run the following command to delete the repository: | ||
|
||
```bash | ||
gh repo delete <repo-name> --confirm | ||
``` | ||
|
||
The same you can do with the Codespaces. Run the following command to delete the Codespace: | ||
|
||
```bash | ||
gh codespace list | ||
gh codespace delete -c <codespace-id> | ||
``` | ||
|
||
Be-careful with the `gh cli` as it can delete things without asking for confirmation. | ||
|
||
## Codespaces | ||
|
||
During the workshop we used GitHub Codespaces. The Codespace will be automatically stopped after 30 minutes of inactivity. But now the workshop is over, you can delete the Codespace to avoid any burning down your free tier or generate costs depending on your payment plan. | ||
|
||
Go to the [Codespace overview page](https://github.com/codespaces) and delete the Codespace created for this workshops. | ||
|
||
## Repositories | ||
|
||
During the workshops you have created several repositories. You can delete the repositories now safely as they are not needed anymore. | ||
|
||
Go to the the your user page, select the repositories tab. Next select the repository you want to delete and go to the settings. Scroll down to the danger zone and delete the repository. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters