Skip to content
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
c6a82c9
initial commit
Apr 14, 2020
8ff5744
bundle to js/mantis
Apr 14, 2020
1544044
added mantis.* to gitignore
Apr 14, 2020
cf76334
js minify script
Apr 14, 2020
b18c0e5
updated package json and hard coded params
Apr 15, 2020
ab9baa7
removed pack script
Apr 15, 2020
4a0391f
IssueService class
Apr 16, 2020
6813e22
Issue models
Apr 16, 2020
1ad7d55
Relationship model
Apr 17, 2020
3cccadf
Implement LocalizedStringsGetCommand
vboctor Apr 17, 2020
7fd1c14
removed console log
Apr 17, 2020
7c08e46
removed unneeded functions and models
Apr 17, 2020
226f998
Implemented ConfigsGetCommand
vboctor Apr 17, 2020
d917ee2
ConfigService
Apr 17, 2020
27d6c80
Include mantis.js in all pages
vboctor Apr 17, 2020
6a139ab
Remove RelationshipsParse() dead code
vboctor Apr 17, 2020
51d2ee4
Remove IssueRelationshipAddRequest
vboctor Apr 17, 2020
ddd64df
Remove ConfigService and use PHP commands instead
vboctor Apr 17, 2020
7b3e632
Emit array of relationship box buttons to HTML
vboctor Apr 17, 2020
27c692b
hard-coded strings to localized strings
Apr 17, 2020
d071180
config to react
Apr 17, 2020
f9cf8bb
relationship buttons
Apr 17, 2020
0eb3cfb
react check resolve bug
Apr 17, 2020
a34f555
removed relationship_get_summary_html
Apr 17, 2020
4e94a09
Remove dead code
vboctor Apr 17, 2020
f9dcac5
fixed wrong relationships box render
Apr 18, 2020
a5445fc
removed default_bug_dependant config
Apr 18, 2020
26d0385
delete relationship confirm dialog
Apr 18, 2020
98b2921
IssueViewPageCommand: support block resolving
vboctor Apr 18, 2020
aa8ae46
Fix escaping of json in HTML
vboctor Apr 18, 2020
883968a
Support auto-complete for related issue ids
vboctor Apr 18, 2020
1abc625
Add internal API to get issue basic info
vboctor Apr 19, 2020
0779139
input field enter key down handler
Apr 19, 2020
f50b583
webpack watch and clean script
Apr 19, 2020
3d23438
Fix setting of relationship warning
vboctor Apr 19, 2020
373e4d9
Expose IssueViewPageCommand via REST API
vboctor Apr 19, 2020
43065ab
Proper handling for relationships warning message
vboctor Apr 19, 2020
471362a
Add `IssueService.GetIssueBasic()`
vboctor Apr 19, 2020
1e109ca
webpack watch
Apr 20, 2020
a28ee88
toast message
Apr 20, 2020
e87e6c3
Merge branches 'react-relationships' and 'react-relationships' of git…
Apr 20, 2020
bc2e367
removed console log
Apr 20, 2020
f14b758
we don't need client/js folder. client/js -> client/
Apr 21, 2020
36304bf
added node_modules to gitignore
Apr 21, 2020
ba6d2c0
relationships input auto-complete
Apr 23, 2020
7eaf632
except issueId itself
Apr 23, 2020
c77a641
Handle arrow key control
Apr 23, 2020
eb20f60
Arrow key input prevents cursor change
Apr 23, 2020
9829146
dropdown mouse over
Apr 23, 2020
44c3803
working with min.js
Apr 24, 2020
a9c9f52
added watching minify script
Apr 24, 2020
1fbf45c
React plugin storybook component
Apr 24, 2020
586ed5b
code splitting
Apr 24, 2020
166f9cd
removed ReactSamplePlugin from Mantisbt repo
Apr 25, 2020
fa71dfd
keyboard event prevent
May 4, 2020
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
71 changes: 6 additions & 65 deletions bug_view_inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,14 +105,17 @@
'duplicate_of',
'has_duplicate',
'dependant_on',
'blocks'
'blocks',
'relationship_warning_blocking_bugs_not_resolved'
);
$t_data = array( 'query' => array( 'string' => $t_strings ) );
$t_cmd = new LocalizedStringsGetCommand( $t_data );
$t_strings_command_results = $t_cmd->execute();

# Get config options
$t_configs = array(
'bug_resolved_status_threshold',
'default_bug_dependant',
'relationship_graph_view_on_click',
'display_bug_padding',
);
Expand Down Expand Up @@ -1001,15 +1004,11 @@ function relationship_buttons( $p_issue_id ) {
* @return void
*/
function bug_view_relationship_view_box( $p_bug_id, $p_can_update ) {
$t_relationships_html = bug_view_relationship_get_summary_html( $p_bug_id );
$t_relationship_all = relationship_get_all( $p_bug_id, $t_show_project );

if( !$p_can_update && empty( $t_relationships_html ) ) {
if( !$p_can_update && empty( $t_relationship_all ) ) {
return;
}

$t_relationship_graph = ON == config_get( 'relationship_graph_enable' );
$t_event_buttons = event_signal( 'EVENT_MENU_ISSUE_RELATIONSHIP', $p_bug_id );
$t_show_top_div = $p_can_update || $t_relationship_graph || !empty( $t_event_buttons );
?>
<div class="col-md-12 col-xs-12">
<div class="space-10"></div>
Expand All @@ -1030,64 +1029,6 @@ function bug_view_relationship_view_box( $p_bug_id, $p_can_update ) {
</a>
</div>
</div>
<div class="widget-body">
<?php
if( $t_show_top_div ) {
?>
<div class="widget-toolbox padding-8 clearfix">
<?php
# Default relationship buttons
$t_buttons = array();
if( $t_relationship_graph ) {
$t_buttons[lang_get( 'relation_graph' )] =
'bug_relationship_graph.php?bug_id=' . $p_bug_id . '&graph=relation';
$t_buttons[lang_get( 'dependency_graph' )] =
'bug_relationship_graph.php?bug_id=' . $p_bug_id . '&graph=dependency';
}

# Plugin-added buttons
foreach( $t_event_buttons as $t_plugin => $t_plugin_buttons ) {
foreach( $t_plugin_buttons as $t_callback => $t_callback_buttons ) {
if( is_array( $t_callback_buttons ) ) {
$t_buttons = array_merge( $t_buttons, $t_callback_buttons );
}
}
}
?>
<div class="btn-group pull-right noprint">
<?php
# Print the buttons, if any
foreach( $t_buttons as $t_label => $t_url ) {
print_small_button( $t_url, $t_label );
}
?>
</div>

<?php
if( $p_can_update ) {
?>
<form method="post" action="bug_relationship_add.php" class="form-inline noprint">
<?php echo form_security_field( 'bug_relationship_add' ) ?>
<input type="hidden" name="src_bug_id" value="<?php echo $p_bug_id?>" />
<label class="inline"><?php echo lang_get( 'this_bug' ) ?>&#160;&#160;</label>
<?php print_relationship_list_box( config_get( 'default_bug_relationship' ) )?>
<input type="text" class="input-sm" name="dest_bug_id" value="" />
<input type="submit" class="btn btn-primary btn-sm btn-white btn-round" name="add_relationship" value="<?php echo lang_get( 'add_new_relationship_button' )?>" />
</form>
<?php
} # can update
?>
</div>
<?php
} # show top div
?>

<div class="widget-main no-padding">
<div class="table-responsive">
<?php echo $t_relationships_html; ?>
</div>
</div>
</div>
<div class="widget-body" id="relationships-body"></div>
</div>
</div>
Expand Down
65 changes: 44 additions & 21 deletions client/js/components/IssueRelationships.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,21 @@ import { IssueService } from '../services';
import { Relationship } from '../models';

type Props = {
/**
* The flag checking issue can be updated
*/
canUpdate: boolean;

/**
* Config values array from div configs-data
*/
configs: Array<any>;

/**
* Id of issue
* Issue data
*/
issueId: number;
issueData: any;

/**
* Localized strings array from div strings-data
*/
localizedStrings: Array<any>;

/**
* Relationships array from div issue-data
*/
relationships: Array<Relationship>;

/**
* Relationship buttons. Rel graph, Dependency graph, etc
*/
Expand All @@ -49,6 +39,11 @@ type States = {
* Relationship dest ids entered in Add form
*/
reqRelDestIds: string,

/**
* Can resolve bug
*/
canResolve: boolean,
}

enum RelationshipTypeEnum {
Expand All @@ -67,22 +62,40 @@ export class IssueRelationships extends React.Component<Props, States> {
super(props);

this.state = {
relationships: props.relationships,
relationships: props.issueData.issue.relationships,
reqRelTyp: RelationshipTypeEnum.RELATED_TO,
reqRelDestIds: ''
reqRelDestIds: '',
canResolve: true,
};
this.Service = new IssueService(props.issueId);
this.Service = new IssueService(props.issueData.issue.id);
}

componentDidUpdate() {
/*this.setState({
canResolve: this.canResolveBug()
});*/
}

canResolveBug() {
const { relationships } = this.state;

for (const relationship of relationships) {
if (relationship.type.id === this.getConfigValue('default_bug_dependant') &&
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@waltergar We should get the config options once before the loop and have them in variables that are used within the loop.

relationship.issue.status?.id! < this.getConfigValue('bug_resolved_status_threshold'))
return false;
}
return true;
}

getLocalizedString(text: string) {
const index = this.props.localizedStrings.findIndex(x => x.name === text);
if (!index) return undefined;
if (index < 0) return undefined;
return this.props.localizedStrings[index].localized;
}

getConfigValue(option: string) {
const index = this.props.configs.findIndex(x => x.option === option);
if (!index) return undefined;
if (index < 0) return undefined;
return this.props.configs[index].value;
}

Expand Down Expand Up @@ -114,13 +127,16 @@ export class IssueRelationships extends React.Component<Props, States> {

render() {
const { relationships, reqRelDestIds, reqRelTyp } = this.state;
const { canUpdate, relationshipButtons } = this.props;
const canUpdate = this.props.issueData.flags['relationships_can_update'];
const relationshipButtons = Object.entries(this.props.relationshipButtons);

return relationships.length ? (
<React.Fragment>
{(canUpdate || relationshipButtons.length) &&
<div className='widget-toolbox padding-8 clearfix'>
{Object.entries(relationshipButtons).length && (
{relationshipButtons.length && (
<div className='btn-group pull-right noprint'>
{Object.entries(relationshipButtons).map(([key, value]) => (
{relationshipButtons.map(([key, value]) => (
<a className='btn btn-primary btn-white btn-round btn-sm' href={value}>{key}</a>
))}
</div>
Expand Down Expand Up @@ -154,7 +170,7 @@ export class IssueRelationships extends React.Component<Props, States> {
{this.getLocalizedString('add_new_relationship_button')}
</button>
</div>}
</div>
</div>}
<div className='widget-main no-padding'>
<div className='table-responsive'>
<table className='table table-bordered table-condensed table-hover'>
Expand Down Expand Up @@ -192,6 +208,13 @@ export class IssueRelationships extends React.Component<Props, States> {
</td>
</tr>
))}
{(relationships.length && !this.canResolveBug()) && (
<tr>
<td colSpan={5}>
<strong>{this.getLocalizedString('relationship_warning_blocking_bugs_not_resolved')}</strong>
</td>
</tr>
)}
</tbody>
</table>
</div>
Expand Down
7 changes: 3 additions & 4 deletions client/js/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,12 @@ if (document.getElementById('issue-data')) {

if (issueData.issue && issueData.issue.relationships && document.getElementById('relationships-body')) {
const relationshipButtonsData = JSON.parse(document.getElementById('relationship-buttons-data')?.dataset.relationshipButtons!);

ReactDOM.render(
<IssueRelationships
issueId={issueData.issue.id}
canUpdate={issueData.flags['relationships_can_update']}
relationships={issueData.issue.relationships}
localizedStrings={stringsData.strings}
configs={configsData.configs}
issueData={issueData}
localizedStrings={stringsData.strings}
relationshipButtons={relationshipButtonsData}
/>,
document.getElementById('relationships-body'));
Expand Down
7 changes: 7 additions & 0 deletions config_defaults_inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -1413,6 +1413,12 @@
*/
$g_default_bug_view_status = VS_PUBLIC;

/**
* Default Bug dependent
* @global integer $g_default_bug_dependant
*/
$g_default_bug_dependant = BUG_DEPENDANT;
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@waltergar There should be no need for us to add config options since we are trying to have parity with the existing system that didn't need such config.


/**
* Default value for bug description field used on bug report page.
*
Expand Down Expand Up @@ -4412,6 +4418,7 @@
'date_partitions',
'datetime_picker_format',
'default_bug_additional_info',
'default_bug_dependant',
'default_bug_description',
'default_bug_eta',
'default_bug_priority',
Expand Down