Skip to content

Commit

Permalink
Replace history with window.location (#67)
Browse files Browse the repository at this point in the history
Signed-off-by: Aravinda Vishwanathapura <[email protected]>
  • Loading branch information
aravindavk authored Jan 14, 2023
1 parent 1e53b7c commit eafea52
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion ui/src/pages/bricks.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export function Bricks({ history }) {
})
.catch(err => {
if (err.response.status === 403) {
history.push('/login');
window.location = '/login';
} else {
setLoading(false);
setError("Failed to get data from the server(HTTP Status: " + err.response.status + ")");
Expand Down
12 changes: 6 additions & 6 deletions ui/src/pages/dashboard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ function dashboardUI(history, volumes, peers) {
}
return (
<div className="">
<Box label="Peers" value={upPeers + ' / ' + peers.length} onClick={() => history.push('/peers')}/>
<Box label="Volumes" value={upVolumes + ' / ' + volumes.length} onClick={() => history.push('/volumes')}/>
<Box label="Bricks" value={upBricks + ' / ' + numBricks} onClick={() => history.push('/bricks')}/>
<Box label="Peers" value={upPeers + ' / ' + peers.length} onClick={() => window.location = '/peers'}/>
<Box label="Volumes" value={upVolumes + ' / ' + volumes.length} onClick={() => window.location = '/volumes'}/>
<Box label="Bricks" value={upBricks + ' / ' + numBricks} onClick={() => window.location = '/bricks'}/>
</div>
);
);
}

export function Dashboard({ history }) {
Expand All @@ -64,7 +64,7 @@ export function Dashboard({ history }) {
})
.catch(err => {
if (err.response.status === 403) {
history.push('/login');
window.location = '/login';
} else {
setLoading(false);
setError("Failed to get data from the server(HTTP Status: " + err.response.status + ")");
Expand All @@ -77,7 +77,7 @@ export function Dashboard({ history }) {
})
.catch(err => {
if (err.response.status === 403) {
history.push('/login');
window.location = '/login';
}
});
}, [refreshRequired, history]);
Expand Down
4 changes: 2 additions & 2 deletions ui/src/pages/login.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export function Login({ history }) {
useEffect(() => {
axios.get("/api/login")
.then((resp) => {
history.push('/dashboard');
window.location = '/dashboard';
});
}, [history]);

Expand All @@ -36,7 +36,7 @@ export function Login({ history }) {
username: username,
password: password
}).then(res => {
history.push('/dashboard');
window.location = '/dashboard';
}).catch(err => {
if (err.response.status === 403) {
setError("Invalid username/password");
Expand Down
2 changes: 1 addition & 1 deletion ui/src/pages/logout.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export function Logout({ history }) {
.then((resp) => {
setMessage("Logged out Successfully...");
setInterval(() => {
history.push('/login');
window.location = '/login';
}, 2000);
}).catch(err => {
setError("Failed to get data from the server(HTTP Status: " + err.response.status + ")");
Expand Down
2 changes: 1 addition & 1 deletion ui/src/pages/peers.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export function Peers({ history }) {
})
.catch(err => {
if (err.response.status === 403) {
history.push('/login');
window.location = '/login';
} else {
setLoading(false);
setError("Failed to get data from the server(HTTP Status: " + err.response.status + ")");
Expand Down
2 changes: 1 addition & 1 deletion ui/src/pages/volumeDetail.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ export function VolumeDetail({ history }) {
})
.catch(err => {
if (err.response.status === 403) {
history.push('/login');
window.location = '/login';
} else {
setLoading(false);
setError("Failed to get data from the server(HTTP Status: " + err.response.status + ")");
Expand Down
2 changes: 1 addition & 1 deletion ui/src/pages/volumes.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export function Volumes({ history }) {
})
.catch(err => {
if (err.response.status === 403) {
history.push('/login');
window.location = '/login';
} else {
setLoading(false);
setError("Failed to get data from the server(HTTP Status: " + err.response.status + ")");
Expand Down

0 comments on commit eafea52

Please sign in to comment.