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

Check form redesign #847

Merged
merged 72 commits into from
Jul 18, 2024
Merged
Show file tree
Hide file tree
Changes from 66 commits
Commits
Show all changes
72 commits
Select commit Hold shift + click to select a range
7a4a9c8
feat: zod validation set-up
ckbedwell May 3, 2024
42fd13e
feat: zod validation set-up
ckbedwell May 3, 2024
81c5a33
Merged in latest
ckbedwell May 22, 2024
21032d8
Merge branch 'main' into feat/zod-validation
ckbedwell May 22, 2024
2db0c27
feat: add multihttp zod schema
ckbedwell May 22, 2024
3eccf2e
feat: add ping schema
ckbedwell May 22, 2024
03a830a
feat: add dns schema
ckbedwell May 22, 2024
5505ef5
feat: tcp check and target validation update
ckbedwell May 22, 2024
ce5c5ba
fix: update tests
ckbedwell May 22, 2024
ee70cc0
feat: added traceroute schema
ckbedwell May 22, 2024
0b679d4
feat: added scripted check schema
ckbedwell May 22, 2024
320f336
feat: add grpc schema and fix regex validation
ckbedwell May 23, 2024
514dd14
fix: update schemas and sanitization to pass tests
ckbedwell May 23, 2024
8eab716
feat: move form wizard sidebar validation to zod without triggering r…
ckbedwell May 23, 2024
59bf6f7
chore: merged in main
ckbedwell May 23, 2024
b19aa5d
fix: self-review
ckbedwell May 29, 2024
1df392a
chore: merged in main
ckbedwell May 29, 2024
efc733a
feat: convert probe form to use zod schema
ckbedwell May 30, 2024
edced20
fix: update probeeditor error text to find
ckbedwell May 30, 2024
3e6a2a5
chore: clean up inline validation and add to schemas
ckbedwell May 30, 2024
9d9333b
fix: expand on assertion type with union for multihttp checks
ckbedwell May 30, 2024
89031d4
chore: update assertion types
ckbedwell May 30, 2024
4794c36
feat: rejigging layout
ckbedwell May 31, 2024
9a89f09
feat: checkform2 POC
ckbedwell Jun 3, 2024
f01f247
fix: pr rename to interpolateErrorMessage and tighten zod schemas
ckbedwell Jun 4, 2024
bbf9c5e
Update src/components/CheckEditor/FormComponents/HttpCheckRegExValida…
ckbedwell Jun 4, 2024
1b58c35
Update src/components/CheckEditor/FormComponents/HttpCheckRegExValida…
ckbedwell Jun 4, 2024
d8e584e
Update src/schemas/general/Header.ts
ckbedwell Jun 4, 2024
25e639f
fix: update error var names
ckbedwell Jun 4, 2024
d66d9ae
Merge branch 'feat/zod-validation' of github.com:grafana/synthetic-mo…
ckbedwell Jun 4, 2024
626a074
feat: add script size validation to schema
ckbedwell Jun 4, 2024
cb00990
chore: merged in main
ckbedwell Jun 4, 2024
88e708d
chore: merge in upstream change
ckbedwell Jun 4, 2024
de8563f
chore: merge in upstream changes
ckbedwell Jun 4, 2024
6fb7abf
chore: merged in main
ckbedwell Jun 7, 2024
66b7986
feat: wip
ckbedwell Jun 10, 2024
9bd5979
feat: multihttp rework
ckbedwell Jun 11, 2024
256b75f
feat: add request method to multihttp display
ckbedwell Jun 13, 2024
fed84d7
chore: merged in main
ckbedwell Jun 13, 2024
d4e7df0
feat: http request and multi http design updates
ckbedwell Jun 13, 2024
347b8d1
feat: clean up request fields design
ckbedwell Jun 13, 2024
d9c279b
feat: update requuest input layout
ckbedwell Jun 13, 2024
4dd6e2c
feat: supporting content
ckbedwell Jun 18, 2024
2b9ca7d
feat: request logs sidebar
ckbedwell Jun 19, 2024
c7004fc
chore: merged in main
ckbedwell Jul 3, 2024
976c97e
chore: merged in main
ckbedwell Jul 4, 2024
e246e6f
feat: add protocols to group type cards
ckbedwell Jul 4, 2024
ae0057f
feat: update check group card design
ckbedwell Jul 5, 2024
728d81c
fix: hook check form submit back up and abstract formlayout not to be…
ckbedwell Jul 5, 2024
956be48
fix: update formsidebar to drop coupling with checkformvalues
ckbedwell Jul 8, 2024
a89d00e
feat: added comprehensive checktype testing
ckbedwell Jul 9, 2024
1fcb406
fix: making editing checks work again
ckbedwell Jul 9, 2024
498ec3e
feat: added comprehensive testing coverage to the checkform
ckbedwell Jul 10, 2024
4accc32
fix: skip feature flag test that has randomly broken
ckbedwell Jul 10, 2024
e2a2689
Merge branch 'main' into feat/single-page-check-creation
ckbedwell Jul 10, 2024
77a967c
fix: hook adhoc test button back up
ckbedwell Jul 11, 2024
6928802
chore: lint fixes
ckbedwell Jul 11, 2024
d29e5f4
feat: add messaging about unable to edit request type after creation
ckbedwell Jul 11, 2024
839e56b
fix: fix all remaining broken tests
ckbedwell Jul 11, 2024
4591eaa
fix: lint errors
ckbedwell Jul 11, 2024
4fabba4
feat: universal disabled for checkform and additional tests
ckbedwell Jul 12, 2024
1619072
chore: self-review
ckbedwell Jul 12, 2024
761a2da
chore: separate http tests to different files
ckbedwell Jul 12, 2024
11b3de4
Merge branch 'main' into feat/single-page-check-creation
ckbedwell Jul 12, 2024
db5c5f0
fix: update messaging on error modal for unfound check
ckbedwell Jul 12, 2024
0e35f7e
fix: transform grpc tlsconfig
ckbedwell Jul 12, 2024
8c8ffeb
fix: remove unnecessary disabled from fields and alphabetize props on…
ckbedwell Jul 15, 2024
646982f
fix: ignore non-formlayout section components when calculating next/p…
ckbedwell Jul 15, 2024
f6c9e00
fix: updated checkeditor types and added comment for disabling reques…
ckbedwell Jul 15, 2024
ee07565
feat: added useDOMId hook
ckbedwell Jul 15, 2024
9c93c43
fix: rename VariablesFields to MultiHttpVariables
ckbedwell Jul 15, 2024
f0bbb4d
feat: make timeout a dumber component with less responsibilities
ckbedwell Jul 15, 2024
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
32 changes: 14 additions & 18 deletions src/components/Card/Card.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { createContext, HTMLAttributes, ReactNode, useContext } from 'react';
import React, { ComponentProps, createContext, HTMLAttributes, ReactNode, useContext } from 'react';
import { GrafanaTheme2 } from '@grafana/data';
import { Link, styleMixins, useStyles2 } from '@grafana/ui';
import { Link, styleMixins, Text, useStyles2 } from '@grafana/ui';
import { css, cx } from '@emotion/css';

type ContextProps = {
Expand All @@ -14,12 +14,12 @@ type CardProps = ContextProps & {

const CardContext = createContext<ContextProps>({ href: '' });

export const Card = ({ children, className, href }: CardProps) => {
export const Card = ({ children, className, href, ...rest }: CardProps) => {
const styles = useStyles2(getStyles);

return (
<CardContext.Provider value={{ href }}>
<div className={cx(styles.card, className)}>{children}</div>
<div className={cx(styles.card, className)} {...rest}>{children}</div>
</CardContext.Provider>
);
};
Expand All @@ -41,20 +41,23 @@ function getStyles(theme: GrafanaTheme2) {
}

type HeadingCommonProps = {
as?: 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6' | 'p' | 'div' | 'span';
children: ReactNode;
as?: ComponentProps<typeof Text>['element'];
children: NonNullable<ReactNode>;
className?: string;
variant?: 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6';
variant?: ComponentProps<typeof Text>['variant'];
};

type HeadingProps = HTMLAttributes<HTMLElement> & HeadingCommonProps;

const Heading = ({ as = 'h2', children, className, variant = 'h2', ...rest }: HeadingProps) => {
const Tag = as;
const styles = useStyles2((theme) => getHeadingStyles(theme, variant));
const styles = useStyles2(getHeadingStyles);
const { href } = useContext(CardContext);

const content = <Tag className={cx(styles.heading, className)}>{children}</Tag>;
const content = (
<Text element={as} variant={variant}>
{children}
</Text>
);

if (href) {
return (
Expand All @@ -67,14 +70,7 @@ const Heading = ({ as = 'h2', children, className, variant = 'h2', ...rest }: He
return content;
};

const getHeadingStyles = (theme: GrafanaTheme2, variant: 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6') => ({
heading: css({
fontFamily: theme.typography[variant].fontFamily,
fontSize: theme.typography[variant].fontSize,
fontWeight: theme.typography[variant].fontWeight,
letterSpacing: theme.typography[variant].letterSpacing,
lineHeight: theme.typography[variant].lineHeight,
}),
const getHeadingStyles = (theme: GrafanaTheme2) => ({
link: css({
display: `block`,
all: 'unset',
Expand Down
74 changes: 74 additions & 0 deletions src/components/CheckEditor/CheckEditor.types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
import { FormEvent } from 'react';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably not related to this PR and not suggesting to change it here, but I wonder why we have two separate folders for form related files, CheckEditor and CheckForm. Don't they refer to the same thing?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, good point! I was thinking as Thomas is out, we should maybe bump up this ticket and tackle it ASAP to cause the least disruption: #848. That way we can address this problem at the same time.

I'll put it in our 1:1 notes and we can discuss it on Wednesday 😃

import { FieldPath } from 'react-hook-form';

import { CheckFormValues, CheckFormValuesPing, CheckFormValuesScripted } from 'types';

export type FieldProps<T extends CheckFormValues = CheckFormValues> = {
name: FieldPath<T>;
onChange?: (e: FormEvent) => void;
'aria-label'?: string;
};

export type TLSConfigFields = {
tlsServerName?: FieldProps;
tlsInsecureSkipVerify?: FieldProps;
tlsCaSCert?: FieldProps;
tlsClientCert?: FieldProps;
tlsClientKey?: FieldProps;
};

export type HttpRequestFields = TLSConfigFields & {
method: FieldProps;
target: FieldProps;
requestHeaders: FieldProps;
requestBody: FieldProps;
followRedirects?: FieldProps;
ipVersion?: FieldProps;
requestContentType?: FieldProps;
requestContentEncoding?: FieldProps;
basicAuth?: FieldProps;
bearerToken?: FieldProps;
proxyUrl?: FieldProps;
proxyHeaders?: FieldProps;
queryParams?: FieldProps;
};

export type DNSRequestFields = {
target: FieldProps;
ipVersion: FieldProps;
recordType: FieldProps;
server: FieldProps;
protocol: FieldProps;
port: FieldProps;
ckbedwell marked this conversation as resolved.
Show resolved Hide resolved
};

export type GRPCRequestFields = TLSConfigFields & {
ipVersion: FieldProps;
target: FieldProps;
service: FieldProps;
useTLS: FieldProps;
};

export type TCPRequestFields = TLSConfigFields & {
target: FieldProps;
ipVersion: FieldProps;
useTLS: FieldProps;
};

export type PingRequestFields = {
target: FieldProps<CheckFormValuesPing>;
ipVersion: FieldProps<CheckFormValuesPing>;
dontFragment: FieldProps<CheckFormValuesPing>;
};

export type TracerouteRequestFields = {
target: FieldProps;
maxHops: FieldProps;
maxUnknownHops: FieldProps;
ptrLookup: FieldProps;
};

export type ScriptedRequestFields = {
target: FieldProps<CheckFormValuesScripted>;
script: FieldProps<CheckFormValuesScripted>;
};
Loading
Loading