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

Frontend refactoring: round 2 #248

Merged
merged 2 commits into from
Dec 12, 2021
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
4 changes: 1 addition & 3 deletions src/e2etests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,9 +261,7 @@ def request_query(log, i, taints=[]):

for j in range(15):
res = requests.get(
"http://web:5000/api/matches/{}?offset=0&limit=50".format(
query_hash
)
f"http://web:5000/api/matches/{query_hash}?offset=0&limit=50"
)
log.info("API response: %s", res.json())
if res.json()["job"]["status"] == "done":
Expand Down
20 changes: 1 addition & 19 deletions src/mqueryfront/src/components/FilteringTableHeader.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import React from "react";
import FilteringThead from "./FilteringThead";
import PropTypes from "prop-types";

const FilteringTableHeader = (props) => {
const head = props.head.map((el, index) => {
const filterData = {
attrubuteName: el.attrubuteName,
attributeName: el.attributeName,
valueList: el.valueList,
onClick: props.onClick,
};
Expand All @@ -27,21 +26,4 @@ const FilteringTableHeader = (props) => {
);
};

FilteringTableHeader.propTypes = {
head: PropTypes.arrayOf(
PropTypes.shape({
title: PropTypes.string.isRequired,
attrubuteName: PropTypes.string,
valueList: PropTypes.arrayOf(
PropTypes.oneOfType([PropTypes.string, PropTypes.number])
),
})
).isRequired,
currentFilter: PropTypes.shape({
name: PropTypes.string,
value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
}),
onClick: PropTypes.func,
};

export default FilteringTableHeader;
20 changes: 2 additions & 18 deletions src/mqueryfront/src/components/FilteringThead.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import React from "react";
import FilterIcon from "./FilterIcon";
import PropTypes from "prop-types";

const FilteringThead = (props) => {
let activeColumn = false;
let icon = null;

if (
props.currentFilter &&
props.currentFilter.name === props.filterData.attrubuteName
props.currentFilter.name === props.filterData.attributeName
) {
activeColumn = true;
icon = (
Expand All @@ -32,7 +31,7 @@ const FilteringThead = (props) => {
className="dropdown-item"
onClick={() =>
props.filterData.onClick(
props.filterData.attrubuteName,
props.filterData.attributeName,
el,
index
)
Expand Down Expand Up @@ -64,19 +63,4 @@ const FilteringThead = (props) => {
);
};

FilteringThead.propTypes = {
title: PropTypes.string.isRequired,
filterData: PropTypes.shape({
attrubuteName: PropTypes.string,
valueList: PropTypes.arrayOf(
PropTypes.oneOfType([PropTypes.string, PropTypes.number])
),
onClick: PropTypes.func,
}).isRequired,
currentFilter: PropTypes.shape({
name: PropTypes.string,
value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
}),
};

export default FilteringThead;
6 changes: 0 additions & 6 deletions src/mqueryfront/src/components/FilteringTitle.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React from "react";
import FilterIcon from "./FilterIcon";
import PropTypes from "prop-types";

const FilteringTitle = (props) => {
const { title, filterValue } = props;
Expand Down Expand Up @@ -47,9 +46,4 @@ const FilteringTitle = (props) => {
else return <h1 className="text-center mq-bottom">{title}</h1>;
};

FilteringTitle.propTypes = {
title: PropTypes.string.isRequired,
filterValue: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
};

export default FilteringTitle;
23 changes: 8 additions & 15 deletions src/mqueryfront/src/components/LoadingPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,13 @@ import React from "react";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { faSpinner } from "@fortawesome/free-solid-svg-icons";

const LoadingPage = () => {
return (
<div>
<h2>
<FontAwesomeIcon
icon={faSpinner}
spin
size="lg"
className="mr-2"
/>
Loading...
</h2>
</div>
);
};
const LoadingPage = () => (
<div>
<h2>
<FontAwesomeIcon icon={faSpinner} spin size="lg" className="mr-2" />
Loading...
</h2>
</div>
);

export default LoadingPage;
125 changes: 0 additions & 125 deletions src/mqueryfront/src/components/MultiSelectDropdown.js

This file was deleted.

9 changes: 0 additions & 9 deletions src/mqueryfront/src/components/PriorityIcon.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import {
faAngleUp,
faAngleDoubleUp,
} from "@fortawesome/free-solid-svg-icons";
import PropTypes from "prop-types";

const PriorityIcon = (props) => {
let icon;
Expand All @@ -29,12 +28,4 @@ const PriorityIcon = (props) => {
);
};

PriorityIcon.defaultProps = {
size: "1x",
};

PriorityIcon.propTypes = {
priority: PropTypes.oneOf(["low", "medium", "high"]).isRequired,
};

export default PriorityIcon;
Empty file.
1 change: 0 additions & 1 deletion src/mqueryfront/src/query/QueryEditParseNav.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import PropTypes from "prop-types";

const QueryEditParseNav = (props) => {
const { onEditQuery, onParseQuery, isEditActive } = props;

let label, onClick, icon, name;

if (isEditActive) {
Expand Down
54 changes: 19 additions & 35 deletions src/mqueryfront/src/query/QueryField.js
Original file line number Diff line number Diff line change
@@ -1,44 +1,28 @@
import React from "react";
import QueryNavigation from "./QueryNavigation";
import QueryMonaco from "./QueryMonaco";
import PropTypes from "prop-types";

const QueryField = (props) => {
return (
<div>
<QueryNavigation
isEditActive={props.readOnly}
const QueryField = (props) => (
<div>
<QueryNavigation
isEditActive={props.readOnly}
onSubmitQuery={props.onSubmitQuery}
onEditQuery={props.onEditQuery}
onParseQuery={props.onParseQuery}
onTaintSelect={props.onTaintSelect}
availableTaints={props.availableTaints}
selectedTaints={props.selectedTaints}
/>
<div className="mt-2 monaco-container">
<QueryMonaco
readOnly={props.readOnly}
rawYara={props.rawYara}
onValueChanged={props.onYaraUpdate}
error={props.parsedError}
onSubmitQuery={props.onSubmitQuery}
onEditQuery={props.onEditQuery}
onParseQuery={props.onParseQuery}
onTaintSelect={props.onTaintSelect}
availableTaints={props.availableTaints}
selectedTaints={props.selectedTaints}
/>
<div className="mt-2 monaco-container">
<QueryMonaco
readOnly={props.readOnly}
rawYara={props.rawYara}
onValueChanged={props.onYaraUpdate}
error={props.parsedError}
onSubmitQuery={props.onSubmitQuery}
/>
</div>
</div>
);
};

QueryField.propTypes = {
rawYara: PropTypes.string.isRequired,
parsedError: PropTypes.arrayOf(PropTypes.string).isRequired,
readOnly: PropTypes.bool.isRequired,
availableTaints: PropTypes.arrayOf(PropTypes.string).isRequired,
onYaraUpdate: PropTypes.func.isRequired,
onSubmitQuery: PropTypes.func.isRequired,
onEditQuery: PropTypes.func.isRequired,
onParseQuery: PropTypes.func.isRequired,
onTaintSelect: PropTypes.func.isRequired,
selectedTaints: PropTypes.arrayOf(PropTypes.string).isRequired,
};
</div>
);

export default QueryField;
1 change: 0 additions & 1 deletion src/mqueryfront/src/query/QueryLayoutManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import React from "react";
import QueryField from "./QueryField";
import QueryResultsStatus from "./QueryResultsStatus";
import QueryParseStatus from "./QueryParseStatus";
// import ToggleLayoutButton from "../components/ToggleLayoutButton";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { faAlignLeft } from "@fortawesome/free-solid-svg-icons";
import ErrorPage from "../components/ErrorPage";
Expand Down
9 changes: 1 addition & 8 deletions src/mqueryfront/src/query/QueryMatches.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ import { API_URL } from "../config";
import Pagination from "react-js-pagination";
import FilterIcon from "../components/FilterIcon";
import QueryMatchesItem from "./QueryMatchesItem";
import PropTypes from "prop-types";
import { PT_MATCHES, PT_PAGINATION } from "../queryUtils";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import axios from "axios";
import {
Expand Down Expand Up @@ -81,6 +79,7 @@ const QueryMatches = (props) => {
} else {
return match;
}
return null;
})
.map((match, index) => {
const downloadUrl =
Expand Down Expand Up @@ -151,10 +150,4 @@ const QueryMatches = (props) => {
);
};

QueryMatches.propTypes = {
matches: PT_MATCHES.isRequired,
qhash: PropTypes.string.isRequired,
pagination: PT_PAGINATION.isRequired,
};

export default QueryMatches;
Loading