Skip to content

Commit

Permalink
feat: add commit has in page header
Browse files Browse the repository at this point in the history
Within the header there will now be a shorthash visible that links to
packit/dashboard page

Part of #209
  • Loading branch information
Venefilyn authored and mfocko committed Apr 4, 2023
1 parent bb08772 commit b349d3d
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 3 deletions.
9 changes: 6 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ TEST_IMAGE ?= packit-dashboard-tests
TEST_TARGET ?= ./tests/
CONTAINER_ENGINE ?= $(shell command -v podman 2> /dev/null || echo docker)
API_STG = "https://stg.packit.dev/api"
GIT_SHA_FETCH := $(shell git rev-parse HEAD)
export GIT_SHA=$(GIT_SHA_FETCH)

install-dependencies: .install-logos
sudo dnf -y install python3-flask yarnpkg npm
Expand All @@ -17,7 +19,7 @@ install-dependencies: .install-logos

# this will transpile jsx into js, minify everything and generate static js for production builds
transpile-prod:
cd frontend && REACT_APP_API_URL=$(API_STG) yarn run build
cd frontend && REACT_APP_GIT_SHA=$(GIT_SHA) REACT_APP_API_URL=$(API_STG) yarn run build


# For Development Mode Only:
Expand All @@ -29,7 +31,7 @@ transpile-prod:
# if you change flask port for dev, also change it in frontend/package.json in the proxy key/value

run-dev-frontend:
cd frontend && REACT_APP_API_URL=$(API_STG) GENERATE_SOURCEMAP=true HTTPS=true yarn start
cd frontend && REACT_APP_GIT_SHA=$(GIT_SHA) REACT_APP_API_URL=$(API_STG) GENERATE_SOURCEMAP=true HTTPS=true yarn start

run-dev-flask:
FLASK_ENV=development FLASK_APP=packit_dashboard.app flask-3 run --host=0.0.0.0
Expand All @@ -39,7 +41,8 @@ run-container-stg: build-stg

build-stg:
$(CONTAINER_ENGINE) build --rm \
--build-arg REACT_APP_API_URL=$(API_STG) \
--build-arg REASCT_APP_API_URL=$(API_STG) \
--build-arg GIT_SHA=$(GIT_SHA) \
-t $(IMAGE) -f Dockerfile .

push-stg: build-stg
Expand Down
1 change: 1 addition & 0 deletions frontend/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="description" content="Dashboard for Packit Service." />
<meta name="ui-version" content="%REACT_APP_GIT_SHA%" />
<style>
html,
body,
Expand Down
21 changes: 21 additions & 0 deletions frontend/src/app/AppLayout/AppLayout.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,16 @@ import {
NavList,
NavItem,
Page,
PageHeaderTools,
PageHeader,
PageSidebar,
Button,
SkipToContent,
} from "@patternfly/react-core";
import { routes } from "../routes";
import packitLogo from "../../static/logo.png";
import { useState, useEffect } from "react";
import { ExternalLinkSquareAltIcon } from "@patternfly/react-icons";

const AppLayout = () => {
const location = useLocation();
Expand Down Expand Up @@ -47,13 +50,31 @@ const AppLayout = () => {
const onPageResize = (props) => {
setIsMobileView(props.mobileView);
};

const HeaderTools = (
<PageHeaderTools>
<Button
component="a"
href={`https://github.com/packit/dashboard/commit/${process.env.REACT_APP_GIT_SHA}`}
target="_blank"
rel="noreferrer"
variant="link"
icon={<ExternalLinkSquareAltIcon />}
iconPosition="right"
aria-label="External link to page source commit"
>
{process.env.REACT_APP_GIT_SHA.substring(0, 7)}
</Button>
</PageHeaderTools>
);
const Header = (
<PageHeader
logo={<Brand src={packitLogo} alt="Packit Logo" />}
logoProps={logoProps}
showNavToggle
isNavOpen={isNavOpen}
onNavToggle={isMobileView ? onNavToggleMobile : onNavToggle}
headerTools={HeaderTools}
/>
);
const Navigation = (
Expand Down

0 comments on commit b349d3d

Please sign in to comment.