Skip to content

Commit

Permalink
WebCommitView: Add a state display
Browse files Browse the repository at this point in the history
This adds a div in the webview to display the current commit
state. It allows us to notify the user of new commits by
showing something in the webview, rather than a modal
dialog.
  • Loading branch information
pieter committed Nov 1, 2008
1 parent e232181 commit 90db001
Show file tree
Hide file tree
Showing 8 changed files with 61 additions and 10 deletions.
4 changes: 3 additions & 1 deletion PBGitCommitController.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@
IBOutlet NSArrayController *unstagedFilesController;
IBOutlet NSArrayController *cachedFilesController;
NSString *status;


IBOutlet id webController;

// We use busy as a count of active processes.
// You can increase it when your process start
// And decrease it after you have finished.
Expand Down
6 changes: 1 addition & 5 deletions PBGitCommitController.m
Original file line number Diff line number Diff line change
Expand Up @@ -269,11 +269,7 @@ - (IBAction) commit:(id) sender
if (ret)
return [self commitFailedBecause:@"Could not update HEAD"];

[[NSAlert alertWithMessageText:@"Commit succesful"
defaultButton:nil
alternateButton:nil
otherButton:nil
informativeTextWithFormat:@"Successfully created commit %@", commit] runModal];
[webController setStateMessage:[NSString stringWithFormat:@"Succesfully created commit %@", commit]];

repository.hasChanged = YES;
self.busy--;
Expand Down
12 changes: 11 additions & 1 deletion PBGitCommitView.xib
Original file line number Diff line number Diff line change
Expand Up @@ -1081,6 +1081,14 @@
</object>
<int key="connectionID">252</int>
</object>
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
<string key="label">webController</string>
<reference key="source" ref="1001"/>
<reference key="destination" ref="1007648253"/>
</object>
<int key="connectionID">253</int>
</object>
</object>
<object class="IBMutableOrderedSet" key="objectRecords">
<object class="NSArray" key="orderedObjects">
Expand Down Expand Up @@ -1514,7 +1522,7 @@
</object>
</object>
<nil key="sourceID"/>
<int key="maxID">252</int>
<int key="maxID">253</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<object class="NSMutableArray" key="referencedPartialClassDescriptions">
Expand Down Expand Up @@ -1566,6 +1574,7 @@
<string>unstagedButtonCell</string>
<string>unstagedFilesController</string>
<string>unstagedTable</string>
<string>webController</string>
</object>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
Expand All @@ -1576,6 +1585,7 @@
<string>PBIconAndTextCell</string>
<string>NSArrayController</string>
<string>NSTableView</string>
<string>id</string>
</object>
</object>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
Expand Down
2 changes: 2 additions & 0 deletions PBWebChangesController.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,6 @@
}

- (void) refresh;
- (void) setStateMessage:(NSString *)state;

@end
9 changes: 8 additions & 1 deletion PBWebChangesController.m
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ - (void)observeValueForKeyPath:(NSString *)keyPath

- (void) refresh
{
if (!finishedLoading)
if (!finishedLoading || !selectedFile)
return;

id script = [view windowScriptObject];
Expand All @@ -67,4 +67,11 @@ - (void) stageHunk:(NSString *)hunk reverse:(BOOL)reverse
[controller stageHunk: hunk reverse:reverse];
[self refresh];
}

- (void) setStateMessage:(NSString *)state
{
id script = [view windowScriptObject];
[script callWebScriptMethod:@"setState" withArguments: [NSArray arrayWithObject:state]];
}

@end
15 changes: 15 additions & 0 deletions html/views/commit/commit.css
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,21 @@ body {
width: 100%;
}

#state {
margin-left: 20px;
margin-right: 20px;
margin-top: 40px;
text-align: center;
font-size: 200%;
padding: 20px;
width: auto;

background-color: #B4D7FF;
border: 2px solid #45A1FE;

-webkit-border-radius: 10px;
}

.floatright {
float: right;
}
Expand Down
14 changes: 14 additions & 0 deletions html/views/commit/commit.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,23 @@ var showNewFile = function(file)
diff.style.display = '';
}

var hideState = function() {
$("state").style.display = "none";
}

var setState = function(state) {
$("state").style.display = "";
$("diff").style.display = "none";
$("state").innerHTML = state.escapeHTML();
}

var showFileChanges = function(file, cached) {
if (!file)
return;

$("diff").style.display = 'none';
hideNotification();
hideState();

if (file.status == 0) // New file?
return showNewFile(file);
Expand Down
9 changes: 7 additions & 2 deletions html/views/commit/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,19 @@
<body>
<h1 id='title'><span id="status">Nothing to commit</span></h1>

<div id="notification" style="display:none;">
<div id="notification" style="display:none">
<img src="../../images/spinner.gif" alt="Spinner" id="spinner"></img>
<div id="notification_message"></div>
</div>

<!-- we use "state" for the current status (as opposed to something in the diff
and we use the notification for short notifications, which can occur together
with a diff display -->
<div id="state">
Nothing to commit (working directory clean)
</div>
<pre>
<code class="diffcode" id='diff'>
Nothing to commit (working directory clean)
</code>
</pre>
</body>

0 comments on commit 90db001

Please sign in to comment.