Skip to content

📈 Open source, privacy-first web analytics — a cookie-less Google Analytics alternative with built-in error tracking and performance monitoring. Self-host it or use our cloud. Get started for free!

Fixed project settings page

Blaumause8636a286420
diff --git a/src/App.js b/src/App.js
index 0b63bfac0..5be593ae3 100644
--- a/src/App.js
+++ b/src/App.js
@@ -91,7 +91,6 @@ const App = () => {
<Route path={routes.reset_password} component={ProtectedForgotPassword} exact />
<Route path={routes.new_password_form} component={ProtectedNewPasswordForm} exact />
<Route path={routes.new_project} component={ProtectedNewProject} exact />
- <Route path={routes.project_settings} component={ProtectedNewProject} exact />
<Route path={routes.project} component={ProtectedViewProject} exact />
<Redirect to={routes.main} />
</Switch>
diff --git a/src/pages/Project/Create/CreateProject.container.jsx b/src/pages/Project/Create/CreateProject.container.jsx
index 3943f9cf0..507c3caeb 100644
--- a/src/pages/Project/Create/CreateProject.container.jsx
+++ b/src/pages/Project/Create/CreateProject.container.jsx
@@ -8,15 +8,13 @@ import { alertsActions } from 'actions/alerts'
import { errorsActions } from 'actions/errors'
import routes from 'routes'
-export default () => {
- const location = useLocation()
+export default ({ onCancel, project }) => {
+ const { pathname } = useLocation()
const history = useHistory()
const dispatch = useDispatch()
- const { name, id } = location.state || {}
+ const { name, id } = project || {}
const onSubmit = async (data) => {
- const { pathname } = location
-
try {
if (pathname === routes.new_project) {
await createProject(data)
@@ -54,6 +52,7 @@ export default () => {
<CreateProject
onSubmit={onSubmit}
onDelete={onDelete}
+ onCancel={onCancel}
name={name}
id={id}
/>
diff --git a/src/pages/Project/Create/CreateProject.jsx b/src/pages/Project/Create/CreateProject.jsx
index efdd69422..efcc1886a 100644
--- a/src/pages/Project/Create/CreateProject.jsx
+++ b/src/pages/Project/Create/CreateProject.jsx
@@ -7,7 +7,7 @@ import { nanoid } from 'utils/random'
import routes from 'routes'
import Modal from 'components/Modal'
-const CreateProject = ({ onSubmit, onDelete, name, id }) => {
+const CreateProject = ({ onSubmit, onDelete, onCancel, name, id }) => {
const [form, setForm] = useState({
name,
id: id || nanoid(),
@@ -97,14 +97,20 @@ const CreateProject = ({ onSubmit, onDelete, name, id }) => {
</Form.Group>
<div className="d-flex justify-content-between">
<div>
- <Link
- to={{
- pathname: id ? routes.project.replace(':id', id) : routes.dashboard,
- state: { id, name },
- }}
- className="btn btn-outline-secondary">
- Cancel
- </Link>
+ {onCancel ? (
+ <button onClick={onCancel} type="button" className="btn btn-outline-secondary">
+ Cancel
+ </button>
+ ) : (
+ <Link
+ to={{
+ pathname: id ? routes.project.replace(':id', id) : routes.dashboard,
+ state: { id, name },
+ }}
+ className="btn btn-outline-secondary">
+ Cancel
+ </Link>
+ )}
<button type="submit" className="btn btn-primary ml-2">
Save
</button>
@@ -136,12 +142,14 @@ CreateProject.propTypes = {
onDelete: PropTypes.func,
name: PropTypes.string,
id: PropTypes.string,
+ onCancel: PropTypes.oneOf([PropTypes.func, null]),
}
CreateProject.defaultProps = {
name: '',
id: '',
onDelete: () => {},
+ onCancel: null,
}
export default CreateProject
\ No newline at end of file
diff --git a/src/pages/Project/View/ViewProject.jsx b/src/pages/Project/View/ViewProject.jsx
index e3097146a..3df99c280 100644
--- a/src/pages/Project/View/ViewProject.jsx
+++ b/src/pages/Project/View/ViewProject.jsx
@@ -1,8 +1,9 @@
-import React from 'react'
+import React, { useState } from 'react'
import PropTypes from 'prop-types'
import { Link } from 'react-router-dom'
import { LineChart, Line, XAxis, YAxis, CartesianGrid, Tooltip, Legend, ResponsiveContainer } from 'recharts'
+import ProjectSettings from 'pages/Project/Create'
import routes from 'routes'
const data = [
@@ -50,20 +51,28 @@ const data = [
},
]
-const ViewProject = ({ id, name }) => {
+const ViewProject = (props) => {
+ const { id, name } = props
+ const [settings, setSettings] = useState(false)
+
+ if (settings) {
+ return (
+ <ProjectSettings
+ onCancel={() => setSettings(false)}
+ project={props}
+ />
+ )
+ }
return (
<div className="container">
<div className="d-flex justify-content-between">
<h2>{name}</h2>
- <Link
- to={{
- pathname: routes.project_settings,
- state: { name, id },
- }}
+ <button
+ onClick={() => setSettings(true)}
className="btn btn-outline-primary h-100">
Settings
- </Link>
+ </button>
</div>
<ResponsiveContainer width="100%" minHeight="300px">
<LineChart
diff --git a/src/routes.js b/src/routes.js
index f72e2698a..ee940388c 100644
--- a/src/routes.js
+++ b/src/routes.js
@@ -9,6 +9,5 @@ export default Object.freeze({
verify: '/verify/:id',
change_email: '/change-email/:id',
new_project: '/projects/new',
- project_settings: '/projects/settings',
project: '/projects/:id',
})
\ No newline at end of file