Skip to content

Commit 49c32d7

Browse files
committed
Initial commit
- Extracted from policies-ui-frontend
0 parents  commit 49c32d7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+14371
-0
lines changed

.babelrc

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"presets": [
3+
"@babel/env",
4+
"@babel/react"
5+
],
6+
"plugins": [
7+
"@babel/plugin-transform-runtime",
8+
"@babel/plugin-syntax-dynamic-import",
9+
"@babel/plugin-proposal-object-rest-spread",
10+
"lodash"
11+
]
12+
}

.dependabot/config.yml

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
version: 1
2+
update_configs:
3+
- package_manager: "javascript"
4+
directory: "/"
5+
update_schedule: "live"
6+
default_reviewers:
7+
- "josejulio"
8+
allowed_updates:
9+
- match:
10+
dependency_name: "@redhat-cloud-services/frontend*"
11+
- match:
12+
dependency_name: "@patternfly/*"
13+
dependency_type: "direct"

.eslintignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
src/demoData/*
2+
/**/*.d.ts
3+
src/utils/Expression/*

.eslintrc.yml

+143
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
parser: '@typescript-eslint/parser'
2+
env:
3+
browser: true
4+
node: true
5+
es6: true
6+
settings:
7+
react:
8+
version: '16.0'
9+
plugins:
10+
- "react-hooks"
11+
- "jest"
12+
- "jest-dom"
13+
- "testing-library"
14+
extends:
15+
- 'plugin:@typescript-eslint/recommended'
16+
- 'prettier'
17+
- 'plugin:react/recommended'
18+
- 'plugin:jest/recommended'
19+
- 'plugin:jest-dom/recommended'
20+
- 'plugin:testing-library/react'
21+
parserOptions:
22+
ecmaVersion: 7
23+
sourceType: module
24+
globals:
25+
beforeAll: true
26+
describe: true
27+
expect: true
28+
global: true
29+
insights: true
30+
it: true
31+
mount: true
32+
process: true
33+
render: true
34+
shallow: true
35+
React: true
36+
rules: # Todo: Remove javascript rules that are duplicated on typescript
37+
'@typescript-eslint/explicit-function-return-type':
38+
- off
39+
'@typescript-eslint/no-explicit-any':
40+
- off
41+
'@typescript-eslint/no-unused-vars':
42+
- error
43+
- argsIgnorePattern: "^_"
44+
ignoreRestSiblings: true
45+
'@typescript-eslint/camelcase':
46+
- error
47+
- properties: never
48+
array-bracket-spacing:
49+
- error
50+
- always
51+
- objectsInArrays: false
52+
comma-dangle: 2
53+
comma-spacing:
54+
- 2
55+
- after: true
56+
comma-style: 2
57+
curly:
58+
- error
59+
- all
60+
dot-notation: 2
61+
eol-last: 2
62+
eqeqeq: 2
63+
func-names:
64+
- error
65+
- never
66+
indent:
67+
- error
68+
- 4
69+
- SwitchCase: 1
70+
MemberExpression: 0
71+
ImportDeclaration: 1
72+
ObjectExpression: 1
73+
react/jsx-curly-spacing:
74+
- error
75+
- always
76+
- allowMultiline: false
77+
- spacing:
78+
- objectLiterals:
79+
- never
80+
react/prop-types: off
81+
react-hooks/rules-of-hooks: error
82+
react-hooks/exhaustive-deps: error
83+
key-spacing: 2
84+
keyword-spacing: 2
85+
linebreak-style:
86+
- error
87+
- unix
88+
max-len:
89+
- 2
90+
- 150
91+
new-cap: 2
92+
no-bitwise: 2
93+
no-caller: 2
94+
no-console: off
95+
no-mixed-spaces-and-tabs: 2
96+
no-multiple-empty-lines:
97+
- error
98+
- max: 1
99+
no-trailing-spaces: 2
100+
no-use-before-define:
101+
- error
102+
- functions: false
103+
no-undef: 2
104+
no-var: 2
105+
no-with: 2
106+
object-shorthand: 2
107+
object-curly-spacing:
108+
- error
109+
- always
110+
- objectsInObjects: false
111+
arraysInObjects: false
112+
one-var:
113+
- error
114+
- never
115+
padding-line-between-statements:
116+
- error
117+
- blankLine: always
118+
prev: block-like
119+
next: "*"
120+
quote-props:
121+
- error
122+
- as-needed
123+
quotes:
124+
- error
125+
- single
126+
- allowTemplateLiterals: true
127+
semi:
128+
- error
129+
- always
130+
no-extra-semi:
131+
- error
132+
space-before-blocks: 2
133+
space-in-parens: 2
134+
space-infix-ops: 2
135+
space-unary-ops:
136+
- error
137+
- words: false
138+
nonwords: false
139+
vars-on-top: 2
140+
wrap-iife: 2
141+
yoda:
142+
- error
143+
- never

.github/scripts/commands.sh

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/bash
2+
3+
TARGET="${TARGET:-dist/index.html}"
4+
5+
function ensure_beta {
6+
sed -i 's/src=\"\/apps/src=\"\/beta\/apps/g' "${TARGET}"
7+
}
8+
9+
function ensure_stable {
10+
sed -i 's/src=\"\/beta\/apps/src=\"\/apps/g' "${TARGET}"
11+
}
+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#!/bin/env bash
2+
3+
TARGET_BRANCH="${TARGET_BRANCH:-master}"
4+
TARGET_PATH="${TARGET_PATH:-openapi.json}"
5+
TOKEN="${TOKEN:-$ACTIONS_RUNTIME_TOKEN}"
6+
7+
CURL="${CURL_COMMAND:-curl --silent}"
8+
9+
function definedOrExit {
10+
if [[ -z "$1" ]]; then
11+
echo "$2"
12+
cat "$3"
13+
exit 1
14+
fi
15+
}
16+
17+
echo "Using curl as \"${CURL}\""
18+
19+
function call_curl {
20+
${CURL} -H "Authorization: Bearer ${TOKEN}" "$@"
21+
}
22+
23+
JOBS_URL="https://api.github.com/repos/RedHatInsights/notifications-ui-backend/actions/workflows/main.yml/runs?status=success&branch=${TARGET_BRANCH}&event=push"
24+
25+
echo "Getting artifacts_url from ${JOBS_URL}"
26+
call_curl "${JOBS_URL}" > .returned
27+
ARTIFACTS_URL=$(jq --raw-output '.workflow_runs[0].artifacts_url | if . == null then "" else . end' < .returned)
28+
definedOrExit "${ARTIFACTS_URL}" "Unable to get artifacts_url" .returned
29+
30+
echo "Getting archive download url from ${ARTIFACTS_URL}"
31+
call_curl "${ARTIFACTS_URL}" > .returned
32+
ARCHIVE_DOWNLOAD_URL=$(jq --raw-output '.artifacts[0].archive_download_url | if . == null then "" else . end' < .returned)
33+
definedOrExit "${ARCHIVE_DOWNLOAD_URL}" "Unable to get archive_download_url" .returned
34+
35+
call_curl -i "${ARCHIVE_DOWNLOAD_URL}" > .returned
36+
echo "Getting download url from ${ARCHIVE_DOWNLOAD_URL}"
37+
DOWNLOAD_URL=$(grep -oP 'Location: \K.+' < .returned)
38+
definedOrExit "${DOWNLOAD_URL}" "Unable to get Location header with download url" .returned
39+
DOWNLOAD_URL=${DOWNLOAD_URL%$'\r'}
40+
rm -f .returned
41+
42+
echo "Downloading artifact package from ${DOWNLOAD_URL}"
43+
call_curl "${DOWNLOAD_URL}" > openapi.json.zip
44+
mkdir -p .tmp
45+
unzip openapi.json.zip openapi.json -d .tmp
46+
mv .tmp/openapi.json "${TARGET_PATH}"
47+
rm -rf .tmp
48+
rm openapi.json.zip

.github/workflows/OpenAPIInSync.yml

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: openapi.json in sync
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
build:
7+
runs-on: ubuntu-latest
8+
9+
steps:
10+
- uses: actions/checkout@v2
11+
- name: Get yarn cache directory path
12+
id: yarn-cache-dir-path
13+
run: echo "::set-output name=dir::$(yarn cache dir)"
14+
- uses: actions/cache@v1
15+
id: yarn-cache
16+
with:
17+
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
18+
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
19+
restore-keys: |
20+
${{ runner.os }}-yarn-
21+
- name: Install
22+
run: yarn install
23+
- name: Download openapi.json from RedHatInsights/notifications-backend-ui@master into ./utils/openapi-generator/openapi.json
24+
run: ACTIONS_RUNTIME_TOKEN=${{ secrets.GITHUB_TOKEN }} TARGET_BRANCH=master TARGET_PATH=./utils/openapi-generator/openapi.json bash .github/scripts/download-latest-openapi.sh
25+
- name: Generate types from openapi.json
26+
run: yarn schema:generate && yarn schema:clean
27+
- name: Check differences
28+
run: >
29+
[[ -z $(git status --porcelain) ]] ||
30+
(
31+
echo "openapi.json types are out of sync, see https://github.com/RedHatInsights/notifications-ui-frontend#generating-types-from-openapi-file" &&
32+
git status &&
33+
git diff &&
34+
false
35+
)

.gitignore

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# See https://help.github.com/ignore-files/ for more about ignoring files.
2+
3+
# vscode config
4+
.vscode/
5+
6+
# ide config
7+
.idea/
8+
9+
# dependencies
10+
node_modules
11+
12+
# production
13+
dist
14+
15+
# openapi-generator
16+
utils/openapi-generator/output
17+
utils/openapi-generator/openapi.json
18+
19+
npm-debug.log*
20+
yarn-debug.log*
21+
yarn-error.log*
22+
23+
.DS_Store
24+
coverage
25+
26+
.yalc
27+
yalc.lock

.scripts/schema/generate.sh

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/usr/bin/env bash
2+
3+
OPENAPI_JSON_PATH=${OPENAPI_JSON_PATH:-./utils/openapi-generator/openapi.json}
4+
5+
OUTPUT_PATH="./src/generated"
6+
OPENAPI_NORMALIZED_PATH="${OUTPUT_PATH}/openapi.json"
7+
SCHEMAS="./utils/openapi-generator/schemas/"
8+
9+
jq -S -c '.' "${OPENAPI_JSON_PATH}" > "${OPENAPI_NORMALIZED_PATH}"
10+
op3-codegen "${OPENAPI_NORMALIZED_PATH}" -o "${OUTPUT_PATH}" -t "${SCHEMAS}" --generateEnums
11+
rm "${OPENAPI_NORMALIZED_PATH}"
12+
eslint --fix "${OUTPUT_PATH}/**/*.ts"

.stylelintrc.json

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"extends": "stylelint-config-recommended-scss"
3+
}

.travis.yml

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
language: node_js
2+
sudo: required
3+
node_js:
4+
- '10'
5+
cache:
6+
yarn: true
7+
directories:
8+
- node_modules
9+
install: yarn --frozen-lockfile --non-interactive || (echo 'package.json is not in sync with yarn.lock, check that you include yarn.lock' && false)
10+
script:
11+
- ./.travis/schema-check.sh && yarn travis && curl -sSL https://raw.githubusercontent.com/RedHatInsights/insights-frontend-builder-common/master/src/bootstrap.sh | bash -s
12+
after_success:
13+
- bash <(curl -s https://codecov.io/bash)
14+
env:
15+
global:
16+
- REPO="[email protected]:RedHatInsights/notifications-ui-frontend-build"
17+
- REPO_DIR="notifications-ui-frontend-build"
18+
- BRANCH=${TRAVIS_PULL_REQUEST_BRANCH:-$TRAVIS_BRANCH}
19+
- NODE_OPTIONS="--max-old-space-size=4096 --max_old_space_size=4096"

.travis/custom_release.sh

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#!/bin/bash
2+
set -e
3+
set -x
4+
5+
source ./.github/scripts/commands.sh
6+
7+
if [ "${TRAVIS_BRANCH}" = "master" ]
8+
then
9+
ensure_beta
10+
for env in ci qa
11+
do
12+
echo "PUSHING ${env}-beta"
13+
rm -rf ./dist/.git
14+
.travis/release.sh "${env}-beta"
15+
done
16+
fi
17+
18+
19+
if [ "${TRAVIS_BRANCH}" = "master" ]
20+
then
21+
ensure_stable
22+
for env in ci qa
23+
do
24+
echo "PUSHING ${env}-stable"
25+
rm -rf ./dist/.git
26+
.travis/release.sh "${env}-stable"
27+
done
28+
fi
29+
30+
if [ "${TRAVIS_BRANCH}" = "prod" ]
31+
then
32+
ensure_beta
33+
echo "PUSHING prod-beta"
34+
rm -rf ./dist/.git
35+
.travis/release.sh "prod-beta"
36+
37+
ensure_stable
38+
echo "PUSHING prod-stable"
39+
rm -rf ./dist/.git
40+
.travis/release.sh "prod-stable"
41+
fi

.travis/deploy_key.enc

3.31 KB
Binary file not shown.

.travis/schema-check.sh

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/bin/bash
2+
3+
if [ "${TRAVIS_BRANCH}" = "prod" ]
4+
then
5+
curl https://cloud.redhat.com/api/notifications/v1.0/openapi.json -o ./utils/openapi-generator/openapi.json
6+
yarn schema:generate && yarn schema:clean
7+
[[ -z $(git status --porcelain) ]] ||
8+
(
9+
git status &&
10+
git diff &&
11+
echo "----------------------------------------------------------------" &&
12+
echo " openapi.json types or actions are out of sync aborting build. " &&
13+
echo "----------------------------------------------------------------" &&
14+
false
15+
)
16+
fi

0 commit comments

Comments
 (0)