Skip to content

Commit

Permalink
Merge pull request #106 from factly/custom-title-logo
Browse files Browse the repository at this point in the history
ability to customise logo and title
  • Loading branch information
shreeharsha-factly authored Dec 1, 2021
2 parents 565dbf3 + 1e6798e commit f98c4cd
Show file tree
Hide file tree
Showing 11 changed files with 42 additions and 36 deletions.
6 changes: 5 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,10 @@ services:
- REACT_APP_DEGA_PUBLIC_URL=http://127.0.0.1:4455/.factly/dega/studio
- REACT_APP_BINDU_PUBLIC_URL=http://127.0.0.1:4455/.factly/bindu/studio
- REACT_APP_KAVACH_TITLE=Kavach
- REACT_APP_COMPANION_URL=http://127.0.0.1:3020
- REACT_APP_API_URL=http://127.0.0.1:4455/.factly/kavach/server
- REACT_APP_KRATOS_PUBLIC_URL=http://127.0.0.1:4455/.ory/kratos/public

volumes:
- type: bind
source: ./web
Expand All @@ -247,4 +251,4 @@ services:
- kavach

networks:
kavach:
kavach:
Binary file removed web/src/assets/factly-logo.png
Binary file not shown.
14 changes: 8 additions & 6 deletions web/src/components/Auth/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ import { Link } from 'react-router-dom';
import { Input, Form, Button, Card, Row, Col, Alert } from 'antd';
import { UserOutlined, LockOutlined } from '@ant-design/icons';
import OIDC from './oidc';
import kavach_logo from '../../assets/kavach_icon.png'

function Auth(props) {
const [ui, setUI] = React.useState({});
const [errorMsg, setErrorMsg] = React.useState('');
const title = (process.env.REACT_APP_KAVACH_TITLE==undefined) ? "Kavach": process.env.REACT_APP_KAVACH_TITLE
const title = process.env.REACT_APP_KAVACH_TITLE || "Kavach"
const logo = process.env.REACT_APP_LOGO_URL || kavach_logo
React.useEffect(() => {
var obj = {};

Expand All @@ -22,18 +24,18 @@ function Auth(props) {

const returnTo = obj['return_to'];
const selfServiceURL = returnTo
? window.REACT_APP_KRATOS_PUBLIC_URL +
? process.env.REACT_APP_KRATOS_PUBLIC_URL +
'/self-service/' +
props.flow +
'/browser?return_to=' +
returnTo
: window.REACT_APP_KRATOS_PUBLIC_URL + '/self-service/' + props.flow + '/browser';
: process.env.REACT_APP_KRATOS_PUBLIC_URL + '/self-service/' + props.flow + '/browser';

if (!obj['flow']) {
window.location.href = selfServiceURL;
}
fetch(
window.REACT_APP_KRATOS_PUBLIC_URL +
process.env.REACT_APP_KRATOS_PUBLIC_URL +
'/self-service/' +
props.flow +
'/flows' +
Expand All @@ -60,7 +62,7 @@ function Auth(props) {
setUI(res.ui);
})
.catch((err) => {
console.log(err);
window.location.href = selfServiceURL;
});
}, [props.flow]);

Expand Down Expand Up @@ -102,7 +104,7 @@ function Auth(props) {
<div className="auth">
<Row className="header">
<Col span={6}>
<img alt="logo" className="logo" src={(title==="Kavach") ? require('../../assets/kavach_icon.png'): require('../../assets/factly-logo.png')} />
<img alt="logo" className="logo" src={logo} />
</Col>
<Col span={18}>
<span className="title">{title}</span>
Expand Down
20 changes: 10 additions & 10 deletions web/src/components/Auth/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ describe('Auth component', () => {
setTimeout(() => {
expect(fetch.mock.calls).toEqual([
[
window.REACT_APP_KRATOS_PUBLIC_URL +
process.env.REACT_APP_KRATOS_PUBLIC_URL +
'/self-service/login/flows?id=' +
'8060d57f-5c69-402f-9ecd-073e283f632a',
{
Expand Down Expand Up @@ -225,7 +225,7 @@ describe('Auth component', () => {
setTimeout(() => {
expect(fetch.mock.calls).toEqual([
[
window.REACT_APP_KRATOS_PUBLIC_URL +
process.env.REACT_APP_KRATOS_PUBLIC_URL +
'/self-service/login/flows?id=' +
'8060d57f-5c69-402f-9ecd-073e283f632a',
{
Expand Down Expand Up @@ -335,7 +335,7 @@ describe('Auth component', () => {
setTimeout(() => {
expect(fetch.mock.calls).toEqual([
[
window.REACT_APP_KRATOS_PUBLIC_URL +
process.env.REACT_APP_KRATOS_PUBLIC_URL +
'/self-service/login/flows?id=' +
'8060d57f-5c69-402f-9ecd-073e283f632a',
{
Expand Down Expand Up @@ -374,7 +374,7 @@ describe('Auth component', () => {
setTimeout(() => {
expect(fetch.mock.calls).toEqual([
[
window.REACT_APP_KRATOS_PUBLIC_URL +
process.env.REACT_APP_KRATOS_PUBLIC_URL +
'/self-service/login/flows?id=' +
'8060d57f-5c69-402f-9ecd-073e283f632a',
{
Expand All @@ -383,7 +383,7 @@ describe('Auth component', () => {
],
]);
expect(window.location.href).toBe(
window.REACT_APP_KRATOS_PUBLIC_URL + '/self-service/login/browser',
process.env.REACT_APP_KRATOS_PUBLIC_URL + '/self-service/login/browser',
);
done();
}, 0);
Expand All @@ -410,22 +410,22 @@ describe('Auth component', () => {
setTimeout(() => {
expect(fetch.mock.calls).toEqual([
[
window.REACT_APP_KRATOS_PUBLIC_URL +
process.env.REACT_APP_KRATOS_PUBLIC_URL +
'/self-service/login/flows?id=' +
'8060d57f-5c69-402f-9ecd-073e283f632a',
{
credentials: 'include',
},
],
[
window.REACT_APP_KRATOS_PUBLIC_URL + '/self-service/login/flows?id=' + undefined,
process.env.REACT_APP_KRATOS_PUBLIC_URL + '/self-service/login/flows?id=' + undefined,
{
credentials: 'include',
},
],
]);
expect(window.location.href).toBe(
window.REACT_APP_KRATOS_PUBLIC_URL + '/self-service/login/browser?return_to=return',
process.env.REACT_APP_KRATOS_PUBLIC_URL + '/self-service/login/browser?return_to=return',
);
done();
}, 0);
Expand Down Expand Up @@ -524,7 +524,7 @@ describe('Auth component', () => {
setTimeout(() => {
expect(fetch.mock.calls).toEqual([
[
window.REACT_APP_KRATOS_PUBLIC_URL +
process.env.REACT_APP_KRATOS_PUBLIC_URL +
'/self-service/registration/flows?id=' +
'8060d57f-5c69-402f-9ecd-073e283f632a',
{
Expand Down Expand Up @@ -629,7 +629,7 @@ describe('Auth component', () => {
setTimeout(() => {
expect(fetch.mock.calls).toEqual([
[
window.REACT_APP_KRATOS_PUBLIC_URL +
process.env.REACT_APP_KRATOS_PUBLIC_URL +
'/self-service/registration/flows?id=' +
'8060d57f-5c69-402f-9ecd-073e283f632a',
{
Expand Down
2 changes: 1 addition & 1 deletion web/src/components/GlobalNav/AccountMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const AccountMenu = () => {
}, [dispatch]);

const handleLogout = () => {
fetch(window.REACT_APP_KRATOS_PUBLIC_URL + '/self-service/logout/browser', {
fetch(process.env.REACT_APP_KRATOS_PUBLIC_URL + '/self-service/logout/browser', {
credentials: 'include',
})
.then((res) => {
Expand Down
2 changes: 1 addition & 1 deletion web/src/components/MediaSelector/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ describe('MediaSelector component', () => {
});
it('should handle Tab change and unselect image', () => {
const onChange = jest.fn();
window.REACT_APP_COMPANION_URL = 'http://127.0.0.1:3020';
process.env.REACT_APP_COMPANION_URL = 'http://127.0.0.1:3020';
act(() => {
wrapper = mount(
<Provider store={store}>
Expand Down
8 changes: 4 additions & 4 deletions web/src/components/Uppy/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ function UppyUploader({ onUpload }) {
return updatedFiles;
},
})
.use(AwsS3, { companionUrl: window.REACT_APP_COMPANION_URL })
.use(Url, { companionUrl: window.REACT_APP_COMPANION_URL })
.use(GoogleDrive, { companionUrl: window.REACT_APP_COMPANION_URL })
.use(AwsS3, { companionUrl: process.env.REACT_APP_COMPANION_URL })
.use(Url, { companionUrl: process.env.REACT_APP_COMPANION_URL })
.use(GoogleDrive, { companionUrl: process.env.REACT_APP_COMPANION_URL })
.use(ImageEditor, {
id: 'ImageEditor',

Expand All @@ -63,7 +63,7 @@ function UppyUploader({ onUpload }) {
autoCropArea: 1,
responsive: true,
},
companionUrl: window.REACT_APP_COMPANION_URL,
companionUrl: process.env.REACT_APP_COMPANION_URL,
});

uppy.on('complete', (result) => {
Expand Down
2 changes: 1 addition & 1 deletion web/src/pages/error/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ function KratosError() {
obj[temp[0]] = temp[1];
});

fetch(window.REACT_APP_KRATOS_PUBLIC_URL + '/self-service/errors?error=' + obj['error'])
fetch(process.env.REACT_APP_KRATOS_PUBLIC_URL + '/self-service/errors?error=' + obj['error'])
.then((res) => {
if (res.status === 200) {
return res.json();
Expand Down
6 changes: 3 additions & 3 deletions web/src/pages/password/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ function Password() {
});

if (!obj['flow']) {
window.location.href = window.REACT_APP_KRATOS_PUBLIC_URL + '/self-service/settings/browser';
window.location.href = process.env.REACT_APP_KRATOS_PUBLIC_URL + '/self-service/settings/browser';
}

fetch(window.REACT_APP_KRATOS_PUBLIC_URL + '/self-service/settings/flows?id=' + obj['flow'], {
fetch(process.env.REACT_APP_KRATOS_PUBLIC_URL + '/self-service/settings/flows?id=' + obj['flow'], {
credentials: 'include',
})
.then((res) => {
Expand All @@ -40,7 +40,7 @@ function Password() {
}
})
.catch((err) => {
window.location.href = window.REACT_APP_KRATOS_PUBLIC_URL + '/self-service/settings/browser';
window.location.href = process.env.REACT_APP_KRATOS_PUBLIC_URL + '/self-service/settings/browser';
});
}, []);

Expand Down
16 changes: 8 additions & 8 deletions web/src/pages/password/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ describe('password component', () => {
setTimeout(() => {
expect(fetch.mock.calls).toEqual([
[
window.REACT_APP_KRATOS_PUBLIC_URL +
process.env.REACT_APP_KRATOS_PUBLIC_URL +
'/self-service/settings/flows?id=' +
'8060d57f-5c69-402f-9ecd-073e283f632a',
],
Expand Down Expand Up @@ -113,13 +113,13 @@ describe('password component', () => {
setTimeout(() => {
expect(fetch.mock.calls).toEqual([
[
window.REACT_APP_KRATOS_PUBLIC_URL +
process.env.REACT_APP_KRATOS_PUBLIC_URL +
'/self-service/settings/flows?id=' +
'8060d57f-5c69-402f-9ecd-073e283f632a',
],
]);
expect(window.location.href).toBe(
window.REACT_APP_KRATOS_PUBLIC_URL + '/self-service/settings/browser',
process.env.REACT_APP_KRATOS_PUBLIC_URL + '/self-service/settings/browser',
);
done();
}, 0);
Expand All @@ -139,14 +139,14 @@ describe('password component', () => {
setTimeout(() => {
expect(fetch.mock.calls).toEqual([
[
window.REACT_APP_KRATOS_PUBLIC_URL +
process.env.REACT_APP_KRATOS_PUBLIC_URL +
'/self-service/settings/flows?id=' +
'8060d57f-5c69-402f-9ecd-073e283f632a',
],
[window.REACT_APP_KRATOS_PUBLIC_URL + '/self-service/settings/flows?id=' + undefined],
[process.env.REACT_APP_KRATOS_PUBLIC_URL + '/self-service/settings/flows?id=' + undefined],
]);
expect(window.location.href).toBe(
window.REACT_APP_KRATOS_PUBLIC_URL + '/self-service/settings/browser',
process.env.REACT_APP_KRATOS_PUBLIC_URL + '/self-service/settings/browser',
);
done();
}, 0);
Expand Down Expand Up @@ -227,7 +227,7 @@ describe('password component', () => {
setTimeout(() => {
expect(fetch.mock.calls).toEqual([
[
window.REACT_APP_KRATOS_PUBLIC_URL +
process.env.REACT_APP_KRATOS_PUBLIC_URL +
'/self-service/settings/flows?id=' +
'8060d57f-5c69-402f-9ecd-073e283f632a',
],
Expand Down Expand Up @@ -310,7 +310,7 @@ describe('password component', () => {
setTimeout(() => {
expect(fetch.mock.calls).toEqual([
[
window.REACT_APP_KRATOS_PUBLIC_URL +
process.env.REACT_APP_KRATOS_PUBLIC_URL +
'/self-service/settings/flows?id=' +
'8060d57f-5c69-402f-9ecd-073e283f632a',
],
Expand Down
2 changes: 1 addition & 1 deletion web/src/utils/axios.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import axios from 'axios';

function createAxiosAuthMiddleware() {
return ({ getState }) => (next) => (action) => {
axios.defaults.baseURL = window.REACT_APP_API_URL;
axios.defaults.baseURL = process.env.REACT_APP_API_URL;
axios.defaults.headers.common['X-Organisation'] = getState().organisations.selected;
axios.defaults.withCredentials = true;
return next(action);
Expand Down

0 comments on commit f98c4cd

Please sign in to comment.