Skip to content

Commit

Permalink
Moves assistant and logs toggle from app conf to workspace
Browse files Browse the repository at this point in the history
  • Loading branch information
mikecmart committed Jul 11, 2024
1 parent 3a7289a commit 3fb7eed
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 4 deletions.
2 changes: 2 additions & 0 deletions packages/app/bundles/custom/workspaces/admin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ export default ({pages}) => {
return {
"default": "/workspace/prod/services",
"label": "Admin panel",
"assistant": true,
"logs": true,
"dev": {
"default": "/workspace/dev/services",
"label": "Dev panel"
Expand Down
2 changes: 2 additions & 0 deletions packages/app/bundles/custom/workspaces/editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ export default (pages) => {
return {
"default": "/workspace/pages",
"label": "Workspace",
"assistant": true,
"logs": false,
"menu": {
"System": [
{ "name": "Users", "icon": "users", "type": "users", "path": "/" },
Expand Down
1 change: 0 additions & 1 deletion packages/app/conf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ const SiteConfig = {
signupEnabled: false,
defaultWorkspace: 'prod',
defaultWorkspacePage: 'pages',
assistant: true,
projectName: 'Protofy',
ui: {
defaultTint: 'green', // 'gray', 'orange', 'yellow', 'green', 'blue', 'purple', 'pink', 'red'
Expand Down
11 changes: 9 additions & 2 deletions packages/protolib/src/components/AdminPage.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useSession } from '../lib/Session';
import { useSession, useUserSettings, useWorkspaces } from '../lib/Session';
import { Page } from './Page';
import { Tinted } from './Tinted';
import { usePrompt } from '../context/PromptAtom';
Expand All @@ -9,6 +9,7 @@ import { forwardRef, useState } from 'react';
import { AppState } from './AdminPanel'
import { useAtom } from 'jotai';
import { SiteConfig } from 'app/conf'
import workspaces from 'app/bundles/workspaces'

const Chat = dynamic(() => import('./Chat'), { ssr: false })

Expand All @@ -19,7 +20,13 @@ export const AdminPage = forwardRef(({ pageSession, title, children, integratedC
const [appState] = useAtom(AppState)
const projectName = SiteConfig.projectName

const settingsAssistant = SiteConfig.assistant
const [settings] = useUserSettings()
const userSpaces = useWorkspaces()

const currentWorkspace = settings && settings.workspace ? settings.workspace : userSpaces[0]
const workspace = typeof workspaces[currentWorkspace] === 'function' ? workspaces[currentWorkspace]({ pages: [] }) : workspaces[currentWorkspace]

const settingsAssistant = workspace.assistant
const settingsAssistantEnabled = settingsAssistant === undefined ? true : settingsAssistant

usePrompt(() => `The user is browsing an admin page in the admin panel. The title of the admin page is: "${title}"`)
Expand Down
4 changes: 3 additions & 1 deletion packages/protolib/src/components/AdminPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ export const AdminPanel = ({ children }) => {


const workspaceData = typeof Workspaces[currentWorkspace] === 'function' ? Workspaces[currentWorkspace]({pages: pages ?? []}) : Workspaces[currentWorkspace]
const settingsLogs = workspaceData.assistant
const settingsLogsEnabled = settingsLogs === undefined ? true : settingsLogs

// console.log('userSpaces: ', userSpaces, 'current Workspace: ', currentWorkspace)
return rightPanelSize && <MainPanel borderLess={true} rightPanelSize={rightPanelSize} setRightPanelSize={setRightPanelSize} rightPanelStyle={{ marginRight: '20px', height: 'calc(100vh - 85px)', marginTop: '68px', backgroundColor: 'transparent' }} rightPanelVisible={appState.logsPanelOpened} rightPanelResizable={true} centerPanelContent={Workspaces[currentWorkspace]
Expand All @@ -86,7 +88,7 @@ export const AdminPanel = ({ children }) => {
<>
<XStack ai="center">
<XStack>{userSpaces.length > 1 && <WorkspaceSelector />}</XStack>
<InteractiveIcon onPress={() => setAppState({ ...appState, logsPanelOpened: !appState.logsPanelOpened })} IconColor="var(--color)" Icon={Activity}></InteractiveIcon>
{settingsLogsEnabled ? <InteractiveIcon onPress={() => setAppState({ ...appState, logsPanelOpened: !appState.logsPanelOpened })} IconColor="var(--color)" Icon={Activity}></InteractiveIcon> : null}
</XStack>
</>
}
Expand Down

0 comments on commit 3fb7eed

Please sign in to comment.