diff --git a/web/app/components/explore/item-operation/index.tsx b/web/app/components/explore/item-operation/index.tsx index d4b4253382..53e82595c8 100644 --- a/web/app/components/explore/item-operation/index.tsx +++ b/web/app/components/explore/item-operation/index.tsx @@ -8,16 +8,20 @@ import s from './style.module.css' export interface IItemOperationProps { className?: string + onDelete: () => void } const ItemOperation: FC = ({ className, + onDelete }) => { return ( -
{}}> +
{ + e.stopPropagation() + }}> +
{'Delete'}
@@ -25,9 +29,9 @@ const ItemOperation: FC = ({ } trigger='click' position='br' - btnElement={
} - btnClassName={(open) => cn(className, 'h-6 w-6 rounded-md border-none p-1 bg-transparent hover:bg-gray-100', open && '!bg-gray-100 !shadow-none')} - className={`!w-[200px] h-fit !z-20`} + btnElement={
} + btnClassName={(open) => cn(className, s.btn, 'h-6 w-6 rounded-md border-none p-1', open && '!bg-gray-100 !shadow-none')} + className={`!w-[120px] h-fit !z-20`} /> ) } diff --git a/web/app/components/explore/item-operation/style.module.css b/web/app/components/explore/item-operation/style.module.css index 738b07ac0d..b3618c9e1d 100644 --- a/web/app/components/explore/item-operation/style.module.css +++ b/web/app/components/explore/item-operation/style.module.css @@ -17,4 +17,15 @@ .actionIcon { @apply bg-gray-500; mask-image: url(~@/app/components/datasets/documents/assets/action.svg); +} + +body .btn { + background: url(~@/app/components/datasets/documents/assets/action.svg) center center no-repeat transparent; + background-size: 16px 16px; + /* mask-image: ; */ +} + +body .btn:hover { + /* background-image: ; */ + background-color: #F2F4F7; } \ No newline at end of file diff --git a/web/app/components/explore/sidebar/app-nav-item/index.tsx b/web/app/components/explore/sidebar/app-nav-item/index.tsx index 2e1b64b33a..9b9ccc53fe 100644 --- a/web/app/components/explore/sidebar/app-nav-item/index.tsx +++ b/web/app/components/explore/sidebar/app-nav-item/index.tsx @@ -1,6 +1,6 @@ 'use client' import cn from 'classnames' -import Link from 'next/link' +import { useRouter } from 'next/navigation' import ItemOperation from '@/app/components/explore/item-operation' import s from './style.module.css' @@ -9,36 +9,49 @@ export default function NavLink({ name, id, isSelected, + onDelete }: { name: string id: string isSelected: boolean + onDelete: (id: string) => void }) { + const router = useRouter() const url = `/explore/installed/${id}` return ( - { + router.push(url) // use Link causes popup item always trigger jump. Can not be solved by e.stopPropagation(). + }} > -
-
{name}
-
e.stopPropagation()}> - +
+
+
{name}
- + { + !isSelected && ( +
e.stopPropagation()}> + onDelete(id)} + /> +
+ ) + } +
) } diff --git a/web/app/components/explore/sidebar/app-nav-item/style.module.css b/web/app/components/explore/sidebar/app-nav-item/style.module.css index 4b7fcc5bcb..8626f071bf 100644 --- a/web/app/components/explore/sidebar/app-nav-item/style.module.css +++ b/web/app/components/explore/sidebar/app-nav-item/style.module.css @@ -8,6 +8,10 @@ font-weight: 500; } +.opBtn { + visibility: hidden; +} + .item:hover .opBtn { - background-color: #F2F4F7; + visibility: visible; } \ No newline at end of file diff --git a/web/app/components/explore/sidebar/index.tsx b/web/app/components/explore/sidebar/index.tsx index ab04cb91a3..7df78cb60d 100644 --- a/web/app/components/explore/sidebar/index.tsx +++ b/web/app/components/explore/sidebar/index.tsx @@ -7,7 +7,7 @@ import cn from 'classnames' import { useSelectedLayoutSegments } from 'next/navigation' import Link from 'next/link' import Item from './app-nav-item' -import { fetchInstalledAppList as doFetchInstalledAppList } from '@/service/explore' +import { fetchInstalledAppList as doFetchInstalledAppList, uninstallApp } from '@/service/explore' const SelectedDiscoveryIcon = () => ( @@ -37,6 +37,11 @@ const SideBar: FC<{ setInstalledApps(installed_apps) } + const handleDelete = async (id: string) => { + await uninstallApp(id) + fetchInstalledAppList() + } + useEffect(() => { fetchInstalledAppList() }, []) @@ -63,7 +68,13 @@ const SideBar: FC<{
{installedApps.map(({id, app : { name }}) => { return ( - + ) })}
diff --git a/web/service/explore.ts b/web/service/explore.ts index 69db63d346..64a46381ca 100644 --- a/web/service/explore.ts +++ b/web/service/explore.ts @@ -1,4 +1,4 @@ -import { get, post } from './base' +import { get, post, del } from './base' export const fetchAppList = () => { return get('/explore/apps') @@ -19,3 +19,7 @@ export const installApp = (id: string) => { } }) } + +export const uninstallApp = (id: string) => { + return del(`/installed-apps/${id}`) +}