Skip to content

Commit

Permalink
Add frontend skeleton
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosthe19916 committed Mar 5, 2024
1 parent 02e9b5e commit 9179ca1
Show file tree
Hide file tree
Showing 100 changed files with 24,852 additions and 1 deletion.
37 changes: 37 additions & 0 deletions .github/workflows/frontend.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: frontend

on:
push:
branches:
- main
pull_request:
branches:
- main

env:
CI: true

jobs:
test:
name: test
runs-on: ubuntu-latest
defaults:
run:
working-directory: frontend

steps:
- uses: actions/checkout@v4
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: 18.x
- name: Verify package-lock.json
run: ./scripts/verify_lock.mjs
- name: Install
run: npm clean-install --ignore-scripts
- name: Lint sources
run: npm run lint
- name: Build
run: npm run build
- name: Test
run: npm run test -- --coverage --watchAll=false
2 changes: 2 additions & 0 deletions frontend/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
*/dist/
13 changes: 13 additions & 0 deletions frontend/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
root=true

[*]
# standard prettier behaviors
charset = utf-8
insert_final_newline = true
trim_trailing_whitespace = true

# Configurable prettier behaviors
end_of_line = lf
indent_style = space
indent_size = 2
max_line_length = 80
94 changes: 94 additions & 0 deletions frontend/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
/* eslint-env node */

module.exports = {
root: true,

env: {
browser: true,
es2020: true,
jest: true,
},

parser: "@typescript-eslint/parser",
parserOptions: {
ecmaFeatures: {
jsx: true,
},
ecmaVersion: 2020, // keep in sync with tsconfig.json
sourceType: "module",
},

// eslint-disable-next-line prettier/prettier
extends: [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:react/recommended",
"prettier",
],

// eslint-disable-next-line prettier/prettier
plugins: [
"prettier",
"unused-imports", // or eslint-plugin-import?
"@typescript-eslint",
"react",
"react-hooks",
"@tanstack/query",
],

// NOTE: Tweak the rules as needed when bulk fixes get merged
rules: {
// TODO: set to "error" when prettier v2 to v3 style changes are fixed
"prettier/prettier": ["warn"],

// TODO: set to "error" when all resolved, but keep the `argsIgnorePattern`
"@typescript-eslint/no-unused-vars": ["warn", { argsIgnorePattern: "^_" }],

// TODO: each one of these can be removed or set to "error" when they're all resolved
"unused-imports/no-unused-imports": ["warn"],
"@typescript-eslint/ban-types": "warn",
"@typescript-eslint/no-explicit-any": "warn",
"react/jsx-key": "warn",
"react-hooks/rules-of-hooks": "warn",
"react-hooks/exhaustive-deps": "warn",
"no-extra-boolean-cast": "warn",
"prefer-const": "warn",

// Allow the "cy-data" property for trustification-ui-test (but should really be "data-cy" w/o this rule)
"react/no-unknown-property": ["error", { ignore: ["cy-data"] }],

"@tanstack/query/exhaustive-deps": "error",
"@tanstack/query/prefer-query-object-syntax": "error",
},

settings: {
react: { version: "detect" },
},

ignorePatterns: [
// don't ignore dot files so config files get linted
"!.*.js",
"!.*.cjs",
"!.*.mjs",

// take the place of `.eslintignore`
"dist/",
"generated/",
"node_modules/",
],

// this is a hack to make sure eslint will look at all of the file extensions we
// care about without having to put it on the command line
overrides: [
{
files: [
"**/*.js",
"**/*.jsx",
"**/*.cjs",
"**/*.mjs",
"**/*.ts",
"**/*.tsx",
],
},
],
};
30 changes: 30 additions & 0 deletions frontend/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
node_modules/
/.pnp
.pnp.js

# testing
coverage/

# production
dist/
/qa/build

# misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local

npm-debug.log*

.eslintcache

# VSCode
.vscode/*

# Intellij IDEA
.idea/
1 change: 1 addition & 0 deletions frontend/.npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
engine-strict=true
12 changes: 12 additions & 0 deletions frontend/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Library, IDE and build locations
**/node_modules/
**/coverage/
**/dist/
.vscode/
.idea/
.eslintcache/

#
# NOTE: Could ignore anything that eslint will look at since eslint also applies
# prettier.
#
14 changes: 14 additions & 0 deletions frontend/.prettierrc.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/** @type {import("prettier").Config} */
const config = {
trailingComma: "es5", // es5 was the default in prettier v2
semi: true,
singleQuote: false,

// Values used from .editorconfig:
// - printWidth == max_line_length
// - tabWidth == indent_size
// - useTabs == indent_style
// - endOfLine == end_of_line
};

export default config;
38 changes: 38 additions & 0 deletions frontend/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Builder image
FROM registry.access.redhat.com/ubi9/nodejs-18:latest as builder

USER 1001
COPY --chown=1001 . .
RUN npm clean-install && npm run build && npm run dist

# Runner image
FROM registry.access.redhat.com/ubi9/nodejs-18-minimal:latest

# Add ps package to allow liveness probe for k8s cluster
# Add tar package to allow copying files with kubectl scp
USER 0
RUN microdnf -y install tar procps-ng && microdnf clean all

USER 1001

LABEL name="trustification/trustification-ui" \
description="Trustification - User Interface" \
help="For more information visit https://trustification.github.io/" \
license="Apache License 2.0" \
maintainer="[email protected]" \
summary="Trustification - User Interface" \
url="https://quay.io/repository/trustification/trustification-ui" \
usage="podman run -p 80 -v trustification/trustification-ui:latest" \
io.k8s.display-name="trustification-ui" \
io.k8s.description="Trustification - User Interface" \
io.openshift.expose-services="80:http" \
io.openshift.tags="operator,trustification,ui,nodejs18" \
io.openshift.min-cpu="100m" \
io.openshift.min-memory="350Mi"

COPY --from=builder /opt/app-root/src/dist /opt/app-root/dist/

ENV DEBUG=1

WORKDIR /opt/app-root/dist
ENTRYPOINT ["./entrypoint.sh"]
28 changes: 27 additions & 1 deletion frontend/README.md
Original file line number Diff line number Diff line change
@@ -1 +1,27 @@
# Where the frontend lives.
## dev-env

Install dependencies:

```shell
npm clean-install --ignore-scripts
```

Init the dev server:

```shell
npm run start:dev
```

Open brower at http://localhost:3000

## Environment variables

| ENV VAR | Description | Defaul value |
| ---------------------- | ----------------------------- | ------------------------------------ |
| TRUSTIFICATION_HUB_URL | Set Trustification API URL | http://localhost:8080 |
| AUTH_REQUIRED | Enable/Disable authentication | false |
| OIDC_CLIENT_ID | Set Oidc Client | frontend |
| OIDC_SERVER_URL | Set Oidc Server URL | http://localhost:8090/realms/chicken |
| OIDC_Scope | Set Oidc Scope | openid |
| ANALYTICS_ENABLED | Enable/Disable analytics | false |
| ANALYTICS_WRITE_KEY | Set Segment Write key | null |
Binary file added frontend/branding/favicon.ico
Binary file not shown.
Binary file added frontend/branding/images/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added frontend/branding/images/logo192.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added frontend/branding/images/logo512.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
40 changes: 40 additions & 0 deletions frontend/branding/images/masthead-logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 15 additions & 0 deletions frontend/branding/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"short_name": "trustification-ui",
"name": "Trustification UI",
"icons": [
{
"src": "favicon.ico",
"sizes": "64x64 32x32 24x24 16x16",
"type": "image/x-icon"
}
],
"start_url": ".",
"display": "standalone",
"theme_color": "#000000",
"background_color": "#ffffff"
}
21 changes: 21 additions & 0 deletions frontend/branding/strings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"application": {
"title": "Trustification",
"name": "Trustification UI",
"description": "Trustification UI"
},
"about": {
"displayName": "Trustification",
"imageSrc": "<%= brandingRoot %>/images/masthead-logo.svg",
"documentationUrl": "https://trustification.io/"
},
"masthead": {
"leftBrand": {
"src": "<%= brandingRoot %>/images/masthead-logo.svg",
"alt": "brand",
"height": "40px"
},
"leftTitle": null,
"rightBrand": null
}
}
Loading

0 comments on commit 9179ca1

Please sign in to comment.