-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Lazy load auth and ai tabs only when ext is enabled + lazy load schem…
…a graph (#398)
- Loading branch information
Showing
17 changed files
with
438 additions
and
431 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
@import "@edgedb/common/mixins.scss"; | ||
|
||
.tabWrapper { | ||
position: relative; | ||
flex-grow: 1; | ||
background-color: var(--app_panel_background); | ||
border-radius: 12px; | ||
box-shadow: 0 0 8px rgba(0, 0, 0, 0.04), 0 0 4px rgba(0, 0, 0, 0.06); | ||
display: flex; | ||
min-width: 0; | ||
min-height: 0; | ||
font-family: "Roboto Flex Variable", sans-serif; | ||
|
||
@include isMobile { | ||
flex-direction: column; | ||
border-radius: 0; | ||
} | ||
|
||
@include darkTheme { | ||
box-shadow: 0px 0px 8px 0px rgba(0, 0, 0, 0.2), | ||
0px 0px 4px 0px rgba(0, 0, 0, 0.3); | ||
} | ||
} | ||
|
||
.loadingSchema { | ||
flex-grow: 1; | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
font-style: italic; | ||
} | ||
|
||
.fallbackSpinner { | ||
margin: auto; | ||
} | ||
|
||
.extDisabled { | ||
display: flex; | ||
flex-direction: column; | ||
align-items: center; | ||
justify-content: center; | ||
text-align: center; | ||
margin: auto; | ||
font-family: "Roboto Flex Variable", sans-serif; | ||
color: #4d4d4d; | ||
|
||
h2 { | ||
color: inherit; | ||
font-size: 18px; | ||
font-style: normal; | ||
font-weight: 500; | ||
line-height: 26px; | ||
margin: 0; | ||
} | ||
|
||
p { | ||
margin: 8px 0; | ||
} | ||
|
||
pre { | ||
background: #eee; | ||
margin: 12px; | ||
padding: 12px 16px; | ||
border-radius: 6px; | ||
user-select: text; | ||
|
||
@include darkTheme { | ||
background: #383838; | ||
} | ||
} | ||
|
||
a { | ||
color: #b044c2; | ||
|
||
@include darkTheme { | ||
color: #ac86f6; | ||
} | ||
} | ||
|
||
@include darkTheme { | ||
color: #ccc; | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
import {useEffect, useLayoutEffect} from "react"; | ||
import {Observer, observer} from "mobx-react-lite"; | ||
|
||
import cn from "@edgedb/common/utils/classNames"; | ||
|
||
import {useTabState} from "../../state"; | ||
import {useDBRouter} from "../../hooks/dbRoute"; | ||
|
||
import {AIAdminState} from "./state"; | ||
import {ProvidersTab} from "./providers"; | ||
import {PlaygroundTab} from "./playground"; | ||
import {PromptsTab} from "./prompts"; | ||
|
||
import styles from "./aiAdmin.module.scss"; | ||
import {WarningIcon} from "@edgedb/common/newui"; | ||
|
||
const aiAdminTabs = [ | ||
{ | ||
path: "", | ||
label: "Playground", | ||
element: <PlaygroundTab />, | ||
}, | ||
{ | ||
path: "prompts", | ||
label: "Prompts", | ||
element: <PromptsTab />, | ||
}, | ||
{ | ||
path: "providers", | ||
label: "Providers", | ||
element: <ProvidersTab />, | ||
warning: ( | ||
<Observer | ||
render={() => { | ||
const state = useTabState(AIAdminState); | ||
return state.indexesWithoutProviders?.length ? ( | ||
<WarningIcon /> | ||
) : null; | ||
}} | ||
/> | ||
), | ||
}, | ||
]; | ||
|
||
const AIAdminPage = observer(function AIAdminPage() { | ||
const state = useTabState(AIAdminState); | ||
|
||
useEffect(() => { | ||
state.refreshConfig(); | ||
}, []); | ||
|
||
const {navigate, currentPath} = useDBRouter(); | ||
|
||
const activePath = currentPath.slice(2).join("/"); | ||
|
||
useEffect(() => { | ||
state.setLastSelectedTab(currentPath.slice(2).join("/")); | ||
}, [currentPath]); | ||
|
||
useLayoutEffect(() => { | ||
if (currentPath.length == 2 && state.lastSelectedTab) { | ||
navigate(`${currentPath.join("/")}/${state.lastSelectedTab}`, true); | ||
} | ||
}, []); | ||
|
||
return ( | ||
<div className={styles.mainLayout}> | ||
<div className={styles.tabs}> | ||
{aiAdminTabs.map((tab) => ( | ||
<div | ||
key={tab.path} | ||
className={cn(styles.tab, { | ||
[styles.active]: activePath === tab.path, | ||
})} | ||
onClick={() => { | ||
navigate( | ||
[...currentPath.slice(0, 2), tab.path] | ||
.join("/") | ||
.replace(/\/$/, "") | ||
); | ||
}} | ||
> | ||
{tab.label} | ||
{tab.warning} | ||
</div> | ||
))} | ||
</div> | ||
|
||
<div className={styles.tabContent}> | ||
{aiAdminTabs.find((tab) => tab.path === activePath)?.element} | ||
</div> | ||
</div> | ||
); | ||
}); | ||
|
||
export default AIAdminPage; |
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
Oops, something went wrong.