From 8de40518c52c677d57fc70586e20f7512809f46a Mon Sep 17 00:00:00 2001 From: Syed M Mokaarim Bin Razi <30526133+xmok@users.noreply.github.com> Date: Thu, 2 Jan 2025 19:49:18 +0500 Subject: [PATCH] [Coolify] view-secret-keys + update-projects (#16003) * [Coolify] view-secret-keys + update-projects * Update CHANGELOG.md and optimise images --------- Co-authored-by: raycastbot --- extensions/coolify/CHANGELOG.md | 8 +++ extensions/coolify/README.md | 4 +- extensions/coolify/package.json | 6 ++ .../src/lib/components/projects/create.tsx | 52 ++++++++++++++++++ .../src/lib/components/projects/update.tsx | 55 +++++++++++++++++++ extensions/coolify/src/lib/types.ts | 5 ++ extensions/coolify/src/private-keys.tsx | 40 ++++++++++++++ extensions/coolify/src/projects.tsx | 18 +++++- 8 files changed, 184 insertions(+), 4 deletions(-) create mode 100644 extensions/coolify/src/lib/components/projects/create.tsx create mode 100644 extensions/coolify/src/lib/components/projects/update.tsx create mode 100644 extensions/coolify/src/private-keys.tsx diff --git a/extensions/coolify/CHANGELOG.md b/extensions/coolify/CHANGELOG.md index f132f165caa..246e1fd66b4 100644 --- a/extensions/coolify/CHANGELOG.md +++ b/extensions/coolify/CHANGELOG.md @@ -1,5 +1,13 @@ # Coolify Changelog +## [Enhancements] - 2025-01-02 + +- In `Projects`: + - Create Project + - Update Project +- In `Private Keys` + - View Private Keys + ## [Enhancements] - 2024-10-23 - Fix issue where `Resources` command would crash if the resource type is not "application" or "service" diff --git a/extensions/coolify/README.md b/extensions/coolify/README.md index 942baae15b6..f6900777d51 100644 --- a/extensions/coolify/README.md +++ b/extensions/coolify/README.md @@ -4,11 +4,11 @@ # Coolify Raycast Extension -This is a Raycast extension for [Coolify](https://coolify.io/). With this extension you can view Servers, Server Details, Resources, Teams, Team Members, Projects, Environments and more in your Coolify instance. +This is a Raycast extension for [Coolify](https://coolify.io/). With this extension you can view Servers, Server Details, Resources, Teams, Team Members, Projects, Environments, Private Keys and more in your Coolify instance. ## 🚀 Getting Started -1. **Install extension**: Click the `Install Extension` button in the top right of [this page](https://www.raycast.com/xmok/coolify) OR via Raycast Store +1. **Install extension**: Click the `Install Extension` button in the top right of [this page](https://www.raycast.com/xmok/coolify) OR `install` via Raycast Store 2. **Enter your Coolify Details**: The first time you use the extension, you'll need to enter the following in Preferences OR at first prompt: diff --git a/extensions/coolify/package.json b/extensions/coolify/package.json index de4aa8f6218..3f38ea9837c 100644 --- a/extensions/coolify/package.json +++ b/extensions/coolify/package.json @@ -53,6 +53,12 @@ "title": "View Projects", "description": "View Projects, Environments and Resources", "mode": "view" + }, + { + "name": "private-keys", + "title": "View Private Keys", + "description": "View Private Keys", + "mode": "view" } ], "dependencies": { diff --git a/extensions/coolify/src/lib/components/projects/create.tsx b/extensions/coolify/src/lib/components/projects/create.tsx new file mode 100644 index 00000000000..ae81befda1a --- /dev/null +++ b/extensions/coolify/src/lib/components/projects/create.tsx @@ -0,0 +1,52 @@ +import { Action, ActionPanel, Form, Icon, useNavigation } from "@raycast/api"; +import { FormValidation, useForm } from "@raycast/utils"; +import { useState } from "react"; +import { type CreateProject } from "../../types"; +import useCoolify from "../../use-coolify"; + +export default function CreateProject({ onAdded }: { onAdded: () => void }) { + const { pop } = useNavigation(); + const [execute, setExecute] = useState(false); + + const { itemProps, handleSubmit, values } = useForm({ + onSubmit() { + setExecute(true); + }, + validation: { + name: FormValidation.Required, + }, + }); + + const { isLoading } = useCoolify("projects", { + method: "POST", + body: values, + execute, + onData() { + onAdded(); + pop(); + }, + onError() { + setExecute(false); + }, + }); + + return ( +
+ + + } + > + + + + + + ); +} diff --git a/extensions/coolify/src/lib/components/projects/update.tsx b/extensions/coolify/src/lib/components/projects/update.tsx new file mode 100644 index 00000000000..37f6aca20b5 --- /dev/null +++ b/extensions/coolify/src/lib/components/projects/update.tsx @@ -0,0 +1,55 @@ +import { Action, ActionPanel, Form, Icon, useNavigation } from "@raycast/api"; +import { FormValidation, useForm } from "@raycast/utils"; +import { useState } from "react"; +import { CreateProject, Project } from "../../types"; +import useCoolify from "../../use-coolify"; + +export default function UpdateProject({ project, onUpdated }: { project: Project; onUpdated: () => void }) { + const { pop } = useNavigation(); + const [execute, setExecute] = useState(false); + + const { itemProps, handleSubmit, values } = useForm({ + onSubmit() { + setExecute(true); + }, + validation: { + name: FormValidation.Required, + }, + initialValues: { + name: project.name, + description: project.description || "", + }, + }); + + const { isLoading } = useCoolify(`projects/${project.uuid}`, { + method: "PATCH", + body: values, + execute, + onData() { + onUpdated(); + pop(); + }, + onError() { + setExecute(false); + }, + }); + + return ( +
+ + + } + > + + + + + ); +} diff --git a/extensions/coolify/src/lib/types.ts b/extensions/coolify/src/lib/types.ts index b5d61846a75..34441478a15 100644 --- a/extensions/coolify/src/lib/types.ts +++ b/extensions/coolify/src/lib/types.ts @@ -85,6 +85,7 @@ export type PrivateKey = { uuid: string; name: string; description: string; + fingerprint: string | null; private_key: string; is_git_related: true; team_id: number; @@ -164,6 +165,10 @@ export type ProjectDetails = Project & { updated_at: string; created_at: string; }; +export type CreateProject = { + name: string; + description: string; +}; export type Environment = { id: number; diff --git a/extensions/coolify/src/private-keys.tsx b/extensions/coolify/src/private-keys.tsx new file mode 100644 index 00000000000..08f07e98c8f --- /dev/null +++ b/extensions/coolify/src/private-keys.tsx @@ -0,0 +1,40 @@ +import { Action, ActionPanel, Icon, List } from "@raycast/api"; +import InvalidUrl from "./lib/components/invalid-url"; +import { PrivateKey } from "./lib/types"; +import useCoolify from "./lib/use-coolify"; +import { isValidCoolifyUrl } from "./lib/utils"; +import { useState } from "react"; + +export default function PrivateKeys() { + if (!isValidCoolifyUrl()) return ; + + const { isLoading, data: keys = [] } = useCoolify("security/keys"); + + const [isShowingDetail, setIsShowingDetail] = useState(false); + + return ( + + + {keys.map((key) => ( + } + actions={ + + setIsShowingDetail((prev) => !prev)} + /> + + + } + /> + ))} + + + ); +} diff --git a/extensions/coolify/src/projects.tsx b/extensions/coolify/src/projects.tsx index 7ff1fedf797..c6d7ac99c34 100644 --- a/extensions/coolify/src/projects.tsx +++ b/extensions/coolify/src/projects.tsx @@ -1,4 +1,4 @@ -import { Action, ActionPanel, Icon, List } from "@raycast/api"; +import { Action, ActionPanel, Icon, Keyboard, List } from "@raycast/api"; import { Environment, EnvironmentDetails, Project, ProjectDetails, Resource } from "./lib/types"; import useCoolify from "./lib/use-coolify"; import { isValidCoolifyUrl } from "./lib/utils"; @@ -6,11 +6,13 @@ import InvalidUrl from "./lib/components/invalid-url"; import OpenInCoolify from "./lib/components/open-in-coolify"; import { getAvatarIcon } from "@raycast/utils"; import { useMemo } from "react"; +import CreateProject from "./lib/components/projects/create"; +import UpdateProject from "./lib/components/projects/update"; export default function Projects() { if (!isValidCoolifyUrl()) return ; - const { isLoading, data: projects = [] } = useCoolify("projects"); + const { isLoading, data: projects = [], revalidate } = useCoolify("projects"); return ( @@ -29,6 +31,18 @@ export default function Projects() { title="View Environments" target={} /> + } + shortcut={Keyboard.Shortcut.Common.Edit} + /> + } + shortcut={Keyboard.Shortcut.Common.New} + /> }