Skip to content

Commit

Permalink
Merge branch 'landing-page-redesign' of github.com:grafana/synthetic-…
Browse files Browse the repository at this point in the history
…monitoring-app into landing-page-redesign
  • Loading branch information
rdubrock committed Apr 26, 2024
2 parents bbd79d0 + a18a4b3 commit 5c96bba
Show file tree
Hide file tree
Showing 8 changed files with 77 additions and 61 deletions.
64 changes: 53 additions & 11 deletions src/components/CheckEditor/FormComponents/ScriptedCheckScript.tsx
@@ -1,24 +1,66 @@
import React from 'react';
import { Controller, useFormContext } from 'react-hook-form';
import { Tab, TabContent, TabsBar } from '@grafana/ui';

import { CheckFormValuesScripted } from 'types';
import { CodeEditor } from 'components/CodeEditor';
import { ScriptExamplesMenu } from 'components/ScriptExamplesMenu/ScriptExamplesMenu';
import { CodeSnippet } from 'components/CodeSnippet';
import { SCRIPT_EXAMPLES } from 'components/WelcomeTabs/constants';

enum ScriptEditorTabs {
Script = 'script',
Examples = 'examples',
}

export const ScriptedCheckScript = () => {
const { control, setValue, getValues } = useFormContext<CheckFormValuesScripted>();
const id = getValues('id');
const { control } = useFormContext<CheckFormValuesScripted>();
const [selectedTab, setSelectedTab] = React.useState(ScriptEditorTabs.Script);

return (
<>
{!id && <ScriptExamplesMenu onSelectExample={(script) => setValue('settings.scripted.script', script)} />}
<Controller
name="settings.scripted.script"
control={control}
render={({ field }) => {
return <CodeEditor {...field} />;
}}
/>
<TabsBar>
<Tab
label="Script"
onChangeTab={() => setSelectedTab(ScriptEditorTabs.Script)}
active={selectedTab === ScriptEditorTabs.Script}
/>
<Tab
label="Examples"
onChangeTab={() => setSelectedTab(ScriptEditorTabs.Examples)}
active={selectedTab === ScriptEditorTabs.Examples}
/>
</TabsBar>
<TabContent>
{selectedTab === ScriptEditorTabs.Script && (
<Controller
name="settings.scripted.script"
control={control}
render={({ field }) => {
return <CodeEditor {...field} />;
}}
/>
)}
{selectedTab === ScriptEditorTabs.Examples && (
<CodeSnippet
hideHeader
canCopy={true}
tabs={[
{
value: 'Example scripts',
label: '',
groups: SCRIPT_EXAMPLES.map(({ label, script }) => ({
value: label,
label,
code: script,
lang: 'js',
})),
},
]}
dedent={true}
lang="js"
/>
)}
</TabContent>
</>
);
};
2 changes: 2 additions & 0 deletions src/components/CodeSnippet/CodeSnippet.tsx
Expand Up @@ -60,6 +60,7 @@ export const CodeSnippet = ({
initialTab,
tabs = [],
className,
hideHeader,
}: CodeSnippetProps) => {
const [activeTab, setActiveTab] = useState<string | undefined>(initialTab);
const [activeGroup, setActiveGroup] = useState<string | undefined>();
Expand Down Expand Up @@ -97,6 +98,7 @@ export const CodeSnippet = ({

return (
<SnippetWindow
hideHeader={hideHeader}
titleContent={
tabs.length > 0 && (
<TabsBar className={styles.tabsBar}>
Expand Down
1 change: 1 addition & 0 deletions src/components/CodeSnippet/CodeSnippet.types.ts
Expand Up @@ -27,6 +27,7 @@ export interface CodeSnippetProps {
tabs?: CodeSnippetTab[];
height?: string;
className?: string;
hideHeader?: boolean;
}

export interface CodeSnippetTabProps {
Expand Down
6 changes: 3 additions & 3 deletions src/components/CodeSnippet/SnippetWindow.tsx
Expand Up @@ -7,6 +7,7 @@ interface SnippetWindowProps {
titleContent?: ReactNode;
children?: ReactNode;
className?: string;
hideHeader?: boolean;
}

interface TitleBarProps {
Expand All @@ -28,12 +29,12 @@ function TitleBar({ children }: TitleBarProps) {
);
}

export function SnippetWindow({ titleContent, className, children }: SnippetWindowProps) {
export function SnippetWindow({ titleContent, className, children, hideHeader }: SnippetWindowProps) {
const styles = useStyles2(getStyles);

return (
<div className={cx(styles.appWindowStyled, className)}>
<TitleBar>{titleContent}</TitleBar>
{!hideHeader && <TitleBar>{titleContent}</TitleBar>}
<div className={styles.contentContainer}>{children}</div>
</div>
);
Expand Down Expand Up @@ -70,7 +71,6 @@ export function getStyles(theme: GrafanaTheme2) {
marginRight: '5px',
}),
contentContainer: css({
width: '100%',
display: 'flex',
flexDirection: 'column',
border: `1px ${theme.colors.border.medium} solid`,
Expand Down
33 changes: 0 additions & 33 deletions src/components/ScriptExamplesMenu/ScriptExamplesMenu.tsx

This file was deleted.

17 changes: 12 additions & 5 deletions src/components/WelcomeTabs/WelcomeTabContent.tsx
Expand Up @@ -20,7 +20,7 @@ export function WelcomeTabContent({ activeTab }: Props) {
case WelcomeTab.Protocol:
return (
<>
<p>Send individual requests via HTTP, DNS, TCP, PING or traceroute</p>
<p className={styles.text}>Send individual requests via HTTP, DNS, TCP, PING or traceroute</p>

<img
src={config.theme2.isDark ? dashboardDark : dashboardLight}
Expand All @@ -32,7 +32,7 @@ export function WelcomeTabContent({ activeTab }: Props) {
case WelcomeTab.K6:
return (
<>
<p>Use k6 scripts to monitor your services flexibly</p>
<p className={styles.text}>Use k6 scripts to monitor your services flexibly</p>
<CodeSnippet
canCopy={true}
className={styles.codeSnippet}
Expand All @@ -56,7 +56,7 @@ export function WelcomeTabContent({ activeTab }: Props) {
case WelcomeTab.PrivateProbes:
return (
<>
<p>
<p className={styles.text}>
In addition to the locations we provide out of the box, you can set up your own probes to run inside your
network or from a location of your choosing
</p>
Expand All @@ -70,7 +70,7 @@ export function WelcomeTabContent({ activeTab }: Props) {
case WelcomeTab.AsCode:
return (
<>
<p>
<p className={styles.text}>
Manage your checks as code, either via{' '}
<a
href="https://registry.terraform.io/providers/grafana/grafana/latest/docs/resources/synthetic_monitoring_check"
Expand Down Expand Up @@ -114,8 +114,15 @@ export function WelcomeTabContent({ activeTab }: Props) {

function getStyles(theme: GrafanaTheme2) {
return {
screenshot: css({ maxHeight: '700px', maxWidth: '100%', marginBottom: theme.spacing(5) }),
screenshot: css({ maxWidth: '100%' }),
tabContent: css({ marginTop: theme.spacing(4) }),
codeSnippet: css({ height: '700px' }),
text: css({
fontSize: theme.typography.h5.fontSize,
marginLeft: `auto`,
marginRight: `auto`,
marginBottom: theme.spacing(4),
maxWidth: `640px`,
}),
};
}
4 changes: 2 additions & 2 deletions src/components/WelcomeTabs/WelcomeTabs.tsx
Expand Up @@ -60,7 +60,7 @@ export function WelcomeTabs() {

function getStyles(theme: GrafanaTheme2) {
return {
tabContent: css({ marginTop: theme.spacing(4), maxWidth: '100%', minHeight: '500px' }),
tabBar: css({ maxWidth: '560px', width: '100%' }),
tabContent: css({ margin: theme.spacing(4, 0, 8) }),
tabBar: css({ maxWidth: '560px', width: '100%', margin: `auto` }),
};
}
11 changes: 4 additions & 7 deletions src/page/WelcomePage.tsx
Expand Up @@ -202,7 +202,7 @@ export const WelcomePage: FC<Props> = () => {
<PluginPage layout={PageLayoutType.Canvas}>
<div className={styles.container}>
<div className={styles.header}>
<img src={meta?.info.logos.large} className={styles.logo} />
<img src={meta?.info.logos.large} className={styles.logo} role="presentation" />
<h1 className={styles.title}>
Proactively monitor your endpoints and user flows from locations around the world
</h1>
Expand Down Expand Up @@ -271,7 +271,7 @@ function getStyles(theme: GrafanaTheme2) {
textAlign: 'center',
}),
header: css({
maxWidth: '520px',
maxWidth: '660px',
display: 'flex',
flexDirection: 'column',
justifyContent: 'flex-start',
Expand All @@ -292,18 +292,15 @@ function getStyles(theme: GrafanaTheme2) {
color: theme.colors.text.secondary,
}),
getStartedButton: css({
marginTop: theme.spacing(8),
marginTop: theme.spacing(4),
}),
divider: css({
width: '100%',
}),
valueProp: css({
marginTop: theme.spacing(6),
maxWidth: '700px',
maxWidth: '860px',
width: '100%',
display: 'flex',
flexDirection: 'column',
alignItems: 'center',
}),
valuePropHeader: css({ marginBottom: theme.spacing(4) }),
};
Expand Down

0 comments on commit 5c96bba

Please sign in to comment.