feat: Better messages for extension enable/disable/remove (#784)

This commit is contained in:
Alex Hancock
2025-01-25 22:08:09 -05:00
committed by GitHub
parent 1fe48a0d97
commit d1ee6f601e
2 changed files with 9 additions and 6 deletions

View File

@@ -1,7 +1,7 @@
import React, { useState, useEffect } from 'react';
import { ScrollArea } from '../ui/scroll-area';
import { useNavigate, useLocation } from 'react-router-dom';
import { Plus } from 'lucide-react';
import { toast } from 'react-toastify';
import { Settings as SettingsType } from './types';
import {
FullExtensionConfig,
@@ -132,9 +132,11 @@ export default function Settings() {
const handleExtensionRemove = async () => {
if (!extensionBeingConfigured) return;
const response = await removeExtension(extensionBeingConfigured.name);
const response = await removeExtension(extensionBeingConfigured.name, true);
if (response.ok) {
toast.success(`Successfully removed ${extensionBeingConfigured.name} extension`);
// Remove from localstorage
setSettings((prev) => ({
...prev,

View File

@@ -1,7 +1,6 @@
import { getApiUrl, getSecretKey } from './config';
import { NavigateFunction } from 'react-router-dom';
import { toast } from 'react-toastify';
import { getStoredProvider } from './utils/providerUtils';
// ExtensionConfig type matching the Rust version
export type ExtensionConfig =
@@ -128,7 +127,7 @@ export async function addExtension(
if (!data.error) {
if (!silent) {
toast.success(`Successfully added extension`);
toast.success(`Successfully enabled ${extension.name} extension`);
}
return response;
}
@@ -145,7 +144,7 @@ export async function addExtension(
}
}
export async function removeExtension(name: string): Promise<Response> {
export async function removeExtension(name: string, silent: boolean = false): Promise<Response> {
try {
const response = await fetch(getApiUrl('/extensions/remove'), {
method: 'POST',
@@ -159,7 +158,9 @@ export async function removeExtension(name: string): Promise<Response> {
const data = await response.json();
if (!data.error) {
toast.success(`Successfully removed ${name} extension`);
if (!silent) {
toast.success(`Successfully disabled ${name} extension`);
}
return response;
}