diff --git a/frontend/src/container/ListOfDashboard/DashboardTemplates/DashboardTemplatesModal.styles.scss b/frontend/src/container/ListOfDashboard/DashboardTemplates/DashboardTemplatesModal.styles.scss index a6df7ffa68..c75ca53893 100644 --- a/frontend/src/container/ListOfDashboard/DashboardTemplates/DashboardTemplatesModal.styles.scss +++ b/frontend/src/container/ListOfDashboard/DashboardTemplates/DashboardTemplatesModal.styles.scss @@ -11,6 +11,15 @@ backdrop-filter: blur(20px); padding: 0; + height: 72vh; + + .ant-modal-body { + height: 100%; + } + } + + .new-dashboard-templates-content-container { + height: 100%; } .new-dashboard-templates-content-header { @@ -19,6 +28,8 @@ align-items: center; justify-content: space-between; border-bottom: 1px solid var(--Slate-500, #161922); + height: 60px; + box-sizing: border-box; } .new-dashboard-templates-content { @@ -26,18 +37,33 @@ display: flex; position: relative; + height: calc(100% - 60px); + .new-dashboard-templates-list { padding: 16px 8px; height: 100%; width: 25%; - box-sizing: border-box; border-right: 1px solid var(--Slate-500, #161922); + .new-dashboard-templates-search { + height: 32px; + margin-bottom: 16px; + } + .templates-list { display: flex; flex-direction: column; gap: 8px; - padding: 16px 0; + padding-bottom: 16px; + overflow-y: auto; + box-sizing: border-box; + + height: calc(100% - 64px); + + &::-webkit-scrollbar { + height: 1rem; + width: 0.1rem; + } .template-list-item { display: flex; @@ -143,7 +169,7 @@ padding: 24px; border: 1px solid var(--bg-ink-50); background: var(--bg-ink-300); - max-height: 440px; + max-height: 100%; object-fit: contain; } } diff --git a/frontend/src/container/ListOfDashboard/DashboardTemplates/DashboardTemplatesModal.tsx b/frontend/src/container/ListOfDashboard/DashboardTemplates/DashboardTemplatesModal.tsx index d2088736bb..eeb540f929 100644 --- a/frontend/src/container/ListOfDashboard/DashboardTemplates/DashboardTemplatesModal.tsx +++ b/frontend/src/container/ListOfDashboard/DashboardTemplates/DashboardTemplatesModal.tsx @@ -17,9 +17,12 @@ import PostgreSQLIcon from 'assets/CustomIcons/PostgreSQLIcon'; import RedisIcon from 'assets/CustomIcons/RedisIcon'; import cx from 'classnames'; import { ConciergeBell, DraftingCompass, Drill, Plus, X } from 'lucide-react'; -import { useState } from 'react'; +import { ChangeEvent, useState } from 'react'; +import { DashboardTemplate } from 'types/api/dashboard/getAll'; -const templatesList = [ +import { filterTemplates } from '../utils'; + +const templatesList: DashboardTemplate[] = [ { name: 'Blank dashboard', icon: , @@ -128,6 +131,16 @@ export default function DashboardTemplatesModal({ templatesList[0], ); + const [dashboardTemplates, setDashboardTemplates] = useState(templatesList); + + const handleDashboardTemplateSearch = ( + event: ChangeEvent, + ) => { + const searchText = event.target.value; + const filteredTemplates = filterTemplates(searchText, templatesList); + setDashboardTemplates(filteredTemplates); + }; + return (
@@ -150,10 +163,11 @@ export default function DashboardTemplatesModal({
- {templatesList.map((template) => ( + {dashboardTemplates.map((template) => (
{ + const searchValueLowerCase = searchValue?.toLowerCase(); + + return dashboardList.filter((item: DashboardTemplate) => { + const { name } = item; + + // Check if any property value contains the searchValue + return name.toLowerCase().includes(searchValueLowerCase); + }); +}; diff --git a/frontend/src/types/api/dashboard/getAll.ts b/frontend/src/types/api/dashboard/getAll.ts index e7faf83023..53e2ca31a7 100644 --- a/frontend/src/types/api/dashboard/getAll.ts +++ b/frontend/src/types/api/dashboard/getAll.ts @@ -54,6 +54,14 @@ export interface Dashboard { isLocked?: boolean; } +export interface DashboardTemplate { + name: string; + icon: React.ReactElement; + id: string; + description: string; + previewImage: string; +} + export interface DashboardData { uuid?: string; description?: string;