@@ -8,6 +8,11 @@ import SharedAi from "./SharedAi";
88import AiOverview from "./AiOverview" ;
99import Calculator from "./Calculator" ;
1010import FileSearch from "./FileSearch" ;
11+ import { Ellipsis } from "lucide-react" ;
12+ import { Menu , MenuButton , MenuItem , MenuItems } from "@headlessui/react" ;
13+ import platformAdapter from "@/utils/platformAdapter" ;
14+ import { useAppStore } from "@/stores/appStore" ;
15+ import { useTranslation } from "react-i18next" ;
1116
1217const Details = ( ) => {
1318 const { rootState } = useContext ( ExtensionsContext ) ;
@@ -23,6 +28,10 @@ const Details = () => {
2328 const setQuickAiAccessAssistant = useExtensionsStore ( ( state ) => {
2429 return state . setQuickAiAccessAssistant ;
2530 } ) ;
31+ const addError = useAppStore ( ( state ) => {
32+ return state . addError ;
33+ } ) ;
34+ const { t } = useTranslation ( ) ;
2635
2736 const renderContent = ( ) => {
2837 if ( ! rootState . activeExtension ) return ;
@@ -66,12 +75,62 @@ const Details = () => {
6675 } ;
6776
6877 return (
69- < div className = "flex-1 h-full overflow-auto" >
70- < h2 className = "text-lg font-semibold text-gray-900 dark:text-white mb-4" >
71- { rootState . activeExtension ?. name }
72- </ h2 >
78+ < div className = "flex-1 h-full pr-4 pb-4 overflow-auto" >
79+ < div className = "flex items-start justify-between gap-4 mb-4" >
80+ < h2 className = "text-lg font-semibold text-gray-900 dark:text-white" >
81+ { rootState . activeExtension ?. name }
82+ </ h2 >
83+
84+ { rootState . activeExtension ?. developer && (
85+ < Menu >
86+ < MenuButton className = "h-7" >
87+ < Ellipsis className = "size-5" />
88+ </ MenuButton >
89+
90+ < MenuItems
91+ anchor = "bottom end"
92+ className = "p-1 text-sm bg-white dark:bg-[#202126] rounded-lg shadow-xs border border-gray-200 dark:border-gray-700"
93+ >
94+ < MenuItem >
95+ < div
96+ className = "px-3 py-2 text-nowrap text-red-500 hover:bg-black/5 hover:dark:bg-white/5 rounded-lg cursor-pointer"
97+ onClick = { async ( ) => {
98+ try {
99+ const { id, developer } = rootState . activeExtension ! ;
100+
101+ await platformAdapter . invokeBackend (
102+ "uninstall_extension" ,
103+ {
104+ extensionId : id ,
105+ developer : developer ,
106+ }
107+ ) ;
108+
109+ Object . assign ( rootState , {
110+ activeExtension : void 0 ,
111+ extensions : rootState . extensions . filter ( ( item ) => {
112+ return item . id !== id ;
113+ } ) ,
114+ } ) ;
115+
116+ addError (
117+ t ( "settings.extensions.hints.uninstallSuccess" ) ,
118+ "info"
119+ ) ;
120+ } catch ( error ) {
121+ addError ( String ( error ) ) ;
122+ }
123+ } }
124+ >
125+ { t ( "settings.extensions.hints.uninstall" ) }
126+ </ div >
127+ </ MenuItem >
128+ </ MenuItems >
129+ </ Menu >
130+ ) }
131+ </ div >
73132
74- < div className = "pr-4 pb-4 text-sm" > { renderContent ( ) } </ div >
133+ < div className = "text-sm" > { renderContent ( ) } </ div >
75134 </ div >
76135 ) ;
77136} ;
0 commit comments