Skip to content

Commit bc2fd64

Browse files
committed
feat: add UniversalSpotlightActionIcon and TemplatesSpotlightWidget
1 parent 6965d8c commit bc2fd64

File tree

5 files changed

+48
-0
lines changed

5 files changed

+48
-0
lines changed

src/features/ui/dashboard/templates/header-action-buttons/header-action-buttons.feature.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import {
2323
useCreateSubscriptionTemplate,
2424
useGetSubscriptionTemplates
2525
} from '@shared/api/hooks'
26+
import { UniversalSpotlightActionIconShared } from '@shared/ui/universal-spotlight'
2627
import { ROUTES } from '@shared/constants'
2728
import { queryClient } from '@shared/api'
2829

@@ -73,6 +74,8 @@ export const TemplatesHeaderActionButtonsFeature = (props: IProps) => {
7374

7475
return (
7576
<Group grow preventGrowOverflow={false} wrap="wrap">
77+
<UniversalSpotlightActionIconShared />
78+
7679
<ActionIconGroup>
7780
<Tooltip label={t('header-action-buttons.feature.update-templates')} withArrow>
7881
<ActionIcon

src/pages/dashboard/templates/ui/components/template-base-page.component.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { motion } from 'motion/react'
66

77
import { TemplatesHeaderActionButtonsFeature } from '@features/ui/dashboard/templates/header-action-buttons'
88
import { TemplatesGridWidget } from '@widgets/dashboard/templates/templates-grid/templates-grid.widget'
9+
import { TemplatesSpotlightWidget } from '@widgets/dashboard/templates/templates-spotlight'
910
import { RenameModalShared } from '@shared/ui/modals/rename-modal.shared'
1011
import { getCoreLogoFromType } from '@shared/ui/get-core-logo-from-type'
1112
import { Page, PageHeaderShared } from '@shared/ui'
@@ -35,6 +36,8 @@ export const TemplateBasePageComponent = (props: Props) => {
3536
<TemplatesGridWidget templates={templates} templateTitle={title} type={type} />
3637
</motion.div>
3738

39+
<TemplatesSpotlightWidget templates={templates} />
40+
3841
<RenameModalShared key="rename-template-modal" renameFrom="template" />
3942
</Page>
4043
)

src/widgets/dashboard/templates/templates-grid/templates-grid.widget.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ export function TemplatesGridWidget(props: IProps) {
9696
columnCount={columnCount}
9797
enableDnd={true}
9898
items={templates}
99+
key={`templates-grid-widget-${type}`}
99100
onReorder={handleReorder}
100101
renderDragOverlay={(template) => (
101102
<TemplatesCardWidget
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './templates-spotlight'
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import {
2+
GetSubscriptionTemplatesCommand,
3+
TSubscriptionTemplateType
4+
} from '@remnawave/backend-contract'
5+
import { generatePath, useNavigate } from 'react-router-dom'
6+
7+
import { UniversalSpotlightContentShared } from '@shared/ui/universal-spotlight'
8+
import { getCoreLogoFromType } from '@shared/ui'
9+
import { ROUTES } from '@shared/constants'
10+
11+
interface IProps {
12+
templates: GetSubscriptionTemplatesCommand.Response['response']['templates']
13+
}
14+
15+
export const TemplatesSpotlightWidget = (props: IProps) => {
16+
const { templates } = props
17+
18+
const navigate = useNavigate()
19+
20+
const handleViewTemplate = (templateUuid: string, templateType: TSubscriptionTemplateType) => {
21+
navigate(
22+
generatePath(ROUTES.DASHBOARD.TEMPLATES.TEMPLATE_EDITOR, {
23+
type: templateType,
24+
uuid: templateUuid
25+
})
26+
)
27+
}
28+
29+
return (
30+
<UniversalSpotlightContentShared
31+
actions={templates.map((template) => ({
32+
label: template.name,
33+
id: template.uuid,
34+
leftSection: getCoreLogoFromType({ type: template.templateType }),
35+
36+
onClick: () => handleViewTemplate(template.uuid, template.templateType)
37+
}))}
38+
/>
39+
)
40+
}

0 commit comments

Comments
 (0)