Change from "Build" to "Version"

Also make version string copy-able
This commit is contained in:
Lim Chee Aun 2023-10-23 08:43:27 +08:00
parent 8d694ecf1b
commit 72842c663a
2 changed files with 40 additions and 15 deletions

View file

@ -140,3 +140,10 @@
color: var(--link-color); color: var(--link-color);
vertical-align: middle; vertical-align: middle;
} }
#settings-container .version-string {
padding: 4px;
font-family: var(--monospace-font);
font-size: 85%;
text-align: center;
}

View file

@ -18,6 +18,7 @@ import {
removeSubscription, removeSubscription,
updateSubscription, updateSubscription,
} from '../utils/push-notifications'; } from '../utils/push-notifications';
import showToast from '../utils/show-toast';
import states from '../utils/states'; import states from '../utils/states';
import store from '../utils/store'; import store from '../utils/store';
@ -508,21 +509,38 @@ function Settings({ onClose }) {
</p> </p>
{__BUILD_TIME__ && ( {__BUILD_TIME__ && (
<p> <p>
<span class="insignificant">Last build:</span>{' '} Version:{' '}
<RelativeTime datetime={new Date(__BUILD_TIME__)} />{' '} <input
{__COMMIT_HASH__ && ( type="text"
<> class="version-string"
readOnly
size="18" // Manually calculated here
value={`${__BUILD_TIME__.slice(0, 10).replace(/-/g, '.')}${
__COMMIT_HASH__ ? `.${__COMMIT_HASH__}` : ''
}`}
onClick={(e) => {
e.target.select();
// Copy to clipboard
try {
navigator.clipboard.writeText(e.target.value);
showToast('Version string copied');
} catch (e) {
console.warn(e);
showToast('Unable to copy version string');
}
}}
/>{' '}
<span class="ib insignificant">
( (
<a <a
href={`https://github.com/cheeaun/phanpy/commit/${__COMMIT_HASH__}`} href={`https://github.com/cheeaun/phanpy/commit/${__COMMIT_HASH__}`}
target="_blank" target="_blank"
rel="noopener noreferrer" rel="noopener noreferrer"
> >
<code>{__COMMIT_HASH__}</code> <RelativeTime datetime={new Date(__BUILD_TIME__)} />
</a> </a>
) )
</> </span>
)}
</p> </p>
)} )}
</section> </section>