github-issue-tower-defence-management 1.88.1 → 1.90.0
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/.github/CODEOWNERS +1 -2
- package/CHANGELOG.md +14 -0
- package/README.md +13 -2
- package/bin/adapter/entry-points/cli/index.js +21 -0
- package/bin/adapter/entry-points/cli/index.js.map +1 -1
- package/bin/adapter/entry-points/console/consoleServer.js +40 -13
- package/bin/adapter/entry-points/console/consoleServer.js.map +1 -1
- package/bin/adapter/entry-points/console/ui-dist/assets/{index-DcOZ02ON.js → index-DDjYPXRT.js} +10 -10
- package/bin/adapter/entry-points/console/ui-dist/assets/index-DHlBLm7d.css +1 -0
- package/bin/adapter/entry-points/console/ui-dist/index.html +2 -2
- package/bin/adapter/entry-points/handlers/OauthTokenSelectHandler.js +97 -0
- package/bin/adapter/entry-points/handlers/OauthTokenSelectHandler.js.map +1 -0
- package/bin/adapter/proxy/RateLimitCache.js +3 -3
- package/bin/adapter/proxy/RateLimitCache.js.map +1 -1
- package/bin/domain/usecases/OauthTokenSelectUseCase.js +87 -0
- package/bin/domain/usecases/OauthTokenSelectUseCase.js.map +1 -0
- package/package.json +1 -1
- package/src/adapter/entry-points/cli/index.ts +38 -0
- package/src/adapter/entry-points/console/consoleServer.test.ts +81 -0
- package/src/adapter/entry-points/console/consoleServer.ts +48 -16
- package/src/adapter/entry-points/console/ui/src/features/console/components/ConsoleProjectHeader.stories.tsx +29 -0
- package/src/adapter/entry-points/console/ui/src/features/console/components/ConsoleProjectHeader.tsx +14 -0
- package/src/adapter/entry-points/console/ui/src/features/console/hooks/useConsoleList.ts +17 -4
- package/src/adapter/entry-points/console/ui/src/features/console/hooks/useConsolePjcode.test.ts +24 -0
- package/src/adapter/entry-points/console/ui/src/features/console/hooks/useConsolePjcode.ts +17 -0
- package/src/adapter/entry-points/console/ui/src/features/console/pages/ConsolePage.tsx +5 -1
- package/src/adapter/entry-points/console/ui/tsconfig.json +2 -1
- package/src/adapter/entry-points/console/ui/vite.config.ts +1 -1
- package/src/adapter/entry-points/console/ui-dist/assets/{index-DcOZ02ON.js → index-DDjYPXRT.js} +10 -10
- package/src/adapter/entry-points/console/ui-dist/assets/index-DHlBLm7d.css +1 -0
- package/src/adapter/entry-points/console/ui-dist/index.html +2 -2
- package/src/adapter/entry-points/handlers/OauthTokenSelectHandler.test.ts +204 -0
- package/src/adapter/entry-points/handlers/OauthTokenSelectHandler.ts +132 -0
- package/src/adapter/proxy/RateLimitCache.ts +9 -4
- package/src/domain/usecases/OauthTokenSelectUseCase.test.ts +179 -0
- package/src/domain/usecases/OauthTokenSelectUseCase.ts +158 -0
- package/types/adapter/entry-points/cli/index.d.ts.map +1 -1
- package/types/adapter/entry-points/console/consoleServer.d.ts +1 -0
- package/types/adapter/entry-points/console/consoleServer.d.ts.map +1 -1
- package/types/adapter/entry-points/handlers/OauthTokenSelectHandler.d.ts +20 -0
- package/types/adapter/entry-points/handlers/OauthTokenSelectHandler.d.ts.map +1 -0
- package/types/adapter/proxy/RateLimitCache.d.ts +2 -2
- package/types/adapter/proxy/RateLimitCache.d.ts.map +1 -1
- package/types/domain/usecases/OauthTokenSelectUseCase.d.ts +35 -0
- package/types/domain/usecases/OauthTokenSelectUseCase.d.ts.map +1 -0
- package/bin/adapter/entry-points/console/ui-dist/assets/index-DFxrSRH4.css +0 -1
- package/src/adapter/entry-points/console/ui-dist/assets/index-DFxrSRH4.css +0 -1
|
@@ -2,7 +2,8 @@ import { useEffect, useState } from 'react';
|
|
|
2
2
|
import type { ConsoleListItem, ConsoleTabName } from '../types';
|
|
3
3
|
import { useConsoleToken } from './useConsoleToken';
|
|
4
4
|
|
|
5
|
-
const buildListUrl = (tab: ConsoleTabName): string =>
|
|
5
|
+
const buildListUrl = (pjcode: string, tab: ConsoleTabName): string =>
|
|
6
|
+
`/projects/${pjcode}/${tab}/list.json`;
|
|
6
7
|
|
|
7
8
|
const extractItems = (payload: unknown): ConsoleListItem[] => {
|
|
8
9
|
if (
|
|
@@ -22,7 +23,10 @@ export type ConsoleListState = {
|
|
|
22
23
|
error: string | null;
|
|
23
24
|
};
|
|
24
25
|
|
|
25
|
-
export const useConsoleList = (
|
|
26
|
+
export const useConsoleList = (
|
|
27
|
+
pjcode: string | null,
|
|
28
|
+
tab: ConsoleTabName,
|
|
29
|
+
): ConsoleListState => {
|
|
26
30
|
const { appendToken } = useConsoleToken();
|
|
27
31
|
const [items, setItems] = useState<ConsoleListItem[]>([]);
|
|
28
32
|
const [isLoading, setIsLoading] = useState<boolean>(true);
|
|
@@ -33,7 +37,16 @@ export const useConsoleList = (tab: ConsoleTabName): ConsoleListState => {
|
|
|
33
37
|
setIsLoading(true);
|
|
34
38
|
setError(null);
|
|
35
39
|
|
|
36
|
-
|
|
40
|
+
if (pjcode === null) {
|
|
41
|
+
setItems([]);
|
|
42
|
+
setIsLoading(false);
|
|
43
|
+
setError('No project specified in the URL path.');
|
|
44
|
+
return () => {
|
|
45
|
+
cancelled = true;
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const url = appendToken(buildListUrl(pjcode, tab));
|
|
37
50
|
fetch(url)
|
|
38
51
|
.then(async (response) => {
|
|
39
52
|
if (!response.ok) {
|
|
@@ -59,7 +72,7 @@ export const useConsoleList = (tab: ConsoleTabName): ConsoleListState => {
|
|
|
59
72
|
return () => {
|
|
60
73
|
cancelled = true;
|
|
61
74
|
};
|
|
62
|
-
}, [tab, appendToken]);
|
|
75
|
+
}, [pjcode, tab, appendToken]);
|
|
63
76
|
|
|
64
77
|
return { items, isLoading, error };
|
|
65
78
|
};
|
package/src/adapter/entry-points/console/ui/src/features/console/hooks/useConsolePjcode.test.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { parsePjcodeFromPath } from './useConsolePjcode';
|
|
2
|
+
|
|
3
|
+
describe('parsePjcodeFromPath', () => {
|
|
4
|
+
it('extracts the pjcode from a projects path', () => {
|
|
5
|
+
expect(parsePjcodeFromPath('/projects/umino')).toBe('umino');
|
|
6
|
+
expect(parsePjcodeFromPath('/projects/umino/prs')).toBe('umino');
|
|
7
|
+
expect(parsePjcodeFromPath('/projects/xmile/triage')).toBe('xmile');
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
it('tolerates a trailing slash', () => {
|
|
11
|
+
expect(parsePjcodeFromPath('/projects/utage3/')).toBe('utage3');
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
it('returns null when the path is not under projects', () => {
|
|
15
|
+
expect(parsePjcodeFromPath('/')).toBeNull();
|
|
16
|
+
expect(parsePjcodeFromPath('/index.html')).toBeNull();
|
|
17
|
+
expect(parsePjcodeFromPath('/assets/app.js')).toBeNull();
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
it('returns null when no pjcode segment follows projects', () => {
|
|
21
|
+
expect(parsePjcodeFromPath('/projects')).toBeNull();
|
|
22
|
+
expect(parsePjcodeFromPath('/projects/')).toBeNull();
|
|
23
|
+
});
|
|
24
|
+
});
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export const parsePjcodeFromPath = (pathname: string): string | null => {
|
|
2
|
+
const segments = pathname.split('/').filter((segment) => segment.length > 0);
|
|
3
|
+
if (segments.length < 2 || segments[0] !== 'projects') {
|
|
4
|
+
return null;
|
|
5
|
+
}
|
|
6
|
+
const pjcode = segments[1];
|
|
7
|
+
if (pjcode.length === 0) {
|
|
8
|
+
return null;
|
|
9
|
+
}
|
|
10
|
+
return pjcode;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export const useConsolePjcode = (): string | null => {
|
|
14
|
+
const pathname =
|
|
15
|
+
typeof window === 'undefined' ? '' : window.location.pathname;
|
|
16
|
+
return parsePjcodeFromPath(pathname);
|
|
17
|
+
};
|
|
@@ -1,17 +1,21 @@
|
|
|
1
1
|
import { useState } from 'react';
|
|
2
2
|
import { ConsoleListView } from '../components/ConsoleListView';
|
|
3
|
+
import { ConsoleProjectHeader } from '../components/ConsoleProjectHeader';
|
|
3
4
|
import { ConsoleTabBar } from '../components/ConsoleTabBar';
|
|
4
5
|
import { useConsoleList } from '../hooks/useConsoleList';
|
|
6
|
+
import { useConsolePjcode } from '../hooks/useConsolePjcode';
|
|
5
7
|
import { CONSOLE_TABS, type ConsoleTabName } from '../types';
|
|
6
8
|
|
|
7
9
|
export const ConsolePage = () => {
|
|
10
|
+
const pjcode = useConsolePjcode();
|
|
8
11
|
const [activeTab, setActiveTab] = useState<ConsoleTabName>(
|
|
9
12
|
CONSOLE_TABS[0].name,
|
|
10
13
|
);
|
|
11
|
-
const { items, isLoading, error } = useConsoleList(activeTab);
|
|
14
|
+
const { items, isLoading, error } = useConsoleList(pjcode, activeTab);
|
|
12
15
|
|
|
13
16
|
return (
|
|
14
17
|
<main className="mx-auto flex max-w-3xl flex-col">
|
|
18
|
+
<ConsoleProjectHeader pjcode={pjcode} />
|
|
15
19
|
<ConsoleTabBar activeTab={activeTab} onSelectTab={setActiveTab} />
|
|
16
20
|
<ConsoleListView items={items} isLoading={isLoading} error={error} />
|
|
17
21
|
</main>
|