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

Fix/delete api #15

Merged
merged 3 commits into from
Oct 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion src/components/inspector/panels/CustomPropsPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ const CustomPropsPanel = () => {
width="100%"
bgColor="lightblue"
>
Add
Save
</Button>
</Flex>
</form>
Expand Down
12 changes: 9 additions & 3 deletions src/components/inspector/panels/ParametersPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,9 @@ const ParametersPanel = () => {
optional
<Tooltip
label="Make parameter optional (?)"
fontSize="sm"
fontSize="xs"
hasArrow
placement="left"
>
<InfoOutlineIcon color="teal.300" w={3} h={3} ml={1} />
</Tooltip>
Expand All @@ -192,7 +193,12 @@ const ParametersPanel = () => {
}}
>
expose
<Tooltip label="Expose this parameter(*)" fontSize="sm" hasArrow>
<Tooltip
label="Expose this parameter(*)"
fontSize="xs"
hasArrow
placement="left"
>
<InfoOutlineIcon color="teal.300" w={3} h={3} ml={1} />
</Tooltip>
</Checkbox>
Expand All @@ -204,7 +210,7 @@ const ParametersPanel = () => {
my={0.5}
bgColor="lightblue"
>
Add
Save
</Button>
</Flex>
</form>
Expand Down
22 changes: 10 additions & 12 deletions src/pages/api/delete-file.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import fs from 'fs'
import { promises as fs } from 'fs'

export default function handler(req, res) {
export default async function handler(req, res) {
const fileName = req.body.path.split('/').slice(-1)[0]
let fileArray = fileName.split('-')
fileArray = fileArray.map(word => {
Expand All @@ -9,20 +9,18 @@ export default function handler(req, res) {
const pascalName = fileArray.join('')
try {
console.log('Deleting files...')
fs.rm(
const deletePreview = fs.unlink(
`src/custom-components/editor/previews/${pascalName}Preview.oc.tsx`,
{ recursive: true },
err => {
if (err) throw err
},
)
fs.rm(
const deletePanel = fs.unlink(
`src/custom-components/inspector/panels/components/${pascalName}Panel.oc.tsx`,
{ recursive: true },
err => {
if (err) throw err
},
)
const deleteTsx = fs.unlink(`src/custom-components/test/${fileName}.tsx`)
const deleteOcTsx = fs.unlink(
`src/custom-components/test/${fileName}.oc.tsx`,
)

await Promise.all([deletePreview, deletePanel, deleteTsx, deleteOcTsx])
res.statusCode = 200
res.json({ message: 'success' })
} catch (err) {
Expand Down