Skip to content
This repository was archived by the owner on May 10, 2024. It is now read-only.

Commit 2c9f600

Browse files
authored
Merge pull request #507 from mulesoft/xmas
Xmas
2 parents 9143e4b + 75fcaa4 commit 2c9f600

17 files changed

+15700
-5144
lines changed

.travis.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
sudo: false
22
language: node_js
33
node_js:
4-
- "4.4"
4+
- "8"
55
before_script:
66
- npm install -g grunt-cli
77
- npm install -g bower
88
- bower update
9-
- node_modules/grunt-protractor-runner/node_modules/protractor/bin/webdriver-manager update
109
before_install:
1110
- "export DISPLAY=:99.0"
1211
- "sh -e /etc/init.d/xvfb start"

app/scripts/services/local-storage-file-system.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -304,8 +304,8 @@
304304
// }
305305
//move all child items
306306
localStorageHelper.forEach(function (entry) {
307-
if (entry.path.toLowerCase() !== source.toLowerCase() &&
308-
entry.path.indexOf(source) === 0) {
307+
if (entry.path.toLowerCase() !== destination.toLowerCase() &&
308+
entry.path.indexOf(source + '/') === 0) {
309309
var newPath = destination + entry.path.substring(source.length);
310310
localStorageHelper.remove(entry.path);
311311
entry.path = newPath;

app/scripts/services/mocking-service-client.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@
66
var self = this;
77

88
self.proxy = null;
9-
// self.baseUri = 'http://mocksvc.mulesoft.com';
10-
self.baseUri = 'http://ec2-52-201-242-128.compute-1.amazonaws.com';
11-
9+
self.baseUri = 'https://mocksvc.qax.mulesoft.com';
1210
self.buildURL = function buildURL() {
1311
var url = self.baseUri + ['/mocks'].concat(Array.prototype.slice.call(arguments, 0)).join('/');
1412
var proxy = self.proxy || $window.RAML.Settings.proxy;

app/scripts/services/raml-repository.js

Lines changed: 76 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@
3737
return file.path.slice(-5) !== '.meta';
3838
}
3939

40+
function metaFile(file) {
41+
return !notMetaFile(file);
42+
}
43+
4044
function handleErrorFor(file) {
4145
return function markFileWithError(error) {
4246
file.error = error;
@@ -144,15 +148,20 @@
144148
separated[entry.type || 'file'].push(entry);
145149
});
146150

147-
var files = separated.file.filter(notMetaFile).map(function (file) {
151+
var createRamlFile = function (file) {
148152
return new RamlFile(file.path, file.contents, { dirty: false, persisted: true, root: file.root} );
149-
});
153+
};
154+
155+
var files = separated.file.filter(notMetaFile).map(createRamlFile);
156+
157+
var metaFiles = separated.file.filter(metaFile).map(createRamlFile);
150158

151159
var directories = separated.folder.map(function (directory) {
152160
return new RamlDirectory(directory.path, directory.meta, directory.children);
153161
});
154162

155163
this.children = directories.concat(files).sort(sortingFunction);
164+
this.metaChildren = directories.concat(metaFiles).sort(sortingFunction);
156165
}
157166

158167
RamlDirectory.prototype.getDirectories = function getDirectories() {
@@ -163,22 +172,34 @@
163172
return this.children.filter(function(t) { return !t.isDirectory; });
164173
};
165174

166-
RamlDirectory.prototype.forEachChildDo = function forEachChildDo(action) {
175+
RamlDirectory.prototype.getMetaFiles = function getMetaFiles() {
176+
return this.metaChildren.filter(function(t) { return !t.isDirectory; });
177+
};
178+
179+
RamlDirectory.prototype.forEachItemDo = function forEachItemDo(action, isMetaChildren) {
167180
// BFS
168-
var queue = this.children.slice();
181+
var queue = isMetaChildren ? this.metaChildren.slice() : this.children.slice();
169182
var current;
170183

171184
while (queue.length > 0) {
172185
current = queue.shift();
173186

174187
if (current.isDirectory) {
175-
queue = queue.concat(current.children);
188+
queue = queue.concat((isMetaChildren) ? current.metaChildren : current.children);
176189
}
177190

178191
action.call(current, current);
179192
}
180193
};
181194

195+
RamlDirectory.prototype.forEachChildDo = function forEachChildDo(action) {
196+
this.forEachItemDo(action, false);
197+
};
198+
199+
RamlDirectory.prototype.forEachMetaChildDo = function forEachChildDo(action) {
200+
this.forEachItemDo(action, true);
201+
};
202+
182203
RamlDirectory.prototype.sortChildren = function sortChildren() {
183204
this.children.sort(sortingFunction);
184205
};
@@ -248,7 +269,8 @@
248269
// and collect all promises into an array
249270
var promises = [];
250271
directory.getDirectories().forEach(function(dir) { promises.push(service.removeDirectory(dir)); });
251-
directory.getFiles().forEach(function(file) { promises.push(service.removeFile(file)); });
272+
directory.getFiles().concat(directory.getMetaFiles())
273+
.forEach(function(file) { promises.push(service.removeFile(file)); });
252274

253275
// remove this directory object from parent's children list
254276
var parent = service.getParent(directory);
@@ -353,10 +375,18 @@
353375
.then(modifyFile, handleErrorFor(file))
354376
.then(function () {
355377
// remove the file object from the parent's children list
356-
var index = parent.children.indexOf(file);
378+
if (notMetaFile(file)) {
379+
var index = parent.children.indexOf(file);
357380

358-
if (index !== -1) {
359-
parent.children.splice(index, 1);
381+
if (index !== -1) {
382+
parent.children.splice(index, 1);
383+
}
384+
} else {
385+
var metaIndex = parent.metaChildren.indexOf(file);
386+
387+
if (metaIndex !== -1) {
388+
parent.metaChildren.splice(metaIndex, 1);
389+
}
360390
}
361391

362392
$rootScope.$broadcast('event:raml-editor-file-removed', file);
@@ -458,7 +488,13 @@
458488
target.forEachChildDo(function(c) {
459489
c.path = c.path.replace(target.path, newPath);
460490
});
491+
492+
// renames the path of each meta child under the current directory
493+
target.forEachMetaChildDo(function(c) {
494+
c.path = c.path.replace(target.path, newPath);
495+
});
461496
} else {
497+
service.moveMeta(target, destination);
462498
promise = target.persisted ? fileSystem.rename(target.path, newPath) : $q.when(target);
463499
}
464500

@@ -475,6 +511,8 @@
475511
var metaFile = new RamlFile(file.path + '.meta', JSON.stringify(meta));
476512
return service.saveFile(metaFile)
477513
.then(function () {
514+
var parent = service.getParent(metaFile);
515+
parent.metaChildren.push(metaFile);
478516
return meta;
479517
})
480518
;
@@ -493,6 +531,35 @@
493531
);
494532
};
495533

534+
service.moveMeta = function moveMeta(file, destination) {
535+
var metaName = file.name + '.meta';
536+
var newMetaPath = service.join(destination.path, metaName);
537+
var metaPathName = file.path + '.meta';
538+
var oldParent = service.getParent(file);
539+
540+
var metaFile = oldParent.metaChildren.find(function(meta) {
541+
return meta.path === metaPathName;
542+
});
543+
544+
if (metaFile) {
545+
return fileSystem.rename(metaFile.path, newMetaPath).then(
546+
function success() {
547+
//Remove old parent meta data
548+
var index = oldParent.metaChildren.indexOf(metaFile);
549+
if (index !== -1) {
550+
oldParent.metaChildren.splice(index, 1);
551+
}
552+
metaFile.path = newMetaPath;
553+
destination.metaChildren.push(metaFile);
554+
return metaFile;
555+
},
556+
function failure() {
557+
return metaFile;
558+
}
559+
);
560+
}
561+
};
562+
496563
service.join = function () {
497564
return Array.prototype.reduce.call(arguments, function (path, segment) {
498565
if (segment == null) {

bower.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "api-designer",
3-
"version": "0.4.7",
3+
"version": "0.4.8",
44
"repository": {
55
"type": "git",
66
"url": "https://github.com/mulesoft/api-designer.git"
@@ -10,7 +10,7 @@
1010
"angular": "~1.3.17",
1111
"angular-bootstrap": ">=0.11.0 <0.14.0",
1212
"angular-ui-tree": "2.1.5",
13-
"api-console": "mulesoft/api-console#v3.0.22",
13+
"api-console": "mulesoft/api-console#v3.0.25",
1414
"es5-shim": "~2.3.0",
1515
"file-saver.js": "~1.20150304.1",
1616
"font-awesome": "~4.0.3",

dist/scripts/api-designer-parser.js

Lines changed: 74 additions & 73 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/scripts/api-designer-parser.min.js

Lines changed: 58 additions & 57 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)