فهرست منبع

Implement URL Link component

jnfrati 3 سال پیش
والد
کامیت
442677c8df

+ 4 - 0
dashboard/src/components/porter-form/PorterForm.tsx

@@ -12,6 +12,7 @@ import {
   SelectField,
   SelectField,
   ServiceIPListField,
   ServiceIPListField,
   TextAreaField,
   TextAreaField,
+  UrlLinkField,
 } from "./types";
 } from "./types";
 import TabRegion, { TabOption } from "../TabRegion";
 import TabRegion, { TabOption } from "../TabRegion";
 import Heading from "../form-components/Heading";
 import Heading from "../form-components/Heading";
@@ -29,6 +30,7 @@ import ResourceList from "./field-components/ResourceList";
 import VeleroForm from "./field-components/VeleroForm";
 import VeleroForm from "./field-components/VeleroForm";
 import CronInput from "./field-components/CronInput";
 import CronInput from "./field-components/CronInput";
 import TextAreaInput from "./field-components/TextAreaInput";
 import TextAreaInput from "./field-components/TextAreaInput";
+import UrlLink from "./field-components/UrlLink";
 
 
 interface Props {
 interface Props {
   leftTabOptions?: TabOption[];
   leftTabOptions?: TabOption[];
@@ -98,6 +100,8 @@ const PorterForm: React.FC<Props> = (props) => {
         return <CronInput {...(bundledProps as CronField)} />;
         return <CronInput {...(bundledProps as CronField)} />;
       case "text-area":
       case "text-area":
         return <TextAreaInput {...(bundledProps as TextAreaField)} />;
         return <TextAreaInput {...(bundledProps as TextAreaField)} />;
+      case "url-link":
+        return <UrlLink {...(bundledProps as UrlLinkField)} />;
     }
     }
     return <p>Not Implemented: {(field as any).type}</p>;
     return <p>Not Implemented: {(field as any).type}</p>;
   };
   };

+ 59 - 0
dashboard/src/components/porter-form/field-components/UrlLink.tsx

@@ -0,0 +1,59 @@
+import React from "react";
+import styled from "styled-components";
+import { UrlLinkField } from "../types";
+import { hasSetValue } from "../utils";
+
+const UrlLink = (props: UrlLinkField) => {
+  const { value, label } = props;
+
+  if (!hasSetValue(props)) {
+    return null;
+  }
+
+  return (
+    <>
+      <Label>{label}</Label>
+      <StyledServiceRow>
+        <a href={value[0]} target="_blank">
+          <i className="material-icons-outlined">link</i>
+          {value[0]}
+        </a>
+      </StyledServiceRow>
+    </>
+  );
+};
+
+export default UrlLink;
+
+const StyledServiceRow = styled.div`
+  width: 100%;
+  height: 40px;
+  background: #ffffff11;
+  margin-bottom: 15px;
+  border-radius: 5px;
+  padding: 15px;
+  display: flex;
+  align-items: center;
+  justify-content: space-between;
+  > a {
+    margin-left: 2px;
+    font-size: 13px;
+    user-select: text;
+    display: flex;
+    -webkit-box-align: center;
+    align-items: center;
+    > i {
+      font-size: 15px;
+      margin-right: 10px;
+    }
+  }
+`;
+
+const Label = styled.div`
+  color: #ffffff;
+  margin-bottom: 10px;
+  display: flex;
+  align-items: center;
+  font-size: 13px;
+  font-family: "Work Sans", sans-serif;
+`;

+ 7 - 1
dashboard/src/components/porter-form/types.ts

@@ -146,6 +146,11 @@ export interface TextAreaField extends GenericInputField {
   };
   };
 }
 }
 
 
+export interface UrlLinkField extends GenericInputField {
+  type: "url-link";
+  label: string;
+}
+
 export type FormField =
 export type FormField =
   | HeadingField
   | HeadingField
   | SubtitleField
   | SubtitleField
@@ -159,7 +164,8 @@ export type FormField =
   | VeleroBackupField
   | VeleroBackupField
   | VariableField
   | VariableField
   | CronField
   | CronField
-  | TextAreaField;
+  | TextAreaField
+  | UrlLinkField;
 
 
 export interface ShowIfAnd {
 export interface ShowIfAnd {
   and: ShowIf[];
   and: ShowIf[];