mirror of
https://github.com/GNS3/gns3-web-ui.git
synced 2025-01-11 23:43:05 +00:00
Searching by keyword added
This commit is contained in:
parent
ad553a6aa2
commit
daf7da2189
24
src/app/components/help/report-issue/filter.tsx
Normal file
24
src/app/components/help/report-issue/filter.tsx
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
import React, {Component} from "react";
|
||||||
|
import Form from 'react-bootstrap/Form';
|
||||||
|
|
||||||
|
const formGroupStyle = {
|
||||||
|
margin: '20px'
|
||||||
|
};
|
||||||
|
|
||||||
|
class FilterComponent extends Component<any, any> {
|
||||||
|
constructor(props) {
|
||||||
|
super(props);
|
||||||
|
}
|
||||||
|
|
||||||
|
render() {
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<Form.Group style={formGroupStyle}>
|
||||||
|
<Form.Control size="lg" type="text" placeholder="Search by keyword" value={this.props.filter} onChange={this.props.handleChange} />
|
||||||
|
</Form.Group>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default FilterComponent;
|
@ -1,7 +1,26 @@
|
|||||||
import React, { Component } from "react";
|
import React, { Component } from "react";
|
||||||
import { FunctionComponent, useEffect, useRef, useState } from 'react';
|
|
||||||
import Card from 'react-bootstrap/Card';
|
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 apiUrl = 'https://api.github.com/repos/GNS3/gns3-web-ui/issues';
|
||||||
const newIssueLink = 'https://github.com/GNS3/gns3-web-ui/issues/new';
|
const newIssueLink = 'https://github.com/GNS3/gns3-web-ui/issues/new';
|
||||||
@ -10,41 +29,60 @@ class IssueListComponent extends Component<any, any> {
|
|||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props);
|
super(props);
|
||||||
this.state = {
|
this.state = {
|
||||||
isFetching: false,
|
issues: [],
|
||||||
issues: []
|
filteredIssues: [],
|
||||||
|
isFetching: true
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
fetch(apiUrl)
|
fetch(apiUrl)
|
||||||
.then(response => response.json())
|
.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() {
|
render() {
|
||||||
const { issues } = this.state;
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div style={{ justifyContent: 'center', display: 'flex', flex: 1, flexDirection: 'row', flexWrap: 'wrap', margin: '20px' }}>
|
<div>
|
||||||
{issues.map(issue =>
|
<div>
|
||||||
<Card key={issue.title} style={{ width: '300px', margin: '20px' }}>
|
<FilterComponent handleChange={this.handleChange} filter={this.state.filter} />
|
||||||
<Card.Body>
|
</div>
|
||||||
<Card.Title style={{ color: 'black' }}>{issue.title}</Card.Title>
|
|
||||||
<Card.Subtitle className="mb-2 text-muted">Status: {issue.state}</Card.Subtitle>
|
{this.state.isFetching ? (
|
||||||
<Card.Text style={{ color: 'black', overflowY: 'auto', height: '100px' }}>
|
<div style={wrapperStyle}>
|
||||||
{issue.body}
|
<Spinner animation="grow" />
|
||||||
</Card.Text>
|
</div>
|
||||||
<Card.Link href={issue.html_url} target = "_blank">{issue.html_url}</Card.Link>
|
) : (
|
||||||
</Card.Body>
|
<div style={wrapperStyle}>
|
||||||
</Card>
|
{this.state.filteredIssues.map(issue =>
|
||||||
|
<IssueComponent key={issue.html_url} data={issue}/>
|
||||||
)}
|
)}
|
||||||
<Card style={{ width: '300px', margin: '20px' }}>
|
<Card style={cardStyle}>
|
||||||
<Card.Body>
|
<Card.Body>
|
||||||
<Card.Title style={{ color: 'red' }}>Don't see your issue here?</Card.Title>
|
<Card.Title style={cardTitleStyle}>Don't see your issue here?</Card.Title>
|
||||||
<Card.Link href={newIssueLink} target = "_blank">Open new issue</Card.Link>
|
<Card.Link href={newIssueLink} target = "_blank">Open new issue</Card.Link>
|
||||||
</Card.Body>
|
</Card.Body>
|
||||||
</Card>
|
</Card>
|
||||||
</div>
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
42
src/app/components/help/report-issue/issue.tsx
Normal file
42
src/app/components/help/report-issue/issue.tsx
Normal file
@ -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<any, any> {
|
||||||
|
constructor(props) {
|
||||||
|
super(props);
|
||||||
|
this.state = {
|
||||||
|
data: this.props.data
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
render() {
|
||||||
|
const issue = this.state.data;
|
||||||
|
return (
|
||||||
|
<Card key={issue.html_url} style={cardStyle}>
|
||||||
|
<Card.Body>
|
||||||
|
<Card.Title style={cardTitleStyle}>{issue.title}</Card.Title>
|
||||||
|
<Card.Subtitle className="mb-2 text-muted">Status: {issue.state}</Card.Subtitle>
|
||||||
|
<Card.Text style={cardTextStyle}>{issue.body}</Card.Text>
|
||||||
|
<Card.Link href={issue.html_url} target = "_blank">{issue.html_url}</Card.Link>
|
||||||
|
</Card.Body>
|
||||||
|
</Card>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export default IssueComponent;
|
Loading…
Reference in New Issue
Block a user