Skip to content

Commit 69dea00

Browse files
authored
Merge pull request #2 from itk-dev/feature/release-json
Added release.json generation to builds
2 parents 513d9a7 + cf079df commit 69dea00

55 files changed

Lines changed: 2086 additions & 262 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/docker_build_stg_images.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,20 @@ jobs:
3434
with:
3535
images: os2display/display-api-service
3636

37+
- name: Set release timestamp
38+
run: |
39+
echo "APP_RELEASE_TIMESTAMP=$(echo $(date +%s))" >> $GITHUB_ENV
40+
echo "APP_RELEASE_TIME=$(echo $(date))" >> $GITHUB_ENV
41+
3742
- name: Build and push (API)
3843
uses: docker/build-push-action@v6
3944
with:
4045
context: ./infrastructure/display-api-service/
4146
file: ./infrastructure/display-api-service/Dockerfile
4247
build-args: |
43-
VERSION=${{ env.APP_VERSION }}
48+
APP_VERSION=${{ env.APP_VERSION }}
49+
APP_RELEASE_TIMESTAMP=${{ env.APP_RELEASE_TIMESTAMP }}
50+
APP_RELEASE_TIME=${{ env.APP_RELEASE_TIME }}
4451
push: true
4552
tags: ${{ steps.meta-api.outputs.tags }}
4653
labels: ${{ steps.meta-api.outputs.labels }}

.github/workflows/github_build_release.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,16 @@ jobs:
3535
docker compose run --rm node npm install
3636
docker compose run --rm node npm run build
3737
38+
- name: Set release timestamp
39+
run: |
40+
echo "APP_RELEASE_TIMESTAMP=$(echo $(date +%s))" >> $GITHUB_ENV
41+
echo "APP_RELEASE_TIME=$(echo $(date))" >> $GITHUB_ENV
42+
43+
- name: Create release file
44+
run: |
45+
printf "{\n \"releaseTimestamp\": ${{ env.APP_RELEASE_TIMESTAMP }},\n \"releaseTime\": \"${{ env.APP_RELEASE_TIME }}\",\n \"releaseVersion\": \"${{ github.ref_name }}\"\n}" > public/release.json
46+
cat public/release.json
47+
3848
- name: Cleanup after install
3949
run: |
4050
sudo chown -R runner:runner .
@@ -102,6 +112,11 @@ jobs:
102112
tags: |
103113
type=raw,value=${{ github.ref_name }}
104114
115+
- name: Set release timestamp
116+
run: |
117+
echo "APP_RELEASE_TIMESTAMP=$(echo $(date +%s))" >> $GITHUB_ENV
118+
echo "APP_RELEASE_TIME=$(echo $(date))" >> $GITHUB_ENV
119+
105120
- name: Build and push Docker image (main)
106121
id: push-main
107122
uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
@@ -110,6 +125,8 @@ jobs:
110125
file: ./infrastructure/display-api-service/Dockerfile
111126
build-args: |
112127
APP_VERSION=${{ github.ref_name }}
128+
APP_RELEASE_TIMESTAMP=${{ env.APP_RELEASE_TIMESTAMP }}
129+
APP_RELEASE_TIME=${{ env.APP_RELEASE_TIME }}
113130
push: true
114131
tags: ${{ steps.meta-main.outputs.tags }}
115132
labels: ${{ steps.meta-main.outputs.labels }}
@@ -132,6 +149,8 @@ jobs:
132149
file: ./infrastructure/nginx/Dockerfile
133150
build-args: |
134151
APP_VERSION=${{ github.ref_name }}
152+
APP_RELEASE_TIMESTAMP=${{ env.APP_RELEASE_TIMESTAMP }}
153+
APP_RELEASE_TIME=${{ env.APP_RELEASE_TIME }}
135154
APP_IMAGE=${{ env.IMAGE_NAME_MAIN }}
136155
push: true
137156
pull: true

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,5 @@ phpstan.neon
6464
###> vincentlanglet/twig-cs-fixer ###
6565
/.twig-cs-fixer.cache
6666
###< vincentlanglet/twig-cs-fixer ###
67+
68+
.claude/

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ All notable changes to this project will be documented in this file.
3131
- Added relations checksum feature flag.
3232
- Fixes saving issues described in issue where saving resulted in infinite spinner.
3333
- Fixed loading of routes containing null string values.
34+
- Fixed release.json creation in v3.
35+
- Fixed relations checksum test.
36+
- Optimized release data fetching.
37+
- Optimized list loading.
3438

3539
### NB! Prior to 3.x the project was split into separate repositories
3640

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -509,9 +509,11 @@ CLIENT_DEBUG=false
509509
waiting for being activated in the administration.
510510

511511
**Default**: 20 s.
512-
- CLIENT_REFRESH_TOKEN_TIMEOUT: How often (milliseconds) should it be checked whether the token needs to be refreshed?
512+
- CLIENT_RELEASE_TIMESTAMP_INTERVAL_TIMEOUT: How often (milliseconds) should it be checked whether a new release is
513+
available?
514+
Value should not be lower than 5 minutes, since release.json is only fetched with a minimum of 5 minutes interval.
513515

514-
**Default**: 30 s.
516+
**Default**: 10 m.
515517
- CLIENT_REFRESH_TOKEN_TIMEOUT: How often (milliseconds) should it be checked whether the token needs to be refreshed?
516518

517519
**Default**: 60 s.

Taskfile.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ tasks:
192192
desc: "Runs API tests (PHPUnit)."
193193
cmds:
194194
- task composer -- test-setup
195-
- task compose -- exec --env SYMFONY_DEPRECATIONS_HELPER=disabled phpfpm composer test
195+
- task compose -- exec --env SYMFONY_DEPRECATIONS_HELPER=disabled phpfpm vendor/bin/phpunit --stop-on-failure {{.CLI_ARGS}}
196196

197197
test:frontend-built:
198198
desc: "Runs frontend tests (Playwright) on the built files. This temporarily stops the node container."

assets/admin/components/groups/groups-columns.jsx

Lines changed: 52 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,57 @@
11
import { useTranslation } from "react-i18next";
2-
import ListButton from "../util/list/list-button";
32
import ColumnHoc from "../util/column-hoc";
43
import SelectColumnHoc from "../util/select-column-hoc";
4+
import useModal from "../../context/modal-context/modal-context-hook.jsx";
5+
import { useDispatch } from "react-redux";
6+
import { enhancedApi } from "../../../shared/redux/enhanced-api.ts";
7+
import idFromUrl from "../util/helpers/id-from-url.jsx";
8+
import getAllPages from "../util/helpers/get-all-pages.js";
9+
import { Link } from "react-router-dom";
10+
import { Button } from "react-bootstrap";
11+
12+
function ScreensButton({ group }) {
13+
const { t } = useTranslation("common", { keyPrefix: "groups-columns" });
14+
const { setModal } = useModal();
15+
const dispatch = useDispatch();
16+
17+
const onClick = () => {
18+
getAllPages(dispatch, enhancedApi.endpoints.getV2ScreenGroupsByIdScreens, {
19+
id: idFromUrl(group.id),
20+
}).then((screens) => {
21+
const content = (
22+
<ul>
23+
{screens.map((screen) => (
24+
<li key={screen["@id"]}>
25+
<Link
26+
to={`screen/edit/${idFromUrl(screen["@id"])}`}
27+
target="_blank"
28+
>
29+
{screen.title}
30+
</Link>
31+
</li>
32+
))}
33+
</ul>
34+
);
35+
36+
setModal({
37+
info: true,
38+
modalTitle: t("screens-modal-title"),
39+
content,
40+
});
41+
});
42+
};
43+
44+
return (
45+
<Button
46+
variant="secondary"
47+
type="button"
48+
onClick={onClick}
49+
disabled={group.screensLength === 0}
50+
>
51+
{group.screensLength}
52+
</Button>
53+
);
54+
}
555

656
/**
757
* Columns for group lists.
@@ -18,14 +68,7 @@ function getGroupColumns({ apiCall, infoModalRedirect, infoModalTitle }) {
1868
const columns = [
1969
{
2070
// eslint-disable-next-line react/prop-types
21-
content: ({ screens }) => (
22-
<ListButton
23-
redirectTo={infoModalRedirect}
24-
displayData={screens}
25-
modalTitle={infoModalTitle}
26-
apiCall={apiCall}
27-
/>
28-
),
71+
content: (group) => <ScreensButton group={group} />,
2972
key: "screens",
3073
label: t("screens"),
3174
},

assets/admin/components/playlist/playlists-columns.jsx

Lines changed: 54 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,59 @@
1-
import { useContext } from "react";
21
import { useTranslation } from "react-i18next";
32
import ColumnHoc from "../util/column-hoc";
43
import SelectColumnHoc from "../util/select-column-hoc";
5-
import UserContext from "../../context/user-context";
6-
import ListButton from "../util/list/list-button";
74
import DateValue from "../util/date-value";
85
import PublishingStatus from "../util/publishingStatus";
6+
import useModal from "../../context/modal-context/modal-context-hook.jsx";
7+
import { useDispatch } from "react-redux";
8+
import { enhancedApi } from "../../../shared/redux/enhanced-api.ts";
9+
import idFromUrl from "../util/helpers/id-from-url.jsx";
10+
import getAllPages from "../util/helpers/get-all-pages.js";
11+
import { Link } from "react-router-dom";
12+
import { Button } from "react-bootstrap";
13+
14+
function SlidesButton({ playlist }) {
15+
const { t } = useTranslation("common", { keyPrefix: "playlists-columns" });
16+
const { setModal } = useModal();
17+
const dispatch = useDispatch();
18+
19+
const onClick = () => {
20+
getAllPages(dispatch, enhancedApi.endpoints.getV2PlaylistsByIdSlides, {
21+
id: idFromUrl(playlist.id),
22+
}).then((playlistSlides) => {
23+
const content = (
24+
<ul>
25+
{playlistSlides.map((playlistSlide) => (
26+
<li key={playlistSlide?.slide["@id"]}>
27+
<Link
28+
to={`slide/edit/${idFromUrl(playlistSlide?.slide["@id"])}`}
29+
target="_blank"
30+
>
31+
{playlistSlide?.slide.title}
32+
</Link>
33+
</li>
34+
))}
35+
</ul>
36+
);
37+
38+
setModal({
39+
info: true,
40+
modalTitle: t("playlist-slide-modal-title"),
41+
content,
42+
});
43+
});
44+
};
45+
46+
return (
47+
<Button
48+
variant="secondary"
49+
type="button"
50+
onClick={onClick}
51+
disabled={playlist.slidesLength === 0}
52+
>
53+
{playlist.slidesLength}
54+
</Button>
55+
);
56+
}
957

1058
/**
1159
* Columns for playlists lists.
@@ -17,40 +65,16 @@ import PublishingStatus from "../util/publishingStatus";
1765
* @param {string} props.dataKey The data key for mapping the data.
1866
* @returns {object} The columns for the playlists lists.
1967
*/
20-
function getPlaylistColumns({
21-
apiCall,
22-
infoModalRedirect,
23-
infoModalTitle,
24-
dataKey,
25-
}) {
26-
const context = useContext(UserContext);
68+
function getPlaylistColumns() {
2769
const { t } = useTranslation("common", {
2870
keyPrefix: "playlists-columns",
2971
});
3072

3173
const columns = [
3274
{
33-
key: "slides",
75+
key: "playlist",
3476
label: t("number-of-slides"),
35-
render: ({ tenants }) => {
36-
return (
37-
tenants?.length === 0 ||
38-
!tenants.find(
39-
(tenant) =>
40-
tenant.tenantKey === context.selectedTenant.get.tenantKey,
41-
)
42-
);
43-
},
44-
// eslint-disable-next-line react/prop-types
45-
content: ({ slides, playlistSlides }) => (
46-
<ListButton
47-
apiCall={apiCall}
48-
redirectTo={infoModalRedirect}
49-
displayData={slides || playlistSlides}
50-
modalTitle={infoModalTitle}
51-
dataKey={dataKey}
52-
/>
53-
),
77+
content: (playlist) => <SlidesButton playlist={playlist} />,
5478
},
5579
{
5680
key: "publishing-from",

assets/admin/components/screen/screen-list.jsx

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import useModal from "../../context/modal-context/modal-context-hook";
1111
import {
1212
useGetV2ScreensQuery,
1313
useDeleteV2ScreensByIdMutation,
14-
useGetV2ScreensByIdScreenGroupsQuery,
1514
} from "../../../shared/redux/enhanced-api.ts";
1615
import {
1716
displaySuccess,
@@ -128,10 +127,6 @@ function ScreenList() {
128127

129128
// The columns for the table.
130129
const columns = ScreenColumns({
131-
handleDelete,
132-
apiCall: useGetV2ScreensByIdScreenGroupsQuery,
133-
infoModalRedirect: "/group/edit",
134-
infoModalTitle: t("info-modal.screen-in-groups"),
135130
displayStatus: showScreenStatus,
136131
});
137132

assets/admin/components/screen/screen-status.jsx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import { enhancedApi } from "../../../shared/redux/enhanced-api.ts";
1818
import { displayError } from "../util/list/toast-component/display-toast";
1919
import FormInput from "../util/forms/form-input";
2020
import AdminConfigLoader from "../util/admin-config-loader.js";
21+
import ReleaseLoader from "../../../shared/release-loader.js";
2122

2223
/**
2324
* Displays screen status.
@@ -92,11 +93,7 @@ function ScreenStatus({ screen, handleInput = () => {}, mode = "default" }) {
9293

9394
useEffect(() => {
9495
if (status) {
95-
const now = dayjs().startOf("minute").valueOf();
96-
97-
fetch(`/release.json?ts=${now}`)
98-
.then((res) => res.json())
99-
.then((data) => setClientRelease(data));
96+
ReleaseLoader.loadRelease().then((data) => setClientRelease(data));
10097
}
10198
}, [status]);
10299

0 commit comments

Comments
 (0)