@skillcdn/console 0.4.6 → 0.4.7
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.
- package/README.md +4 -4
- package/dist/api.d.ts +2 -2
- package/dist/api.d.ts.map +1 -1
- package/dist/api.js +2 -2
- package/dist/api.js.map +1 -1
- package/dist/cli/cli.d.ts +6 -0
- package/dist/cli/cli.d.ts.map +1 -1
- package/dist/cli/cli.js +60 -30
- package/dist/cli/cli.js.map +1 -1
- package/dist/cli/format.d.ts.map +1 -1
- package/dist/cli/format.js +1 -0
- package/dist/cli/format.js.map +1 -1
- package/dist/cli/help.js +5 -5
- package/dist/cli/help.js.map +1 -1
- package/dist/cli/keys.d.ts +10 -0
- package/dist/cli/keys.d.ts.map +1 -0
- package/dist/cli/keys.js +59 -0
- package/dist/cli/keys.js.map +1 -0
- package/dist/cli/main.js +2 -1
- package/dist/cli/main.js.map +1 -1
- package/dist/cli/terminal.d.ts +7 -0
- package/dist/cli/terminal.d.ts.map +1 -1
- package/dist/cli/terminal.js +39 -0
- package/dist/cli/terminal.js.map +1 -1
- package/dist/client.d.ts +7 -1
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +4 -1
- package/dist/client.js.map +1 -1
- package/dist/components/plugin-frame.d.ts.map +1 -1
- package/dist/components/plugin-frame.js +53 -10
- package/dist/components/plugin-frame.js.map +1 -1
- package/dist/components/sessions.d.ts +15 -0
- package/dist/components/sessions.d.ts.map +1 -0
- package/dist/components/sessions.js +17 -0
- package/dist/components/sessions.js.map +1 -0
- package/dist/components/shell.d.ts.map +1 -1
- package/dist/components/shell.js +198 -28
- package/dist/components/shell.js.map +1 -1
- package/dist/components/workspace.d.ts +2 -0
- package/dist/components/workspace.d.ts.map +1 -1
- package/dist/components/workspace.js +19 -4
- package/dist/components/workspace.js.map +1 -1
- package/dist/console.css +228 -21
- package/dist/console.d.ts +5 -2
- package/dist/console.d.ts.map +1 -1
- package/dist/console.js +106 -21
- package/dist/console.js.map +1 -1
- package/dist/data.d.ts +7 -1
- package/dist/data.d.ts.map +1 -1
- package/dist/data.js +26 -5
- package/dist/data.js.map +1 -1
- package/dist/i18n/en.d.ts +24 -0
- package/dist/i18n/en.d.ts.map +1 -1
- package/dist/i18n/en.js +21 -0
- package/dist/i18n/en.js.map +1 -1
- package/dist/i18n/index.d.ts +2 -2
- package/dist/i18n/index.d.ts.map +1 -1
- package/dist/i18n/index.js +7 -3
- package/dist/i18n/index.js.map +1 -1
- package/dist/i18n/ko.d.ts.map +1 -1
- package/dist/i18n/ko.js +23 -2
- package/dist/i18n/ko.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/plugin/bridge.d.ts +3 -0
- package/dist/plugin/bridge.d.ts.map +1 -1
- package/dist/plugin/bridge.js +1 -0
- package/dist/plugin/bridge.js.map +1 -1
- package/dist/plugin/context.d.ts +9 -0
- package/dist/plugin/context.d.ts.map +1 -1
- package/dist/plugin/define.d.ts.map +1 -1
- package/dist/plugin/define.js +6 -3
- package/dist/plugin/define.js.map +1 -1
- package/dist/plugin/sandbox.d.ts.map +1 -1
- package/dist/plugin/sandbox.js +8 -1
- package/dist/plugin/sandbox.js.map +1 -1
- package/dist/router.d.ts +6 -0
- package/dist/router.d.ts.map +1 -1
- package/dist/router.js +5 -0
- package/dist/router.js.map +1 -1
- package/dist/routes.d.ts +3 -1
- package/dist/routes.d.ts.map +1 -1
- package/dist/routes.js +2 -0
- package/dist/routes.js.map +1 -1
- package/dist/schemas.d.ts +38 -0
- package/dist/schemas.d.ts.map +1 -1
- package/dist/schemas.js +37 -1
- package/dist/schemas.js.map +1 -1
- package/dist/tokens.d.ts.map +1 -1
- package/dist/tokens.js +1 -0
- package/dist/tokens.js.map +1 -1
- package/dist/vocabulary.d.ts +6 -0
- package/dist/vocabulary.d.ts.map +1 -1
- package/dist/vocabulary.js +7 -0
- package/dist/vocabulary.js.map +1 -1
- package/docs/specs/cli.md +3 -3
- package/docs/specs/plugins.md +7 -6
- package/docs/specs/rest.md +9 -5
- package/package.json +1 -1
- package/skills/building-a-plugin/SKILL.md +2 -2
- package/skills/planning-the-board/references/setting-up.md +1 -1
- package/src/api.ts +6 -0
- package/src/cli/cli.ts +81 -29
- package/src/cli/format.ts +1 -0
- package/src/cli/help.ts +5 -5
- package/src/cli/keys.ts +69 -0
- package/src/cli/main.ts +2 -1
- package/src/cli/terminal.ts +40 -0
- package/src/client.ts +14 -0
- package/src/components/plugin-frame.tsx +72 -17
- package/src/components/sessions.tsx +108 -0
- package/src/components/shell.tsx +265 -52
- package/src/components/workspace.tsx +46 -2
- package/src/console.tsx +181 -16
- package/src/data.ts +33 -5
- package/src/i18n/en.ts +25 -0
- package/src/i18n/index.ts +11 -3
- package/src/i18n/ko.ts +27 -2
- package/src/index.ts +1 -0
- package/src/plugin/bridge.ts +4 -0
- package/src/plugin/context.ts +9 -0
- package/src/plugin/define.ts +10 -2
- package/src/plugin/sandbox.ts +9 -1
- package/src/router.ts +7 -0
- package/src/routes.ts +3 -1
- package/src/schemas.ts +41 -0
- package/src/styles/console.css +228 -21
- package/src/tokens.ts +1 -0
- package/src/vocabulary.ts +9 -0
|
@@ -8,7 +8,8 @@ import {
|
|
|
8
8
|
WEEK_STARTS,
|
|
9
9
|
type WeekStart,
|
|
10
10
|
} from "../api.js";
|
|
11
|
-
import { useWords } from "../i18n/index.js";
|
|
11
|
+
import { DEFAULT_LANGUAGES, packFor, useWords } from "../i18n/index.js";
|
|
12
|
+
import { CONSOLE_LANGUAGES } from "../vocabulary.js";
|
|
12
13
|
import { Button } from "./ui.js";
|
|
13
14
|
|
|
14
15
|
// The workspace's own settings (ADR-0035), as an administrator keeps them on the Settings page:
|
|
@@ -34,6 +35,14 @@ export function timeZoneOf(workspace: RestWorkspace | undefined): string | undef
|
|
|
34
35
|
return workspace?.timeZone ?? undefined;
|
|
35
36
|
}
|
|
36
37
|
|
|
38
|
+
/** The workspace's language (ADR-0081), or none. */
|
|
39
|
+
export function workspaceLanguageOf(workspace: RestWorkspace | undefined): string | undefined {
|
|
40
|
+
return workspace?.language ?? undefined;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/** A language as it calls itself, `한국어`, from the packs the package ships; the tag where none speaks it. */
|
|
44
|
+
const languageLabel = (tag: string): string => packFor(tag, DEFAULT_LANGUAGES)?.label ?? tag;
|
|
45
|
+
|
|
37
46
|
/** The zones this browser knows, for the picker to offer; none where it cannot say. */
|
|
38
47
|
export function knownTimeZones(): readonly string[] {
|
|
39
48
|
try {
|
|
@@ -133,6 +142,7 @@ export function WorkspaceSettingsView(props: WorkspaceSettingsViewProps) {
|
|
|
133
142
|
const zone = timeZoneOf(props.workspace);
|
|
134
143
|
const device = deviceTimeZone();
|
|
135
144
|
const offset = zone === undefined ? undefined : offsetOf(zone, new Date());
|
|
145
|
+
const language = workspaceLanguageOf(props.workspace);
|
|
136
146
|
return (
|
|
137
147
|
<dl className="sc-settings-list">
|
|
138
148
|
{props.console !== undefined && (
|
|
@@ -170,6 +180,10 @@ export function WorkspaceSettingsView(props: WorkspaceSettingsViewProps) {
|
|
|
170
180
|
)}
|
|
171
181
|
</dd>
|
|
172
182
|
</div>
|
|
183
|
+
<div className="sc-settings-item">
|
|
184
|
+
<dt>{settings.language}</dt>
|
|
185
|
+
<dd>{language === undefined ? settings.languageNone : languageLabel(language)}</dd>
|
|
186
|
+
</div>
|
|
173
187
|
</dl>
|
|
174
188
|
);
|
|
175
189
|
}
|
|
@@ -186,17 +200,19 @@ export interface WorkspaceSettingsFormProps {
|
|
|
186
200
|
export function WorkspaceSettingsForm(props: WorkspaceSettingsFormProps) {
|
|
187
201
|
const words = useWords();
|
|
188
202
|
const settings = words.settings.workspace;
|
|
189
|
-
const ids = { people: useId(), week: useId(), zone: useId() };
|
|
203
|
+
const ids = { people: useId(), week: useId(), zone: useId(), language: useId() };
|
|
190
204
|
const current = {
|
|
191
205
|
peopleVisibility: peopleVisibilityOf(props.workspace),
|
|
192
206
|
weekStart: weekStartOf(props.workspace),
|
|
193
207
|
timeZone: timeZoneOf(props.workspace) ?? "",
|
|
208
|
+
language: workspaceLanguageOf(props.workspace) ?? "",
|
|
194
209
|
};
|
|
195
210
|
const [peopleVisibility, setPeopleVisibility] = useState<PeopleVisibility>(
|
|
196
211
|
current.peopleVisibility,
|
|
197
212
|
);
|
|
198
213
|
const [weekStart, setWeekStart] = useState<WeekStart>(current.weekStart);
|
|
199
214
|
const [timeZone, setTimeZone] = useState(current.timeZone);
|
|
215
|
+
const [language, setLanguage] = useState(current.language);
|
|
200
216
|
const device = useMemo(deviceTimeZone, []);
|
|
201
217
|
// UTC is offered whatever the browser lists, beside the zone set and the device's.
|
|
202
218
|
const groups = useMemo(
|
|
@@ -207,6 +223,11 @@ export function WorkspaceSettingsForm(props: WorkspaceSettingsFormProps) {
|
|
|
207
223
|
...(peopleVisibility === current.peopleVisibility ? {} : { peopleVisibility }),
|
|
208
224
|
...(weekStart === current.weekStart ? {} : { weekStart }),
|
|
209
225
|
...(timeZone === current.timeZone ? {} : { timeZone: timeZone === "" ? null : timeZone }),
|
|
226
|
+
...(language === current.language
|
|
227
|
+
? {}
|
|
228
|
+
: {
|
|
229
|
+
language: CONSOLE_LANGUAGES.find((candidate) => candidate === language) ?? null,
|
|
230
|
+
}),
|
|
210
231
|
};
|
|
211
232
|
const changed = Object.keys(patch).length > 0;
|
|
212
233
|
const submit = (event: FormEvent) => {
|
|
@@ -301,6 +322,29 @@ export function WorkspaceSettingsForm(props: WorkspaceSettingsFormProps) {
|
|
|
301
322
|
)}
|
|
302
323
|
</div>
|
|
303
324
|
</div>
|
|
325
|
+
<div className="sc-settings-row">
|
|
326
|
+
<div className="sc-settings-words">
|
|
327
|
+
<label className="sc-settings-label" htmlFor={ids.language}>
|
|
328
|
+
{settings.language}
|
|
329
|
+
</label>
|
|
330
|
+
<p className="sc-settings-hint">{settings.languageHint}</p>
|
|
331
|
+
</div>
|
|
332
|
+
<div className="sc-settings-control">
|
|
333
|
+
<select
|
|
334
|
+
id={ids.language}
|
|
335
|
+
className="sc-input"
|
|
336
|
+
value={language}
|
|
337
|
+
onChange={(event) => setLanguage(event.target.value)}
|
|
338
|
+
>
|
|
339
|
+
<option value="">{settings.languageNone}</option>
|
|
340
|
+
{CONSOLE_LANGUAGES.map((candidate) => (
|
|
341
|
+
<option key={candidate} value={candidate} lang={candidate}>
|
|
342
|
+
{languageLabel(candidate)}
|
|
343
|
+
</option>
|
|
344
|
+
))}
|
|
345
|
+
</select>
|
|
346
|
+
</div>
|
|
347
|
+
</div>
|
|
304
348
|
<div className="sc-form-actions">
|
|
305
349
|
<Button type="submit" variant="primary" disabled={props.busy === true || !changed}>
|
|
306
350
|
{settings.save}
|
package/src/console.tsx
CHANGED
|
@@ -31,6 +31,7 @@ import {
|
|
|
31
31
|
type RestProjectRules,
|
|
32
32
|
type RestReachedDecision,
|
|
33
33
|
type RestRules,
|
|
34
|
+
type RestSessions,
|
|
34
35
|
type RestTask,
|
|
35
36
|
type RestTaskInput,
|
|
36
37
|
type RestToken,
|
|
@@ -72,6 +73,7 @@ import {
|
|
|
72
73
|
import { type RemotePictureSrc, RemotePicturesContext } from "./components/remote-pictures.js";
|
|
73
74
|
import { GoalTimeline } from "./components/roadmap.js";
|
|
74
75
|
import { RulesForm, RulesView } from "./components/rules.js";
|
|
76
|
+
import { SessionList, type SessionListProps } from "./components/sessions.js";
|
|
75
77
|
import {
|
|
76
78
|
type Brand,
|
|
77
79
|
isPlainClick,
|
|
@@ -166,6 +168,7 @@ export interface ConsoleComponents {
|
|
|
166
168
|
readonly EventFeed: ComponentType<EventFeedProps>;
|
|
167
169
|
readonly SignIn: ComponentType<SignInProps>;
|
|
168
170
|
readonly TokenList: ComponentType<TokenListProps>;
|
|
171
|
+
readonly SessionList: ComponentType<SessionListProps>;
|
|
169
172
|
readonly PeopleList: ComponentType<PeopleListProps>;
|
|
170
173
|
readonly TeamList: ComponentType<TeamListProps>;
|
|
171
174
|
readonly SkillList: ComponentType<SkillListProps>;
|
|
@@ -185,6 +188,7 @@ export const DEFAULT_COMPONENTS: ConsoleComponents = {
|
|
|
185
188
|
EventFeed,
|
|
186
189
|
SignIn,
|
|
187
190
|
TokenList,
|
|
191
|
+
SessionList,
|
|
188
192
|
PeopleList,
|
|
189
193
|
TeamList,
|
|
190
194
|
SkillList,
|
|
@@ -414,12 +418,14 @@ export function languageToKeep(
|
|
|
414
418
|
|
|
415
419
|
/**
|
|
416
420
|
* The pages a console that holds a token does not offer: the tokens themselves, and the
|
|
417
|
-
* approval of an agent's connection, which makes one; a person's own
|
|
418
|
-
* own pages, signed in. Everything else a person may do, their agent may
|
|
421
|
+
* approval of an agent's connection, which makes one; the browsers signed in; a person's own
|
|
422
|
+
* doing on the console's own pages, signed in. Everything else a person may do, their agent may
|
|
423
|
+
* (ADR-0021).
|
|
419
424
|
*/
|
|
420
425
|
export function onlyOnOwnPages(route: Route): boolean {
|
|
421
426
|
return (
|
|
422
427
|
route.name === "agents" ||
|
|
428
|
+
route.name === "sessions" ||
|
|
423
429
|
route.name === "new-token" ||
|
|
424
430
|
route.name === "person-agents" ||
|
|
425
431
|
route.name === "connect"
|
|
@@ -1796,6 +1802,106 @@ function ProjectSettingsPage(props: {
|
|
|
1796
1802
|
);
|
|
1797
1803
|
}
|
|
1798
1804
|
|
|
1805
|
+
/**
|
|
1806
|
+
* The views of the settings: the workspace's, read by everyone, and the browsers the person is
|
|
1807
|
+
* signed in on (board #309), which a console that holds a token does not offer, and so does not
|
|
1808
|
+
* name.
|
|
1809
|
+
*/
|
|
1810
|
+
function SettingsViews(props: { readonly on: "workspace" | "sessions" }) {
|
|
1811
|
+
const views = useWords().settings.views;
|
|
1812
|
+
return (
|
|
1813
|
+
<nav className="sc-subtabs sc-settings-views" aria-label={views.aria}>
|
|
1814
|
+
<a
|
|
1815
|
+
className={cx("sc-tab", props.on === "workspace" && "sc-tab-current")}
|
|
1816
|
+
href={PATHS.settings}
|
|
1817
|
+
aria-current={props.on === "workspace" ? "page" : undefined}
|
|
1818
|
+
>
|
|
1819
|
+
{views.workspace}
|
|
1820
|
+
</a>
|
|
1821
|
+
<a
|
|
1822
|
+
className={cx("sc-tab", props.on === "sessions" && "sc-tab-current")}
|
|
1823
|
+
href={PATHS.sessions}
|
|
1824
|
+
aria-current={props.on === "sessions" ? "page" : undefined}
|
|
1825
|
+
>
|
|
1826
|
+
{views.sessions}
|
|
1827
|
+
</a>
|
|
1828
|
+
</nav>
|
|
1829
|
+
);
|
|
1830
|
+
}
|
|
1831
|
+
|
|
1832
|
+
/**
|
|
1833
|
+
* The browsers whoever is signed in is signed in on (board #309): read when the page opens, and
|
|
1834
|
+
* again once one of them, or all the others, are signed out.
|
|
1835
|
+
*/
|
|
1836
|
+
function SessionsPage(props: {
|
|
1837
|
+
readonly data: ConsoleData;
|
|
1838
|
+
readonly components: ConsoleComponents;
|
|
1839
|
+
}) {
|
|
1840
|
+
const words = useWords();
|
|
1841
|
+
const { data, components } = props;
|
|
1842
|
+
const { busy, error, act } = useAction();
|
|
1843
|
+
const [sessions, setSessions] = useState<RestSessions | undefined>(undefined);
|
|
1844
|
+
const [failure, setFailure] = useState<string | undefined>(undefined);
|
|
1845
|
+
const read = data.actions.sessions;
|
|
1846
|
+
useEffect(() => {
|
|
1847
|
+
const controller = new AbortController();
|
|
1848
|
+
read(controller.signal)
|
|
1849
|
+
.then((found) => {
|
|
1850
|
+
if (!controller.signal.aborted) {
|
|
1851
|
+
setSessions(found);
|
|
1852
|
+
}
|
|
1853
|
+
})
|
|
1854
|
+
.catch((caught: unknown) => {
|
|
1855
|
+
if (!controller.signal.aborted) {
|
|
1856
|
+
setFailure(errorWords(caught, words.common.somethingWentWrong, words));
|
|
1857
|
+
}
|
|
1858
|
+
});
|
|
1859
|
+
return () => controller.abort();
|
|
1860
|
+
}, [read, words]);
|
|
1861
|
+
return (
|
|
1862
|
+
<>
|
|
1863
|
+
<div className="sc-page-head">
|
|
1864
|
+
<h1 className="sc-page-title">{words.settings.title}</h1>
|
|
1865
|
+
</div>
|
|
1866
|
+
<SettingsViews on="sessions" />
|
|
1867
|
+
{(error ?? failure) !== undefined && <Callout tone="danger">{error ?? failure}</Callout>}
|
|
1868
|
+
{sessions === undefined ? (
|
|
1869
|
+
failure === undefined && (
|
|
1870
|
+
<div className="sc-loading">
|
|
1871
|
+
<Spinner label={words.sessions.loading} />
|
|
1872
|
+
</div>
|
|
1873
|
+
)
|
|
1874
|
+
) : (
|
|
1875
|
+
<components.SessionList
|
|
1876
|
+
sessions={sessions.items}
|
|
1877
|
+
idleDays={sessions.idleDays}
|
|
1878
|
+
busy={busy}
|
|
1879
|
+
onEnd={(session) =>
|
|
1880
|
+
void act(async () => {
|
|
1881
|
+
// Read again whether it went or not: one ended from elsewhere, or whose time
|
|
1882
|
+
// ended, is not found, and its row goes all the same.
|
|
1883
|
+
try {
|
|
1884
|
+
await data.actions.endSession(session.id);
|
|
1885
|
+
} finally {
|
|
1886
|
+
setSessions(await read());
|
|
1887
|
+
}
|
|
1888
|
+
})
|
|
1889
|
+
}
|
|
1890
|
+
onEndOthers={() =>
|
|
1891
|
+
void act(async () => {
|
|
1892
|
+
try {
|
|
1893
|
+
await data.actions.endOtherSessions();
|
|
1894
|
+
} finally {
|
|
1895
|
+
setSessions(await read());
|
|
1896
|
+
}
|
|
1897
|
+
})
|
|
1898
|
+
}
|
|
1899
|
+
/>
|
|
1900
|
+
)}
|
|
1901
|
+
</>
|
|
1902
|
+
);
|
|
1903
|
+
}
|
|
1904
|
+
|
|
1799
1905
|
/**
|
|
1800
1906
|
* The workspace's settings (ADR-0023): its rules, the console's own until an administrator
|
|
1801
1907
|
* writes the organization's; its categories, kept on their own page; and where its skills come
|
|
@@ -1943,6 +2049,7 @@ function WorkspaceSettingsPage(props: {
|
|
|
1943
2049
|
return (
|
|
1944
2050
|
<>
|
|
1945
2051
|
{head}
|
|
2052
|
+
{!holdsToken(data) && <SettingsViews on="workspace" />}
|
|
1946
2053
|
{error !== undefined && <Callout tone="danger">{error}</Callout>}
|
|
1947
2054
|
{workspace !== undefined && (
|
|
1948
2055
|
<section className="sc-panel" aria-label={words.settings.workspace.aria}>
|
|
@@ -2169,10 +2276,23 @@ interface Plate {
|
|
|
2169
2276
|
* A plate, read when the page is opened: the person's own, or another person's for whoever
|
|
2170
2277
|
* oversees them. The week at the top is the address's.
|
|
2171
2278
|
*/
|
|
2279
|
+
/**
|
|
2280
|
+
* What a person's own pages showed last, by what each read: come back to, a page stands at once
|
|
2281
|
+
* with what it showed and reads again behind it, rather than wait on the server every time a
|
|
2282
|
+
* tab is pressed. Forgotten when the person signs out.
|
|
2283
|
+
*/
|
|
2284
|
+
const shownBefore = new Map<string, unknown>();
|
|
2285
|
+
|
|
2286
|
+
function rememberedAs<T>(key: string): T | undefined {
|
|
2287
|
+
return shownBefore.get(key) as T | undefined;
|
|
2288
|
+
}
|
|
2289
|
+
|
|
2172
2290
|
function PlatePage(props: {
|
|
2173
2291
|
readonly components: ConsoleComponents;
|
|
2174
2292
|
/** Reads the plate; stable across renders, since the page reads again whenever it changes. */
|
|
2175
2293
|
readonly load: (signal: AbortSignal) => Promise<Plate>;
|
|
2294
|
+
/** What the plate is remembered by, with whose it is: come back to, the page shows it at once and reads again. */
|
|
2295
|
+
readonly remember: string;
|
|
2176
2296
|
readonly title: string;
|
|
2177
2297
|
/** What stands beside the title: the way back, on another person's plate. */
|
|
2178
2298
|
readonly aside?: ReactNode;
|
|
@@ -2188,18 +2308,19 @@ function PlatePage(props: {
|
|
|
2188
2308
|
readonly weekStart?: WeekStart | undefined;
|
|
2189
2309
|
}) {
|
|
2190
2310
|
const words = useWords();
|
|
2191
|
-
const { components, load, couldNotLoad, refused } = props;
|
|
2192
|
-
const [plate, setPlate] = useState<Plate | undefined>(
|
|
2311
|
+
const { components, load, couldNotLoad, refused, remember } = props;
|
|
2312
|
+
const [plate, setPlate] = useState<Plate | undefined>(() => rememberedAs<Plate>(remember));
|
|
2193
2313
|
const [problem, setProblem] = useState<string | undefined>(undefined);
|
|
2194
2314
|
const [forbidden, setForbidden] = useState(false);
|
|
2195
2315
|
useEffect(() => {
|
|
2196
2316
|
const controller = new AbortController();
|
|
2197
|
-
setPlate(
|
|
2317
|
+
setPlate(rememberedAs<Plate>(remember));
|
|
2198
2318
|
setProblem(undefined);
|
|
2199
2319
|
setForbidden(false);
|
|
2200
2320
|
load(controller.signal)
|
|
2201
2321
|
.then((answer) => {
|
|
2202
2322
|
if (!controller.signal.aborted) {
|
|
2323
|
+
shownBefore.set(remember, answer);
|
|
2203
2324
|
setPlate(answer);
|
|
2204
2325
|
}
|
|
2205
2326
|
})
|
|
@@ -2218,7 +2339,7 @@ function PlatePage(props: {
|
|
|
2218
2339
|
}
|
|
2219
2340
|
});
|
|
2220
2341
|
return () => controller.abort();
|
|
2221
|
-
}, [load, couldNotLoad, refused]);
|
|
2342
|
+
}, [load, couldNotLoad, refused, remember]);
|
|
2222
2343
|
return (
|
|
2223
2344
|
<>
|
|
2224
2345
|
<div className="sc-page-head">
|
|
@@ -2336,13 +2457,25 @@ interface DecisionsRead {
|
|
|
2336
2457
|
}
|
|
2337
2458
|
|
|
2338
2459
|
/** The decisions addressed to the person, or, with `raised`, those they raised for someone else (ADR-0042). */
|
|
2460
|
+
/** The first page of a person's decisions as it was shown last, remembered for the next time. */
|
|
2461
|
+
interface RememberedDecisions {
|
|
2462
|
+
readonly items: RestMyDecisions["items"];
|
|
2463
|
+
readonly more: boolean;
|
|
2464
|
+
}
|
|
2465
|
+
|
|
2339
2466
|
function useMyDecisions(
|
|
2340
2467
|
myDecisions: ConsoleData["actions"]["myDecisions"],
|
|
2341
2468
|
raised: boolean,
|
|
2342
2469
|
couldNotLoad: string,
|
|
2470
|
+
/** What the first page is remembered by, with whose it is. */
|
|
2471
|
+
remember: string,
|
|
2343
2472
|
): DecisionsRead {
|
|
2344
|
-
const [items, setItems] = useState<RestMyDecisions["items"] | undefined>(
|
|
2345
|
-
|
|
2473
|
+
const [items, setItems] = useState<RestMyDecisions["items"] | undefined>(
|
|
2474
|
+
() => rememberedAs<RememberedDecisions>(remember)?.items,
|
|
2475
|
+
);
|
|
2476
|
+
const [more, setMore] = useState(
|
|
2477
|
+
() => rememberedAs<RememberedDecisions>(remember)?.more ?? false,
|
|
2478
|
+
);
|
|
2346
2479
|
const [busy, setBusy] = useState(false);
|
|
2347
2480
|
const [problem, setProblem] = useState<string | undefined>(undefined);
|
|
2348
2481
|
const read = useCallback(
|
|
@@ -2353,6 +2486,9 @@ function useMyDecisions(
|
|
|
2353
2486
|
if (signal?.aborted === true) {
|
|
2354
2487
|
return;
|
|
2355
2488
|
}
|
|
2489
|
+
if (offset === 0) {
|
|
2490
|
+
shownBefore.set(remember, { items: page.items, more: page.more });
|
|
2491
|
+
}
|
|
2356
2492
|
setItems((before) => (offset === 0 ? page.items : [...(before ?? []), ...page.items]));
|
|
2357
2493
|
setMore(page.more);
|
|
2358
2494
|
} catch (failure: unknown) {
|
|
@@ -2365,15 +2501,17 @@ function useMyDecisions(
|
|
|
2365
2501
|
}
|
|
2366
2502
|
}
|
|
2367
2503
|
},
|
|
2368
|
-
[myDecisions, raised, couldNotLoad],
|
|
2504
|
+
[myDecisions, raised, couldNotLoad, remember],
|
|
2369
2505
|
);
|
|
2370
2506
|
useEffect(() => {
|
|
2371
2507
|
const controller = new AbortController();
|
|
2372
|
-
|
|
2508
|
+
const kept = rememberedAs<RememberedDecisions>(remember);
|
|
2509
|
+
setItems(kept?.items);
|
|
2510
|
+
setMore(kept?.more ?? false);
|
|
2373
2511
|
setProblem(undefined);
|
|
2374
2512
|
void read(0, controller.signal);
|
|
2375
2513
|
return () => controller.abort();
|
|
2376
|
-
}, [read]);
|
|
2514
|
+
}, [read, remember]);
|
|
2377
2515
|
const readMore = useCallback(() => void read(items?.length ?? 0), [read, items]);
|
|
2378
2516
|
const reload = useCallback(() => void read(0), [read]);
|
|
2379
2517
|
return { items, more, busy, problem, readMore, reload };
|
|
@@ -2386,8 +2524,19 @@ function useMyDecisions(
|
|
|
2386
2524
|
function MyDecisionsPage(props: { readonly data: ConsoleData }) {
|
|
2387
2525
|
const words = useWords();
|
|
2388
2526
|
const { myDecisions, answerReachedDecision } = props.data.actions;
|
|
2389
|
-
const
|
|
2390
|
-
const
|
|
2527
|
+
const whose = props.data.me?.person?.id ?? "";
|
|
2528
|
+
const addressed = useMyDecisions(
|
|
2529
|
+
myDecisions,
|
|
2530
|
+
false,
|
|
2531
|
+
words.myDecisions.couldNotLoad,
|
|
2532
|
+
`decisions:${whose}:addressed`,
|
|
2533
|
+
);
|
|
2534
|
+
const raised = useMyDecisions(
|
|
2535
|
+
myDecisions,
|
|
2536
|
+
true,
|
|
2537
|
+
words.myDecisions.couldNotLoad,
|
|
2538
|
+
`decisions:${whose}:raised`,
|
|
2539
|
+
);
|
|
2391
2540
|
const { busy, error, act } = useAction();
|
|
2392
2541
|
const problem = addressed.problem ?? raised.problem ?? error;
|
|
2393
2542
|
// Answered at the decision's own address (ADR-0068), so that one that reaches the person from a
|
|
@@ -2441,6 +2590,7 @@ function WorkPage(props: {
|
|
|
2441
2590
|
<PlatePage
|
|
2442
2591
|
components={props.components}
|
|
2443
2592
|
load={work}
|
|
2593
|
+
remember={`work:${props.data.me?.person?.id ?? ""}`}
|
|
2444
2594
|
title={words.work.title}
|
|
2445
2595
|
week={props.week}
|
|
2446
2596
|
weekStart={weekStartOf(props.data.me?.workspace)}
|
|
@@ -2469,6 +2619,7 @@ function PersonWorkPage(props: {
|
|
|
2469
2619
|
<PlatePage
|
|
2470
2620
|
components={props.components}
|
|
2471
2621
|
load={load}
|
|
2622
|
+
remember={`work:${data.me?.person?.id ?? ""}:${id}`}
|
|
2472
2623
|
title={words.people.workOf(name)}
|
|
2473
2624
|
aside={<LinkButton href={PATHS.people}>{words.nav.people}</LinkButton>}
|
|
2474
2625
|
week={props.week}
|
|
@@ -2530,6 +2681,9 @@ function WorkspacePage(props: {
|
|
|
2530
2681
|
if (route.name === "person-work") {
|
|
2531
2682
|
return <PersonWorkPage id={route.id} data={data} components={components} week={route.week} />;
|
|
2532
2683
|
}
|
|
2684
|
+
if (route.name === "sessions") {
|
|
2685
|
+
return <SessionsPage data={data} components={components} />;
|
|
2686
|
+
}
|
|
2533
2687
|
if (route.name === "workspace-settings") {
|
|
2534
2688
|
return (
|
|
2535
2689
|
<WorkspaceSettingsPage
|
|
@@ -2818,16 +2972,19 @@ export function createConsole(config: ConsoleConfig = {}): ConsoleApp {
|
|
|
2818
2972
|
const failure = signInFailureOf(location.search);
|
|
2819
2973
|
const title = data.me?.workspace.name ?? fallbackTitle;
|
|
2820
2974
|
const viaToken = holdsToken(data);
|
|
2821
|
-
// The language: the person's own, else the browser's, else the
|
|
2975
|
+
// The language: the person's own, else the browser's, else the workspace's (ADR-0081), else
|
|
2976
|
+
// the first the console speaks.
|
|
2822
2977
|
const chosen = data.me?.language;
|
|
2978
|
+
const fallback = data.me?.workspace.language;
|
|
2823
2979
|
const pack = useMemo(
|
|
2824
2980
|
() =>
|
|
2825
2981
|
chooseLanguage(
|
|
2826
2982
|
chosen,
|
|
2827
2983
|
typeof navigator === "undefined" ? [] : navigator.languages,
|
|
2828
2984
|
languages,
|
|
2985
|
+
fallback,
|
|
2829
2986
|
),
|
|
2830
|
-
[chosen],
|
|
2987
|
+
[chosen, fallback],
|
|
2831
2988
|
);
|
|
2832
2989
|
const words = pack.messages;
|
|
2833
2990
|
|
|
@@ -2951,6 +3108,7 @@ export function createConsole(config: ConsoleConfig = {}): ConsoleApp {
|
|
|
2951
3108
|
label: words.nav.settings,
|
|
2952
3109
|
current:
|
|
2953
3110
|
route.name === "workspace-settings" ||
|
|
3111
|
+
route.name === "sessions" ||
|
|
2954
3112
|
route.name === "categories" ||
|
|
2955
3113
|
route.name === "plugins-settings",
|
|
2956
3114
|
},
|
|
@@ -3147,7 +3305,14 @@ export function createConsole(config: ConsoleConfig = {}): ConsoleApp {
|
|
|
3147
3305
|
))
|
|
3148
3306
|
}
|
|
3149
3307
|
onNavigate={(href) => navigation.go(href)}
|
|
3150
|
-
onSignOut={
|
|
3308
|
+
onSignOut={
|
|
3309
|
+
viaToken
|
|
3310
|
+
? undefined
|
|
3311
|
+
: () => {
|
|
3312
|
+
shownBefore.clear();
|
|
3313
|
+
void data.actions.signOut();
|
|
3314
|
+
}
|
|
3315
|
+
}
|
|
3151
3316
|
>
|
|
3152
3317
|
{page}
|
|
3153
3318
|
</components.Shell>
|
package/src/data.ts
CHANGED
|
@@ -49,6 +49,7 @@ import {
|
|
|
49
49
|
type RestRulesInput,
|
|
50
50
|
type RestRulesPlugin,
|
|
51
51
|
type RestRun,
|
|
52
|
+
type RestSessions,
|
|
52
53
|
type RestSkills,
|
|
53
54
|
type RestTask,
|
|
54
55
|
type RestTaskInput,
|
|
@@ -212,6 +213,12 @@ export interface ConsoleActions {
|
|
|
212
213
|
/** Makes a token for whoever is signed in; the answer carries the secret, this once. */
|
|
213
214
|
createToken(input: RestTokenInput): Promise<RestTokenCreated>;
|
|
214
215
|
revokeToken(id: string): Promise<void>;
|
|
216
|
+
/** The browsers whoever is signed in is signed in on (board #309), the current first: read by the page that shows them. */
|
|
217
|
+
sessions(signal?: AbortSignal): Promise<RestSessions>;
|
|
218
|
+
/** Ends one of the person's other sessions. */
|
|
219
|
+
endSession(id: string): Promise<void>;
|
|
220
|
+
/** Ends every session of the person but this browser's. */
|
|
221
|
+
endOtherSessions(): Promise<void>;
|
|
215
222
|
/** What asks to connect under a code (ADR-0011), for the person who approves it. */
|
|
216
223
|
connectRequest(code: string, signal?: AbortSignal): Promise<RestConnectRequest>;
|
|
217
224
|
approveConnection(code: string, input: RestTokenInput): Promise<RestConnectRequest>;
|
|
@@ -487,10 +494,27 @@ export function useConsoleData(client: ConsoleClient, projectKey: string | undef
|
|
|
487
494
|
setError(undefined);
|
|
488
495
|
setFailure(undefined);
|
|
489
496
|
const run = async () => {
|
|
497
|
+
// The workspace's lists and the person's tokens are asked for along with who is signed
|
|
498
|
+
// in, rather than once that answer has come: a round trip fewer before a page stands.
|
|
499
|
+
// Where nobody is signed in they are given up unheard, and so are the tokens where an
|
|
500
|
+
// agent's token asks, since a token cannot list tokens: a console that holds one has none
|
|
501
|
+
// to show.
|
|
502
|
+
const asked = new AbortController();
|
|
503
|
+
const askedTokens = new AbortController();
|
|
504
|
+
const giveUp = () => {
|
|
505
|
+
asked.abort();
|
|
506
|
+
askedTokens.abort();
|
|
507
|
+
};
|
|
508
|
+
signal.addEventListener("abort", giveUp);
|
|
509
|
+
const lists = refreshWorkspace(asked.signal);
|
|
510
|
+
const tokens = client.tokens(askedTokens.signal);
|
|
511
|
+
lists.catch(() => undefined);
|
|
512
|
+
tokens.catch(() => undefined);
|
|
490
513
|
let answer: RestMe;
|
|
491
514
|
try {
|
|
492
515
|
answer = await client.me(signal);
|
|
493
516
|
} catch (failure) {
|
|
517
|
+
giveUp();
|
|
494
518
|
if (!signal.aborted) {
|
|
495
519
|
setFailure(failure);
|
|
496
520
|
setError(wordsOf(failure, "The server could not be reached."));
|
|
@@ -502,15 +526,16 @@ export function useConsoleData(client: ConsoleClient, projectKey: string | undef
|
|
|
502
526
|
}
|
|
503
527
|
setMe(answer);
|
|
504
528
|
if (answer.person === null) {
|
|
529
|
+
giveUp();
|
|
505
530
|
setLoaded(false);
|
|
506
531
|
return;
|
|
507
532
|
}
|
|
533
|
+
if (answer.agent !== null) {
|
|
534
|
+
askedTokens.abort();
|
|
535
|
+
}
|
|
508
536
|
try {
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
// A token cannot list tokens: a console that holds one has none to show.
|
|
512
|
-
answer.agent === null ? client.tokens(signal) : Promise.resolve({ items: [] }),
|
|
513
|
-
]);
|
|
537
|
+
await lists;
|
|
538
|
+
const mine = answer.agent === null ? await tokens : { items: [] };
|
|
514
539
|
if (signal.aborted) {
|
|
515
540
|
return;
|
|
516
541
|
}
|
|
@@ -898,6 +923,9 @@ export function useConsoleData(client: ConsoleClient, projectKey: string | undef
|
|
|
898
923
|
await client.revokeToken(id);
|
|
899
924
|
setTokens((current) => current.filter((token) => token.id !== id));
|
|
900
925
|
},
|
|
926
|
+
sessions: (signal) => client.sessions(signal),
|
|
927
|
+
endSession: (id) => client.endSession(id),
|
|
928
|
+
endOtherSessions: () => client.endOtherSessions(),
|
|
901
929
|
rules: (signal) => client.rules(signal),
|
|
902
930
|
writeRules: (input) => client.writeRules(input),
|
|
903
931
|
archiveRules: () => client.archiveRules(),
|
package/src/i18n/en.ts
CHANGED
|
@@ -266,6 +266,7 @@ export const en = {
|
|
|
266
266
|
"task.too_many": "The project has as many tasks as it can hold.",
|
|
267
267
|
"token.expiry_at_most": "A token can't last that many days here.",
|
|
268
268
|
"token.not_found": "The token was not found.",
|
|
269
|
+
"session.not_found": "The session was not found.",
|
|
269
270
|
"token.too_many": "You have as many tokens as you can hold. Remove one first.",
|
|
270
271
|
"workspace.pack_connect_refused": "SkillCDN refused the connection.",
|
|
271
272
|
"workspace.pack_connect_unsupported": "This console can't connect a pack.",
|
|
@@ -923,6 +924,7 @@ export const en = {
|
|
|
923
924
|
|
|
924
925
|
settings: {
|
|
925
926
|
title: "Settings",
|
|
927
|
+
views: { aria: "Settings", workspace: "Workspace", sessions: "Sessions" },
|
|
926
928
|
categories: "Categories",
|
|
927
929
|
manageCategories: "Manage the categories",
|
|
928
930
|
skills: "Skills",
|
|
@@ -939,6 +941,10 @@ export const en = {
|
|
|
939
941
|
aria: "Workspace settings",
|
|
940
942
|
consoleVersion: "Console version",
|
|
941
943
|
consoleTakes: (range: string) => `Takes the console command ${range}`,
|
|
944
|
+
language: "Default language",
|
|
945
|
+
languageHint:
|
|
946
|
+
"For whoever has not chosen a language: the pages speak it to someone whose browser asks for none the console speaks, and plugins write in it to someone who has never opened the pages, in a decision, a task or a chat. Everyone who chose a language keeps their own.",
|
|
947
|
+
languageNone: "Not set: English",
|
|
942
948
|
peopleVisibility: "Member visibility",
|
|
943
949
|
peopleVisibilityHint:
|
|
944
950
|
"Whom a member sees on the People page and in the pickers: everyone of the workspace, or only the people they share a project with. An administrator always sees everyone, and a project open to the workspace has everyone in it.",
|
|
@@ -1035,6 +1041,7 @@ export const en = {
|
|
|
1035
1041
|
peopleVisibility: "the member visibility",
|
|
1036
1042
|
weekStart: "the first day of the week",
|
|
1037
1043
|
timeZone: "the time zone",
|
|
1044
|
+
language: "the default language",
|
|
1038
1045
|
packToken: "the SkillCDN token",
|
|
1039
1046
|
} as Readonly<Record<string, string>>,
|
|
1040
1047
|
event: {
|
|
@@ -1425,6 +1432,24 @@ export const en = {
|
|
|
1425
1432
|
},
|
|
1426
1433
|
},
|
|
1427
1434
|
|
|
1435
|
+
sessions: {
|
|
1436
|
+
title: "Sessions",
|
|
1437
|
+
list: "Your sessions",
|
|
1438
|
+
loading: "Loading the sessions",
|
|
1439
|
+
intro:
|
|
1440
|
+
"The browsers signed in to your account. Sign out of any you do not recognize or no longer use.",
|
|
1441
|
+
introIdle: (days: string) =>
|
|
1442
|
+
`The browsers signed in to your account. Sign out of any you do not recognize or no longer use. A session not used for ${days} days ends on its own.`,
|
|
1443
|
+
current: "Current session",
|
|
1444
|
+
on: (browser: string, platform: string) => `${browser} on ${platform}`,
|
|
1445
|
+
unknownBrowser: "Unknown browser",
|
|
1446
|
+
lastActive: "Last active",
|
|
1447
|
+
signedIn: "Signed in",
|
|
1448
|
+
from: (address: string) => `IP ${address}`,
|
|
1449
|
+
end: "Sign out",
|
|
1450
|
+
endOthers: "Sign out of all other sessions",
|
|
1451
|
+
},
|
|
1452
|
+
|
|
1428
1453
|
connect: {
|
|
1429
1454
|
title: "Connect an agent",
|
|
1430
1455
|
aria: "Connect",
|
package/src/i18n/index.ts
CHANGED
|
@@ -4,7 +4,8 @@ import { ko } from "./ko.js";
|
|
|
4
4
|
|
|
5
5
|
// The languages the pages speak (ADR-0012): a pack is a tag, a label and every word the
|
|
6
6
|
// default console shows; the components take their words from a context, with English where
|
|
7
|
-
// there is none above them; the person's choice, else the browser's languages, else
|
|
7
|
+
// there is none above them; the person's choice, else the browser's languages, else the
|
|
8
|
+
// workspace's language (ADR-0081), else English.
|
|
8
9
|
|
|
9
10
|
export type { Messages } from "./en.js";
|
|
10
11
|
|
|
@@ -68,12 +69,19 @@ export function browserPack(
|
|
|
68
69
|
|
|
69
70
|
/**
|
|
70
71
|
* The language to speak: the person's own when it names a pack, else the first of the browser's
|
|
71
|
-
* languages that does, else the first pack.
|
|
72
|
+
* languages that does, else the workspace's (ADR-0081) when it names one, else the first pack.
|
|
72
73
|
*/
|
|
73
74
|
export function chooseLanguage(
|
|
74
75
|
chosen: string | null | undefined,
|
|
75
76
|
browser: readonly string[],
|
|
76
77
|
packs: readonly LanguagePack[] = DEFAULT_LANGUAGES,
|
|
78
|
+
workspace?: string | null | undefined,
|
|
77
79
|
): LanguagePack {
|
|
78
|
-
return
|
|
80
|
+
return (
|
|
81
|
+
packFor(chosen, packs) ??
|
|
82
|
+
browserPack(browser, packs) ??
|
|
83
|
+
packFor(workspace, packs) ??
|
|
84
|
+
packs[0] ??
|
|
85
|
+
ENGLISH
|
|
86
|
+
);
|
|
79
87
|
}
|