Skip to content

Commit

Permalink
Merge pull request #1525 from flanksource/965-add-link-documentation
Browse files Browse the repository at this point in the history
chore: add link to the documentation for canary checker
  • Loading branch information
moshloop authored Nov 27, 2023
2 parents e0830db + 94838f5 commit e5dee3f
Show file tree
Hide file tree
Showing 4 changed files with 103 additions and 37 deletions.
16 changes: 8 additions & 8 deletions src/components/Forms/SpecEditorForm.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import clsx from "clsx";
import { Form, Formik } from "formik";
import React, { useCallback, useMemo, useRef, useState } from "react";
import { Button } from "../Button";
import { Tabs, Tab } from "../Tabs/Tabs";
import { FormikCodeEditor } from "./Formik/FormikCodeEditor";
import { Icon } from "../Icon";
import DeleteResource from "../SchemaResourcePage/Delete/DeleteResource";
import {
SchemaResourceType,
schemaResourceTypes
} from "../SchemaResourcePage/resourceTypes";
import FormikTextInput from "./Formik/FormikTextInput";
import { Tab, Tabs } from "../Tabs/Tabs";
import FormikAutocompleteDropdown from "./Formik/FormikAutocompleteDropdown";
import { FormikCodeEditor } from "./Formik/FormikCodeEditor";
import FormikIconPicker from "./Formik/FormikIconPicker";
import DeleteResource from "../SchemaResourcePage/Delete/DeleteResource";
import clsx from "clsx";
import { Icon } from "../Icon";
import FormikTextInput from "./Formik/FormikTextInput";

type SpecEditorFormProps = {
loadSpec: () => Record<string, any>;
Expand Down Expand Up @@ -206,8 +206,8 @@ export default function SpecEditorForm({
)}
</div>
</div>
<div className="flex flex-row bg-gray-100 p-4">
<div className="flex flex-1 flex-row space-x-4 justify-end">
<div className="flex flex-row bg-gray-100 p-4">
<div className="flex flex-1 flex-row items-center space-x-4 justify-end">
{!!cantEditMessage && !canEdit && !!initialValues.id && (
<div className="flex items-center px-4 space-x-2 flex-1">
<Icon name="k8s" />
Expand Down
30 changes: 29 additions & 1 deletion src/components/Modal/index.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,19 @@
import { Dialog, Transition } from "@headlessui/react";
import { XIcon } from "@heroicons/react/solid";
import clsx from "clsx";
import { atom, useAtom } from "jotai";
import PropTypes from "prop-types";
import React, { Fragment } from "react";
import { IoMdHelp } from "react-icons/io";

/**
*
* An atom that can be used to set the help link for a modal. This is used to
* display a help icon in the top right corner of the modal that links to the
* documentation for the modal.
*
*/
export const modalHelpLinkAtom = atom<string | undefined>(undefined);

type ModalSize = "small" | "slightly-small" | "medium" | "large" | "full";

Expand Down Expand Up @@ -46,6 +57,8 @@ export function Modal({
dialogClassName = "fixed z-50 inset-0 overflow-y-auto 2xl:my-20",
...rest
}: IModalProps) {
const [helpLink] = useAtom(modalHelpLinkAtom);

return (
/* @ts-ignore */
<Transition.Root show={open} as={Fragment}>
Expand Down Expand Up @@ -90,7 +103,7 @@ export function Modal({
modalClassMap[size]
)}
>
<div className="py-4 px-4 flex item-center rounded-t-lg justify-between bg-gray-100">
<div className="py-4 px-4 gap-2 flex item-center rounded-t-lg justify-between bg-gray-100">
<h1
className={clsx(
"font-semibold flex-1 overflow-x-auto text-lg",
Expand All @@ -99,6 +112,21 @@ export function Modal({
>
{title}
</h1>
{/*
If the modal has a help link, display a help icon in the top right
corner of the modal that links to the documentation for the modal.
*/}
{helpLink && (
<a
title="Link to documentation"
href={helpLink}
target="_blank"
rel="noopener noreferrer"
className="flex items-center justify-center text-gray-400 hover:text-gray-500 focus:outline-none"
>
<IoMdHelp size={22} className="inline-block" />
</a>
)}
{/* top-right close button */}
{!hideCloseButton && (
<div className="flex pointer-events-none sm:pointer-events-auto">
Expand Down
84 changes: 56 additions & 28 deletions src/components/SpecEditor/HealthSpecEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ export default function HealthSpecEditor({
configForm: HTTPHealthFormEditor,
specsMapField: "http.0",
rawSpecInput: false,
schemaFilePrefix: "canary"
schemaFilePrefix: "canary",
docsLink: "https://canarychecker.io/reference/http"
},
{
name: "awsConfigRule",
Expand All @@ -60,7 +61,8 @@ export default function HealthSpecEditor({
configForm: null,
specsMapField: "awsConfigRule.0",
rawSpecInput: true,
schemaFilePrefix: "canary"
schemaFilePrefix: "canary",
docsLink: "https://canarychecker.io/reference/aws-config-rule"
},
{
name: "awsConfig",
Expand All @@ -75,7 +77,8 @@ export default function HealthSpecEditor({
configForm: null,
specsMapField: "awsConfig.0",
rawSpecInput: true,
schemaFilePrefix: "canary"
schemaFilePrefix: "canary",
docsLink: "https://canarychecker.io/reference/aws-config"
},
{
name: "github",
Expand Down Expand Up @@ -105,7 +108,8 @@ export default function HealthSpecEditor({
configForm: null,
specsMapField: "ec2.0",
rawSpecInput: true,
schemaFilePrefix: "canary"
schemaFilePrefix: "canary",
docsLink: "https://canarychecker.io/reference/ec2"
},
{
name: "ldap",
Expand All @@ -120,7 +124,8 @@ export default function HealthSpecEditor({
configForm: null,
specsMapField: "ldap.0",
rawSpecInput: true,
schemaFilePrefix: "canary"
schemaFilePrefix: "canary",
docsLink: "https://canarychecker.io/reference/ldap"
},
{
name: "pod",
Expand All @@ -135,7 +140,8 @@ export default function HealthSpecEditor({
configForm: null,
specsMapField: "pod.0",
rawSpecInput: true,
schemaFilePrefix: "canary"
schemaFilePrefix: "canary",
docsLink: "https://canarychecker.io/reference/pod"
},
{
name: "exec",
Expand All @@ -150,7 +156,8 @@ export default function HealthSpecEditor({
configForm: ExecHealthFormEditor,
specsMapField: "exec.0",
rawSpecInput: false,
schemaFilePrefix: "canary"
schemaFilePrefix: "canary",
docsLink: "https://canarychecker.io/reference/exec"
},
{
name: "alertManager",
Expand All @@ -165,7 +172,8 @@ export default function HealthSpecEditor({
configForm: AlertmanagerHealthFormEditor,
specsMapField: "alertManager.0",
rawSpecInput: false,
schemaFilePrefix: "canary"
schemaFilePrefix: "canary",
docsLink: "https://canarychecker.io/reference/alert-manager"
},
{
name: "cloudwatch",
Expand All @@ -180,7 +188,8 @@ export default function HealthSpecEditor({
configForm: null,
specsMapField: "cloudwatch.0",
rawSpecInput: true,
schemaFilePrefix: "canary"
schemaFilePrefix: "canary",
docsLink: "https://canarychecker.io/reference/cloudwatch"
},
{
name: "elasticsearch",
Expand All @@ -195,7 +204,8 @@ export default function HealthSpecEditor({
configForm: ElasticsearchHealthFormEditor,
specsMapField: "elasticsearch.0",
rawSpecInput: false,
schemaFilePrefix: "canary"
schemaFilePrefix: "canary",
docsLink: "https://canarychecker.io/reference/elasticsearch"
},
{
name: "redis",
Expand All @@ -210,7 +220,8 @@ export default function HealthSpecEditor({
configForm: RedisHealthFormEditor,
specsMapField: "redis.0",
rawSpecInput: false,
schemaFilePrefix: "canary"
schemaFilePrefix: "canary",
docsLink: "https://canarychecker.io/reference/redis"
},
{
name: "mongo",
Expand All @@ -225,7 +236,8 @@ export default function HealthSpecEditor({
configForm: MongoHealthFormEditor,
specsMapField: "mongo.0",
rawSpecInput: false,
schemaFilePrefix: "canary"
schemaFilePrefix: "canary",
docsLink: "https://canarychecker.io/reference/mongo"
},
{
name: "dns",
Expand All @@ -240,7 +252,8 @@ export default function HealthSpecEditor({
configForm: null,
specsMapField: "dns.0",
rawSpecInput: true,
schemaFilePrefix: "canary"
schemaFilePrefix: "canary",
docsLink: "https://canarychecker.io/reference/dns"
},
{
name: "ping",
Expand All @@ -254,7 +267,8 @@ export default function HealthSpecEditor({
icon: "icmp",
configForm: ICMPHealthFormEditor,
specsMapField: "icmp.0",
schemaFilePrefix: "canary"
schemaFilePrefix: "canary",
docsLink: "https://canarychecker.io/reference/icmp"
},
{
name: "gcs",
Expand All @@ -269,7 +283,8 @@ export default function HealthSpecEditor({
configForm: null,
specsMapField: "gcs.0",
rawSpecInput: true,
schemaFilePrefix: "canary"
schemaFilePrefix: "canary",
docsLink: "https://canarychecker.io/reference/gcs-bucket"
},
{
name: "s3",
Expand All @@ -284,7 +299,8 @@ export default function HealthSpecEditor({
configForm: null,
specsMapField: "s3.0",
rawSpecInput: true,
schemaFilePrefix: "canary"
schemaFilePrefix: "canary",
docsLink: "https://canarychecker.io/reference/s3-bucket"
},
{
name: "smb",
Expand All @@ -299,7 +315,8 @@ export default function HealthSpecEditor({
configForm: null,
specsMapField: "smb.0",
rawSpecInput: true,
schemaFilePrefix: "canary"
schemaFilePrefix: "canary",
docsLink: "https://canarychecker.io/reference/smb"
},
{
name: "sftp",
Expand All @@ -314,7 +331,8 @@ export default function HealthSpecEditor({
configForm: null,
specsMapField: "sftp.0",
rawSpecInput: true,
schemaFilePrefix: "canary"
schemaFilePrefix: "canary",
docsLink: "https://canarychecker.io/reference/sftp"
},
{
name: "folder",
Expand All @@ -329,7 +347,8 @@ export default function HealthSpecEditor({
configForm: FolderHealthFormEditor,
specsMapField: "folder.0",
rawSpecInput: false,
schemaFilePrefix: "canary"
schemaFilePrefix: "canary",
docsLink: "https://canarychecker.io/reference/folder"
},
{
name: "prometheus",
Expand All @@ -344,7 +363,8 @@ export default function HealthSpecEditor({
configForm: null,
specsMapField: "prometheus.0",
rawSpecInput: true,
schemaFilePrefix: "canary"
schemaFilePrefix: "canary",
docsLink: "https://canarychecker.io/reference/prometheus"
},
{
name: "kubernetes",
Expand All @@ -359,7 +379,8 @@ export default function HealthSpecEditor({
configForm: null,
specsMapField: "kubernetes.0",
rawSpecInput: true,
schemaFilePrefix: "canary"
schemaFilePrefix: "canary",
docsLink: "https://canarychecker.io/reference/kubernetes"
},
{
name: "sql",
Expand All @@ -374,7 +395,8 @@ export default function HealthSpecEditor({
configForm: null,
specsMapField: "sql.0",
rawSpecInput: true,
schemaFilePrefix: "canary"
schemaFilePrefix: "canary",
docsLink: "https://canarychecker.io/reference/postgres"
},
{
name: "configDB",
Expand All @@ -389,7 +411,8 @@ export default function HealthSpecEditor({
configForm: null,
specsMapField: "configDB.0",
rawSpecInput: true,
schemaFilePrefix: "canary"
schemaFilePrefix: "canary",
docsLink: "https://canarychecker.io/reference/configdb"
},
{
name: "azureDevops",
Expand All @@ -404,7 +427,8 @@ export default function HealthSpecEditor({
configForm: null,
specsMapField: "azureDevops.0",
rawSpecInput: true,
schemaFilePrefix: "canary"
schemaFilePrefix: "canary",
docsLink: "https://canarychecker.io/reference/azure-devops"
},
{
name: "jmeter",
Expand All @@ -419,7 +443,8 @@ export default function HealthSpecEditor({
configForm: null,
specsMapField: "jmeter.0",
rawSpecInput: true,
schemaFilePrefix: "canary"
schemaFilePrefix: "canary",
docsLink: "https://canarychecker.io/reference/jmeter"
},
{
name: "junit",
Expand All @@ -434,7 +459,8 @@ export default function HealthSpecEditor({
configForm: null,
specsMapField: "junit.0",
rawSpecInput: true,
schemaFilePrefix: "canary"
schemaFilePrefix: "canary",
docsLink: "https://canarychecker.io/reference/junit"
},
{
name: "dynatrace",
Expand Down Expand Up @@ -464,7 +490,8 @@ export default function HealthSpecEditor({
configForm: null,
specsMapField: "namespace.0",
rawSpecInput: true,
schemaFilePrefix: "canary"
schemaFilePrefix: "canary",
docsLinks: "https://canarychecker.io/reference/kubernetes"
},
{
name: "tcp",
Expand All @@ -479,7 +506,8 @@ export default function HealthSpecEditor({
configForm: TCPHealthFormEditor,
specsMapField: "tcp.0",
rawSpecInput: false,
schemaFilePrefix: "canary"
schemaFilePrefix: "canary",
docsLink: "https://canarychecker.io/reference/tcp"
},
{
name: "custom",
Expand Down
Loading

0 comments on commit e5dee3f

Please sign in to comment.