#654 - Add the open on website action

This commit is contained in:
Elio Struyf
2023-09-07 16:25:52 +02:00
parent 3f578fdfa9
commit c6ec07fa17
22 changed files with 154 additions and 18 deletions
+3
View File
@@ -7,6 +7,7 @@ import { SlugAction } from './SlugAction';
import { StartServerButton } from './StartServerButton';
import * as l10n from '@vscode/l10n';
import { LocalizationKey } from '../../localization';
import { OpenOnWebsiteAction } from './Actions/OpenOnWebsiteAction';
export interface IActionsProps {
metadata: any;
@@ -28,6 +29,8 @@ const Actions: React.FunctionComponent<IActionsProps> = ({
{settings?.preview?.host && <Preview slug={metadata.slug} />}
<OpenOnWebsiteAction baseUrl={settings.websiteUrl} slug={metadata.slug} />
<StartServerButton settings={settings} />
{settings && settings.scripts && settings.scripts.length > 0 && (
@@ -0,0 +1,33 @@
import { messageHandler } from '@estruyf/vscode/dist/client';
import * as React from 'react';
import { ActionButton } from '../ActionButton';
import * as l10n from "@vscode/l10n"
import { LocalizationKey } from '../../../localization';
import { GeneralCommands } from '../../../constants';
export interface IOpenOnWebsiteActionProps {
baseUrl: string;
slug: string;
}
export const OpenOnWebsiteAction: React.FunctionComponent<IOpenOnWebsiteActionProps> = ({
baseUrl,
slug
}: React.PropsWithChildren<IOpenOnWebsiteActionProps>) => {
const open = () => {
messageHandler.send(GeneralCommands.toVSCode.openOnWebsite, {
websiteUrl: baseUrl,
});
};
if (!baseUrl || !slug) {
return null;
}
return (
<ActionButton
title={l10n.t(LocalizationKey.commonOpenOnWebsite)}
onClick={open} />
);
};
@@ -0,0 +1 @@
export * from './OpenOnWebsiteAction';