-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(admin): add server runtime config settings (#7618)
- Loading branch information
Showing
17 changed files
with
762 additions
and
223 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
packages/frontend/admin/src/modules/nav/collapsible-item.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import { | ||
Accordion, | ||
AccordionContent, | ||
AccordionItem, | ||
AccordionTrigger, | ||
} from '@affine/admin/components/ui/accordion'; | ||
import { useCallback } from 'react'; | ||
import { Link } from 'react-router-dom'; | ||
|
||
import { useNav } from './context'; | ||
|
||
export const CollapsibleItem = ({ | ||
items, | ||
title, | ||
changeModule, | ||
}: { | ||
title: string; | ||
items: string[]; | ||
changeModule?: (module: string) => void; | ||
}) => { | ||
const { activeSubTab, setActiveSubTab } = useNav(); | ||
const handleClick = useCallback( | ||
(id: string) => { | ||
const targetElement = document.getElementById(id); | ||
if (targetElement) { | ||
targetElement.scrollIntoView({ | ||
behavior: 'smooth', | ||
block: 'center', | ||
}); | ||
} | ||
changeModule?.(title); | ||
setActiveSubTab(id); | ||
}, | ||
[changeModule, setActiveSubTab, title] | ||
); | ||
|
||
return ( | ||
<Accordion type="multiple" className="w-full "> | ||
<AccordionItem value="item-1" className="border-b-0"> | ||
<Link to={`/admin/settings#${title}`}> | ||
<AccordionTrigger | ||
onClick={() => handleClick(title)} | ||
className={`py-2 px-3 rounded ${activeSubTab === title ? 'bg-zinc-100' : ''}`} | ||
> | ||
{title} | ||
</AccordionTrigger> | ||
</Link> | ||
<AccordionContent className=" flex flex-col gap-2"> | ||
{items.map((item, index) => ( | ||
<Link | ||
key={index} | ||
to={`/admin/settings#${item}`} | ||
className="px-3 overflow-hidden" | ||
> | ||
<AccordionContent | ||
onClick={() => handleClick(item)} | ||
className={`py-1 px-2 rounded text-ellipsis whitespace-nowrap overflow-hidden ${activeSubTab === item ? 'bg-zinc-100' : ''}`} | ||
> | ||
{item} | ||
</AccordionContent> | ||
</Link> | ||
))} | ||
</AccordionContent> | ||
</AccordionItem> | ||
</Accordion> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { createContext, useContext } from 'react'; | ||
|
||
interface NavContextType { | ||
activeTab: string; | ||
activeSubTab: string; | ||
currentModule: string; | ||
setActiveTab: (tab: string) => void; | ||
setActiveSubTab: (tab: string) => void; | ||
setCurrentModule: (module: string) => void; | ||
} | ||
|
||
export const NavContext = createContext<NavContextType | undefined>(undefined); | ||
export const useNav = () => { | ||
const context = useContext(NavContext); | ||
|
||
if (!context) { | ||
throw new Error('useNav must be used within a NavProvider'); | ||
} | ||
|
||
return context; | ||
}; |
Oops, something went wrong.