Skip to content

Commit 663f12d

Browse files
authored
Improve settings modal and build with script (#1645)
* Remove built with script for Pro users * Handle subscriptions better * Improve imports * Update settings modal usage * Update pro plan description
1 parent 99ac6fa commit 663f12d

File tree

38 files changed

+76
-36
lines changed

38 files changed

+76
-36
lines changed

apps/studio/electron/main/index.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -148,17 +148,22 @@ const setupAppEventListeners = () => {
148148
]);
149149
} catch (error) {
150150
console.error('Cleanup failed or timed out:', error);
151-
} finally {
152-
cleanupComplete = true;
153151
}
154152
}
155153

156154
app.on('before-quit', (event) => {
157155
if (!cleanupComplete) {
156+
cleanupComplete = false;
158157
event.preventDefault();
159-
cleanUp().then(() => {
160-
app.quit();
161-
});
158+
cleanUp()
159+
.catch((error) => {
160+
console.error('Cleanup failed:', error);
161+
app.quit();
162+
})
163+
.finally(() => {
164+
cleanupComplete = true;
165+
app.quit();
166+
});
162167
}
163168
});
164169

apps/studio/src/App.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,10 @@ import { Toaster } from '@onlook/ui/toaster';
33
import { TooltipProvider } from '@onlook/ui/tooltip';
44
import { I18nextProvider } from 'react-i18next';
55
import { AppBar } from './components/AppBar';
6+
import { Modals } from './components/Modals';
67
import { ThemeProvider } from './components/ThemeProvider';
78
import i18n from './i18n';
89
import { Routes } from './routes';
9-
import { QuittingModal } from './routes/modals/Quitting';
10-
import { SettingsModal } from './routes/modals/Settings';
1110

1211
function App() {
1312
return (
@@ -16,8 +15,7 @@ function App() {
1615
<TooltipProvider>
1716
<AppBar />
1817
<Routes />
19-
<SettingsModal />
20-
<QuittingModal />
18+
<Modals />
2119
<Toaster />
2220
</TooltipProvider>
2321
</ThemeProvider>

apps/studio/src/routes/editor/TopBar/Subscription/PricingPage.tsx renamed to apps/studio/src/components/Modals/Subscription/PricingPage.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { useEffect, useState } from 'react';
1414
import { useTranslation } from 'react-i18next';
1515
import { PricingCard } from './PricingCard';
1616

17-
export const PricingModal = observer(() => {
17+
export const SubscriptionModal = observer(() => {
1818
const userManager = useUserManager();
1919
const editorEngine = useEditorEngine();
2020
const { t } = useTranslation();
@@ -117,6 +117,11 @@ export const PricingModal = observer(() => {
117117
setIsCheckingOut(null);
118118
} catch (error) {
119119
console.error('Error managing subscription:', error);
120+
toast({
121+
variant: 'destructive',
122+
title: 'Error managing subscription',
123+
description: `${error}`,
124+
});
120125
setIsCheckingOut(null);
121126
}
122127
};
@@ -238,5 +243,3 @@ export const PricingModal = observer(() => {
238243
</AnimatePresence>
239244
);
240245
});
241-
242-
export default PricingModal;
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { QuittingModal } from './Quitting';
2+
import { SettingsModal } from './Settings';
3+
import { SubscriptionModal } from './Subscription/PricingPage';
4+
5+
export const Modals = () => {
6+
return (
7+
<>
8+
<SettingsModal />
9+
<QuittingModal />
10+
<SubscriptionModal />
11+
</>
12+
);
13+
};

apps/studio/src/lib/editor/engine/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import { AstManager } from './ast';
1212
import { CanvasManager } from './canvas';
1313
import { ChatManager } from './chat';
1414
import { CodeManager } from './code';
15-
import { ThemeManager } from './theme';
1615
import { CopyManager } from './copy';
1716
import { ElementManager } from './element';
1817
import { ErrorManager } from './error';
@@ -26,6 +25,7 @@ import { PagesManager } from './pages';
2625
import { ProjectInfoManager } from './projectinfo';
2726
import { StyleManager } from './style';
2827
import { TextEditingManager } from './text';
28+
import { ThemeManager } from './theme';
2929
import { WebviewManager } from './webview';
3030

3131
export class EditorEngine {
@@ -36,7 +36,7 @@ export class EditorEngine {
3636

3737
private _editorMode: EditorMode = EditorMode.DESIGN;
3838
private _editorPanelTab: EditorTabValue = EditorTabValue.CHAT;
39-
private _settingsTab: SettingsTabValue = SettingsTabValue.DOMAIN;
39+
private _settingsTab: SettingsTabValue = SettingsTabValue.PREFERENCES;
4040

4141
private canvasManager: CanvasManager;
4242
private chatManager: ChatManager;

apps/studio/src/lib/user/subscription.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ export class SubscriptionManager {
99
constructor() {
1010
makeAutoObservable(this);
1111
this.restoreCachedPlan();
12+
this.getPlanFromServer();
1213
}
1314

1415
private restoreCachedPlan() {

apps/studio/src/locales/en/translation.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@
117117
"Unlimited projects",
118118
"Unlimited AI chat messages a day",
119119
"Unlimited monthly chats",
120-
"Multiple screenshots per chat",
120+
"Remove built with Onlook watermark",
121121
"1 free custom domain hosted with Onlook",
122122
"Priority support"
123123
]

apps/studio/src/locales/ja/translation.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
"無制限のプロジェクト",
2323
"無制限のAIチャットメッセージ(1日あたり)",
2424
"無制限の月間チャット",
25-
"1つのチャットで複数のスクリーンショットが可能",
25+
"ビルド時にOnlookの透かしを削除",
2626
"Onlookでホスティングされた1つの無料カスタムドメイン",
2727
"優先サポート"
2828
]

apps/studio/src/locales/zh/translation.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@
117117
"无限制项目",
118118
"每日无限制 AI 聊天消息",
119119
"每月无限制聊天",
120-
"每次聊天可使用多张截图",
120+
"移除 Onlook 水印",
121121
"1 个免费使用 Onlook 托管的自定义域名",
122122
"优先支持"
123123
]

apps/studio/src/routes/editor/TopBar/ProjectSelect/index.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { useEditorEngine, useProjectsManager, useRouteManager } from '@/components/Context';
2+
import { SettingsTabValue } from '@/lib/models';
23
import { ProjectTabs } from '@/lib/projects';
34
import { Route } from '@/lib/routes';
45
import { invokeMainChannel } from '@/lib/utils';
@@ -173,6 +174,7 @@ const ProjectBreadcrumb = observer(() => {
173174
<DropdownMenuItem
174175
onClick={() => {
175176
editorEngine.isSettingsOpen = true;
177+
editorEngine.settingsTab = SettingsTabValue.PROJECT;
176178
}}
177179
>
178180
{t('projects.actions.settings')}

apps/studio/src/routes/editor/TopBar/Publish/Dropdown/Domain.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ export const DomainSection = observer(
7979
return;
8080
}
8181
domainManager.publish({
82-
skipBadge: type === DomainType.CUSTOM,
82+
skipBadge: type === DomainType.CUSTOM || plan === UsagePlanType.PRO,
8383
buildFlags: userManager.settings.settings?.editor?.buildFlags,
8484
});
8585
};

apps/studio/src/routes/editor/index.tsx

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
1-
import { SettingsModal } from '../modals/Settings';
21
import { Canvas } from './Canvas';
32
import { EditPanel } from './EditPanel';
43
import { HotkeysModal } from './HotkeysModal';
54
import { LayersPanel } from './LayersPanel';
65
import { Toolbar } from './Toolbar';
76
import { EditorTopBar } from './TopBar';
8-
import { PricingModal } from './TopBar/Subscription/PricingPage';
97
import { WebviewArea } from './WebviewArea';
108

11-
function ProjectEditor() {
9+
export function ProjectEditor() {
1210
return (
1311
<>
1412
<div className="relative flex flex-row h-[calc(100vh-2.60rem)] select-none">
@@ -32,11 +30,7 @@ function ProjectEditor() {
3230
<EditorTopBar />
3331
</div>
3432
</div>
35-
<PricingModal />
36-
<SettingsModal />
3733
<HotkeysModal />
3834
</>
3935
);
4036
}
41-
42-
export default ProjectEditor;

apps/studio/src/routes/index.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { useAuthManager, useProjectsManager, useRouteManager } from '@/components/Context';
22
import { Route } from '@/lib/routes';
33
import { observer } from 'mobx-react-lite';
4-
import ProjectEditor from './editor';
5-
import Projects from './projects';
6-
import SignIn from './signin';
4+
import { ProjectEditor } from './editor';
5+
import { Projects } from './projects';
6+
import { SignIn } from './signin';
77

88
export const Routes = observer(() => {
99
const routeManager = useRouteManager();

apps/studio/src/routes/projects/TopBar/index.tsx

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
1-
import { useAuthManager, useEditorEngine, useProjectsManager } from '@/components/Context';
1+
import {
2+
useAuthManager,
3+
useEditorEngine,
4+
useProjectsManager,
5+
useUserManager,
6+
} from '@/components/Context';
27
import UserProfileDropdown from '@/components/ui/UserProfileDropdown';
8+
import { SettingsTabValue } from '@/lib/models';
39
import { ProjectTabs } from '@/lib/projects';
10+
import { UsagePlanType } from '@onlook/models/usage';
411
import { Button } from '@onlook/ui/button';
512
import {
613
DropdownMenu,
@@ -16,6 +23,8 @@ export const TopBar = observer(() => {
1623
const editorEngine = useEditorEngine();
1724
const projectsManager = useProjectsManager();
1825
const authManager = useAuthManager();
26+
const userManager = useUserManager();
27+
const plan = userManager.subscription?.plan;
1928

2029
function signOut() {
2130
authManager.signOut();
@@ -73,6 +82,25 @@ export const TopBar = observer(() => {
7382
</DropdownMenuContent>
7483
</DropdownMenu>
7584
<UserProfileDropdown>
85+
{plan === UsagePlanType.PRO && (
86+
<DropdownMenuItem
87+
onSelect={() => {
88+
editorEngine.isPlansOpen = true;
89+
}}
90+
>
91+
<Icons.Person className="w-4 h-4 mr-2" />
92+
Subscription
93+
</DropdownMenuItem>
94+
)}
95+
<DropdownMenuItem
96+
onSelect={() => {
97+
editorEngine.isSettingsOpen = true;
98+
editorEngine.settingsTab = SettingsTabValue.PREFERENCES;
99+
}}
100+
>
101+
<Icons.Gear className="w-4 h-4 mr-2" />
102+
Settings
103+
</DropdownMenuItem>
76104
<DropdownMenuItem disabled={!authManager.isAuthEnabled} onSelect={signOut}>
77105
<Icons.Exit className="w-4 h-4 mr-2" />
78106
Sign out

apps/studio/src/routes/projects/index.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import PromptCreation from './PromptCreation';
77
import TopBar from './TopBar';
88
import { CreateMethod } from './helpers';
99

10-
const Projects = observer(() => {
10+
export const Projects = observer(() => {
1111
const projectsManager = useProjectsManager();
1212
const renderTab = () => {
1313
switch (projectsManager.projectsTab) {
@@ -38,5 +38,3 @@ const Projects = observer(() => {
3838
</div>
3939
);
4040
});
41-
42-
export default Projects;

apps/studio/src/routes/signin/index.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ enum SignInMethod {
1313
GOOGLE = 'google',
1414
}
1515

16-
const SignIn = observer(() => {
16+
export const SignIn = observer(() => {
1717
const { t } = useTranslation();
1818
const authManager = useAuthManager();
1919
const userManager = useUserManager();
@@ -109,5 +109,3 @@ const SignIn = observer(() => {
109109
</div>
110110
);
111111
});
112-
113-
export default SignIn;

packages/ai/src/tools/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { anthropic } from '@ai-sdk/anthropic';
22
import { tool, type ToolSet } from 'ai';
33
import { readFile } from 'fs/promises';
4-
import { ONLOOK_PROMPT } from 'src/prompt/onlook';
54
import { z } from 'zod';
5+
import { ONLOOK_PROMPT } from '../prompt/onlook';
66
import { getAllFiles } from './helpers';
77

88
export const listFilesTool = tool({

0 commit comments

Comments
 (0)