Skip to content

Commit 26338f4

Browse files
committed
Add login
1 parent f699e1d commit 26338f4

File tree

24 files changed

+18236
-17742
lines changed

24 files changed

+18236
-17742
lines changed

mobile/android/app/src/main/AndroidManifest.xml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?xml version="1.0" encoding="utf-8"?>
1+
<?xml version="1.0" encoding="utf-8" ?>
22
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
33
<!-- To allow clear text traffic only over localhost, -->
44
<!-- replace 'android:usesClearTextTraffic="true"' with the following: -->
@@ -10,8 +10,7 @@
1010
android:roundIcon="@mipmap/ic_launcher_round"
1111
android:supportsRtl="true"
1212
android:theme="@style/AppTheme"
13-
android:usesCleartextTraffic="true"
14-
>
13+
android:usesCleartextTraffic="true">
1514
<activity
1615
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|smallestScreenSize|screenLayout|uiMode"
1716
android:name=".MainActivity"
@@ -30,8 +29,7 @@
3029
android:authorities="${applicationId}.fileprovider"
3130
android:exported="false"
3231
android:grantUriPermissions="true">
33-
<meta-data android:name="android.support.FILE_PROVIDER_PATHS"
34-
android:resource="@xml/file_paths" />
32+
<meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/file_paths" />
3533
</provider>
3634
</application>
3735

@@ -48,4 +46,4 @@
4846
<!-- Maybe need to remove this storage on Play Store to stay compliant; use this on OA full
4947
version. -->
5048
<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE" />
51-
</manifest>
49+
</manifest>

package-lock.json

Lines changed: 17669 additions & 17662 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
],
1313
"scripts": {
1414
"web-dev": "npm run dev --workspace=web",
15+
"web-dev-https": "npm run dev-https --workspace=web",
1516
"web-build": "npm run build --workspace=web",
1617
"web-start": "npm run start --workspace=web",
1718
"desktop-dev": "npm --prefix ./desktop run dev",

web/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,5 @@ yarn-error.log*
3535
# typescript
3636
*.tsbuildinfo
3737
next-env.d.ts
38+
39+
certificates

web/app/(main-layout)/layout.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { Metadata } from "next";
22
import "./globals.css";
3-
import WrappedHeroUIProvider from "@/components/providers/wrapped-hero-ui-provider";
3+
import WrappedHeroUIProvider from "@/components/providers/wrapped-hero-ui-provider";
44
import EditorContextProvider from "@/components/providers/editor-context-provider";
55
import { Toaster } from "react-hot-toast";
66
import "material-icons/iconfont/material-icons.css";

web/components/interface/editor-toolbar.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import toast from "react-hot-toast";
1212
import ExtensionModal from "../modals/extension-modal";
1313
import AgentConfigModal from "../modals/agent-config-modal";
1414
import useSpeech2Speech from "@/lib/hooks/use-speech2speech";
15-
import { getAPIKey } from "@/lib/settings/settings";
15+
import { getAPIKey } from "@/lib/settings/api-manager-utils";
1616
import { editorAssistantAgent } from "@/lib/agent/built-in-agents/editor-assistant";
1717
import { getAgentLLMConfig, runAgentMethod } from "@/lib/agent/agent-runner";
1818
import useExtensionCommands from "@/lib/hooks/use-extension-commands";

web/components/interface/nav.tsx

Lines changed: 127 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,17 @@
11
"use client";
22

3-
import { Button } from "@heroui/react";
3+
import {
4+
Button,
5+
Dropdown,
6+
DropdownItem,
7+
DropdownMenu,
8+
DropdownTrigger,
9+
Select,
10+
SelectItem,
11+
} from "@heroui/react";
412
import Icon from "../misc/icon";
513
import { useContext, useEffect, useState } from "react";
6-
import PasswordScreen from "../modals/password-modal";
14+
import PasswordModal from "../modals/password-modal";
715
import { useTheme } from "next-themes";
816
import NavMenu from "./nav-menu";
917
import { EditorContext } from "../providers/editor-context-provider";
@@ -12,23 +20,31 @@ import { PlatformEnum } from "@/lib/types";
1220
import Loading from "./loading";
1321
import VoiceIndicator from "./voice-indicator";
1422
import ProjectIndicator from "./project-indicator";
23+
import LoginModal from "../modals/login-modal";
24+
import { useAuth } from "@/lib/hooks/use-auth";
25+
import WorkspaceSettingsModal from "../modals/workspace-settings-model";
26+
import { useWorkspace } from "@/lib/hooks/use-workspace";
1527

1628
export default function Nav({ children }: { children: React.ReactNode }) {
1729
const [mounted, setMounted] = useState(false);
1830

1931
const editorContext = useContext(EditorContext);
2032
const [isMenuOpen, setIsMenuOpen] = useState(false);
21-
const [isPasswordScreenOpen, setIsPasswordScreenOpen] = useState(false);
33+
const [isPasswordModalOpen, setIsPasswordModalOpen] = useState(false);
34+
const [isShowNavbar, setIsShowNavbar] = useState(true);
35+
const [isWorkspaceSettingsModalOpen, setIsWorkspaceSettingsModalOpen] =
36+
useState(false);
2237

2338
const { theme, setTheme } = useTheme();
39+
const { session, isLoading: isLoadingSession, signIn, signOut } = useAuth();
2440

25-
const [isShowNavbar, setIsShowNavbar] = useState(true);
41+
const workspaceHook = useWorkspace();
2642

2743
useEffect(() => {
2844
const platform = getPlatform();
2945
// Hide NavMenu if opened in VSCode Extension,
3046
// rely on VSCode's native navigation instead.
31-
console.log("Platform:", platform);
47+
console.log("Current platform:", platform);
3248
if (platform === PlatformEnum.VSCode) {
3349
setIsShowNavbar(false);
3450

@@ -43,10 +59,8 @@ export default function Nav({ children }: { children: React.ReactNode }) {
4359

4460
// Open PasswordScreen if password is used
4561
useEffect(() => {
46-
if (
47-
editorContext?.persistSettings?.isUsePassword
48-
) {
49-
setIsPasswordScreenOpen(true);
62+
if (editorContext?.persistSettings?.isUsePassword) {
63+
setIsPasswordModalOpen(true);
5064
}
5165
}, [editorContext?.persistSettings]);
5266

@@ -55,22 +69,29 @@ export default function Nav({ children }: { children: React.ReactNode }) {
5569
return <Loading />;
5670
}
5771

58-
5972
return (
60-
<div className="grid grid-rows-[max-content_auto] h-full w-full flex-col overflow-x-hidden">
61-
<PasswordScreen
62-
isOpen={isPasswordScreenOpen}
63-
setIsOpen={setIsPasswordScreenOpen}
73+
<div className="grid h-full w-full grid-rows-[max-content_auto] flex-col overflow-x-hidden">
74+
<PasswordModal
75+
isOpen={isPasswordModalOpen}
76+
setIsOpen={setIsPasswordModalOpen}
77+
/>
78+
79+
{!isLoadingSession && !session && <LoginModal signIn={signIn} />}
80+
81+
<WorkspaceSettingsModal
82+
isOpen={isWorkspaceSettingsModalOpen}
83+
setIsOpen={setIsWorkspaceSettingsModalOpen}
84+
workspaceHook={workspaceHook}
6485
/>
6586

6687
{isShowNavbar && (
6788
<div className="z-40 h-12 w-full">
6889
<div
6990
className={
70-
"grid h-12 w-full grid-cols-3 grid-rows-1 px-2 py-1 text-default-foreground"
91+
"text-default-foreground grid h-12 w-full grid-cols-3 grid-rows-1 px-2 py-1"
7192
}
7293
>
73-
<div className="col-start-1">
94+
<div className="col-start-1 flex gap-x-2">
7495
<Button
7596
isIconOnly
7697
onPress={() => {
@@ -85,17 +106,72 @@ export default function Nav({ children }: { children: React.ReactNode }) {
85106
<Icon name="menu" variant="round" />
86107
)}
87108
</Button>
109+
<Select
110+
className="max-w-50"
111+
classNames={{
112+
mainWrapper: "h-10",
113+
trigger: "py-0.5 min-h-10",
114+
}}
115+
label="Workspace"
116+
placeholder="Select Workspace"
117+
isLoading={!workspaceHook.cloudWorkspaces}
118+
selectedKeys={
119+
workspaceHook.workspace ? [workspaceHook.workspace.id] : []
120+
}
121+
size="sm"
122+
disabledKeys={workspaceHook.workspace ? [] : ["settings"]}
123+
>
124+
<>
125+
{workspaceHook.cloudWorkspaces?.map((workspace) => (
126+
<SelectItem
127+
key={workspace.id}
128+
onPress={() => {
129+
workspaceHook.selectWorkspace(workspace.id);
130+
}}
131+
>
132+
{workspace.name}
133+
</SelectItem>
134+
)) ?? []}
135+
<SelectItem
136+
className="bg-primary text-primary-foreground"
137+
color="primary"
138+
onPress={() => {
139+
setIsWorkspaceSettingsModalOpen(true);
140+
}}
141+
startContent={
142+
<div className="text-primary-foreground h-4 w-4">
143+
<Icon name="add" variant="round" />
144+
</div>
145+
}
146+
>
147+
Create New
148+
</SelectItem>
149+
<SelectItem
150+
key={"settings"}
151+
className="bg-default"
152+
onPress={() => {
153+
setIsWorkspaceSettingsModalOpen(true);
154+
}}
155+
startContent={
156+
<div className="h-4 w-4">
157+
<Icon name="settings" variant="round" />
158+
</div>
159+
}
160+
>
161+
Settings
162+
</SelectItem>
163+
</>
164+
</Select>
88165
</div>
89166
<div className="col-start-2 flex flex-col items-center justify-center">
90167
{editorContext?.editorStates.project && <ProjectIndicator />}
91168
<VoiceIndicator />
92169
</div>
93-
<div className="col-start-3 flex justify-end">
170+
<div className="col-start-3 flex justify-end gap-x-1">
94171
<Button
95172
// Disable on hover background
96173
className="data-[hover=true]:bg-transparent"
97174
isIconOnly
98-
disableRipple
99175
variant="light"
100176
onPress={() => {
101177
setTheme(theme === "dark" ? "light" : "dark");
@@ -107,14 +183,44 @@ export default function Nav({ children }: { children: React.ReactNode }) {
107183
<Icon name="light_mode" variant="round" />
108184
)}
109185
</Button>
186+
{session && (
187+
<Dropdown>
188+
<DropdownTrigger>
189+
<Button
190+
isIconOnly
191+
className="text-md-on-secondary-container bg-md-secondary-container rounded-full"
192+
variant="light"
193+
>
194+
<Icon name="account_circle" variant="round" />
195+
</Button>
196+
</DropdownTrigger>
197+
<DropdownMenu
198+
topContent={
199+
<p className="text-medium w-full px-2">
200+
Welcome,{" "}
201+
<span className="font-semibold">
202+
{session.user.name}
203+
</span>
204+
</p>
205+
}
206+
>
207+
<DropdownItem
208+
key={"sign-out"}
209+
onPress={() => {
210+
signOut();
211+
}}
212+
>
213+
Sign out
214+
</DropdownItem>
215+
</DropdownMenu>
216+
</Dropdown>
217+
)}
110218
</div>
111219
</div>
112220
</div>
113221
)}
114222

115-
<div
116-
className={`flex h-full w-full overflow-hidden`}
117-
>
223+
<div className={`flex h-full w-full overflow-hidden`}>
118224
{isShowNavbar && (
119225
<NavMenu isMenuOpen={isMenuOpen} setIsMenuOpen={setIsMenuOpen} />
120226
)}

web/components/modals/app-settings-modal.tsx

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import { PlatformEnum } from "@/lib/types";
2121
import useExtensionManager from "@/lib/hooks/use-extension-manager";
2222
import { ExtensionTypeEnum } from "@pulse-editor/shared-utils";
2323
import { llmProviderOptions } from "@/lib/modalities/llm/options";
24-
import { getAPIKey, setAPIKey } from "@/lib/settings/settings";
24+
import { getAPIKey, setAPIKey } from "@/lib/settings/api-manager-utils";
2525
import { imageGenProviderOptions } from "@/lib/modalities/image-gen/options";
2626
import { videoGenProviderOptions } from "@/lib/modalities/video-gen/options";
2727

@@ -945,20 +945,15 @@ export default function AppSettingsModal({
945945

946946
return (
947947
<ModalWrapper isOpen={isOpen} setIsOpen={setIsOpen} title={"App Settings"}>
948-
<>
949-
<div className="flex w-full flex-col gap-2">
950-
<AISettings editorContext={editorContext} />
951-
<Divider />
952-
<SecuritySettings
953-
editorContext={editorContext}
954-
setIsOpen={setIsOpen}
955-
/>
956-
<Divider />
957-
<DevExtensionSettings editorContext={editorContext} />
958-
<Divider />
959-
<ExtensionDefinedSettings editorContext={editorContext} />
960-
</div>
961-
</>
948+
<div className="flex w-full flex-col gap-2">
949+
<AISettings editorContext={editorContext} />
950+
<Divider />
951+
<SecuritySettings editorContext={editorContext} setIsOpen={setIsOpen} />
952+
<Divider />
953+
<DevExtensionSettings editorContext={editorContext} />
954+
<Divider />
955+
<ExtensionDefinedSettings editorContext={editorContext} />
956+
</div>
962957
</ModalWrapper>
963958
);
964959
}

0 commit comments

Comments
 (0)