Skip to content

Commit

Permalink
build(config): add build properties JSON file (#547)
Browse files Browse the repository at this point in the history
* build(config): add build properties JSON file

Easy build-time overriding of distribution URLs for bug trackers, mailing list, product name, etc.

* commit hash URL can be overridden, is not a link if the URL string is empty
  • Loading branch information
andrewazores authored Oct 11, 2022
1 parent c8dbc3d commit 4fbd51e
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 21 deletions.
3 changes: 2 additions & 1 deletion src/app/About/About.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
*/

import React from 'react';
import build from '@app/build.json';
import cryostatLogoHorizontal from '@app/assets/logo-cryostat-3-horizontal.svg';
import { BreadcrumbPage } from '@app/BreadcrumbPage/BreadcrumbPage';
import { AboutDescription, CRYOSTAT_TRADEMARK } from './AboutDescription';
Expand All @@ -47,7 +48,7 @@ export const About = () => {
<BreadcrumbPage pageTitle="About">
<Card>
<CardHeader>
<Brand alt="Cryostat" src={cryostatLogoHorizontal} className="cryostat-logo" />
<Brand alt={build.productName} src={cryostatLogoHorizontal} className="cryostat-logo" />
</CardHeader>
<CardBody>
<AboutDescription />
Expand Down
43 changes: 24 additions & 19 deletions src/app/About/AboutDescription.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@

import { Text, TextContent, TextList, TextListItem, TextVariants } from '@patternfly/react-core';
import React from 'react';
import build from '@app/build.json';
import { ServiceContext } from '@app/Shared/Services/Services';
import { NotificationsContext } from '@app/Notifications/Notifications';

Expand Down Expand Up @@ -69,55 +70,59 @@ export const AboutDescription = () => {
return result.groups?.describe || 'main';
}, [cryostatVersion, notificationsContext]);

const versionComponent = React.useMemo(() => {
if (build.commitHashUrl) {
return (
<Text
component={TextVariants.a}
target="_blank"
href={build.commitHashUrl.replace('__REPLACE_HASH__', cryostatCommitHash || '')}
>
{cryostatVersion}
</Text>
);
} else {
return <Text component={TextVariants.p}>{cryostatVersion}</Text>;
}
}, [build.commitHashUrl, cryostatCommitHash]);

return (
<>
<TextContent>
<TextList component="dl">
<TextListItem component="dt">Version</TextListItem>
<TextListItem component="dd">
<Text
component={TextVariants.a}
target="_blank"
href={`https://github.com/cryostatio/cryostat/commits/${cryostatCommitHash}`}
>
{cryostatVersion}
</Text>
</TextListItem>
<TextListItem component="dd">{versionComponent}</TextListItem>
<TextListItem component="dt">Homepage</TextListItem>
<TextListItem component="dd">
<Text component={TextVariants.a} target="_blank" href="https://cryostat.io">
<Text component={TextVariants.a} target="_blank" href={build.homePageUrl}>
cryostat.io
</Text>
</TextListItem>
<TextListItem component="dt">Bugs</TextListItem>
<TextListItem component="dd">
<Text>
<Text component={TextVariants.a} target="_blank" href="https://github.com/cryostatio/cryostat/issues">
<Text component={TextVariants.a} target="_blank" href={build.knownIssuesUrl}>
Known Issues
</Text>
&nbsp;|&nbsp;
<Text
component={TextVariants.a}
target="_blank"
href={`https://github.com/cryostatio/cryostat/issues/new?labels=user+report,bug&body=Affects+${cryostatVersion}`}
href={build.fileIssueUrl.replace('__REPLACE_VERSION__', cryostatVersion || 'unknown')}
>
File a Report
</Text>
</Text>
</TextListItem>
<TextListItem component="dt">Mailing List</TextListItem>
<TextListItem component="dd">
<Text component={TextVariants.a} target="_blank" href="https://groups.google.com/g/cryostat-development">
Google Groups
<Text component={TextVariants.a} target="_blank" href={build.mailingListUrl}>
{build.mailingListName}
</Text>
</TextListItem>
<TextListItem component="dt">Open Source License</TextListItem>
<TextListItem component="dd">
<Text
component={TextVariants.a}
target="_blank"
href="https://github.com/cryostatio/cryostat/blob/main/LICENSE"
>
<Text component={TextVariants.a} target="_blank" href={build.licenseUrl}>
License
</Text>
</TextListItem>
Expand Down
10 changes: 10 additions & 0 deletions src/app/build.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"productName": "Cryostat",
"commitHashUrl": "https://github.com/cryostatio/cryostat/commits/__REPLACE_HASH__",
"homePageUrl": "https://cryostat.io",
"knownIssuesUrl": "https://github.com/cryostatio/cryostat/issues",
"fileIssueUrl": "https://github.com/cryostatio/cryostat/issues/new?labels=user+report,bug&body=Affects+__REPLACE_VERSION__",
"mailingListName": "Google Groups",
"mailingListUrl": "https://groups.google.com/g/cryostat-development",
"licenseUrl": "https://github.com/cryostatio/cryostat/blob/main/LICENSE"
}
3 changes: 2 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
"**/*.ts",
"**/*.tsx",
"**/*.jsx",
"**/*.js"
"**/*.js",
"**/*.json"
],
"exclude": ["node_modules"]
}

0 comments on commit 4fbd51e

Please sign in to comment.