Skip to content

Commit

Permalink
Post-rebase fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
karevn committed Oct 7, 2021
1 parent 4cfa5bd commit e7d0adb
Show file tree
Hide file tree
Showing 9 changed files with 76 additions and 98 deletions.
5 changes: 0 additions & 5 deletions ui/src/src/App.css
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,8 @@
}

.tree-side{
<<<<<<< HEAD
height: 100vh;
overflow-y: scroll;
=======
height: 100%;
overflow-y: auto;
>>>>>>> 24554e4 (New filtering and tree)
z-index: 0;
}

Expand Down
3 changes: 0 additions & 3 deletions ui/src/src/common/Main.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import Attributes from "../attributes/Attributes";
import TestCaseForm from "../testcases/TestCaseForm";
import TestCase from "../testcases/TestCase";
import Auth from "../user/Auth";
import IdpAuth from "../user/IdpAuth";
import Login from "../user/Login";
import Profile from "../user/Profile";
import ChangePassword from "../user/ChangePassword";
Expand Down Expand Up @@ -55,8 +54,6 @@ class Main extends Component {

<Route exact path="/auth" component={Auth} />



<Route exact path="/user/profile/:profileId" component={Profile} />
<Route exact path="/user/changepass" component={ChangePassword} />

Expand Down
33 changes: 0 additions & 33 deletions ui/src/src/services/backend.js

This file was deleted.

7 changes: 6 additions & 1 deletion ui/src/src/services/backend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,12 @@ const fetchInternal = (url: string, method: HttpMethod, options?: RequestInit) =
fetch(getApiBaseUrl(url), { ...getOptions(options), method })
.then(async response => {
if (!response.ok) {
if (response.status === 401 && window.location.pathname !== "/login") {
if (
response.status === 401 &&
window.location.pathname !== "/login" &&
window.location.pathname !== "/idpauth" &&
window.location.pathname !== "/login"
) {
window.location.href = "/login?" + qs.stringify({ retpath: window.location.pathname });
} else {
throw new Error(await response.text());
Expand Down
70 changes: 41 additions & 29 deletions ui/src/src/testcases/TestCase.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,16 +152,19 @@ class TestCase extends SubComponent {
});
}

cloneTestCase(){
Backend.post(this.projectId + "/testcase/" + this.state.testcase.id + "/clone")
.then(response => {
window.location.href = window.location.href.replace('testcase=' + this.state.testcase.id, 'testcase=' + response.id)
})
.catch(error => {
Utils.onErrorMessage("Couldn't clone testcase: ", error);
this.state.loading = false;
this.setState(this.state);
});
cloneTestCase() {
Backend.post(this.projectId + "/testcase/" + this.state.testcase.id + "/clone")
.then(response => {
window.location.href = window.location.href.replace(
"testcase=" + this.state.testcase.id,
"testcase=" + response.id,
);
})
.catch(error => {
Utils.onErrorMessage("Couldn't clone testcase: ", error);
this.state.loading = false;
this.setState(this.state);
});
}

handleChange(fieldName, event, index, arrObjectKey, skipStateRefresh) {
Expand Down Expand Up @@ -382,7 +385,7 @@ class TestCase extends SubComponent {
getAttributeKeysToAdd() {
return (this.state.projectAttributes || [])
.filter(attribute => !(Object.keys(this.state.testcase.attributes || {}) || []).includes(attribute.id))
.filter(attribute => attribute.id !== 'broken')
.filter(attribute => attribute.id !== "broken")
.map(attribute => ({ value: attribute.id, label: attribute.name }));
}

Expand Down Expand Up @@ -545,17 +548,27 @@ class TestCase extends SubComponent {
</h1>
</div>
{!this.state.readonly && (
<div className="col-1">
<div class="dropdown">
<span class="dropdown-toggle clickable" href="#" role="button" id="dropdownMenuLink" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<FontAwesomeIcon icon={faBars} />
</span>
<div class="dropdown-menu" aria-labelledby="dropdownMenuLink">
<a class="dropdown-item" href="#" onClick={e => this.cloneTestCase()}>Clone</a>
</div>
</div>
</div>
)}
<div className="col-1">
<div class="dropdown">
<span
class="dropdown-toggle clickable"
href="#"
role="button"
id="dropdownMenuLink"
data-toggle="dropdown"
aria-haspopup="true"
aria-expanded="false"
>
<FontAwesomeIcon icon={faBars} />
</span>
<div class="dropdown-menu" aria-labelledby="dropdownMenuLink">
<a class="dropdown-item" href="#" onClick={e => this.cloneTestCase()}>
Clone
</a>
</div>
</div>
</div>
)}
{!this.state.readonly && (
<div className="col-2">
<Checkbox
Expand All @@ -566,7 +579,6 @@ class TestCase extends SubComponent {
/>
</div>
)}

</div>
{!this.state.readonly && (
<div id="name-form" className="inplace-form" style={{ display: "none" }}>
Expand Down Expand Up @@ -626,7 +638,7 @@ class TestCase extends SubComponent {
menubar: false,
plugins: this.tinymcePlugins,
toolbar: this.tinymceToolbar,
content_style: this.tinymceContentStyle
content_style: this.tinymceContentStyle,
}}
onEditorChange={val =>
this.handleChange("description", { target: { value: val } }, null, null, true)
Expand Down Expand Up @@ -682,7 +694,7 @@ class TestCase extends SubComponent {
menubar: false,
plugins: this.tinymcePlugins,
toolbar: this.tinymceToolbar,
content_style: this.tinymceContentStyle
content_style: this.tinymceContentStyle,
}}
onEditorChange={val =>
this.handleChange("preconditions", { target: { value: val } }, null, null, true)
Expand Down Expand Up @@ -729,7 +741,7 @@ class TestCase extends SubComponent {
menubar: false,
plugins: this.tinymcePlugins,
toolbar: this.tinymceToolbar,
content_style: this.tinymceContentStyle
content_style: this.tinymceContentStyle,
}}
onEditorChange={val => this.handleStepActionChange(i, val, false)}
/>
Expand All @@ -743,7 +755,7 @@ class TestCase extends SubComponent {
menubar: false,
plugins: this.tinymcePlugins,
toolbar: this.tinymceToolbar,
content_style: this.tinymceContentStyle
content_style: this.tinymceContentStyle,
}}
onEditorChange={val => this.handleStepExpectationChange(i, val, false)}
/>
Expand Down Expand Up @@ -822,7 +834,7 @@ class TestCase extends SubComponent {
menubar: false,
plugins: this.tinymcePlugins,
toolbar: this.tinymceToolbar,
content_style: this.tinymceContentStyle
content_style: this.tinymceContentStyle,
}}
onEditorChange={val => this.handleStepActionChange(i, val, false)}
/>
Expand All @@ -836,7 +848,7 @@ class TestCase extends SubComponent {
menubar: false,
plugins: this.tinymcePlugins,
toolbar: this.tinymceToolbar,
content_style: this.tinymceContentStyle
content_style: this.tinymceContentStyle,
}}
onEditorChange={val => this.handleStepExpectationChange(i, val, false)}
/>
Expand Down
18 changes: 9 additions & 9 deletions ui/src/src/user/Auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@ class Auth extends Component {
.then(response => {
var url = response.url || "/login";
var retpath = params.retpath || "";
if(!response.strictUrl){
var retpathParamName = response.retpathParamName || "retpath";
if (
retpath.startsWith(window.location.origin + "/auth") ||
retpath.startsWith(window.location.origin + "/login")
) {
retpath = "/";
}
if (!response.strictUrl) {
var retpathParamName = response.retpathParamName || "retpath";
if (
retpath.startsWith(window.location.origin + "/auth") ||
retpath.startsWith(window.location.origin + "/login")
) {
retpath = "/";
}

url = url + "?" + retpathParamName + "=" + encodeURIComponent(retpath);
url = url + "?" + retpathParamName + "=" + encodeURIComponent(retpath);
}
window.location = url;
})
Expand Down
11 changes: 6 additions & 5 deletions ui/src/src/user/CreateUser.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,12 @@ class CreateUser extends Component {

handleSubmit(event) {
Backend.post("user", this.state.user)
.then(response => {
window.location = decodeURI("/user/profile/" + response.login);
}).catch(error => {
Utils.onErrorMessage("Couldn't create a user: ", error);
});
.then(response => {
window.location = decodeURI("/user/profile/" + response.login);
})
.catch(error => {
Utils.onErrorMessage("Couldn't create a user: ", error);
});
event.preventDefault();
}

Expand Down
2 changes: 1 addition & 1 deletion ui/src/src/user/IdpAuth.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { Component } from "react";
import { withRouter } from "react-router";
import qs from "qs";

import Backend from "../services/backend";
class IdpAuth extends Component {
render() {
Expand Down
25 changes: 13 additions & 12 deletions ui/src/src/user/Login.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,19 @@ class Login extends Component {

handleSubmit(event) {
Backend.post("user/login?login=" + this.state.login + "&password=" + this.state.password)
.then(response => {
this.onSessionChange(response);
var params = qs.parse(this.props.location.search.substring(1));
var retpath = decodeURIComponent(params.retpath || "");
var decodedReptath = decodeURI(retpath);
if (decodedReptath === "") {
decodedReptath = "/";
}
window.location = decodeURI(decodedReptath);
}).catch(error => {
Utils.onErrorMessage("Unable to login: ", error);
});
.then(response => {
this.onSessionChange(response);
var params = qs.parse(this.props.location.search.substring(1));
var retpath = decodeURIComponent(params.retpath || "");
var decodedReptath = decodeURI(retpath);
if (decodedReptath === "") {
decodedReptath = "/";
}
window.location = decodeURI(decodedReptath);
})
.catch(error => {
Utils.onErrorMessage("Unable to login: ", error);
});
event.preventDefault();
}

Expand Down

0 comments on commit e7d0adb

Please sign in to comment.