2011-04-04 04:20:47 +02:00
|
|
|
/**
|
|
|
|
* @requires multirow-row-manager
|
Bring Javelin into Phabricator via git submodule, not copy-and-paste
Summary:
Javelin is currently embedded in Phabricator via copy-and-paste of prebuilt
packages. This is not so great.
Pull it in as a submodule instead and make all the Phabriator resources declare
proper dependency trees. Add Javelin linting.
Test Plan:
I tried to run through pretty much all the JS functionality on the site. This is
still a high-risk change, but I did a pretty thorough test
Differential: inline comments, revealing diffs, list tokenizers, comment
preview, editing/deleting comments, add review action.
Maniphest: list tokenizer, comment actions
Herald: rule editing, tokenizers, add/remove rows
Reviewed By: tomo
Reviewers: aran, tomo, mroch, jungejason, tuomaspelkonen
CC: aran, tomo, epriestley
Differential Revision: 223
2011-05-04 00:11:55 +02:00
|
|
|
* javelin-install
|
2011-04-04 04:20:47 +02:00
|
|
|
* path-typeahead
|
Bring Javelin into Phabricator via git submodule, not copy-and-paste
Summary:
Javelin is currently embedded in Phabricator via copy-and-paste of prebuilt
packages. This is not so great.
Pull it in as a submodule instead and make all the Phabriator resources declare
proper dependency trees. Add Javelin linting.
Test Plan:
I tried to run through pretty much all the JS functionality on the site. This is
still a high-risk change, but I did a pretty thorough test
Differential: inline comments, revealing diffs, list tokenizers, comment
preview, editing/deleting comments, add review action.
Maniphest: list tokenizer, comment actions
Herald: rule editing, tokenizers, add/remove rows
Reviewed By: tomo
Reviewers: aran, tomo, mroch, jungejason, tuomaspelkonen
CC: aran, tomo, epriestley
Differential Revision: 223
2011-05-04 00:11:55 +02:00
|
|
|
* javelin-dom
|
|
|
|
* javelin-util
|
2012-12-07 02:23:56 +01:00
|
|
|
* phabricator-prefab
|
Use a tokenizer, not a gigantic poorly-ordered "<select />", to choose repositories in Owners
Summary: Depends on D19190. Fixes T12590. Ref T13099. Replaces the barely-usable, gigantic, poorly ordered "<select />" control with a tokenizer. Attempts to fix various minor issues.
Test Plan:
- Edited paths: include/exclude paths, from different repositories, different actual paths.
- Used "Add New Path" to add rows, got repository selector prepopulated with last value.
- Used "remove".
- Used validation typeahead, got reasonable behaviors?
The error behavior if you delete the repository for a path is a little sketchy still, but roughly okay.
Maniphest Tasks: T13099, T12590
Differential Revision: https://secure.phabricator.com/D19191
2018-03-08 02:29:06 +01:00
|
|
|
* phuix-form-control-view
|
2011-04-04 04:20:47 +02:00
|
|
|
* @provides owners-path-editor
|
|
|
|
* @javelin
|
|
|
|
*/
|
|
|
|
|
|
|
|
JX.install('OwnersPathEditor', {
|
|
|
|
construct : function(config) {
|
|
|
|
var root = JX.$(config.root);
|
|
|
|
|
|
|
|
this._rowManager = new JX.MultirowRowManager(
|
|
|
|
JX.DOM.find(root, 'table', config.table));
|
|
|
|
|
|
|
|
JX.DOM.listen(
|
|
|
|
JX.DOM.find(root, 'a', config.add_button),
|
|
|
|
'click',
|
|
|
|
null,
|
|
|
|
JX.bind(this, this._onaddpath));
|
|
|
|
|
|
|
|
this._count = 0;
|
|
|
|
this._inputTemplate = config.input_template;
|
Use a tokenizer, not a gigantic poorly-ordered "<select />", to choose repositories in Owners
Summary: Depends on D19190. Fixes T12590. Ref T13099. Replaces the barely-usable, gigantic, poorly ordered "<select />" control with a tokenizer. Attempts to fix various minor issues.
Test Plan:
- Edited paths: include/exclude paths, from different repositories, different actual paths.
- Used "Add New Path" to add rows, got repository selector prepopulated with last value.
- Used "remove".
- Used validation typeahead, got reasonable behaviors?
The error behavior if you delete the repository for a path is a little sketchy still, but roughly okay.
Maniphest Tasks: T13099, T12590
Differential Revision: https://secure.phabricator.com/D19191
2018-03-08 02:29:06 +01:00
|
|
|
this._repositoryTokenizerSpec = config.repositoryTokenizerSpec;
|
2011-04-04 04:20:47 +02:00
|
|
|
|
|
|
|
this._completeURI = config.completeURI;
|
|
|
|
this._validateURI = config.validateURI;
|
Use a tokenizer, not a gigantic poorly-ordered "<select />", to choose repositories in Owners
Summary: Depends on D19190. Fixes T12590. Ref T13099. Replaces the barely-usable, gigantic, poorly ordered "<select />" control with a tokenizer. Attempts to fix various minor issues.
Test Plan:
- Edited paths: include/exclude paths, from different repositories, different actual paths.
- Used "Add New Path" to add rows, got repository selector prepopulated with last value.
- Used "remove".
- Used validation typeahead, got reasonable behaviors?
The error behavior if you delete the repository for a path is a little sketchy still, but roughly okay.
Maniphest Tasks: T13099, T12590
Differential Revision: https://secure.phabricator.com/D19191
2018-03-08 02:29:06 +01:00
|
|
|
this._icons = config.icons;
|
|
|
|
this._modeOptions = config.modeOptions;
|
2011-04-04 04:20:47 +02:00
|
|
|
|
|
|
|
this._initializePaths(config.pathRefs);
|
|
|
|
},
|
|
|
|
members : {
|
|
|
|
/*
|
|
|
|
* MultirowRowManager for controlling add/remove behavior
|
|
|
|
*/
|
|
|
|
_rowManager : null,
|
|
|
|
|
|
|
|
/*
|
|
|
|
* How many rows have been created, for form name generation.
|
|
|
|
*/
|
|
|
|
_count : 0,
|
|
|
|
/*
|
|
|
|
* URL for the typeahead datasource.
|
|
|
|
*/
|
|
|
|
_completeURI : null,
|
|
|
|
/*
|
|
|
|
* URL for path validation requests.
|
|
|
|
*/
|
|
|
|
_validateURI : null,
|
|
|
|
/*
|
|
|
|
* Template typeahead markup to be copied per row.
|
|
|
|
*/
|
|
|
|
_inputTemplate : null,
|
|
|
|
/*
|
|
|
|
* Most packages will be in one repository, so remember whenever
|
|
|
|
* the user chooses a repository, and use that repository as the
|
|
|
|
* default for future rows.
|
|
|
|
*/
|
|
|
|
_lastRepositoryChoice : null,
|
Use a tokenizer, not a gigantic poorly-ordered "<select />", to choose repositories in Owners
Summary: Depends on D19190. Fixes T12590. Ref T13099. Replaces the barely-usable, gigantic, poorly ordered "<select />" control with a tokenizer. Attempts to fix various minor issues.
Test Plan:
- Edited paths: include/exclude paths, from different repositories, different actual paths.
- Used "Add New Path" to add rows, got repository selector prepopulated with last value.
- Used "remove".
- Used validation typeahead, got reasonable behaviors?
The error behavior if you delete the repository for a path is a little sketchy still, but roughly okay.
Maniphest Tasks: T13099, T12590
Differential Revision: https://secure.phabricator.com/D19191
2018-03-08 02:29:06 +01:00
|
|
|
_icons: null,
|
|
|
|
_modeOptions: null,
|
2011-04-04 04:20:47 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Initialize with 0 or more rows.
|
|
|
|
* Adds one initial row if none are given.
|
|
|
|
*/
|
|
|
|
_initializePaths : function(path_refs) {
|
|
|
|
for (var k in path_refs) {
|
|
|
|
this.addPath(path_refs[k]);
|
|
|
|
}
|
|
|
|
if (!JX.keys(path_refs).length) {
|
|
|
|
this.addPath();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Build a row.
|
|
|
|
*/
|
|
|
|
addPath : function(path_ref) {
|
|
|
|
// Smart default repository. See _lastRepositoryChoice.
|
|
|
|
if (path_ref) {
|
Use a tokenizer, not a gigantic poorly-ordered "<select />", to choose repositories in Owners
Summary: Depends on D19190. Fixes T12590. Ref T13099. Replaces the barely-usable, gigantic, poorly ordered "<select />" control with a tokenizer. Attempts to fix various minor issues.
Test Plan:
- Edited paths: include/exclude paths, from different repositories, different actual paths.
- Used "Add New Path" to add rows, got repository selector prepopulated with last value.
- Used "remove".
- Used validation typeahead, got reasonable behaviors?
The error behavior if you delete the repository for a path is a little sketchy still, but roughly okay.
Maniphest Tasks: T13099, T12590
Differential Revision: https://secure.phabricator.com/D19191
2018-03-08 02:29:06 +01:00
|
|
|
this._lastRepositoryChoice = path_ref.repositoryValue;
|
|
|
|
} else {
|
|
|
|
path_ref = {
|
|
|
|
repositoryValue: this._lastRepositoryChoice || {}
|
|
|
|
};
|
2011-04-04 04:20:47 +02:00
|
|
|
}
|
|
|
|
|
Use a tokenizer, not a gigantic poorly-ordered "<select />", to choose repositories in Owners
Summary: Depends on D19190. Fixes T12590. Ref T13099. Replaces the barely-usable, gigantic, poorly ordered "<select />" control with a tokenizer. Attempts to fix various minor issues.
Test Plan:
- Edited paths: include/exclude paths, from different repositories, different actual paths.
- Used "Add New Path" to add rows, got repository selector prepopulated with last value.
- Used "remove".
- Used validation typeahead, got reasonable behaviors?
The error behavior if you delete the repository for a path is a little sketchy still, but roughly okay.
Maniphest Tasks: T13099, T12590
Differential Revision: https://secure.phabricator.com/D19191
2018-03-08 02:29:06 +01:00
|
|
|
var repo = this._newRepoCell(path_ref.repositoryValue);
|
|
|
|
var path = this._newPathCell(path_ref.display);
|
|
|
|
var icon = this._newIconCell();
|
|
|
|
var mode_cell = this._newModeCell(path_ref.excluded);
|
2012-12-07 02:23:56 +01:00
|
|
|
|
2011-04-04 04:20:47 +02:00
|
|
|
var row = this._rowManager.addRow(
|
Use a tokenizer, not a gigantic poorly-ordered "<select />", to choose repositories in Owners
Summary: Depends on D19190. Fixes T12590. Ref T13099. Replaces the barely-usable, gigantic, poorly ordered "<select />" control with a tokenizer. Attempts to fix various minor issues.
Test Plan:
- Edited paths: include/exclude paths, from different repositories, different actual paths.
- Used "Add New Path" to add rows, got repository selector prepopulated with last value.
- Used "remove".
- Used validation typeahead, got reasonable behaviors?
The error behavior if you delete the repository for a path is a little sketchy still, but roughly okay.
Maniphest Tasks: T13099, T12590
Differential Revision: https://secure.phabricator.com/D19191
2018-03-08 02:29:06 +01:00
|
|
|
[
|
|
|
|
mode_cell,
|
|
|
|
repo.cell,
|
|
|
|
path.cell,
|
|
|
|
icon.cell
|
|
|
|
]);
|
2011-04-04 04:20:47 +02:00
|
|
|
|
|
|
|
new JX.PathTypeahead({
|
Use a tokenizer, not a gigantic poorly-ordered "<select />", to choose repositories in Owners
Summary: Depends on D19190. Fixes T12590. Ref T13099. Replaces the barely-usable, gigantic, poorly ordered "<select />" control with a tokenizer. Attempts to fix various minor issues.
Test Plan:
- Edited paths: include/exclude paths, from different repositories, different actual paths.
- Used "Add New Path" to add rows, got repository selector prepopulated with last value.
- Used "remove".
- Used validation typeahead, got reasonable behaviors?
The error behavior if you delete the repository for a path is a little sketchy still, but roughly okay.
Maniphest Tasks: T13099, T12590
Differential Revision: https://secure.phabricator.com/D19191
2018-03-08 02:29:06 +01:00
|
|
|
repositoryTokenizer: repo.tokenizer,
|
|
|
|
path_input : path.input,
|
|
|
|
hardpoint : path.hardpoint,
|
|
|
|
error_display : icon.cell,
|
2011-04-04 04:20:47 +02:00
|
|
|
completeURI : this._completeURI,
|
Use a tokenizer, not a gigantic poorly-ordered "<select />", to choose repositories in Owners
Summary: Depends on D19190. Fixes T12590. Ref T13099. Replaces the barely-usable, gigantic, poorly ordered "<select />" control with a tokenizer. Attempts to fix various minor issues.
Test Plan:
- Edited paths: include/exclude paths, from different repositories, different actual paths.
- Used "Add New Path" to add rows, got repository selector prepopulated with last value.
- Used "remove".
- Used validation typeahead, got reasonable behaviors?
The error behavior if you delete the repository for a path is a little sketchy still, but roughly okay.
Maniphest Tasks: T13099, T12590
Differential Revision: https://secure.phabricator.com/D19191
2018-03-08 02:29:06 +01:00
|
|
|
validateURI : this._validateURI,
|
|
|
|
icons: this._icons
|
2018-03-08 01:41:35 +01:00
|
|
|
}).start();
|
2011-04-04 04:20:47 +02:00
|
|
|
|
|
|
|
this._count++;
|
|
|
|
return row;
|
|
|
|
},
|
|
|
|
|
|
|
|
_onaddpath : function(e) {
|
|
|
|
e.kill();
|
|
|
|
this.addPath();
|
|
|
|
},
|
|
|
|
|
Use a tokenizer, not a gigantic poorly-ordered "<select />", to choose repositories in Owners
Summary: Depends on D19190. Fixes T12590. Ref T13099. Replaces the barely-usable, gigantic, poorly ordered "<select />" control with a tokenizer. Attempts to fix various minor issues.
Test Plan:
- Edited paths: include/exclude paths, from different repositories, different actual paths.
- Used "Add New Path" to add rows, got repository selector prepopulated with last value.
- Used "remove".
- Used validation typeahead, got reasonable behaviors?
The error behavior if you delete the repository for a path is a little sketchy still, but roughly okay.
Maniphest Tasks: T13099, T12590
Differential Revision: https://secure.phabricator.com/D19191
2018-03-08 02:29:06 +01:00
|
|
|
_newModeCell: function(value) {
|
|
|
|
var options = this._modeOptions;
|
|
|
|
|
|
|
|
var name = 'exclude[' + this._count + ']';
|
|
|
|
|
|
|
|
var control = JX.Prefab.renderSelect(options, value, {name: name});
|
|
|
|
|
|
|
|
return JX.$N(
|
|
|
|
'td',
|
|
|
|
{
|
|
|
|
className: 'owners-path-mode-control'
|
|
|
|
},
|
|
|
|
control);
|
|
|
|
},
|
|
|
|
|
|
|
|
_newRepoCell: function(value) {
|
|
|
|
var repo_control = new JX.PHUIXFormControl()
|
|
|
|
.setControl('tokenizer', this._repositoryTokenizerSpec)
|
|
|
|
.setValue(value);
|
|
|
|
|
|
|
|
var repo_tokenizer = repo_control.getTokenizer();
|
|
|
|
var name = 'repo[' + this._count + ']';
|
|
|
|
|
|
|
|
function get_phid() {
|
|
|
|
var phids = repo_control.getValue();
|
|
|
|
if (!phids.length) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
return phids[0];
|
2011-04-04 04:20:47 +02:00
|
|
|
}
|
Use a tokenizer, not a gigantic poorly-ordered "<select />", to choose repositories in Owners
Summary: Depends on D19190. Fixes T12590. Ref T13099. Replaces the barely-usable, gigantic, poorly ordered "<select />" control with a tokenizer. Attempts to fix various minor issues.
Test Plan:
- Edited paths: include/exclude paths, from different repositories, different actual paths.
- Used "Add New Path" to add rows, got repository selector prepopulated with last value.
- Used "remove".
- Used validation typeahead, got reasonable behaviors?
The error behavior if you delete the repository for a path is a little sketchy still, but roughly okay.
Maniphest Tasks: T13099, T12590
Differential Revision: https://secure.phabricator.com/D19191
2018-03-08 02:29:06 +01:00
|
|
|
|
|
|
|
var input = JX.$N(
|
|
|
|
'input',
|
|
|
|
{
|
|
|
|
type: 'hidden',
|
|
|
|
name: name,
|
|
|
|
value: get_phid()
|
|
|
|
});
|
|
|
|
|
|
|
|
repo_tokenizer.listen('change', JX.bind(this, function() {
|
|
|
|
this._lastRepositoryChoice = repo_tokenizer.getTokens();
|
|
|
|
|
|
|
|
input.value = get_phid();
|
|
|
|
}));
|
|
|
|
|
|
|
|
var cell = JX.$N(
|
|
|
|
'td',
|
|
|
|
{
|
|
|
|
className: 'owners-path-repo-control'
|
|
|
|
},
|
|
|
|
[
|
|
|
|
repo_control.getRawInputNode(),
|
|
|
|
input
|
|
|
|
]);
|
|
|
|
|
|
|
|
return {
|
|
|
|
cell: cell,
|
|
|
|
tokenizer: repo_tokenizer
|
|
|
|
};
|
|
|
|
},
|
|
|
|
|
|
|
|
_newPathCell: function(value) {
|
|
|
|
var path_cell = JX.$N(
|
|
|
|
'td',
|
|
|
|
{
|
|
|
|
className: 'owners-path-path-control'
|
|
|
|
},
|
|
|
|
JX.$H(this._inputTemplate));
|
|
|
|
|
|
|
|
var path_input = JX.DOM.find(path_cell, 'input');
|
|
|
|
|
|
|
|
JX.copy(
|
|
|
|
path_input,
|
|
|
|
{
|
|
|
|
value: value || '',
|
|
|
|
name: 'path[' + this._count + ']'
|
|
|
|
});
|
|
|
|
|
|
|
|
var hardpoint = JX.DOM.find(
|
|
|
|
path_cell,
|
|
|
|
'div',
|
|
|
|
'typeahead-hardpoint');
|
|
|
|
|
|
|
|
return {
|
|
|
|
cell: path_cell,
|
|
|
|
input: path_input,
|
|
|
|
hardpoint: hardpoint
|
|
|
|
};
|
|
|
|
},
|
|
|
|
|
|
|
|
_newIconCell: function() {
|
|
|
|
var cell = JX.$N(
|
|
|
|
'td',
|
|
|
|
{
|
|
|
|
className: 'owners-path-icon-control'
|
|
|
|
});
|
|
|
|
|
|
|
|
return {
|
|
|
|
cell: cell
|
|
|
|
};
|
2011-04-04 04:20:47 +02:00
|
|
|
}
|
Use a tokenizer, not a gigantic poorly-ordered "<select />", to choose repositories in Owners
Summary: Depends on D19190. Fixes T12590. Ref T13099. Replaces the barely-usable, gigantic, poorly ordered "<select />" control with a tokenizer. Attempts to fix various minor issues.
Test Plan:
- Edited paths: include/exclude paths, from different repositories, different actual paths.
- Used "Add New Path" to add rows, got repository selector prepopulated with last value.
- Used "remove".
- Used validation typeahead, got reasonable behaviors?
The error behavior if you delete the repository for a path is a little sketchy still, but roughly okay.
Maniphest Tasks: T13099, T12590
Differential Revision: https://secure.phabricator.com/D19191
2018-03-08 02:29:06 +01:00
|
|
|
|
2011-04-04 04:20:47 +02:00
|
|
|
}
|
Use a tokenizer, not a gigantic poorly-ordered "<select />", to choose repositories in Owners
Summary: Depends on D19190. Fixes T12590. Ref T13099. Replaces the barely-usable, gigantic, poorly ordered "<select />" control with a tokenizer. Attempts to fix various minor issues.
Test Plan:
- Edited paths: include/exclude paths, from different repositories, different actual paths.
- Used "Add New Path" to add rows, got repository selector prepopulated with last value.
- Used "remove".
- Used validation typeahead, got reasonable behaviors?
The error behavior if you delete the repository for a path is a little sketchy still, but roughly okay.
Maniphest Tasks: T13099, T12590
Differential Revision: https://secure.phabricator.com/D19191
2018-03-08 02:29:06 +01:00
|
|
|
|
2011-04-04 04:20:47 +02:00
|
|
|
});
|