diff --git a/apps/studio-next/package.json b/apps/studio-next/package.json index 7facaebfd..b3381f274 100644 --- a/apps/studio-next/package.json +++ b/apps/studio-next/package.json @@ -7,6 +7,7 @@ "build": "next build", "start": "next start", "lint": "next lint", + "lint:fix": "next lint --fix", "cy:e2e:chrome": "cypress run --e2e --browser chrome", "cy:e2e:chromium": "cypress run --e2e --browser chromium", "cy:e2e:edge": "cypress run --e2e --browser edge", @@ -30,6 +31,7 @@ "@netlify/blobs": "^8.0.1", "@netlify/functions": "^2.8.1", "@stoplight/yaml": "^4.3.0", + "@tippyjs/react": "^4.2.6", "@types/node": "20.4.6", "@types/react": "18.2.18", "@types/react-dom": "18.2.7", diff --git a/apps/studio-next/src/netlify/functions/share-retreive.ts b/apps/studio-next/src/netlify/functions/share-retreive.ts index 69f0ee661..5cc87135b 100644 --- a/apps/studio-next/src/netlify/functions/share-retreive.ts +++ b/apps/studio-next/src/netlify/functions/share-retreive.ts @@ -1,27 +1,27 @@ -import { getStore } from "@netlify/blobs"; -import type { Config, Context } from "@netlify/functions"; +import { getStore } from '@netlify/blobs'; +import type { Config, Context } from '@netlify/functions'; export default async (req: Request, context: Context) => { - const share = getStore("share"); + const share = getStore('share'); const { shareId } = context.params; if (!shareId) { - return new Response("Not found", { status: 404 }); + return new Response('Not found', { status: 404 }); } const shareData = await share.get(shareId); if (!shareData) { - return new Response("Not found", { status: 404 }); + return new Response('Not found', { status: 404 }); } return new Response(shareData, { headers: { - "content-type": "application/json", + 'content-type': 'application/json', }, }); } export const config: Config = { - path: "/share/:shareId", + path: '/share/:shareId', }; \ No newline at end of file diff --git a/apps/studio-next/src/netlify/functions/share-store.ts b/apps/studio-next/src/netlify/functions/share-store.ts index 7e08119c9..9baf43280 100644 --- a/apps/studio-next/src/netlify/functions/share-store.ts +++ b/apps/studio-next/src/netlify/functions/share-store.ts @@ -1,26 +1,26 @@ -import { getStore } from "@netlify/blobs"; -import type { Config, Context } from "@netlify/functions"; -import { randomUUID } from "crypto"; +import { getStore } from '@netlify/blobs'; +import type { Config, Context } from '@netlify/functions'; +import { randomUUID } from 'crypto'; export default async (req: Request, context: Context) => { - const share = getStore("share"); + const share = getStore('share'); const shareId = randomUUID(); const state = await req.json(); await share.set(shareId, JSON.stringify({ - URL: context.site.url + "?share=" + shareId, + URL: `${context.site.url }?share=${ shareId}`, ...state, created: Date.now(), })) return new Response(shareId, { headers: { - "content-type": "text/plain", + 'content-type': 'text/plain', }, }); }; export const config: Config = { - path: "/share", + path: '/share', } \ No newline at end of file diff --git a/apps/studio-next/src/services/app.service.ts b/apps/studio-next/src/services/app.service.ts index 7e8b7eca6..a9abb7640 100644 --- a/apps/studio-next/src/services/app.service.ts +++ b/apps/studio-next/src/services/app.service.ts @@ -14,7 +14,7 @@ export class ApplicationService extends AbstractService { const { readOnly, url, base64, share } = this.svcs.navigationSvc.getUrlParameters(); // readOnly state should be only set to true when someone pass also url or base64 or share parameter - const isStrictReadonly = Boolean(readOnly && (url || base64 || share )); + const isStrictReadonly = Boolean(readOnly && (url || base64 || share)); let error: any; try { @@ -66,11 +66,19 @@ export class ApplicationService extends AbstractService { const language = this.svcs.formatSvc.retrieveLangauge(content); const source = url || undefined; + let from = 'url'; + + if (base64) { + from = 'base64'; + } else if (share) { + from = 'share'; + } + updateFile('asyncapi', { content, language, source, - from: url ? 'url' : base64 ? 'base64' : 'storage', + from: from as 'url' | 'base64' | 'share', }); await this.svcs.parserSvc.parse('asyncapi', content, { source }); } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 153290e6a..2c53e859a 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -440,6 +440,9 @@ importers: '@stoplight/yaml': specifier: ^4.3.0 version: 4.3.0 + '@tippyjs/react': + specifier: ^4.2.6 + version: 4.2.6(react-dom@18.2.0(react@18.2.0))(react@18.2.0) '@types/node': specifier: 20.4.6 version: 20.4.6