From 7c3930207c59fe7e9751ff6faa30b2ed86e05693 Mon Sep 17 00:00:00 2001 From: Alexander Vogt Date: Mon, 29 Dec 2025 12:52:15 +0100 Subject: [PATCH 1/2] display hash of build commit --- frontend/webEditor/.gitignore | 1 + frontend/webEditor/package.json | 7 ++++++- frontend/webEditor/scripts/fetchHash.js | 13 +++++++++++++ frontend/webEditor/src/settings/SettingsUi.ts | 17 +++++++++++++++++ frontend/webEditor/src/settings/settingsUi.css | 8 ++++++++ 5 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 frontend/webEditor/scripts/fetchHash.js diff --git a/frontend/webEditor/.gitignore b/frontend/webEditor/.gitignore index f06235c4..4f2b814a 100644 --- a/frontend/webEditor/.gitignore +++ b/frontend/webEditor/.gitignore @@ -1,2 +1,3 @@ node_modules dist +src/settings/hash.json \ No newline at end of file diff --git a/frontend/webEditor/package.json b/frontend/webEditor/package.json index 5e118773..1515d8c3 100644 --- a/frontend/webEditor/package.json +++ b/frontend/webEditor/package.json @@ -6,6 +6,7 @@ "type": "git", "url": "https://github.com/DataFlowAnalysis/OnlineEditor.git" }, + "type": "module", "devDependencies": { "@eslint/eslintrc": "^3.3.3", "@eslint/js": "^9.39.1", @@ -32,7 +33,11 @@ "preview": "vite preview", "format": "prettier --write \"./**/*.{html,css,ts,tsx,json}\"", "lint": "eslint --max-warnings 0 --no-warn-ignored", - "prepare": "husky" + "prepare": "husky", + "postprepare": "npm run fetch-hash", + "prebuild": "npm run fetch-hash", + "predev": "npm run fetch-hash", + "fetch-hash": "node ./scripts/fetchHash.js" }, "lint-staged": { "*.{html,css,ts,tsx,json}": [ diff --git a/frontend/webEditor/scripts/fetchHash.js b/frontend/webEditor/scripts/fetchHash.js new file mode 100644 index 00000000..81d1297b --- /dev/null +++ b/frontend/webEditor/scripts/fetchHash.js @@ -0,0 +1,13 @@ +import { writeFileSync } from 'fs' +import { execSync } from 'child_process' + +let hash = 'unknown' +try { + hash = execSync('git rev-parse HEAD').toString().trim() +} catch (e) { + // eslint-disable-next-line no-console + console.warn('Could not retrieve git hash:', e) +} +const filePath = 'src/settings/hash.json' +const fileContent = JSON.stringify({ hash }) +writeFileSync(filePath, fileContent) \ No newline at end of file diff --git a/frontend/webEditor/src/settings/SettingsUi.ts b/frontend/webEditor/src/settings/SettingsUi.ts index 70f6194a..e13b477c 100644 --- a/frontend/webEditor/src/settings/SettingsUi.ts +++ b/frontend/webEditor/src/settings/SettingsUi.ts @@ -6,6 +6,7 @@ import { HideEdgeNames, SETTINGS, SimplifyNodeNames } from "./Settings"; import { EditorModeController } from "./editorMode"; import { Theme, ThemeManager } from "./Theme"; import { ShownLabels, ShownLabelsValue } from "./ShownLabels"; +import hashJson from './hash.json' @injectable() export class SettingsUI extends AccordionUiExtension { @@ -42,6 +43,7 @@ export class SettingsUI extends AccordionUiExtension { this.addBooleanSwitch(grid, "Hide Edge Names", this.hideEdgeNames); this.addBooleanSwitch(grid, "Simplify Node Names", this.simplifyNodeNames); this.addSwitch(grid, "Read Only", this.editorModeController, { true: "view", false: "edit" }); + contentElement.appendChild(this.buildCommitHash()) } protected initializeHeaderContent(headerElement: HTMLElement): void { @@ -49,6 +51,21 @@ export class SettingsUI extends AccordionUiExtension { headerElement.innerText = "Settings"; } + private buildCommitHash(): HTMLElement { + const holder = document.createElement('div') + holder.id = 'hashHolder' + holder.innerHTML = 'Commit:' + + const link = document.createElement('a') + link.innerHTML = hashJson.hash.substring(0, 6) + link.href = `https://github.com/DataFlowAnalysis/OnlineEditor/tree/${hashJson.hash}` + link.id = 'hash' + link.target = '_blank' + + holder.appendChild(link) + return holder + } + private addBooleanSwitch(container: HTMLElement, title: string, value: SettingsValue): void { this.addSwitch(container, title, value, { true: true, false: false }); } diff --git a/frontend/webEditor/src/settings/settingsUi.css b/frontend/webEditor/src/settings/settingsUi.css index 90517902..d1d71a86 100644 --- a/frontend/webEditor/src/settings/settingsUi.css +++ b/frontend/webEditor/src/settings/settingsUi.css @@ -108,3 +108,11 @@ input:checked + .slider:before { .slider.round:before { border-radius: 50%; } + +.settings-ui #hashHolder { + font-size: small; + margin-top: 8px; + display: flex; + gap: 2px; +} + From f1f7bb68e0f3861264b9a115b380e9abafb9aedb Mon Sep 17 00:00:00 2001 From: Alexander Vogt Date: Mon, 29 Dec 2025 13:00:52 +0100 Subject: [PATCH 2/2] move hash to help --- frontend/webEditor/.gitignore | 2 +- frontend/webEditor/scripts/fetchHash.js | 4 ++-- frontend/webEditor/src/helpUi/helpUi.css | 7 +++++++ frontend/webEditor/src/helpUi/helpUi.ts | 18 ++++++++++++++++++ frontend/webEditor/src/settings/SettingsUi.ts | 17 ----------------- frontend/webEditor/src/settings/settingsUi.css | 8 -------- 6 files changed, 28 insertions(+), 28 deletions(-) diff --git a/frontend/webEditor/.gitignore b/frontend/webEditor/.gitignore index 4f2b814a..81071fd2 100644 --- a/frontend/webEditor/.gitignore +++ b/frontend/webEditor/.gitignore @@ -1,3 +1,3 @@ node_modules dist -src/settings/hash.json \ No newline at end of file +src/helpUi/hash.json \ No newline at end of file diff --git a/frontend/webEditor/scripts/fetchHash.js b/frontend/webEditor/scripts/fetchHash.js index 81d1297b..fe23fa64 100644 --- a/frontend/webEditor/scripts/fetchHash.js +++ b/frontend/webEditor/scripts/fetchHash.js @@ -5,9 +5,9 @@ let hash = 'unknown' try { hash = execSync('git rev-parse HEAD').toString().trim() } catch (e) { - // eslint-disable-next-line no-console + // eslint-disable-next-line no-console, no-undef console.warn('Could not retrieve git hash:', e) } -const filePath = 'src/settings/hash.json' +const filePath = 'src/helpUi/hash.json' const fileContent = JSON.stringify({ hash }) writeFileSync(filePath, fileContent) \ No newline at end of file diff --git a/frontend/webEditor/src/helpUi/helpUi.css b/frontend/webEditor/src/helpUi/helpUi.css index a5e496ec..44ef0853 100644 --- a/frontend/webEditor/src/helpUi/helpUi.css +++ b/frontend/webEditor/src/helpUi/helpUi.css @@ -14,4 +14,11 @@ vertical-align: text-top; margin-right: 4px; } + + #hashHolder { + font-size: small; + margin-top: 4px; + display: flex; + gap: 2px; + } } diff --git a/frontend/webEditor/src/helpUi/helpUi.ts b/frontend/webEditor/src/helpUi/helpUi.ts index 76f94676..dde57bb0 100644 --- a/frontend/webEditor/src/helpUi/helpUi.ts +++ b/frontend/webEditor/src/helpUi/helpUi.ts @@ -1,6 +1,7 @@ import { injectable } from "inversify"; import "./helpUi.css"; import { AccordionUiExtension } from "../accordionUiExtension"; +import hashJson from "./hash.json"; @injectable() export class HelpUI extends AccordionUiExtension { @@ -35,9 +36,26 @@ export class HelpUI extends AccordionUiExtension {

Esc: Disable current creation tool

Toggle Creation Tool: Refer to key in the tool palette

`; + + contentElement.appendChild(this.buildCommitHash()); } protected initializeHeaderContent(headerElement: HTMLElement) { headerElement.classList.add("help-accordion-icon"); headerElement.innerText = "Keyboard Shortcuts | Help"; } + + private buildCommitHash(): HTMLElement { + const holder = document.createElement("div"); + holder.id = "hashHolder"; + holder.innerHTML = "Commit:"; + + const link = document.createElement("a"); + link.innerHTML = hashJson.hash.substring(0, 6); + link.href = `https://github.com/DataFlowAnalysis/OnlineEditor/tree/${hashJson.hash}`; + link.id = "hash"; + link.target = "_blank"; + + holder.appendChild(link); + return holder; + } } diff --git a/frontend/webEditor/src/settings/SettingsUi.ts b/frontend/webEditor/src/settings/SettingsUi.ts index e13b477c..70f6194a 100644 --- a/frontend/webEditor/src/settings/SettingsUi.ts +++ b/frontend/webEditor/src/settings/SettingsUi.ts @@ -6,7 +6,6 @@ import { HideEdgeNames, SETTINGS, SimplifyNodeNames } from "./Settings"; import { EditorModeController } from "./editorMode"; import { Theme, ThemeManager } from "./Theme"; import { ShownLabels, ShownLabelsValue } from "./ShownLabels"; -import hashJson from './hash.json' @injectable() export class SettingsUI extends AccordionUiExtension { @@ -43,7 +42,6 @@ export class SettingsUI extends AccordionUiExtension { this.addBooleanSwitch(grid, "Hide Edge Names", this.hideEdgeNames); this.addBooleanSwitch(grid, "Simplify Node Names", this.simplifyNodeNames); this.addSwitch(grid, "Read Only", this.editorModeController, { true: "view", false: "edit" }); - contentElement.appendChild(this.buildCommitHash()) } protected initializeHeaderContent(headerElement: HTMLElement): void { @@ -51,21 +49,6 @@ export class SettingsUI extends AccordionUiExtension { headerElement.innerText = "Settings"; } - private buildCommitHash(): HTMLElement { - const holder = document.createElement('div') - holder.id = 'hashHolder' - holder.innerHTML = 'Commit:' - - const link = document.createElement('a') - link.innerHTML = hashJson.hash.substring(0, 6) - link.href = `https://github.com/DataFlowAnalysis/OnlineEditor/tree/${hashJson.hash}` - link.id = 'hash' - link.target = '_blank' - - holder.appendChild(link) - return holder - } - private addBooleanSwitch(container: HTMLElement, title: string, value: SettingsValue): void { this.addSwitch(container, title, value, { true: true, false: false }); } diff --git a/frontend/webEditor/src/settings/settingsUi.css b/frontend/webEditor/src/settings/settingsUi.css index d1d71a86..90517902 100644 --- a/frontend/webEditor/src/settings/settingsUi.css +++ b/frontend/webEditor/src/settings/settingsUi.css @@ -108,11 +108,3 @@ input:checked + .slider:before { .slider.round:before { border-radius: 50%; } - -.settings-ui #hashHolder { - font-size: small; - margin-top: 8px; - display: flex; - gap: 2px; -} -