forked from mantisbt/mantisbt
-
Notifications
You must be signed in to change notification settings - Fork 1
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
Prototyping React #4
Draft
vboctor
wants to merge
55
commits into
master
Choose a base branch
from
react-relationships
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+10,264
−433
Draft
Changes from 18 commits
Commits
Show all changes
55 commits
Select commit
Hold shift + click to select a range
c6a82c9
initial commit
8ff5744
bundle to js/mantis
1544044
added mantis.* to gitignore
cf76334
js minify script
b18c0e5
updated package json and hard coded params
ab9baa7
removed pack script
4a0391f
IssueService class
6813e22
Issue models
1ad7d55
Relationship model
3cccadf
Implement LocalizedStringsGetCommand
vboctor 7fd1c14
removed console log
7c08e46
removed unneeded functions and models
226f998
Implemented ConfigsGetCommand
vboctor d917ee2
ConfigService
27d6c80
Include mantis.js in all pages
vboctor 6a139ab
Remove RelationshipsParse() dead code
vboctor 51d2ee4
Remove IssueRelationshipAddRequest
vboctor ddd64df
Remove ConfigService and use PHP commands instead
vboctor 7b3e632
Emit array of relationship box buttons to HTML
vboctor 27c692b
hard-coded strings to localized strings
d071180
config to react
f9cf8bb
relationship buttons
0eb3cfb
react check resolve bug
a34f555
removed relationship_get_summary_html
4e94a09
Remove dead code
vboctor f9dcac5
fixed wrong relationships box render
a5445fc
removed default_bug_dependant config
26d0385
delete relationship confirm dialog
98b2921
IssueViewPageCommand: support block resolving
vboctor aa8ae46
Fix escaping of json in HTML
vboctor 883968a
Support auto-complete for related issue ids
vboctor 1abc625
Add internal API to get issue basic info
vboctor 0779139
input field enter key down handler
f50b583
webpack watch and clean script
3d23438
Fix setting of relationship warning
vboctor 373e4d9
Expose IssueViewPageCommand via REST API
vboctor 43065ab
Proper handling for relationships warning message
vboctor 471362a
Add `IssueService.GetIssueBasic()`
vboctor 1e109ca
webpack watch
a28ee88
toast message
e87e6c3
Merge branches 'react-relationships' and 'react-relationships' of git…
bc2e367
removed console log
f14b758
we don't need client/js folder. client/js -> client/
36304bf
added node_modules to gitignore
ba6d2c0
relationships input auto-complete
7eaf632
except issueId itself
c77a641
Handle arrow key control
eb20f60
Arrow key input prevents cursor change
9829146
dropdown mouse over
44c3803
working with min.js
a9c9f52
added watching minify script
1fbf45c
React plugin storybook component
586ed5b
code splitting
166f9cd
removed ReactSamplePlugin from Mantisbt repo
fa71dfd
keyboard event prevent
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"presets": [ | ||
"@babel/preset-env", | ||
"@babel/preset-typescript", | ||
"@babel/preset-react" | ||
], | ||
"plugins": [ | ||
"@babel/plugin-transform-runtime" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,144 @@ | ||
import React from 'react'; | ||
import { IssueService } from '../services'; | ||
import { Relationship } from '../models'; | ||
|
||
type Props = { | ||
relationships: Array<Relationship>; | ||
issueId: number; | ||
canUpdate: boolean; | ||
warning?: string; | ||
} | ||
|
||
type States = { | ||
relationships: Array<Relationship>, | ||
reqRelTyp: RelationshipTypeEnum, | ||
reqRelDestIds: string, | ||
} | ||
|
||
enum RelationshipTypeEnum { | ||
DUPLICATE_OF = 0, | ||
RELATED_TO = 1, | ||
PARENT_OF = 2, | ||
CHILD_OF = 3, | ||
HAS_DUPLICATE = 4, | ||
} | ||
|
||
export class IssueRelationships extends React.Component<Props, States> { | ||
|
||
protected readonly Service: IssueService; | ||
|
||
constructor(props: Props) { | ||
super(props); | ||
|
||
this.state = { | ||
relationships: props.relationships, | ||
reqRelTyp: RelationshipTypeEnum.RELATED_TO, | ||
reqRelDestIds: '' | ||
}; | ||
this.Service = new IssueService(props.issueId); | ||
} | ||
|
||
async handleRelationshipAdd() { | ||
try { | ||
this.state.reqRelDestIds.split('|').forEach(async (issueId) => { | ||
const relationships = await this.Service.RelationshipAdd(this.state.reqRelTyp, parseInt(issueId)); | ||
this.setState({ relationships }); | ||
}); | ||
} catch (error) { | ||
|
||
} | ||
this.setState({ | ||
reqRelDestIds: '', | ||
reqRelTyp: RelationshipTypeEnum.RELATED_TO | ||
}); | ||
this.forceUpdate(); | ||
} | ||
|
||
async handleRelationshipDelete(relId: number) { | ||
try { | ||
const relationships = await this.Service.RelationshipDelete(relId); | ||
this.setState({ relationships }); | ||
} catch (error) { | ||
|
||
} | ||
this.forceUpdate(); | ||
} | ||
|
||
render() { | ||
const { relationships, reqRelDestIds, reqRelTyp } = this.state; | ||
const { canUpdate, warning } = this.props; | ||
return relationships.length ? ( | ||
<React.Fragment> | ||
<div className='widget-toolbox padding-8 clearfix'> | ||
{canUpdate && <div className='form-inline noprint'> | ||
<label className='inline'>Current issue </label> | ||
<select | ||
className='input-sm' | ||
name='rel_type' | ||
onChange={(e) => this.setState({ reqRelTyp: parseInt(e.target.value) })} | ||
value={reqRelTyp} | ||
> | ||
<option value={RelationshipTypeEnum.PARENT_OF}>parent of</option> | ||
<option value={RelationshipTypeEnum.CHILD_OF}>child of</option> | ||
<option value={RelationshipTypeEnum.DUPLICATE_OF}>duplicate of</option> | ||
<option value={RelationshipTypeEnum.HAS_DUPLICATE}>has duplicate</option> | ||
<option value={RelationshipTypeEnum.RELATED_TO}>related to</option> | ||
</select> | ||
| ||
<input | ||
type='text' | ||
className='input-sm' | ||
onChange={(e) => this.setState({ reqRelDestIds: e.target.value })} | ||
value={reqRelDestIds} | ||
/> | ||
| ||
<button | ||
onClick={() => this.handleRelationshipAdd()} | ||
className='btn btn-primary btn-sm btn-white btn-round' | ||
>Add</button> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @waltergar Replace all hard-coded strings with localized one that are now available in the html div that I added. |
||
</div>} | ||
</div> | ||
<div className='widget-main no-padding'> | ||
<div className='table-responsive'> | ||
<table className='table table-bordered table-condensed table-hover'> | ||
<tbody> | ||
{relationships.map((relationship: Relationship, key: number) => ( | ||
<tr key={key}> | ||
<td><span className='nowrap'>{relationship.type.label}</span></td> | ||
<td><a href={`view.php?id=${relationship.issue.id}`}>{relationship.issue.id}</a></td> | ||
<td> | ||
<i className={`fa fa-square fa-status-box`} style={{ color: relationship.issue.status?.color }}></i> | ||
| ||
<span className='issue-status' title={relationship.issue.resolution?.name || ''}>{relationship.issue.status?.label}</span> | ||
</td> | ||
<td> | ||
<span className='nowrap'> | ||
<a href={`view_user_page.php?id=${relationship.issue.handler?.id}`}>{relationship.issue.handler?.name}</a> | ||
</span> | ||
</td> | ||
<td> | ||
{relationship.issue.summary} | ||
{canUpdate && ( | ||
<a | ||
className='red noprint zoom-130' | ||
onClick={() => this.handleRelationshipDelete(relationship['id'])} | ||
> | ||
<i className='ace-icon fa fa-trash-o bigger-115'></i> | ||
</a> | ||
)} | ||
</td> | ||
</tr> | ||
))} | ||
{warning && ( | ||
<tr> | ||
<td colSpan={5}><strong>{warning}</strong></td> | ||
</tr> | ||
)} | ||
</tbody> | ||
</table> | ||
</div> | ||
</div> | ||
</React.Fragment> | ||
) : null | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import React from 'react'; | ||
import ReactDOM from 'react-dom'; | ||
import { IssueRelationships } from './components/IssueRelationships'; | ||
|
||
if (document.getElementById('issue-data')) { | ||
const _compIssueData = document.getElementById('issue-data'); | ||
const issueData = JSON.parse(_compIssueData?.dataset.issue!); | ||
|
||
if (issueData.issue && issueData.issue.relationships && document.getElementById('relationships-body')) { | ||
ReactDOM.render( | ||
<IssueRelationships | ||
issueId={issueData.issue.id} | ||
canUpdate={issueData.flags['relationships_can_update']} | ||
relationships={issueData.issue.relationships} | ||
/>, | ||
document.getElementById('relationships-body')); | ||
} | ||
} | ||
|
||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@waltergar Typing the issue id and then pressing Enter, no longer works.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@vboctor why not? I think it's working properly