Skip to content

Commit 2103848

Browse files
committed
Standardize settings UI layout and add a notices slot to the Group component
- move the notice 'credentials are stored...' to 'model providers' subsection - group should accept 'notices_slot' and space them with gap 10px - should use 'nth type' in Item instead of [Fragment]
1 parent 71eb215 commit 2103848

5 files changed

Lines changed: 80 additions & 51 deletions

File tree

‎apps/editor/src/views/settings/frontend/Home/sections/ApiConfigurationsSection.tsx‎

Lines changed: 43 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -73,26 +73,6 @@ export const ApiConfigurationsSection = forwardRef<HTMLDivElement, Props>(
7373
title={t('sections.api-configurations')}
7474
subtitle={t('configurations.subtitle')}
7575
>
76-
<UiNotice type="info">
77-
<Translation
78-
id="model-providers.notice.credentials"
79-
components={{
80-
link: (
81-
<a
82-
href="#"
83-
onClick={(e) => {
84-
e.preventDefault()
85-
props.on_open_external_url(
86-
'https://code.visualstudio.com/api/references/vscode-api#SecretStorage'
87-
)
88-
}}
89-
>
90-
SecretStorage
91-
</a>
92-
)
93-
}}
94-
/>
95-
</UiNotice>
9676
<UiGroup>
9777
<UiItem
9878
title={t('preferences.intelligent-update.auto-run.title')}
@@ -109,12 +89,39 @@ export const ApiConfigurationsSection = forwardRef<HTMLDivElement, Props>(
10989
</UiGroup>
11090

11191
<div ref={(el) => props.set_section_ref('model-providers', el)}>
112-
<UiGroup title={t('sections.model-providers')}>
113-
{props.providers.length == 0 && (
114-
<UiNotice type="warning">
115-
{t('model-providers.notice.missing')}
116-
</UiNotice>
117-
)}
92+
<UiGroup
93+
title={t('sections.model-providers')}
94+
notices_slot={
95+
<>
96+
<UiNotice type="info">
97+
<Translation
98+
id="model-providers.notice.credentials"
99+
components={{
100+
link: (
101+
<a
102+
href="#"
103+
onClick={(e) => {
104+
e.preventDefault()
105+
props.on_open_external_url(
106+
'https://code.visualstudio.com/api/references/vscode-api#SecretStorage'
107+
)
108+
}}
109+
>
110+
SecretStorage
111+
</a>
112+
)
113+
}}
114+
/>
115+
</UiNotice>
116+
117+
{!props.providers.length && (
118+
<UiNotice type="warning">
119+
{t('model-providers.notice.missing')}
120+
</UiNotice>
121+
)}
122+
</>
123+
}
124+
>
118125
<ModelProvidersSection
119126
providers={props.providers}
120127
on_reorder={(reordered) => {
@@ -162,12 +169,16 @@ export const ApiConfigurationsSection = forwardRef<HTMLDivElement, Props>(
162169
</div>
163170

164171
<div ref={(el) => props.set_section_ref('api-configurations', el)}>
165-
<UiGroup title={t('web-configurations.configurations.title')}>
166-
{props.api_configurations.length == 0 && (
167-
<UiNotice type="warning">
168-
{t('configurations.notice.missing')}
169-
</UiNotice>
170-
)}
172+
<UiGroup
173+
title={t('web-configurations.configurations.title')}
174+
notices_slot={
175+
!props.api_configurations.length ? (
176+
<UiNotice type="warning">
177+
{t('configurations.notice.missing')}
178+
</UiNotice>
179+
) : undefined
180+
}
181+
>
171182
{props.api_configurations && (
172183
<SortableList
173184
items={props.api_configurations}

‎packages/ui/src/components/editor/settings/Group/Group.module.scss‎

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,8 @@
1010
color: var(--cwc-text-color-dimmed);
1111
}
1212

13-
.container {
14-
color: var(--vscode-sideBarTitle-foreground);
15-
16-
> div {
17-
border-top: 1px solid var(--cwc-border-color-dimmed);
18-
}
19-
20-
> div:first-child {
21-
border-top-width: 0;
22-
border-top-left-radius: 10px;
23-
border-top-right-radius: 10px;
24-
}
25-
26-
> div:last-child {
27-
border-bottom-left-radius: 10px;
28-
border-bottom-right-radius: 10px;
29-
}
13+
.notices {
14+
display: flex;
15+
flex-direction: column;
16+
gap: 10px;
3017
}

‎packages/ui/src/components/editor/settings/Group/Group.tsx‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,19 @@ import styles from './Group.module.scss'
33
type Props = {
44
children: React.ReactNode
55
title?: string
6+
notices_slot?: React.ReactNode
67
}
78

89
export const Group: React.FC<Props> = (props) => {
910
return (
10-
<div className={props.title ? styles.wrapper : undefined}>
11+
<div
12+
className={props.title || props.notices_slot ? styles.wrapper : undefined}
13+
>
1114
{props.title && <div className={styles.title}>{props.title}</div>}
12-
<div className={styles.container}>{props.children}</div>
15+
{props.notices_slot && (
16+
<div className={styles.notices}>{props.notices_slot}</div>
17+
)}
18+
<div>{props.children}</div>
1319
</div>
1420
)
1521
}

‎packages/ui/src/components/editor/settings/Item/Item.module.scss‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,19 @@
77
&--hoverable:hover:not(:has(button:hover, a:hover)) {
88
background-color: var(--vscode-toolbar-hoverBackground);
99
}
10+
11+
border-top: 1px solid var(--cwc-border-color-dimmed);
12+
13+
&:first-of-type {
14+
border-top-width: 0;
15+
border-top-left-radius: 10px;
16+
border-top-right-radius: 10px;
17+
}
18+
19+
&:last-of-type {
20+
border-bottom-left-radius: 10px;
21+
border-bottom-right-radius: 10px;
22+
}
1023
}
1124

1225
.main {

‎packages/ui/src/components/editor/settings/SortableList/SortableList.module.scss‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,18 @@
33
flex-direction: column;
44
--row-height: 40px;
55
background-color: var(--cwc-bg-tertiary);
6+
border-top: 1px solid var(--cwc-border-color-dimmed);
7+
8+
&:first-of-type {
9+
border-top-width: 0;
10+
border-top-left-radius: 10px;
11+
border-top-right-radius: 10px;
12+
}
13+
14+
&:last-of-type {
15+
border-bottom-left-radius: 10px;
16+
border-bottom-right-radius: 10px;
17+
}
618
}
719

820
.header {

0 commit comments

Comments
 (0)