Skip to content

Commit e82d994

Browse files
authored
Merge pull request #64 from data-for-change/63-implement-use-authentication-with-google-service
63 implement use authentication with google service
2 parents dd31c9d + 3a2354e commit e82d994

File tree

19 files changed

+1180
-928
lines changed

19 files changed

+1180
-928
lines changed

.github/workflows/deploy.yml

Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,31 @@
11
name: Deploy
22
on:
3-
workflow_dispatch:
4-
5-
push:
6-
branches:
7-
- main
3+
workflow_dispatch:
4+
5+
push:
6+
branches:
7+
- main
88

99
jobs:
10-
Build-safety-data-client:
11-
if: github.repository == "${{ github.repository_owner }}/safety-data-client"
12-
runs-on: ubuntu-latest
13-
steps:
14-
- name: Login to GitHub Container Registry
15-
uses: docker/login-action@v3
16-
with:
17-
registry: ghcr.io
18-
username: ${{ github.repository_owner }}
19-
password: ${{ secrets.GITHUB_TOKEN }}
10+
Build-safety-data-client:
11+
if: github.repository == "${{ github.repository_owner }}/safety-data-client"
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Login to GitHub Container Registry
15+
uses: docker/login-action@v3
16+
with:
17+
registry: ghcr.io
18+
username: ${{ github.repository_owner }}
19+
password: ${{ secrets.GITHUB_TOKEN }}
2020

21-
- name: Build and push safety-data-client Docker image
22-
uses: docker/build-push-action@v6
23-
with:
24-
file: Dockerfile.prod
25-
push: true
26-
tags: ghcr.io/${{ github.repository_owner }}/safety-data-client:latest
27-
build-args: |
28-
REACT_APP_API_URL=${{ secrets.REACT_APP_API_URL }}
29-
VITE_API_URL=${{ secrets.VITE_API_URL }}
30-
VITE_API_URL2=${{ secrets.VITE_API_URL2 }}
21+
- name: Build and push safety-data-client Docker image
22+
uses: docker/build-push-action@v6
23+
with:
24+
file: Dockerfile.prod
25+
push: true
26+
tags: ghcr.io/${{ github.repository_owner }}/safety-data-client:latest
27+
build-args: |
28+
REACT_APP_API_URL=${{ secrets.REACT_APP_API_URL }}
29+
VITE_API_URL=${{ secrets.VITE_API_URL }}
30+
VITE_API_ANYWAY_URL=${{ secrets.VITE_API_ANYWAY_URL }}
31+
VITE_API_SAFETY_DATA_URL=${{ secrets.VITE_API_SAFETY_DATA_URL }}

.github/workflows/deploy_app.yml

Lines changed: 51 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,55 @@
11
name: deploy_app
22
on:
3-
push:
4-
branches:
5-
- dev
3+
push:
4+
branches:
5+
- dev
66

77
jobs:
8-
Build-safety-data-client:
9-
if: github.repository == "${{ github.repository_owner }}/safety-data-client"
10-
runs-on: ubuntu-latest
11-
steps:
12-
- name: Login to GitHub Container Registry
13-
uses: docker/login-action@v3
14-
with:
15-
registry: ghcr.io
16-
username: ${{ github.repository_owner }}
17-
password: ${{ secrets.GITHUB_TOKEN }}
18-
- name: Get Short SHA
19-
run: echo "SHORT_SHA=${GITHUB_SHA::7}" >> $GITHUB_ENV
20-
- name: Build and push safety-data-client Docker image
21-
uses: docker/build-push-action@v6
22-
with:
23-
file: Dockerfile.prod
24-
push: true
25-
tags: |
26-
ghcr.io/${{ github.repository_owner }}/safety-data-client:latest
27-
ghcr.io/${{ github.repository_owner }}/safety-data-client:sha-${{ env.SHORT_SHA }}
28-
build-args: |
29-
REACT_APP_API_URL=${{ secrets.REACT_APP_API_URL }}
30-
VITE_API_URL=${{ secrets.VITE_API_URL }}
31-
VITE_API_URL2=${{ secrets.VITE_API_URL2 }}
32-
deploy:
33-
needs: Build-safety-data-client
34-
runs-on: ubuntu-latest
35-
steps:
36-
- uses: actions/checkout@v3
37-
- env:
38-
SAFETY_DATA_CLIENT_IMAGE_NAME: ghcr.io/data-for-change/safety-data-client
39-
DFC_IAC_DEPLOY_KEY: ${{ secrets.DFC_IAC_DEPLOY_KEY }}
40-
run: |
41-
SHA_TAG=sha-`git rev-parse --short $GITHUB_SHA` &&\
42-
echo SHA_TAG=$SHA_TAG &&\
43-
cd `mktemp -d` &&\
44-
echo "${DFC_IAC_DEPLOY_KEY}" > dfc_iac_deploy_key &&\
45-
chmod 400 dfc_iac_deploy_key &&\
46-
export GIT_SSH_COMMAND="ssh -i `pwd`/dfc_iac_deploy_key -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no" &&\
47-
git clone git@github.com:data-for-change/dfc-iac.git &&\
48-
cd dfc-iac &&\
49-
SAFETY_DATA_CLIENT_IMAGE="${SAFETY_DATA_CLIENT_IMAGE_NAME}:${SHA_TAG}" &&\
50-
bin/update_anyway_env.py '{"safetyDataClientImage":"'${SAFETY_DATA_CLIENT_IMAGE}'"}' &&\
51-
git config --global user.name "Anyway CI" &&\
52-
git config --global user.email "anyway-ci@localhost" &&\
53-
git add apps/anyway/.env && git commit -m "automatic update of anyway (safety data)" &&\
54-
git push origin main
8+
Build-safety-data-client:
9+
if: github.repository == "${{ github.repository_owner }}/safety-data-client"
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Login to GitHub Container Registry
13+
uses: docker/login-action@v3
14+
with:
15+
registry: ghcr.io
16+
username: ${{ github.repository_owner }}
17+
password: ${{ secrets.GITHUB_TOKEN }}
18+
- name: Get Short SHA
19+
run: echo "SHORT_SHA=${GITHUB_SHA::7}" >> $GITHUB_ENV
20+
- name: Build and push safety-data-client Docker image
21+
uses: docker/build-push-action@v6
22+
with:
23+
file: Dockerfile.prod
24+
push: true
25+
tags: |
26+
ghcr.io/${{ github.repository_owner }}/safety-data-client:latest
27+
ghcr.io/${{ github.repository_owner }}/safety-data-client:sha-${{ env.SHORT_SHA }}
28+
build-args: |
29+
REACT_APP_API_URL=${{ secrets.REACT_APP_API_URL }}
30+
VITE_API_URL=${{ secrets.VITE_API_URL }}
31+
VITE_API_ANYWAY_URL=${{ secrets.VITE_API_ANYWAY_URL }}
32+
VITE_API_SAFETY_DATA_URL=${{ secrets.VITE_API_SAFETY_DATA_URL }}
33+
deploy:
34+
needs: Build-safety-data-client
35+
runs-on: ubuntu-latest
36+
steps:
37+
- uses: actions/checkout@v3
38+
- env:
39+
SAFETY_DATA_CLIENT_IMAGE_NAME: ghcr.io/data-for-change/safety-data-client
40+
DFC_IAC_DEPLOY_KEY: ${{ secrets.DFC_IAC_DEPLOY_KEY }}
41+
run: |
42+
SHA_TAG=sha-`git rev-parse --short $GITHUB_SHA` &&\
43+
echo SHA_TAG=$SHA_TAG &&\
44+
cd `mktemp -d` &&\
45+
echo "${DFC_IAC_DEPLOY_KEY}" > dfc_iac_deploy_key &&\
46+
chmod 400 dfc_iac_deploy_key &&\
47+
export GIT_SSH_COMMAND="ssh -i `pwd`/dfc_iac_deploy_key -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no" &&\
48+
git clone git@github.com:data-for-change/dfc-iac.git &&\
49+
cd dfc-iac &&\
50+
SAFETY_DATA_CLIENT_IMAGE="${SAFETY_DATA_CLIENT_IMAGE_NAME}:${SHA_TAG}" &&\
51+
bin/update_anyway_env.py '{"safetyDataClientImage":"'${SAFETY_DATA_CLIENT_IMAGE}'"}' &&\
52+
git config --global user.name "Anyway CI" &&\
53+
git config --global user.email "anyway-ci@localhost" &&\
54+
git add apps/anyway/.env && git commit -m "automatic update of anyway (safety data)" &&\
55+
git push origin main

Dockerfile.prod

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@ COPY package*.json ./
55
RUN npm install
66
COPY . .
77
ARG VITE_API_URL
8-
ARG VITE_API_URL2
8+
ARG VITE_API_ANYWAY_URL
9+
ARG VITE_API_SAFETY_DATA_URL
910
ENV VITE_API_URL=${VITE_API_URL}
10-
ENV VITE_API_URL2=${VITE_API_URL2}
11+
ENV VITE_API_ANYWAY_URL=${VITE_API_ANYWAY_URL}
12+
ENV VITE_API_SAFETY_DATA_URL=${VITE_API_SAFETY_DATA_URL}
1113
RUN npm run build
1214

1315
#copy static pages to nginx and serve them

configs/Main/.env.Base

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
VITE_API_URL=http://localhost:5000
2-
VITE_API_URL2=https://www.anyway.co.il
2+
VITE_API_ANYWAY_URL=https://www.anyway.co.il
3+
VITE_API_SAFETY_DATA_URL=https://www.safety-data.anyway.co.il

package-lock.json

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"version": "0.2.0",
44
"private": true,
55
"dependencies": {
6+
"@react-oauth/google": "^0.13.4",
67
"@reduxjs/toolkit": "^2.6.1",
78
"@svgr/webpack": "^8.1.0",
89
"@tanstack/react-table": "^8.20.5",

public/close-popup.html

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<title>Logging in...</title>
5+
</head>
6+
<body>
7+
<script>
8+
// This page is reached after the backend redirect cycle (/sd-callback/google -> redirect_url)
9+
// It simply closes the popup window. The main window will detect it's closed and refresh.
10+
window.close();
11+
</script>
12+
</body>
13+
</html>
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
import React from 'react';
2+
import { Button } from 'react-bootstrap';
3+
import { useTranslation } from 'react-i18next';
4+
import { useStore } from '../../stores/storeConfig';
5+
import { observer } from 'mobx-react';
6+
import { Loader } from '../common';
7+
8+
const EnvelopeIcon = ({ color = 'white', size = 20 }: { color?: string; size?: number }) => (
9+
<svg
10+
width={size}
11+
height={size}
12+
viewBox='0 0 24 24'
13+
fill='none'
14+
xmlns='http://www.w3.org/2000/svg'
15+
style={{ marginLeft: '10px', verticalAlign: 'middle' }}
16+
>
17+
<path
18+
d='M4 4H20C21.1 4 22 4.9 22 6V18C22 19.1 21.1 20 20 20H4C2.9 20 2 19.1 2 18V6C2 4.9 2.9 4 4 4Z'
19+
stroke={color}
20+
strokeWidth='2'
21+
strokeLinecap='round'
22+
strokeLinejoin='round'
23+
/>
24+
<path d='M22 6L12 13L2 6' stroke={color} strokeWidth='2' strokeLinecap='round' strokeLinejoin='round' />
25+
</svg>
26+
);
27+
28+
const RiskHotspotModel = observer(() => {
29+
const { t } = useTranslation();
30+
const { userStore } = useStore();
31+
32+
if (userStore.isLoading) {
33+
return <Loader />;
34+
}
35+
36+
const hasPermission = userStore.isAuthenticated && userStore.hasEditPermission;
37+
38+
if (hasPermission) {
39+
return (
40+
<div>
41+
<h1>{t('RiskModel')}</h1>
42+
</div>
43+
);
44+
}
45+
46+
return (
47+
<div className='d-flex flex-column align-items-center justify-content-center' style={{ minHeight: '400px', gap: '20px' }}>
48+
<Button
49+
variant='success'
50+
className='rounded-3 px-5 py-3 shadow-sm'
51+
style={{
52+
backgroundColor: '#00FF00',
53+
border: 'none',
54+
color: 'black',
55+
fontWeight: '500',
56+
fontSize: '1.2rem',
57+
width: '320px',
58+
borderRadius: '15px',
59+
}}
60+
onClick={() => userStore.login()}
61+
>
62+
{t('LoginOrSwitchUser')}
63+
</Button>
64+
<Button
65+
variant='dark'
66+
className='rounded-3 px-5 py-3 d-flex align-items-center justify-content-center shadow-sm'
67+
style={{
68+
backgroundColor: '#4E6A5C',
69+
border: 'none',
70+
fontSize: '1.2rem',
71+
width: '320px',
72+
borderRadius: '15px',
73+
}}
74+
href='mailto:gal@natoon.co.il'
75+
>
76+
<EnvelopeIcon />
77+
{t('ContactForMoreDetails')}
78+
</Button>
79+
</div>
80+
);
81+
});
82+
83+
export default RiskHotspotModel;

0 commit comments

Comments
 (0)