Skip to content

Commit

Permalink
#394 added folder completions on the move wizard
Browse files Browse the repository at this point in the history
  • Loading branch information
jstrachan committed Jul 16, 2013
1 parent 7a0485c commit 2146e47
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 22 deletions.
58 changes: 40 additions & 18 deletions hawtio-web/src/main/webapp/app/git/js/git.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,52 +5,63 @@ module Git {
* file and source control system which is versioned
*/
export interface GitRepository {

/**
* Returns the file metadata if the file or directory exists or null if it does not exist
*/
exists(branch:string, path:string, fn);

/**
* Read the contents of a file or directory
* with text or children being returned and a directory flag
*/
read(branch:string, path:string, fn): void;
read(branch:string, path:string, fn);

/**
* Completes the available path or file names given the branch and completion text
*/
completePath(branch:string, completionText:string, directoriesOnly:boolean, fn);

/**
* Write the content of a file
*/
write(branch:string, path:string, commitMessage:string, contents:string, fn): void;
write(branch:string, path:string, commitMessage:string, contents:string, fn);

/**
* Reverts to a specific version of the file
*/
revertTo(objectId:string, blobPath:string, commitMessage:string, fn): void;
revertTo(objectId:string, blobPath:string, commitMessage:string, fn);

/**
* Renames a file or moves a file to a new location
*/
rename(branch:string, oldPath:string, newPath:string, commitMessage:string, fn): void;
rename(branch:string, oldPath:string, newPath:string, commitMessage:string, fn);

/**
* Removes a file if it exists
*/
remove(branch:string, path:string, commitMessage:string, fn): void;
remove(branch:string, path:string, commitMessage:string, fn);


/**
* returns the commit history of a directory or file
*/
history(objectId:string, path:string, limit:number, fn): void;
history(objectId:string, path:string, limit:number, fn);

/**
* Get the contents of a blobPath for a given commit objectId
*/
getContent(objectId:string, blobPath:string, fn): void;
getContent(objectId:string, blobPath:string, fn);

/**
* Get the JSON contents of children in a directory matching a name wildcard and content search
*/
readJsonChildContent(path:string, nameWildcard:string, search:string, fn): void;
readJsonChildContent(path:string, nameWildcard:string, search:string, fn);

/**
* Returns the diff of this commit verses the previous or another commit
*/
diff(objectId:string, baseObjectId:string, path:string, fn): void;
diff(objectId:string, baseObjectId:string, path:string, fn);

/**
* Returns the user name
Expand All @@ -71,65 +82,76 @@ module Git {
constructor(public mbean:string, public jolokia, public localStorage, public branch = "master") {
}

public exists(branch:string, path:string, fn) {
return this.jolokia.execute(this.mbean, "exists", branch, path, onSuccess(fn));
}

public read(branch:string, path:string, fn) {
this.jolokia.execute(this.mbean, "read", branch, path, onSuccess(fn));
return this.jolokia.execute(this.mbean, "read", branch, path, onSuccess(fn));
}

public write(branch:string, path:string, commitMessage:string, contents:string, fn) {
var authorName = this.getUserName();
var authorEmail = this.getUserEmail();

this.jolokia.execute(this.mbean, "write", this.branch, path, commitMessage, authorName, authorEmail, contents, onSuccess(fn));
return this.jolokia.execute(this.mbean, "write", this.branch, path, commitMessage, authorName, authorEmail, contents, onSuccess(fn));
}

public revertTo(objectId:string, blobPath:string, commitMessage:string, fn) {
var authorName = this.getUserName();
var authorEmail = this.getUserEmail();

this.jolokia.execute(this.mbean, "revertTo", this.branch, objectId, blobPath, commitMessage, authorName, authorEmail, onSuccess(fn));
return this.jolokia.execute(this.mbean, "revertTo", this.branch, objectId, blobPath, commitMessage, authorName, authorEmail, onSuccess(fn));
}

public rename(branch:string, oldPath: string, newPath:string, commitMessage:string, fn) {
var authorName = this.getUserName();
var authorEmail = this.getUserEmail();

this.jolokia.execute(this.mbean, "rename", branch, oldPath, newPath, commitMessage, authorName, authorEmail, onSuccess(fn));
return this.jolokia.execute(this.mbean, "rename", branch, oldPath, newPath, commitMessage, authorName, authorEmail, onSuccess(fn));
}

public remove(branch:string, path:string, commitMessage:string, fn) {
var authorName = this.getUserName();
var authorEmail = this.getUserEmail();

this.jolokia.execute(this.mbean, "remove", branch, path, commitMessage, authorName, authorEmail, onSuccess(fn));
return this.jolokia.execute(this.mbean, "remove", branch, path, commitMessage, authorName, authorEmail, onSuccess(fn));
}

/**
* Completes the available path or file names given the branch and completion text
*/
public completePath(branch:string, completionText:string, directoriesOnly:boolean, fn) {
return this.jolokia.execute(this.mbean, "completePath", branch, completionText, directoriesOnly, onSuccess(fn));
}

/**
* Return the history of the repository or a specific directory or file path
*/
public history(objectId:string, path:string, limit:number, fn) {
this.jolokia.execute(this.mbean, "history", objectId, path, limit, onSuccess(fn));
return this.jolokia.execute(this.mbean, "history", objectId, path, limit, onSuccess(fn));
}

/**
* Returns a diff
*/
public diff(objectId:string, baseObjectId:string, path:string, fn) {
this.jolokia.execute(this.mbean, "diff", objectId, baseObjectId, path, onSuccess(fn));
return this.jolokia.execute(this.mbean, "diff", objectId, baseObjectId, path, onSuccess(fn));
}

/**
* Get the contents of a blobPath for a given commit objectId
*/
public getContent(objectId:string, blobPath:string, fn) {
this.jolokia.execute(this.mbean, "getContent", objectId, blobPath, onSuccess(fn));
return this.jolokia.execute(this.mbean, "getContent", objectId, blobPath, onSuccess(fn));
}


/**
* Get the JSON contents of children in a directory matching a name wildcard and content search
*/
public readJsonChildContent(path:string, nameWildcard:string, search:string, fn) {
this.jolokia.execute(this.mbean, "readJsonChildContent", this.branch, path, nameWildcard, search, onSuccess(fn));
return this.jolokia.execute(this.mbean, "readJsonChildContent", this.branch, path, nameWildcard, search, onSuccess(fn));
}


Expand Down
3 changes: 2 additions & 1 deletion hawtio-web/src/main/webapp/app/wiki/html/viewPage.html
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,8 @@
<label class="control-label" for="moveFolder">Folder</label>

<div class="controls">
<input type="text" id="moveFolder" ng-model="moveFolder">
<input type="text" id="moveFolder" ng-model="moveFolder"
typeahead="title for title in folderNames($viewValue) | filter:$viewValue" typeahead-editable='true'>
</div>
</div>
</div>
Expand Down
10 changes: 7 additions & 3 deletions hawtio-web/src/main/webapp/app/wiki/js/view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -292,10 +292,11 @@ module Wiki {
var files = $scope.gridOptions.selectedItems;
var fileCount = files.length;
var moveFolder = $scope.moveFolder;
if (moveFolder && fileCount) {
console.log("Moveing " + fileCount + " file(s) to " + moveFolder);
var oldFolder = $scope.pageId;
if (moveFolder && fileCount && moveFolder !== oldFolder) {
console.log("Moving " + fileCount + " file(s) to " + moveFolder);
angular.forEach(files, (file, idx) => {
var oldPath = $scope.pageId + "/" + file.name;
var oldPath = oldFolder + "/" + file.name;
var newPath = moveFolder + "/" + file.name;
console.log("About to move " + oldPath + " to " + newPath);
$scope.git = wikiRepository.rename($scope.branch, oldPath, newPath, null, (result) => {
Expand All @@ -313,6 +314,9 @@ module Wiki {
$scope.moveDialog.close();
};

$scope.folderNames = (text) => {
return wikiRepository.completePath($scope.branch, text, true, null);
}

updateView();

Expand Down
9 changes: 9 additions & 0 deletions hawtio-web/src/main/webapp/app/wiki/js/wikiRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,15 @@ module Wiki {
constructor(public factoryMethod:() => Git.GitRepository) {
}

public exists(branch:string, path:string, fn) {
var fullPath = this.getPath(path);
this.git().exists(branch, fullPath, fn);
}

public completePath(branch:string, completionText:string, directoriesOnly:boolean, fn) {
return this.git().completePath(branch, completionText, directoriesOnly, fn);
}

public getPage(branch:string, path:string, objectId:string, fn) {
var git = this.git();
path = path || "/";
Expand Down

0 comments on commit 2146e47

Please sign in to comment.