feat: Better messages for extension enable/disable/remove (#784)
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
import React, { useState, useEffect } from 'react';
|
import React, { useState, useEffect } from 'react';
|
||||||
import { ScrollArea } from '../ui/scroll-area';
|
import { ScrollArea } from '../ui/scroll-area';
|
||||||
import { useNavigate, useLocation } from 'react-router-dom';
|
import { useNavigate, useLocation } from 'react-router-dom';
|
||||||
import { Plus } from 'lucide-react';
|
import { toast } from 'react-toastify';
|
||||||
import { Settings as SettingsType } from './types';
|
import { Settings as SettingsType } from './types';
|
||||||
import {
|
import {
|
||||||
FullExtensionConfig,
|
FullExtensionConfig,
|
||||||
@@ -132,9 +132,11 @@ export default function Settings() {
|
|||||||
const handleExtensionRemove = async () => {
|
const handleExtensionRemove = async () => {
|
||||||
if (!extensionBeingConfigured) return;
|
if (!extensionBeingConfigured) return;
|
||||||
|
|
||||||
const response = await removeExtension(extensionBeingConfigured.name);
|
const response = await removeExtension(extensionBeingConfigured.name, true);
|
||||||
|
|
||||||
if (response.ok) {
|
if (response.ok) {
|
||||||
|
toast.success(`Successfully removed ${extensionBeingConfigured.name} extension`);
|
||||||
|
|
||||||
// Remove from localstorage
|
// Remove from localstorage
|
||||||
setSettings((prev) => ({
|
setSettings((prev) => ({
|
||||||
...prev,
|
...prev,
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import { getApiUrl, getSecretKey } from './config';
|
import { getApiUrl, getSecretKey } from './config';
|
||||||
import { NavigateFunction } from 'react-router-dom';
|
import { NavigateFunction } from 'react-router-dom';
|
||||||
import { toast } from 'react-toastify';
|
import { toast } from 'react-toastify';
|
||||||
import { getStoredProvider } from './utils/providerUtils';
|
|
||||||
|
|
||||||
// ExtensionConfig type matching the Rust version
|
// ExtensionConfig type matching the Rust version
|
||||||
export type ExtensionConfig =
|
export type ExtensionConfig =
|
||||||
@@ -128,7 +127,7 @@ export async function addExtension(
|
|||||||
|
|
||||||
if (!data.error) {
|
if (!data.error) {
|
||||||
if (!silent) {
|
if (!silent) {
|
||||||
toast.success(`Successfully added extension`);
|
toast.success(`Successfully enabled ${extension.name} extension`);
|
||||||
}
|
}
|
||||||
return response;
|
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 {
|
try {
|
||||||
const response = await fetch(getApiUrl('/extensions/remove'), {
|
const response = await fetch(getApiUrl('/extensions/remove'), {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
@@ -159,7 +158,9 @@ export async function removeExtension(name: string): Promise<Response> {
|
|||||||
const data = await response.json();
|
const data = await response.json();
|
||||||
|
|
||||||
if (!data.error) {
|
if (!data.error) {
|
||||||
toast.success(`Successfully removed ${name} extension`);
|
if (!silent) {
|
||||||
|
toast.success(`Successfully disabled ${name} extension`);
|
||||||
|
}
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user