add url input for url jdd argument
Summary: Ref T2859 Reviewers: kuba-orlik Reviewed By: kuba-orlik Subscribers: jenkins-user Maniphest Tasks: T2859 Differential Revision: https://hub.sealcode.org/D1386
This commit is contained in:
parent
ec457ebd76
commit
20ae31bff8
@ -1,4 +1,4 @@
|
||||
import { Enum, Image, List, Structured, Table, TableData } from "@sealcode/jdd";
|
||||
import { ComponentArguments, Enum, Image, List, Structured, Table, TableData } from "@sealcode/jdd";
|
||||
import { ComponentArgument } from "@sealcode/jdd";
|
||||
import { StatefulPage } from "@sealcode/sealgen";
|
||||
import { TempstreamJSX } from "tempstream";
|
||||
@ -10,6 +10,9 @@ import { ComponentInputStructured } from "./component-input-structured.js";
|
||||
import { ComponentInputTable } from "./component-input-table.js";
|
||||
import { printArgPath } from "./print-arg-path.js";
|
||||
|
||||
export const actionName = "Components";
|
||||
const absoluteUrlPattern = "http(s?)(://)((www.)?)(([^.]+).)?([a-zA-z0-9-_]+)";
|
||||
|
||||
export function ComponentInput<State extends ComponentPreviewState, T>({
|
||||
state,
|
||||
arg_path,
|
||||
@ -30,6 +33,12 @@ export function ComponentInput<State extends ComponentPreviewState, T>({
|
||||
return ComponentInputList({ state, arg_path, arg, value: value as T[], page });
|
||||
}
|
||||
|
||||
const argType = arg.getTypeName();
|
||||
const isUrlAbsolute =
|
||||
arg instanceof ComponentArguments.URL &&
|
||||
arg.urlType === "absolute";
|
||||
const inputType = isUrlAbsolute ? "url" : "text";
|
||||
|
||||
if (arg instanceof Structured) {
|
||||
return ComponentInputStructured({
|
||||
state,
|
||||
@ -74,7 +83,7 @@ export function ComponentInput<State extends ComponentPreviewState, T>({
|
||||
<div>
|
||||
<label>
|
||||
{arg_path.at(-1) || ""}
|
||||
{arg.getTypeName() == "markdown" ? (
|
||||
{argType == "markdown" ? (
|
||||
<textarea
|
||||
name={`$.component_args${printArgPath(arg_path)}`}
|
||||
onblur={page.rerender()}
|
||||
@ -84,10 +93,11 @@ export function ComponentInput<State extends ComponentPreviewState, T>({
|
||||
</textarea>
|
||||
) : (
|
||||
<input
|
||||
type="text"
|
||||
type={inputType}
|
||||
name={`$.component_args${printArgPath(arg_path)}`}
|
||||
value={value as string}
|
||||
size="40"
|
||||
pattern={isUrlAbsolute ? absoluteUrlPattern : undefined}
|
||||
/>
|
||||
)}
|
||||
</label>
|
||||
|
Loading…
x
Reference in New Issue
Block a user