Skip to content

Commit 93e288a

Browse files
authored
settings-to-modal (#10139)
* feat(settings): settings modals via UI state hooks * feat(ui): simplify project settings and tweak UI copy and overlays * refactor(routes): remove unused settings routes and to simplify routing
1 parent ccbf334 commit 93e288a

27 files changed

+560
-671
lines changed

apps/desktop/src/components/AccountLink.svelte

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
<script lang="ts">
2-
import { goto } from '$app/navigation';
3-
import { newSettingsPath } from '$lib/routes/routes.svelte';
2+
import { useSettingsModal } from '$lib/settings/settingsModal.svelte';
43
import { USER } from '$lib/user/user';
54
import { inject } from '@gitbutler/core/context';
65
import { Icon } from '@gitbutler/ui';
@@ -13,13 +12,14 @@
1312
const { pop = false, isNavCollapsed = false }: Props = $props();
1413
1514
const user = inject(USER);
15+
const { openGeneralSettings } = useSettingsModal();
1616
</script>
1717

1818
<button
1919
type="button"
2020
class="btn"
2121
class:pop
22-
onclick={async () => goto(newSettingsPath())}
22+
onclick={async () => openGeneralSettings()}
2323
class:collapsed={isNavCollapsed}
2424
>
2525
{#if !isNavCollapsed}

apps/desktop/src/components/AiCredentialCheck.svelte

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -231,13 +231,12 @@
231231
</span>
232232
{/if}
233233
{:else}
234-
<div class="text-12 text-body success-text">
235-
<h4 class="text-bold">Response:</h4>
234+
<div class="text-12 text-body ai-response">
236235
<pre class:streaming={isStreaming}>{isStreaming
237236
? streamingResult
238237
? streamingResult.trim()
239238
: 'Loading...'
240-
: result?.trim()}
239+
: `Response:\n\n${result?.trim()}`}
241240
</pre>
242241
</div>
243242
{/if}
@@ -304,16 +303,23 @@
304303
display: flex;
305304
flex-direction: column;
306305
margin-top: 4px;
306+
overflow-x: auto;
307307
gap: 4px;
308308
}
309309
310-
.success-text {
310+
.ai-response {
311311
display: flex;
312312
flex-direction: column;
313-
padding: 14px;
314313
gap: 10px;
315314
border-radius: var(--radius-m);
316315
background-color: var(--clr-bg-1);
316+
317+
pre {
318+
max-width: 100%;
319+
padding: 14px;
320+
overflow-x: auto;
321+
white-space: pre;
322+
}
317323
}
318324
319325
/* DEBUG SECTION */

apps/desktop/src/components/AnalyticsSettings.svelte

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@
1212
<div class="analytics-settings__content">
1313
<p class="text-13 text-body analytics-settings__text">
1414
GitButler uses telemetry strictly to help us improve the client. We do not collect any personal
15-
information, unless explicitly allowed below (<Link
15+
information, unless explicitly allowed below. <Link
1616
target="_blank"
1717
rel="noreferrer"
1818
href="https://gitbutler.com/privacy"
1919
>
20-
privacy policy
21-
</Link>).
20+
Privacy policy
21+
</Link>
2222
</p>
2323
<p class="text-13 text-body analytics-settings__text">
2424
We kindly ask you to consider keeping these settings enabled as it helps us catch issues more

apps/desktop/src/components/AuthorizationBanner.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
1010
const {
1111
title: titleLabel = 'Authorization Required',
12-
message = 'You need to authorize GitButler to access this service.'
12+
message = 'Authorize GitButler to use this service'
1313
}: Props = $props();
1414
</script>
1515

apps/desktop/src/components/ChromeSidebar.svelte

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,14 @@
88
ircPath,
99
isBranchesPath,
1010
isIrcPath,
11-
isNewProjectSettingsPath,
1211
isWorkspacePath,
1312
historyPath,
1413
isHistoryPath,
15-
newProjectSettingsPath,
16-
newSettingsPath,
1714
workspacePath,
1815
isCodegenPath,
1916
codegenPath
2017
} from '$lib/routes/routes.svelte';
18+
import { useSettingsModal } from '$lib/settings/settingsModal.svelte';
2119
import { SETTINGS } from '$lib/settings/userSettings';
2220
import { USER } from '$lib/user/user';
2321
import { USER_SERVICE } from '$lib/user/userService';
@@ -44,6 +42,7 @@
4442
4543
const userService = inject(USER_SERVICE);
4644
const userSettings = inject(SETTINGS);
45+
const { openGeneralSettings, openProjectSettings } = useSettingsModal();
4746
</script>
4847

4948
<div class="sidebar">
@@ -271,20 +270,13 @@
271270
<div class="bottom">
272271
<div class="bottom__primary-actions">
273272
<div>
274-
{#if isNewProjectSettingsPath()}
275-
<div class="active-page-indicator" in:slide={{ axis: 'x', duration: 150 }}></div>
276-
{/if}
277273
<Button
278274
kind="outline"
279275
onclick={() => {
280-
if (isNewProjectSettingsPath()) {
281-
goto(workspacePath(projectId));
282-
} else {
283-
goto(newProjectSettingsPath(projectId));
284-
}
276+
openProjectSettings(projectId);
285277
}}
286278
width={34}
287-
class={['btn-square', isNewProjectSettingsPath() && 'btn-active']}
279+
class="btn-square"
288280
tooltipPosition="top"
289281
tooltipAlign="start"
290282
tooltip="Project settings"
@@ -382,7 +374,7 @@
382374
<ContextMenuItem
383375
label="Global settings"
384376
onclick={() => {
385-
goto(newSettingsPath());
377+
openGeneralSettings();
386378
contextMenuEl?.close();
387379
}}
388380
keyboardShortcut="⌘,"

apps/desktop/src/components/CloudForm.svelte

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
<script lang="ts">
2-
import { goto } from '$app/navigation';
32
import AiPromptSelect from '$components/AIPromptSelect.svelte';
43
import Section from '$components/Section.svelte';
54
import WelcomeSigninAction from '$components/WelcomeSigninAction.svelte';
65
import { projectAiExperimentalFeaturesEnabled, projectAiGenEnabled } from '$lib/config/config';
7-
import { newSettingsPath } from '$lib/routes/routes.svelte';
6+
import { useSettingsModal } from '$lib/settings/settingsModal.svelte';
87
import { USER_SERVICE } from '$lib/user/userService';
98
import { inject } from '@gitbutler/core/context';
109
import { Button, SectionCard, Spacer, Toggle } from '@gitbutler/ui';
@@ -13,6 +12,7 @@
1312
1413
const userService = inject(USER_SERVICE);
1514
const user = userService.user;
15+
const { openGeneralSettings } = useSettingsModal();
1616
1717
const aiGenEnabled = $derived(projectAiGenEnabled(projectId));
1818
const experimentalAiGenEnabled = $derived(projectAiExperimentalFeaturesEnabled(projectId));
@@ -90,7 +90,7 @@
9090
You can apply your own custom prompts to the project. By default, the project uses GitButler
9191
prompts, but you can create your own prompts in the general settings.
9292
</p>
93-
<Button kind="outline" icon="edit" onclick={() => goto(newSettingsPath('ai'))}
93+
<Button kind="outline" icon="edit" onclick={() => openGeneralSettings('ai')}
9494
>Customize prompts</Button
9595
>
9696
</SectionCard>

apps/desktop/src/components/Feed.svelte

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
<script lang="ts">
2-
import { goto } from '$app/navigation';
32
import FeedItem from '$components/FeedItem.svelte';
43
import CliSymLink from '$components/profileSettings/CliSymLink.svelte';
54
import { ACTION_SERVICE } from '$lib/actions/actionService.svelte';
@@ -8,7 +7,7 @@
87
import { SETTINGS_SERVICE } from '$lib/config/appSettingsV2';
98
import { projectAiGenEnabled } from '$lib/config/config';
109
import { FEED_FACTORY } from '$lib/feed/feed';
11-
import { newProjectSettingsPath } from '$lib/routes/routes.svelte';
10+
import { useSettingsModal } from '$lib/settings/settingsModal.svelte';
1211
import { inject } from '@gitbutler/core/context';
1312
import { Badge, Button, Icon, RichTextEditor, Spacer, Link } from '@gitbutler/ui';
1413
import { tick } from 'svelte';
@@ -28,6 +27,7 @@
2827
2928
const cliManager = inject(CLI_MANAGER);
3029
const [instalCLI, installingCLI] = cliManager.install;
30+
const { openProjectSettings } = useSettingsModal();
3131
3232
const combinedEntries = $derived(feed.combined);
3333
const lastAddedId = $derived(feed.lastAddedId);
@@ -132,7 +132,7 @@
132132
<Button
133133
kind="outline"
134134
onclick={() => {
135-
goto(newProjectSettingsPath(projectId, 'ai'));
135+
openProjectSettings(projectId, 'ai');
136136
}}
137137
>
138138
Enable in settings

apps/desktop/src/components/ForgeForm.svelte

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,22 @@
22
import { DEFAULT_FORGE_FACTORY } from '$lib/forge/forgeFactory.svelte';
33
import { GITLAB_STATE } from '$lib/forge/gitlab/gitlabState.svelte';
44
import { PROJECTS_SERVICE } from '$lib/project/projectsService';
5-
import { inject } from '@gitbutler/core/context';
5+
import { inject, injectOptional } from '@gitbutler/core/context';
66
import { Link, SectionCard, Select, SelectItem, Spacer, Textbox } from '@gitbutler/ui';
7+
import { writable } from 'svelte/store';
78
89
import type { ForgeName } from '$lib/forge/interface/forge';
910
import type { Project } from '$lib/project/project';
1011
1112
const { projectId }: { projectId: string } = $props();
1213
1314
const forge = inject(DEFAULT_FORGE_FACTORY);
14-
const gitLabState = inject(GITLAB_STATE);
15+
const gitLabState = injectOptional(GITLAB_STATE, null);
1516
const determinedForgeType = forge.determinedForgeType;
16-
const token = gitLabState.token;
17-
const forkProjectId = gitLabState.forkProjectId;
18-
const upstreamProjectId = gitLabState.upstreamProjectId;
19-
const instanceUrl = gitLabState.instanceUrl;
17+
const token = gitLabState?.token ?? writable<string | undefined>('');
18+
const forkProjectId = gitLabState?.forkProjectId ?? writable<string | undefined>('');
19+
const upstreamProjectId = gitLabState?.upstreamProjectId ?? writable<string | undefined>('');
20+
const instanceUrl = gitLabState?.instanceUrl ?? writable<string | undefined>('');
2021
2122
const projectsService = inject(PROJECTS_SERVICE);
2223
const projectResult = $derived(projectsService.getProject(projectId));

0 commit comments

Comments
 (0)