Skip to content

Commit

Permalink
feat: Better messages for extension enable/disable/remove (#784)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexhancock authored Jan 26, 2025
1 parent 1fe48a0 commit d1ee6f6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
6 changes: 4 additions & 2 deletions ui/desktop/src/components/settings/Settings.tsx
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -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,
Expand Down
9 changes: 5 additions & 4 deletions ui/desktop/src/extensions.ts
Original file line number Diff line number Diff line change
@@ -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 =
Expand Down Expand Up @@ -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;
}
Expand All @@ -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',
Expand All @@ -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;
}

Expand Down

0 comments on commit d1ee6f6

Please sign in to comment.