Skip to content

Commit

Permalink
Add actions
Browse files Browse the repository at this point in the history
  • Loading branch information
XInTheDark committed Dec 27, 2024
1 parent 34b63d9 commit 73a55e5
Showing 1 changed file with 25 additions and 5 deletions.
30 changes: 25 additions & 5 deletions src/components/preferences/manageCustomAPIs.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { getCustomAPIInfo, updateCustomAPIInfo } from "#root/src/api/providers_c

import { help_action } from "../../helpers/helpPage.jsx";

import { Form, ActionPanel, Action, showToast, Toast, useNavigation, List } from "@raycast/api";
import { Form, ActionPanel, Action, showToast, Toast, useNavigation, List, Icon, confirmAlert } from "@raycast/api";

import { Preferences } from "#root/src/api/preferences.js";
import { updatePreferences } from "#root/src/helpers/preferences_helper.js";
Expand Down Expand Up @@ -116,13 +116,33 @@ export const ManageCustomAPIs = () => {
title="Edit"
target={<EditAPIConfig customAPIData={customAPIData} setCustomAPIData={setCustomAPIData} url={url} />}
/>
<Action.Push
title="Add API"
icon={Icon.PlusCircle}
target={<EditAPIConfig customAPIData={customAPIData} setCustomAPIData={setCustomAPIData} url="" />}
shortcut={{ modifiers: ["cmd"], key: "n" }}
/>
<Action
title="Delete"
title="Delete API"
style={Action.Style.Destructive}
icon={Icon.Trash}
onAction={async () => {
const newData = { ...customAPIData };
delete newData[url];
setCustomAPIData(newData);
await confirmAlert({
title: "Are you sure?",
message: "You cannot recover this API.",
icon: Icon.Trash,
primaryAction: {
title: "Delete API Forever",
style: Action.Style.Destructive,
onAction: () => {
const newData = { ...customAPIData };
delete newData[url];
setCustomAPIData(newData);
},
},
});
}}
shortcut={{ modifiers: ["cmd", "shift"], key: "delete" }}
/>
</ActionPanel>
}
Expand Down

0 comments on commit 73a55e5

Please sign in to comment.