Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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
21 changes: 18 additions & 3 deletions pkg/app/web/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,27 @@ genrule(
visibility = ["//visibility:public"],
)

genrule(
name = "embed_version",
srcs = ["webpack.config.js", "webpack.common.js"],
outs = ["gen_webpack.config.js","gen_webpack.common.js"],
cmd = """
for f in $(SRCS)
do
sed -e "s/unknown/$$(cat ./bazel-out/stable-status.txt | grep STABLE_VERSION | awk '{print $$2}')/g" $$f > $(@D)/gen_$$(basename $$f)
done
""",
output_to_bindir = 1,
stamp = True,
)

webpack(
name = "public_files",
args = [
"--mode",
"production",
"--config",
"$(execpath webpack.config.js)",
"$(execpath gen_webpack.config.js)",
"--env htmlTemplate=./$(execpath base.html)",
"--env bazelBinPath=./$(BINDIR)",
"--output-path",
Expand All @@ -92,9 +106,10 @@ webpack(
"base.html",
"compile",
"copy_assets",
"embed_version",
"gen_webpack.config.js",
"gen_webpack.common.js",
"model",
"webpack.common.js",
"webpack.config.js",
"public/mockServiceWorker.js",
"@npm//:node_modules",
] + glob(["assets/**/*"]),
Expand Down
2 changes: 1 addition & 1 deletion pkg/app/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"private": true,
"license": "Apache-2.0",
"scripts": {
"dev": "webpack serve --env htmlTemplate=./base.html --config ./webpack.config.dev.js",
"dev": "STABLE_VERSION=`git describe --tags --always --dirty --abbrev=7` webpack serve --env htmlTemplate=./base.html --config ./webpack.config.dev.js",
"gen": "scaffdog generate",
"test": "TZ=Asia/Tokyo jest --config jest.config.local.js",
"test:coverage": "yarn test --coverage",
Expand Down
14 changes: 13 additions & 1 deletion pkg/app/web/src/components/header/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -206,11 +206,23 @@ export const Header: FC = memo(function Header() {
Events
</Link>
</MenuItem>
<MenuItem>
<MenuItem divider={true}>
<Link component={RouterLink} to={PAGE_PATH_SETTINGS}>
Settings
</Link>
</MenuItem>
<MenuItem>
<Link
href="https://pipecd.dev/docs/"
target="_blank"
rel="noreferrer"
>
Docs

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Docs
Documentation

</Link>
</MenuItem>
<MenuItem disabled={true} dense={true}>
{process.env.STABLE_VERSION?.substring(0, 10)}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
{process.env.STABLE_VERSION?.substring(0, 10)}
Version: {process.env.STABLE_VERSION?.substring(0, 10)}

nits

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

btw, not sure why do we need to cut the string, why not just show the full version string? Since the last part is the commit hash and can be used to refer to source code on pipecd repo, which could be useful in some cases 👀

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

I think this one is easier to understand, but the display looks like this. Which one do you think is better?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I get your point 👍 Then, how about remove the Version: part and show the full version string?

@Hosshii Hosshii Mar 1, 2022

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

Sorry, my comment was not updated and I missed it.

This is what it looks like when I put them all up. Personally, I find it too long.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is exactly what I was thinking about.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

About the version string, I think showing the full one is fine. Because on the production it is not that long.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!
I changed Docs to Documentation and add a icon.
image

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks so beautiful!

Just a nit:

How do you think about moving the menu popup to be lower to avoid overlapping the tab bar?
We can resolve it in another PR.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Than sounds good to me.

</MenuItem>
</Menu>
</AppBar>
);
Expand Down
5 changes: 4 additions & 1 deletion pkg/app/web/webpack.config.dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ module.exports = (env) =>
},
plugins: [
new ForkTsCheckerWebpackPlugin(),
new webpack.EnvironmentPlugin(["API_ENDPOINT"]),
new webpack.EnvironmentPlugin({
API_ENDPOINT: process.env.API_ENDPOINT || null,
STABLE_VERSION: process.env.STABLE_VERSION || null,
}),
],
});
11 changes: 10 additions & 1 deletion pkg/app/web/webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
/* eslint @typescript-eslint/no-var-requires: 0 */
"use strict";
const commonConfig = require("./webpack.common");
const commonConfig = require("./gen_webpack.common");
const { merge } = require("webpack-merge");
const path = require("path");
const webpack = require("webpack");

// overridden by bazel
const version = "unknown";

module.exports = (env) => {
return merge(commonConfig(env), {
Expand All @@ -25,5 +29,10 @@ module.exports = (env) => {
],
},
mode: "production",
plugins: [
new webpack.EnvironmentPlugin({
STABLE_VERSION: version || null,
}),
],
});
};