Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions frontend/webEditor/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
node_modules
dist
src/helpUi/hash.json
7 changes: 6 additions & 1 deletion frontend/webEditor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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}": [
Expand Down
13 changes: 13 additions & 0 deletions frontend/webEditor/scripts/fetchHash.js
Original file line number Diff line number Diff line change
@@ -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, no-undef
console.warn('Could not retrieve git hash:', e)
}
const filePath = 'src/helpUi/hash.json'
const fileContent = JSON.stringify({ hash })
writeFileSync(filePath, fileContent)
7 changes: 7 additions & 0 deletions frontend/webEditor/src/helpUi/helpUi.css
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,11 @@
vertical-align: text-top;
margin-right: 4px;
}

#hashHolder {
font-size: small;
margin-top: 4px;
display: flex;
gap: 2px;
}
}
18 changes: 18 additions & 0 deletions frontend/webEditor/src/helpUi/helpUi.ts
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down Expand Up @@ -35,9 +36,26 @@ export class HelpUI extends AccordionUiExtension {
<p><kbd>Esc</kbd>: Disable current creation tool</p>
<p>Toggle Creation Tool: Refer to key in the tool palette</p>
`;

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;
}
}