Skip to content
This repository was archived by the owner on Sep 3, 2024. It is now read-only.

Commit d8a53eb

Browse files
providing client version in info page
1 parent 257017b commit d8a53eb

File tree

4 files changed

+55
-32
lines changed

4 files changed

+55
-32
lines changed

Dockerfile

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ RUN yarn --frozen-lockfile
1919

2020
COPY . .
2121

22-
RUN yarn build && \
22+
COPY --from=version /src/.version ./
23+
24+
RUN REACT_APP_CLIENT_VERSION=$(cat .version) yarn build && \
2325
yarn build:dist && \
2426
yarn cache clean
2527

@@ -30,15 +32,14 @@ RUN test -z "$MYGET_API_KEY" || \
3032
yarn publish --new-version $(cat .version) && \
3133
echo "No API key found, skipping publishing..."
3234

33-
COPY --from=version /src/.version /app/build
34-
3535
FROM nginx:1.15.5-alpine AS runtime
3636

3737
COPY ./nginx/nginx.conf /etc/nginx/nginx.conf
3838

3939
COPY ./nginx/mime.types /etc/nginx/mime.types
4040

4141
COPY --from=build /app/build/ /var/www/
42+
COPY --from=version /src/.version /var/www
4243

4344
EXPOSE 80
4445

src/stream-store/Viewer/HalViewer/Home.tsx

Lines changed: 46 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,47 @@ import { Observable as obs } from 'rxjs';
66
import rels from 'stream-store/rels';
77
import store from 'stream-store/store';
88
import { HalResource } from 'types';
9+
import { clientVersion } from 'utils';
910
import { HalViewerProps } from './types';
1011

1112
const provider$ = store.hal$.body$.map(({ provider }) => provider);
1213

1314
const versions$ = store.hal$.body$.map(({ versions }) => versions);
1415

16+
const info$ = provider$.zip(versions$).map(([provider, versions]) =>
17+
[
18+
{
19+
id: 'Provider',
20+
value: inflector.camel2words(
21+
inflector.underscore(provider),
22+
) as string,
23+
},
24+
]
25+
.concat(
26+
Object.keys(versions).map(key => ({
27+
id: `${inflector.camel2words(
28+
inflector.underscore(key),
29+
)} Version`,
30+
value: versions[key] as string,
31+
})),
32+
)
33+
.concat({
34+
id: 'Client Version',
35+
value: clientVersion as string,
36+
}),
37+
);
38+
1539
interface RecentState {
1640
recent: HalResource[];
1741
}
1842

43+
interface InfoLineProps {
44+
id: string;
45+
value: string;
46+
}
47+
1948
interface InfoState {
20-
provider: string;
21-
versions: { [key: string]: string };
49+
info: InfoLineProps[];
2250
}
2351

2452
interface IndexState extends RecentState, InfoState {}
@@ -29,50 +57,39 @@ const recent$ = store.hal$.body$.map(
2957

3058
const state$ = createState<IndexState>(
3159
obs.merge(
32-
provider$.map(provider => ['provider', () => provider]),
33-
versions$.map(versions => ['versions', () => versions]),
60+
info$.map(info => ['info', () => info]),
3461
recent$.map(recent => ['recent', () => recent]),
3562
),
36-
obs.of<IndexState>({ recent: [], provider: '', versions: {} }),
63+
obs.of<IndexState>({ recent: [], info: [] }),
3764
);
3865

39-
const Info: StatelessComponent<InfoState> = ({ provider, versions }) => (
66+
const InfoLine: StatelessComponent<InfoLineProps> = ({ id, value }) => (
67+
<Table.Row>
68+
<Table.Cell>
69+
<strong>{id}</strong>
70+
</Table.Cell>
71+
<Table.Cell>{value}</Table.Cell>
72+
</Table.Row>
73+
);
74+
75+
const Info: StatelessComponent<InfoState> = ({ info }) => (
4076
<Table>
4177
<Table.Head>
4278
<Table.Row>
4379
<Table.Cell colSpan={2}>{'Server Information'}</Table.Cell>
4480
</Table.Row>
4581
</Table.Head>
4682
<Table.Body>
47-
<Table.Row>
48-
<Table.Cell>
49-
<strong>{'Provider'}</strong>
50-
</Table.Cell>
51-
<Table.Cell>
52-
{inflector.camel2words(inflector.underscore(provider))}
53-
</Table.Cell>
54-
</Table.Row>
55-
{Object.keys(versions).map(key => (
56-
<Table.Row key={key}>
57-
<Table.Cell>
58-
<strong>
59-
{inflector.camel2words(inflector.underscore(key))}{' '}
60-
{'Version'}
61-
</strong>
62-
</Table.Cell>
63-
<Table.Cell>{versions[key]}</Table.Cell>
64-
</Table.Row>
83+
{info.map(({ id, value }) => (
84+
<InfoLine key={id} id={id} value={value} />
6585
))}
6686
</Table.Body>
6787
</Table>
6888
);
6989

70-
const Index: ComponentType<IndexState & HalViewerProps> = ({
71-
provider,
72-
versions,
73-
}) => (
90+
const Index: ComponentType<IndexState & HalViewerProps> = ({ info }) => (
7491
<section>
75-
<Info provider={provider} versions={versions} />
92+
<Info info={info} />
7693
</section>
7794
);
7895

src/utils/clientVersion.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
const clientVersion: string | undefined = process.env.REACT_APP_CLIENT_VERSION;
2+
3+
export default clientVersion;

src/utils/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,5 @@ export { default as mediaTypes } from './mediaTypes';
99
export { default as hal } from './hal';
1010

1111
export { default as reactJsonTheme } from './reactJsonTheme';
12+
13+
export { default as clientVersion } from './clientVersion';

0 commit comments

Comments
 (0)