fixing lints
Some checks failed
CI / Rustfmt (push) Successful in 52s
CI / Clippy (push) Failing after 22m37s
CI / Cargo Audit & Deny (push) Successful in 2m11s
CI / Security Blocking Checks (push) Successful in 52s
CI / Web Advisory Checks (push) Failing after 20m36s
CI / Web Blocking Checks (push) Failing after 38m23s
CI / Security Advisory Checks (push) Failing after 11m48s
CI / Tests (push) Failing after 1h32m20s
Publish Images And Chart / Resolve Publish Metadata (push) Successful in 5s
Publish Images And Chart / Publish migrations (push) Failing after 39s
Publish Images And Chart / Publish sensor (push) Failing after 33s
Publish Images And Chart / Publish web (push) Failing after 34s
Publish Images And Chart / Publish init-user (push) Failing after 2m0s
Publish Images And Chart / Publish worker (push) Failing after 33s
Publish Images And Chart / Publish api (push) Failing after 32s
Publish Images And Chart / Publish executor (push) Failing after 34s
Publish Images And Chart / Publish notifier (push) Failing after 37s
Publish Images And Chart / Publish init-packs (push) Failing after 12m15s
Publish Images And Chart / Publish Helm Chart (push) Has been cancelled
Some checks failed
CI / Rustfmt (push) Successful in 52s
CI / Clippy (push) Failing after 22m37s
CI / Cargo Audit & Deny (push) Successful in 2m11s
CI / Security Blocking Checks (push) Successful in 52s
CI / Web Advisory Checks (push) Failing after 20m36s
CI / Web Blocking Checks (push) Failing after 38m23s
CI / Security Advisory Checks (push) Failing after 11m48s
CI / Tests (push) Failing after 1h32m20s
Publish Images And Chart / Resolve Publish Metadata (push) Successful in 5s
Publish Images And Chart / Publish migrations (push) Failing after 39s
Publish Images And Chart / Publish sensor (push) Failing after 33s
Publish Images And Chart / Publish web (push) Failing after 34s
Publish Images And Chart / Publish init-user (push) Failing after 2m0s
Publish Images And Chart / Publish worker (push) Failing after 33s
Publish Images And Chart / Publish api (push) Failing after 32s
Publish Images And Chart / Publish executor (push) Failing after 34s
Publish Images And Chart / Publish notifier (push) Failing after 37s
Publish Images And Chart / Publish init-packs (push) Failing after 12m15s
Publish Images And Chart / Publish Helm Chart (push) Has been cancelled
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -78,3 +78,4 @@ docker-compose.override.yml
|
|||||||
*.pid
|
*.pid
|
||||||
|
|
||||||
packs.examples/
|
packs.examples/
|
||||||
|
codex/
|
||||||
|
|||||||
@@ -2,6 +2,5 @@ target/
|
|||||||
web/dist/
|
web/dist/
|
||||||
web/node_modules/
|
web/node_modules/
|
||||||
web/src/api/
|
web/src/api/
|
||||||
packs/
|
|
||||||
packs.dev/
|
packs.dev/
|
||||||
packs.external/
|
packs.external/
|
||||||
|
|||||||
@@ -29,8 +29,8 @@ use crate::{
|
|||||||
pack::{
|
pack::{
|
||||||
BuildPackEnvsRequest, BuildPackEnvsResponse, CreatePackRequest, DownloadPacksRequest,
|
BuildPackEnvsRequest, BuildPackEnvsResponse, CreatePackRequest, DownloadPacksRequest,
|
||||||
DownloadPacksResponse, GetPackDependenciesRequest, GetPackDependenciesResponse,
|
DownloadPacksResponse, GetPackDependenciesRequest, GetPackDependenciesResponse,
|
||||||
InstallPackRequest, PackInstallResponse, PackResponse, PackSummary,
|
InstallPackRequest, PackDescriptionPatch, PackInstallResponse, PackResponse,
|
||||||
PackDescriptionPatch, PackWorkflowSyncResponse, PackWorkflowValidationResponse,
|
PackSummary, PackWorkflowSyncResponse, PackWorkflowValidationResponse,
|
||||||
RegisterPackRequest, RegisterPacksRequest, RegisterPacksResponse, UpdatePackRequest,
|
RegisterPackRequest, RegisterPacksRequest, RegisterPacksResponse, UpdatePackRequest,
|
||||||
WorkflowSyncResult,
|
WorkflowSyncResult,
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -26,8 +26,8 @@ use crate::{
|
|||||||
common::{PaginatedResponse, PaginationParams},
|
common::{PaginatedResponse, PaginationParams},
|
||||||
trigger::{
|
trigger::{
|
||||||
CreateSensorRequest, CreateTriggerRequest, SensorJsonPatch, SensorResponse,
|
CreateSensorRequest, CreateTriggerRequest, SensorJsonPatch, SensorResponse,
|
||||||
SensorSummary, TriggerJsonPatch, TriggerResponse, TriggerStringPatch,
|
SensorSummary, TriggerJsonPatch, TriggerResponse, TriggerStringPatch, TriggerSummary,
|
||||||
TriggerSummary, UpdateSensorRequest, UpdateTriggerRequest,
|
UpdateSensorRequest, UpdateTriggerRequest,
|
||||||
},
|
},
|
||||||
ApiResponse, SuccessResponse,
|
ApiResponse, SuccessResponse,
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import tseslint from 'typescript-eslint'
|
|||||||
import { defineConfig, globalIgnores } from 'eslint/config'
|
import { defineConfig, globalIgnores } from 'eslint/config'
|
||||||
|
|
||||||
export default defineConfig([
|
export default defineConfig([
|
||||||
globalIgnores(['dist']),
|
globalIgnores(['dist', 'src/api']),
|
||||||
{
|
{
|
||||||
files: ['**/*.{ts,tsx}'],
|
files: ['**/*.{ts,tsx}'],
|
||||||
extends: [
|
extends: [
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { useEffect, useMemo, useState } from "react";
|
import { useMemo, useState } from "react";
|
||||||
import { useNavigate } from "react-router-dom";
|
import { useNavigate } from "react-router-dom";
|
||||||
import { usePacks } from "@/hooks/usePacks";
|
import { usePacks } from "@/hooks/usePacks";
|
||||||
import { useCreateRuntime, useUpdateRuntime } from "@/hooks/useRuntimes";
|
import { useCreateRuntime, useUpdateRuntime } from "@/hooks/useRuntimes";
|
||||||
@@ -15,7 +15,15 @@ interface RuntimeFormProps {
|
|||||||
onCancel?: () => void;
|
onCancel?: () => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
type JsonObject = Record<string, any>;
|
type JsonValue =
|
||||||
|
| string
|
||||||
|
| number
|
||||||
|
| boolean
|
||||||
|
| null
|
||||||
|
| { [key: string]: JsonValue }
|
||||||
|
| JsonValue[];
|
||||||
|
type JsonObject = { [key: string]: JsonValue };
|
||||||
|
type NonNullJsonValue = Exclude<JsonValue, null>;
|
||||||
|
|
||||||
function prettyJson(value: unknown): string {
|
function prettyJson(value: unknown): string {
|
||||||
return JSON.stringify(value ?? {}, null, 2);
|
return JSON.stringify(value ?? {}, null, 2);
|
||||||
@@ -40,7 +48,11 @@ function validateObjectJson(label: string, raw: string): JsonObject {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function validateJsonValue(label: string, raw: string, required = true): any {
|
function validateJsonValue(
|
||||||
|
label: string,
|
||||||
|
raw: string,
|
||||||
|
required = true,
|
||||||
|
): NonNullJsonValue | null {
|
||||||
if (!raw.trim()) {
|
if (!raw.trim()) {
|
||||||
if (required) {
|
if (required) {
|
||||||
throw new Error(`${label} is required`);
|
throw new Error(`${label} is required`);
|
||||||
@@ -49,7 +61,7 @@ function validateJsonValue(label: string, raw: string, required = true): any {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return JSON.parse(raw) as any;
|
return JSON.parse(raw) as NonNullJsonValue;
|
||||||
} catch {
|
} catch {
|
||||||
throw new Error(`${label} must be valid JSON`);
|
throw new Error(`${label} must be valid JSON`);
|
||||||
}
|
}
|
||||||
@@ -66,31 +78,23 @@ export default function RuntimeForm({
|
|||||||
const createRuntime = useCreateRuntime();
|
const createRuntime = useCreateRuntime();
|
||||||
const updateRuntime = useUpdateRuntime();
|
const updateRuntime = useUpdateRuntime();
|
||||||
|
|
||||||
const [ref, setRef] = useState("");
|
const [ref, setRef] = useState(() => initialData?.ref ?? "");
|
||||||
const [packRef, setPackRef] = useState("");
|
const [packRef, setPackRef] = useState(() => initialData?.pack_ref ?? "");
|
||||||
const [name, setName] = useState("");
|
const [name, setName] = useState(() => initialData?.name ?? "");
|
||||||
const [description, setDescription] = useState("");
|
const [description, setDescription] = useState(
|
||||||
const [distributions, setDistributions] = useState("{}");
|
() => initialData?.description ?? "",
|
||||||
const [installation, setInstallation] = useState("");
|
);
|
||||||
const [executionConfig, setExecutionConfig] = useState("{}");
|
const [distributions, setDistributions] = useState(() =>
|
||||||
|
prettyJson(initialData?.distributions ?? {}),
|
||||||
|
);
|
||||||
|
const [installation, setInstallation] = useState(() =>
|
||||||
|
initialData?.installation == null ? "" : prettyJson(initialData.installation),
|
||||||
|
);
|
||||||
|
const [executionConfig, setExecutionConfig] = useState(() =>
|
||||||
|
prettyJson(initialData?.execution_config ?? {}),
|
||||||
|
);
|
||||||
const [errors, setErrors] = useState<Record<string, string>>({});
|
const [errors, setErrors] = useState<Record<string, string>>({});
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (!initialData) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
setRef(initialData.ref);
|
|
||||||
setPackRef(initialData.pack_ref ?? "");
|
|
||||||
setName(initialData.name);
|
|
||||||
setDescription(initialData.description ?? "");
|
|
||||||
setDistributions(prettyJson(initialData.distributions));
|
|
||||||
setInstallation(
|
|
||||||
initialData.installation == null ? "" : prettyJson(initialData.installation),
|
|
||||||
);
|
|
||||||
setExecutionConfig(prettyJson(initialData.execution_config));
|
|
||||||
}, [initialData]);
|
|
||||||
|
|
||||||
const canEditRef = !isEditing;
|
const canEditRef = !isEditing;
|
||||||
const isSubmitting = createRuntime.isPending || updateRuntime.isPending;
|
const isSubmitting = createRuntime.isPending || updateRuntime.isPending;
|
||||||
const selectedPackExists =
|
const selectedPackExists =
|
||||||
@@ -113,7 +117,7 @@ export default function RuntimeForm({
|
|||||||
|
|
||||||
let parsedDistributions: JsonObject | undefined;
|
let parsedDistributions: JsonObject | undefined;
|
||||||
let parsedExecutionConfig: JsonObject | undefined;
|
let parsedExecutionConfig: JsonObject | undefined;
|
||||||
let parsedInstallation: any = null;
|
let parsedInstallation: NonNullJsonValue | null = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
parsedDistributions = validateObjectJson("Distributions", distributions);
|
parsedDistributions = validateObjectJson("Distributions", distributions);
|
||||||
@@ -146,6 +150,11 @@ export default function RuntimeForm({
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
if (isEditing && initialData) {
|
if (isEditing && initialData) {
|
||||||
|
const installationPatch =
|
||||||
|
installation.trim().length > 0 && parsedInstallation !== null
|
||||||
|
? { op: NullableJsonPatch.op.SET, value: parsedInstallation }
|
||||||
|
: null;
|
||||||
|
|
||||||
await updateRuntime.mutateAsync({
|
await updateRuntime.mutateAsync({
|
||||||
ref: initialData.ref,
|
ref: initialData.ref,
|
||||||
data: {
|
data: {
|
||||||
@@ -154,10 +163,7 @@ export default function RuntimeForm({
|
|||||||
: null,
|
: null,
|
||||||
name: name.trim(),
|
name: name.trim(),
|
||||||
distributions: parsedDistributions,
|
distributions: parsedDistributions,
|
||||||
installation:
|
installation: installationPatch,
|
||||||
installation.trim().length > 0
|
|
||||||
? { op: NullableJsonPatch.op.SET, value: parsedInstallation }
|
|
||||||
: null,
|
|
||||||
execution_config: parsedExecutionConfig,
|
execution_config: parsedExecutionConfig,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { useEffect, useMemo, useState } from "react";
|
import { useMemo, useState } from "react";
|
||||||
import { Link, useNavigate, useParams } from "react-router-dom";
|
import { Link, useNavigate, useParams } from "react-router-dom";
|
||||||
import { Code2, Pencil, Plus, Search, Trash2, X } from "lucide-react";
|
import { Code2, Pencil, Plus, Search, Trash2, X } from "lucide-react";
|
||||||
import type { RuntimeSummary } from "@/api";
|
import type { RuntimeSummary } from "@/api";
|
||||||
@@ -144,7 +144,7 @@ export default function RuntimesPage() {
|
|||||||
{ref === "new" ? (
|
{ref === "new" ? (
|
||||||
<RuntimeForm />
|
<RuntimeForm />
|
||||||
) : ref ? (
|
) : ref ? (
|
||||||
<RuntimeDetail runtimeRef={ref} />
|
<RuntimeDetail key={ref} runtimeRef={ref} />
|
||||||
) : (
|
) : (
|
||||||
<div className="flex items-center justify-center h-full">
|
<div className="flex items-center justify-center h-full">
|
||||||
<div className="text-center text-gray-500">
|
<div className="text-center text-gray-500">
|
||||||
@@ -169,10 +169,6 @@ function RuntimeDetail({ runtimeRef }: { runtimeRef: string }) {
|
|||||||
const deleteRuntime = useDeleteRuntime();
|
const deleteRuntime = useDeleteRuntime();
|
||||||
const [isEditing, setIsEditing] = useState(false);
|
const [isEditing, setIsEditing] = useState(false);
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
setIsEditing(false);
|
|
||||||
}, [runtimeRef]);
|
|
||||||
|
|
||||||
if (isLoading) {
|
if (isLoading) {
|
||||||
return (
|
return (
|
||||||
<div className="p-6">
|
<div className="p-6">
|
||||||
|
|||||||
Reference in New Issue
Block a user