diff --git a/src/app/components/help/report-issue/filter.tsx b/src/app/components/help/report-issue/filter.tsx new file mode 100644 index 00000000..0ced31d4 --- /dev/null +++ b/src/app/components/help/report-issue/filter.tsx @@ -0,0 +1,24 @@ +import React, {Component} from "react"; +import Form from 'react-bootstrap/Form'; + +const formGroupStyle = { + margin: '20px' +}; + +class FilterComponent extends Component { + constructor(props) { + super(props); + } + + render() { + return ( +
+ + + +
+ ) + } +} + +export default FilterComponent; \ No newline at end of file diff --git a/src/app/components/help/report-issue/issue-list.tsx b/src/app/components/help/report-issue/issue-list.tsx index 6798caec..d7811e68 100644 --- a/src/app/components/help/report-issue/issue-list.tsx +++ b/src/app/components/help/report-issue/issue-list.tsx @@ -1,7 +1,26 @@ import React, { Component } from "react"; -import { FunctionComponent, useEffect, useRef, useState } from 'react'; import Card from 'react-bootstrap/Card'; -import CardGroup from 'react-bootstrap/CardGroup'; +import Spinner from 'react-bootstrap/Spinner'; +import IssueComponent from './issue'; +import FilterComponent from './filter'; + +const wrapperStyle = { + justifyContent: 'center', + display: 'flex', + flex: 1, + flexDirection: 'row', + flexWrap: 'wrap', + margin: '20px' +}; + +const cardStyle = { + width: '300px', + margin: '20px' +}; + +const cardTitleStyle = { + color: 'red' +}; const apiUrl = 'https://api.github.com/repos/GNS3/gns3-web-ui/issues'; const newIssueLink = 'https://github.com/GNS3/gns3-web-ui/issues/new'; @@ -10,41 +29,60 @@ class IssueListComponent extends Component { constructor(props) { super(props); this.state = { - isFetching: false, - issues: [] + issues: [], + filteredIssues: [], + isFetching: true }; } componentDidMount() { fetch(apiUrl) .then(response => response.json()) - .then(data => this.setState({ issues: data })); + .then(data => this.setState({ + issues: data, + filteredIssues: data, + isFetching: false + })); + } + + handleChange = (e) => { + let filter = e.target.value; + let filteredIssues = this.state.issues; + + filteredIssues = filteredIssues.filter((issue) => { + return issue.title.toLowerCase().includes(filter.toLowerCase()) + }); + + this.setState({ + filteredIssues: filteredIssues + }); } render() { - const { issues } = this.state; - return ( -
- {issues.map(issue => - - - {issue.title} - Status: {issue.state} - - {issue.body} - - {issue.html_url} - - - )} - - - Don't see your issue here? - Open new issue - - -
+
+
+ +
+ + {this.state.isFetching ? ( +
+ +
+ ) : ( +
+ {this.state.filteredIssues.map(issue => + + )} + + + Don't see your issue here? + Open new issue + + +
+ )} +
); } }; diff --git a/src/app/components/help/report-issue/issue.tsx b/src/app/components/help/report-issue/issue.tsx new file mode 100644 index 00000000..1fe0e53a --- /dev/null +++ b/src/app/components/help/report-issue/issue.tsx @@ -0,0 +1,42 @@ +import React, { Component } from "react"; +import Card from 'react-bootstrap/Card'; + +const cardStyle = { + width: '300px', + margin: '20px' +}; + +const cardTitleStyle = { + color: 'black' +}; + +const cardTextStyle = { + color: 'black', + overflowY: 'auto', + height: '100px' +}; + +class IssueComponent extends Component { + constructor(props) { + super(props); + this.state = { + data: this.props.data + } + } + + render() { + const issue = this.state.data; + return ( + + + {issue.title} + Status: {issue.state} + {issue.body} + {issue.html_url} + + + ); + } +}; + +export default IssueComponent; \ No newline at end of file