@linxin666/dsh-client-ui-task-board-team 0.4.13 → 0.4.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -9,6 +9,14 @@
9
9
  * back: the field always renders empty and the status line says whether one is
10
10
  * stored.
11
11
  *
12
+ * The block is one nested settings card of the board's topic list, exactly like
13
+ * the sibling provider sections: the family card chrome supplies the border, the
14
+ * header, the body insets and the hairline between rows, so this module owns only
15
+ * the rows themselves. Its rows use the shared field grid (label and hint on the
16
+ * left, the control at the trailing edge) instead of a hand-rolled flex row, so a
17
+ * label is never squeezed into a character-per-line column by the control beside
18
+ * it.
19
+ *
12
20
  * The block stays reachable while the extension is switched off, because it is
13
21
  * where the switch is turned back on; it only reports that fact instead of
14
22
  * pretending the forms still apply.
@@ -16,6 +24,9 @@
16
24
  * @module dsh-task-board-team/client/team/settings
17
25
  */
18
26
  import { useState, type ReactElement } from 'react'
27
+ import type { CardShell } from '../settings-form.ts'
28
+ import { PluginSettingsCard } from '../PluginSettingsCard.tsx'
29
+ import card from '../settings-card.module.css'
19
30
  import type { TaskBoardExtensionDispatch, TaskBoardSettingsSectionProps } from '../../core/contract.ts'
20
31
  import { TEAM_EXTENSION_ID } from '../../core/identity.ts'
21
32
  import type { TeamExtensionSummary } from '../../host/service.ts'
@@ -32,6 +43,25 @@ interface PublishedConfiguration {
32
43
  questionWaitMinutes?: number
33
44
  }
34
45
 
46
+ /**
47
+ * The card state this block reports: the chrome asks for the family shape, and
48
+ * this block answers every field immediately through its own action channel, so
49
+ * there is never a pending draft or an invalid one.
50
+ * @param failed - whether the last write was refused.
51
+ * @returns the shell the card renders.
52
+ */
53
+ function shellOf(failed: boolean): CardShell {
54
+ return {
55
+ available: true,
56
+ exposed: true,
57
+ writable: true,
58
+ dirty: false,
59
+ invalid: false,
60
+ saving: false,
61
+ failed,
62
+ }
63
+ }
64
+
35
65
  /**
36
66
  * Read the configuration half of one summary.
37
67
  * @param summary - the published summary, or undefined.
@@ -72,24 +102,72 @@ async function send(
72
102
  }
73
103
  }
74
104
 
75
- /** One capability line of the settings block. */
105
+ /** A label with its control at the row's trailing edge. */
106
+ function ValueRow({ label, value }: { label: string; value: string }): ReactElement {
107
+ return (
108
+ <div className={card.field}>
109
+ <span className={card.head}><span className={card.label}>{label}</span></span>
110
+ <span className={styles.value}>{value}</span>
111
+ </div>
112
+ )
113
+ }
114
+
115
+ /** A label with a text input: the hint sits under the label, the field at the trailing edge. */
116
+ function TextRow(props: {
117
+ id: string
118
+ label: string
119
+ hint?: string
120
+ value: string
121
+ placeholder?: string
122
+ numeric?: boolean
123
+ onEdit: (next: string) => void
124
+ }): ReactElement {
125
+ return (
126
+ <div className={card.field}>
127
+ <span className={card.head}>
128
+ <label className={card.label} htmlFor={props.id}>{props.label}</label>
129
+ </span>
130
+ {props.hint === undefined ? null : <p className={card.hint}>{props.hint}</p>}
131
+ <input
132
+ id={props.id}
133
+ className={card.input}
134
+ {...(props.placeholder === undefined ? {} : { placeholder: props.placeholder })}
135
+ {...(props.numeric === true ? { inputMode: 'numeric' as const } : {})}
136
+ value={props.value}
137
+ onChange={event => { props.onEdit(event.target.value) }}
138
+ />
139
+ </div>
140
+ )
141
+ }
142
+
143
+ /**
144
+ * One capability line of the settings block: the name, whether this deployment
145
+ * serves it, and what a reader can do when it does not.
146
+ */
76
147
  function Capability({ label, available, missing }: { label: string; available: boolean; missing: string }): ReactElement {
77
148
  return (
78
- <div className={styles.row}>
79
- <span className={styles.label}>{label}</span>
149
+ <div className={card.field} data-dsh-part="team-capability">
150
+ <span className={card.head}><span className={card.label}>{label}</span></span>
151
+ {available ? null : <p className={card.hint}>{missing}</p>}
80
152
  <span className={styles.value}>
81
- {available ? t('section.capability.available') : t('section.capability.missing') + ' — ' + missing}
153
+ {available ? t('section.capability.available') : t('section.capability.missing')}
82
154
  </span>
83
155
  </div>
84
156
  )
85
157
  }
86
158
 
87
159
  /**
88
- * The settings block.
89
- * @param props - the board's settings seat props.
90
- * @returns the block.
160
+ * The body of the settings card: the configuration form and what the Host
161
+ * reports about it. It is its own component so the card can own the disclosure
162
+ * and the write report while this half owns the drafts.
163
+ * @param props - the board's action dispatcher, plus the write report the card
164
+ * renders in its footer.
165
+ * @returns the card body.
91
166
  */
92
- export function TeamSettingsSection({ dispatch }: TaskBoardSettingsSectionProps): ReactElement {
167
+ export function TeamSettingsBody({ dispatch, onSaved }: {
168
+ dispatch: TaskBoardSettingsSectionProps['dispatch']
169
+ onSaved: (accepted: boolean) => void
170
+ }): ReactElement {
93
171
  const summary = useTeamSummary()
94
172
  const configuration = readConfiguration(summary)
95
173
  const [hubUrl, setHubUrl] = useState<string | undefined>(undefined)
@@ -97,7 +175,7 @@ export function TeamSettingsSection({ dispatch }: TaskBoardSettingsSectionProps)
97
175
  const [members, setMembers] = useState<string | undefined>(undefined)
98
176
  const [waitMinutes, setWaitMinutes] = useState<string | undefined>(undefined)
99
177
  const [token, setToken] = useState('')
100
- const [saved, setSaved] = useState(false)
178
+ const [saved, setSaved] = useState<boolean | undefined>(undefined)
101
179
 
102
180
  const connection = summary?.connection.state ?? 'idle'
103
181
  const membersValue = members ?? (summary?.agents ?? []).map(agent => agent.memberId).join(', ')
@@ -116,127 +194,155 @@ export function TeamSettingsSection({ dispatch }: TaskBoardSettingsSectionProps)
116
194
  questionWaitMinutes: Number.parseInt(waitMinutes ?? String(configuration.questionWaitMinutes ?? 0), 10) || 0,
117
195
  })
118
196
  setSaved(ok)
197
+ onSaved(ok)
119
198
  }
120
199
 
121
200
  return (
122
- <div className={styles.section} data-dsh-plugin="task-board-team" data-dsh-part="team-settings">
123
- <p className={styles.title}>{t('section.title')}</p>
124
- <div className={styles.row}>
125
- <span className={styles.label}>{t('section.connection')}</span>
126
- <span className={styles.value} data-dsh-part="team-connection">{t(stateKey)}</span>
127
- </div>
128
- {summary?.connection.hostId === undefined ? null : (
129
- <div className={styles.row}>
130
- <span className={styles.label}>{t('section.host')}</span>
131
- <span className={styles.value}>{summary.connection.hostId}</span>
132
- </div>
133
- )}
134
- <label className={styles.row}>
135
- <span className={styles.label}>{t('section.hub')}</span>
136
- <input
137
- className={styles.input}
138
- value={hubUrl ?? configuration.hubUrl ?? ''}
139
- placeholder="https://hub.example.com"
140
- onChange={event => { setHubUrl(event.target.value) }}
141
- />
142
- </label>
143
- <label className={styles.row}>
144
- <span className={styles.label}>{t('section.team')}</span>
145
- <input
146
- className={styles.input}
147
- value={teamId ?? configuration.teamId ?? ''}
148
- placeholder="team_..."
149
- onChange={event => { setTeamId(event.target.value) }}
150
- />
151
- </label>
152
- <label className={styles.row}>
153
- <span className={styles.label}>{t('section.token')}</span>
154
- <span className={styles.value}>
155
- {configuration.tokenConfigured === true ? t('section.token.configured') : t('section.token.missing')}
156
- </span>
157
- </label>
158
- <input
159
- className={styles.input}
160
- type="password"
161
- placeholder={t('section.token.placeholder')}
162
- value={token}
163
- onChange={event => { setToken(event.target.value) }}
201
+ <div data-dsh-plugin="task-board-team" data-dsh-part="team-settings">
202
+ <ValueRow label={t('section.connection')} value={t(stateKey)} />
203
+ {summary?.connection.hostId === undefined
204
+ ? null
205
+ : <ValueRow label={t('section.host')} value={summary.connection.hostId} />}
206
+ <TextRow
207
+ id="task-board-team-hub"
208
+ label={t('section.hub')}
209
+ placeholder="https://hub.example.com"
210
+ value={hubUrl ?? configuration.hubUrl ?? ''}
211
+ onEdit={setHubUrl}
164
212
  />
165
- <label className={styles.row}>
166
- <span className={styles.label}>{t('section.agents')}</span>
167
- <input
168
- className={styles.input}
169
- value={membersValue}
170
- placeholder="member_..."
171
- onChange={event => { setMembers(event.target.value) }}
172
- />
173
- </label>
174
- <p className={styles.meta}>{t('section.agents.hint')}</p>
175
- <label className={styles.row}>
176
- <span className={styles.label}>{t('section.questionWait')}</span>
213
+ <TextRow
214
+ id="task-board-team-team"
215
+ label={t('section.team')}
216
+ placeholder="team_..."
217
+ value={teamId ?? configuration.teamId ?? ''}
218
+ onEdit={setTeamId}
219
+ />
220
+ <div className={card.field}>
221
+ <span className={card.head}>
222
+ <label className={card.label} htmlFor="task-board-team-token">{t('section.token')}</label>
223
+ <span className={styles.status} data-dsh-part="team-token-state">
224
+ {configuration.tokenConfigured === true ? t('section.token.configured') : t('section.token.missing')}
225
+ </span>
226
+ </span>
227
+ <p className={card.hint}>{t('section.token.placeholder')}</p>
177
228
  <input
178
- className={styles.input}
179
- inputMode="numeric"
180
- value={waitMinutes ?? String(configuration.questionWaitMinutes ?? 0)}
181
- onChange={event => { setWaitMinutes(event.target.value) }}
229
+ id="task-board-team-token"
230
+ className={card.input}
231
+ type="password"
232
+ autoComplete="off"
233
+ spellCheck={false}
234
+ placeholder={t('section.token.placeholderShort')}
235
+ value={token}
236
+ onChange={event => { setToken(event.target.value) }}
182
237
  />
183
- </label>
184
- <p className={styles.meta}>{t('section.questionWait.hint')}</p>
238
+ </div>
239
+ <TextRow
240
+ id="task-board-team-agents"
241
+ label={t('section.agents')}
242
+ hint={t('section.agents.hint')}
243
+ placeholder="member_..."
244
+ value={membersValue ?? ''}
245
+ onEdit={setMembers}
246
+ />
247
+ <TextRow
248
+ id="task-board-team-wait"
249
+ label={t('section.questionWait')}
250
+ hint={t('section.questionWait.hint')}
251
+ numeric
252
+ value={waitMinutes ?? String(configuration.questionWaitMinutes ?? 0)}
253
+ onEdit={setWaitMinutes}
254
+ />
185
255
  {(summary?.agents ?? []).length === 0 ? <p className={styles.empty}>{t('section.agents.empty')}</p> : null}
186
256
  <div className={styles.actions}>
187
- <button className={styles.button} type="button" onClick={() => { void saveSettings() }}>{t('section.save')}</button>
257
+ <button className={styles.primaryButton} type="button" onClick={() => { void saveSettings() }}>
258
+ {t('section.save')}
259
+ </button>
188
260
  <button
189
261
  className={styles.button}
190
262
  type="button"
191
263
  disabled={token.trim() === ''}
192
264
  onClick={() => {
193
265
  void send(dispatch, 'set-token', { token }).then(ok => {
194
- if (ok) { setToken(''); setSaved(true) } else setSaved(false)
266
+ setSaved(ok)
267
+ if (ok) setToken('')
195
268
  })
196
269
  }}
197
270
  >
198
271
  {t('section.token.save')}
199
272
  </button>
200
- <button className={styles.button} type="button" onClick={() => { void send(dispatch, 'clear-token') }}>{t('section.token.clear')}</button>
201
- <button className={styles.button} type="button" onClick={() => { void send(dispatch, 'refresh') }}>{t('section.refresh')}</button>
202
- </div>
203
- {saved ? <p className={styles.meta}>{t('section.saved')}</p> : null}
204
- <div>
205
- <p className={styles.title}>{t('section.capabilities')}</p>
206
- <Capability
207
- label={t('section.capability.followUp')}
208
- available={summary?.capabilities.followUp === true}
209
- missing={t('section.capability.followUpMissing')}
210
- />
211
- <Capability
212
- label={t('section.capability.rework')}
213
- available={summary?.capabilities.rework === true}
214
- missing={t('section.capability.reworkMissing')}
215
- />
216
- <Capability
217
- label={t('section.capability.run')}
218
- available={summary?.capabilities.run === true}
219
- missing={t('section.capability.runMissing')}
220
- />
221
- <Capability
222
- label={t('section.capability.presetPin')}
223
- available={summary?.presetPin === 'supported'}
224
- missing={t('section.capability.presetPinMissing')}
225
- />
273
+ <button className={styles.button} type="button" onClick={() => { void send(dispatch, 'clear-token') }}>
274
+ {t('section.token.clear')}
275
+ </button>
276
+ <button className={styles.button} type="button" onClick={() => { void send(dispatch, 'refresh') }}>
277
+ {t('section.refresh')}
278
+ </button>
226
279
  </div>
280
+ {saved === true ? <p className={styles.saved}>{t('section.saved')}</p> : null}
281
+ <p className={styles.groupTitle}>{t('section.capabilities')}</p>
282
+ <Capability
283
+ label={t('section.capability.followUp')}
284
+ available={summary?.capabilities.followUp === true}
285
+ missing={t('section.capability.followUpMissing')}
286
+ />
287
+ <Capability
288
+ label={t('section.capability.rework')}
289
+ available={summary?.capabilities.rework === true}
290
+ missing={t('section.capability.reworkMissing')}
291
+ />
292
+ <Capability
293
+ label={t('section.capability.run')}
294
+ available={summary?.capabilities.run === true}
295
+ missing={t('section.capability.runMissing')}
296
+ />
297
+ <Capability
298
+ label={t('section.capability.presetPin')}
299
+ available={summary?.presetPin === 'supported'}
300
+ missing={t('section.capability.presetPinMissing')}
301
+ />
227
302
  {(summary?.problems ?? []).length === 0 ? null : (
228
- <div>
229
- <p className={styles.title}>{t('section.problems')}</p>
303
+ <>
304
+ <p className={styles.groupTitle}>{t('section.problems')}</p>
230
305
  <ul className={styles.list}>
231
306
  {(summary?.problems ?? []).map(problem => (
232
307
  <li key={problem} className={styles.entry}><span className={styles.body}>{problem}</span></li>
233
308
  ))}
234
309
  </ul>
235
- </div>
310
+ </>
236
311
  )}
237
312
  {summary?.connection.lastError === undefined ? null : (
238
313
  <p className={styles.error}>{summary.connection.lastError}</p>
239
314
  )}
240
315
  </div>
241
316
  )
242
- }
317
+ }
318
+
319
+ /**
320
+ * The settings block: one topic of the board's own settings card.
321
+ *
322
+ * Closed on arrival like the sibling provider card — the settings page opens as
323
+ * a topic list, and this topic is one of them. The body is read only by a reader
324
+ * who opens it, and its rows are written through the board's action channel, so
325
+ * the card holds no staged draft: save and discard are the no-ops of an
326
+ * always-committed form, and the footer reports a refused write.
327
+ * @param props - the board's settings seat props.
328
+ * @returns the block.
329
+ */
330
+ export function TeamSettingsSection({ dispatch }: TaskBoardSettingsSectionProps): ReactElement {
331
+ const [saved, setSaved] = useState<boolean | undefined>(undefined)
332
+ return (
333
+ <PluginSettingsCard
334
+ t={t}
335
+ titleKey="section.title"
336
+ descriptionKey="section.description"
337
+ // One topic inside the board's own settings card, so it takes the same
338
+ // compact chrome its sibling provider and topic cards use.
339
+ density="nested"
340
+ defaultOpen={false}
341
+ state={shellOf(saved === false)}
342
+ onSave={() => {}}
343
+ onDiscard={() => {}}
344
+ >
345
+ <TeamSettingsBody dispatch={dispatch} onSaved={setSaved} />
346
+ </PluginSettingsCard>
347
+ )
348
+ }
@@ -1,4 +1,10 @@
1
- /* Team provider seats: one quiet block per surface, tokens only. */
1
+ /* Team provider seats: tokens only.
2
+ *
3
+ * The settings block's chrome, rows and inputs belong to the shared family card
4
+ * slice (`settings-card.module.css`, generated); this file owns the detail
5
+ * block's own lines, the settings row controls the shared slice has no class for
6
+ * (the status word, the group headings and the action row) and the badge.
7
+ */
2
8
 
3
9
  .section {
4
10
  display: flex;
@@ -14,9 +20,13 @@
14
20
  margin: 0;
15
21
  }
16
22
 
23
+ /* One label/value line: the label column sizes to its own text, so a long value
24
+ wraps inside the remaining width instead of squeezing the label into a
25
+ character-per-line column. */
17
26
  .row {
18
- display: flex;
19
- justify-content: space-between;
27
+ display: grid;
28
+ grid-template-columns: max-content minmax(0, 1fr);
29
+ align-items: baseline;
20
30
  gap: 8px;
21
31
  }
22
32
 
@@ -25,11 +35,20 @@
25
35
  }
26
36
 
27
37
  .value {
38
+ min-width: 0;
28
39
  color: var(--dsw-alias-label-primary);
29
40
  text-align: right;
30
41
  overflow-wrap: anywhere;
31
42
  }
32
43
 
44
+ /* A status word that keeps its own line beside a label, never wrapping into it. */
45
+ .status {
46
+ flex: none;
47
+ white-space: nowrap;
48
+ font-size: 12px;
49
+ color: var(--dsw-alias-label-secondary);
50
+ }
51
+
33
52
  .badge {
34
53
  display: inline-flex;
35
54
  align-items: center;
@@ -88,35 +107,87 @@
88
107
  color: var(--dsw-alias-label-secondary);
89
108
  border-left: 2px solid var(--dsw-alias-border-primary);
90
109
  padding-left: 6px;
110
+ margin: 12px 0 0;
111
+ font-size: 12px;
112
+ overflow-wrap: anywhere;
91
113
  }
92
114
 
93
- .input {
94
- width: 100%;
95
- box-sizing: border-box;
96
- padding: 4px 6px;
97
- border: 1px solid var(--dsw-alias-border-secondary);
98
- border-radius: 6px;
99
- background: var(--dsw-alias-bg-primary);
100
- color: var(--dsw-alias-label-primary);
101
- font: inherit;
115
+ /* A heading inside the card body that groups the rows under it. */
116
+ .groupTitle {
117
+ margin: 18px 0 0;
118
+ font-size: 12px;
119
+ font-weight: 600;
120
+ color: var(--dsw-alias-label-secondary);
102
121
  }
103
122
 
123
+ /* The card's own action row, under the form it commits. */
104
124
  .actions {
105
125
  display: flex;
106
- gap: 6px;
126
+ gap: 8px;
107
127
  flex-wrap: wrap;
128
+ padding: 16px 0 4px;
129
+ }
130
+
131
+ /* The row's committing action: the primary-action token trio, so it stays
132
+ legible in every theme and under skins. Never brand-primary as a fill. */
133
+ .primaryButton {
134
+ padding: 4px 14px;
135
+ border: 1px solid transparent;
136
+ border-radius: 8px;
137
+ background: var(--dsw-alias-button-primary-fill, var(--dsw-alias-label-primary));
138
+ color: var(--dsw-alias-label-primary-foreground, var(--dsw-alias-bg-layer-3));
139
+ font: inherit;
140
+ font-size: 13px;
141
+ font-weight: 500;
142
+ line-height: 18px;
143
+ cursor: pointer;
144
+ }
145
+
146
+ .primaryButton:hover:not(:disabled) {
147
+ background: var(--dsw-alias-button-primary-hover, var(--dsw-alias-button-primary-fill, var(--dsw-alias-label-primary)));
148
+ }
149
+
150
+ .primaryButton:focus-visible {
151
+ outline: 2px solid var(--dsw-alias-brand-primary);
152
+ outline-offset: 2px;
108
153
  }
109
154
 
155
+ /* A secondary action of the same row: the card surface with a hairline. */
110
156
  .button {
111
- padding: 2px 10px;
112
- border: 1px solid var(--dsw-alias-border-secondary);
113
- border-radius: 6px;
157
+ padding: 4px 12px;
158
+ border: 1px solid var(--dsw-alias-border-l2);
159
+ border-radius: 8px;
114
160
  background: transparent;
115
161
  color: var(--dsw-alias-label-primary);
116
162
  font: inherit;
163
+ font-size: 13px;
164
+ line-height: 18px;
117
165
  cursor: pointer;
118
166
  }
119
167
 
168
+ .button:hover:not(:disabled) {
169
+ background: var(--dsw-alias-interactive-bg-hover);
170
+ }
171
+
172
+ .button:focus-visible {
173
+ outline: 2px solid var(--dsw-alias-brand-primary);
174
+ outline-offset: 2px;
175
+ }
176
+
177
+ .primaryButton:disabled,
178
+ .button:disabled {
179
+ opacity: 0.45;
180
+ cursor: default;
181
+ }
182
+
183
+ .saved {
184
+ margin: 8px 0 0;
185
+ font-size: 12px;
186
+ color: var(--dsw-alias-label-secondary);
187
+ }
188
+
120
189
  .empty {
121
190
  color: var(--dsw-alias-label-secondary);
191
+ padding-top: 12px;
192
+ margin: 0;
122
193
  }