Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tab title will update according to the automation page #653

Merged
merged 4 commits into from
Oct 29, 2020
Merged
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
REACT_APP_API_PREFIX=""
SENTRY_DSN=""
REACT_APP_GLIFIC_API_PORT=4000
REACT_APP_APPLICATION_NAME="Glific: Two way communication platform"
2 changes: 1 addition & 1 deletion public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>Glific: Two way communication platform</title>
<title>%REACT_APP_APPLICATION_NAME%</title>
</head>

<body>
Expand Down
11 changes: 10 additions & 1 deletion src/components/floweditor/FlowEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import styles from './FlowEditor.module.css';
import { ReactComponent as HelpIcon } from '../../assets/images/icons/Help.svg';
import { Button } from '../UI/Form/Button/Button';
import { PUBLISH_AUTOMATION } from '../../graphql/mutations/Automation';
import { FLOW_EDITOR_CONFIGURE_LINK } from '../../config/index';
import { APP_NAME, FLOW_EDITOR_CONFIGURE_LINK } from '../../config/index';
import { FLOW_EDITOR_API } from '../../config/index';
import * as Manifest from '@nyaruka/flow-editor/build/asset-manifest.json';
import { GET_AUTOMATION_NAME } from '../../graphql/queries/Automation';
Expand Down Expand Up @@ -155,6 +155,15 @@ export const FlowEditor = (props: FlowEditorProps) => {
},
});

useEffect(() => {
if (automationName) {
document.title = automationName.flows[0].name;
}
return () => {
document.title = APP_NAME;
};
}, [automationName]);

useEffect(() => {
const files = loadfiles();
return () => {
Expand Down
5 changes: 5 additions & 0 deletions src/config/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
const envVariables = process.env;

let appName = envVariables.REACT_APP_APPLICATION_NAME;

const API_PORT = envVariables.REACT_APP_GLIFIC_API_PORT;
const PROTOCOL = window.location.protocol;
const API_PREFIX = envVariables.REACT_APP_API_PREFIX;
Expand All @@ -26,3 +28,6 @@ export const RESET_PASSWORD = GLIFIC_API_URL + '/v1/registration/reset-password'
export const RENEW_TOKEN = USER_SESSION + '/renew';
export const FLOW_EDITOR_CONFIGURE_LINK = `${PROTOCOL}//${window.location.host}/automation/configure`;
export const GUPSHUP_CALLBACK_URL = GLIFIC_BACKEND_URL + '/gupshup';
export const APP_NAME = appName ? appName : 'Glific: Two way communication platform';