initialize: function () {
this.listenTo(this.options.app.profiles, 'select', this.onProfileSelect);
- this.listenTo(this.options.app.profiles, 'copy', this.onProfileCopy);
this.listenTo(this.options.app.profiles, 'setAsDefault', this.onProfileSetAsDefault);
this.listenTo(this.options.app.profiles, 'destroy', this.onProfileDestroy);
},
});
},
- onProfileCopy: function (name, profile) {
- var that = this,
- lang = profile.get('language');
- this.fetchProfiles().done(function () {
- var newProfile = that.options.app.profiles.findWhere({ language: lang, name: name });
- if (newProfile != null) {
- newProfile.trigger('select', newProfile);
- }
- });
- },
-
onProfileSetAsDefault: function (profile) {
var that = this,
url = baseUrl + '/api/qualityprofiles/set_default',
*/
define([
'common/modal-form',
+ 'quality-profiles/profile',
'templates/quality-profiles'
-], function (ModalFormView) {
+], function (ModalFormView, Profile) {
var $ = jQuery;
// do not show global error
400: null
}
- }).done(function () {
- // TODO open new profile using key from response
- that.model.trigger('copy', name, that.model);
+ }).done(function (r) {
+ that.addProfile(r);
that.close();
}).fail(function (jqXHR) {
that.showErrors(jqXHR.responseJSON.errors, jqXHR.responseJSON.warnings);
});
+ },
+
+ addProfile: function (profileData) {
+ var profile = new Profile(profileData);
+ this.model.collection.add([profile]);
+ profile.trigger('select', profile);
}
});
.start(lib.buildUrl('quality_profiles'), function () {
lib.setDefaultViewport();
- this.searchMock = lib.mockRequestFromFile('/api/qualityprofiles/search', 'search.json');
+ lib.mockRequestFromFile('/api/qualityprofiles/search', 'search.json');
lib.mockRequestFromFile('/api/rules/search', 'rules.json');
- lib.mockRequest('/api/qualityprofiles/copy', '{}');
+ lib.mockRequestFromFile('/api/qualityprofiles/copy', 'copy.json');
})
.then(function () {
})
.then(function () {
- lib.clearRequestMock(this.searchMock);
- lib.mockRequestFromFile('/api/qualityprofiles/search', 'search-with-copy.json');
-
casper.evaluate(function () {
jQuery('#copy-name').val('Copied Profile');
});
--- /dev/null
+{
+ "key": "java-copied-profile-11711",
+ "name": "Copied Profile",
+ "activeRuleCount": 161,
+ "language": "java",
+ "languageName": "Java",
+ "isInherited": false
+}