Skip to content

Commit

Permalink
Merge pull request #909 from bes-internal/crash
Browse files Browse the repository at this point in the history
Updating crash page with instructions and adblock detection
  • Loading branch information
FredrikNoren authored Apr 26, 2017
2 parents 65c1ac1 + 8c77bf0 commit 8045a73
Show file tree
Hide file tree
Showing 8 changed files with 75 additions and 30 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).
Use the following format for additions: ` - VERSION: [feature/patch (if applicable)] Short description of change. Links to relevant issues/PRs.`

- 1.1.15: Updating crash page with instructions and adblock detection
- 1.1.14: Disable strict mode for startup params and config [#890](https://github.com/FredrikNoren/ungit/issues/890)
- 1.1.13: Fix startup args bug: [#896](https://github.com/FredrikNoren/ungit/issues/896)
- 1.1.12:
Expand Down
1 change: 1 addition & 0 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,7 @@ module.exports = function(grunt) {
b.require('path', { expose: 'path' });
b.require('diff2html', { expose: 'diff2html' });
b.require('bluebird', { expose: 'bluebird' });
b.require('just-detect-adblock', { expose: 'just-detect-adblock' });
b.require('./node_modules/snapsvg/src/mina.js', { expose: 'mina' });
var outFile = fs.createWriteStream('./public/js/ungit.js');
outFile.on('close', function() {
Expand Down
36 changes: 36 additions & 0 deletions components/crash/crash.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<div class="container" >
<div class="panel panel-default crash" data-ta-container="user-error-page">
<div class="panel-body">
<h1>Whooops</h1>
Unfortunately ungit interrupted its work because: <code data-bind="html: eventcause"></code><br>
The following tips will help solve this problem depending on the error:
<br><br>
<ul>
<li>General:
<ul>
<li>something went wrong, reload the page to start over
<li>check server out or logs for errors
<li>~/.ungitrc must contain valid JSON. Minimal valid json is "{}"
</ul>
<li>Connection Lost:
<ul>
<li>check status of server or network connection to the ungit server
</ul>
<li>Ad Blockers and Privacy Extensions:
<ul>
<li>add ungit server url to adblocker exception (with port definition) or disable for a while
</ul>
<li>Git does not have enough permissions:
<ul>
<li>check if you could write to .git directory (preferably on unix systems)
</ul>
<li>Other:
<ul>
<li>Find or report bug at <a href=https://github.com/FredrikNoren/ungit/issues>ungit github</a>.<br>
Just common sense; do a quick search before posting, someone might already have created an issue (or resolved the problem!).<br>
If you're posting a bug; try to include as much relevant information as possible (ungit version, node and npm version, os, any git errors displayed, output from cli console and output from the browser console).
</ul>
</ul>
</div>
</div>
</div>
17 changes: 17 additions & 0 deletions components/crash/crash.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@

var ko = require('knockout');
var components = require('ungit-components');
var adBlocker = require('just-detect-adblock');

components.register('crash', function(err, err2) {
return new CrashViewModel(err, err2);
});

var CrashViewModel = function(err, err2) {
if (adBlocker.isDetected()) {err='adblock'}
this.eventcause = err || err2 || 'unknown error';
}

CrashViewModel.prototype.updateNode = function(parentElement) {
ko.renderTemplate('crash', this, {}, parentElement);
}
8 changes: 8 additions & 0 deletions components/crash/ungit-plugin.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"exports": {
"knockoutTemplates": {
"crash": "crash.html"
},
"javascript": "crash.bundle.js"
}
}
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "ungit",
"author": "Fredrik Norén <fredrik.jw.noren@gmail.com>",
"description": "Git made easy",
"version": "1.1.14",
"version": "1.1.15",
"ungitPluginApiVersion": "0.2.0",
"scripts": {
"start": "node ./bin/ungit",
Expand Down Expand Up @@ -31,6 +31,7 @@
"getmac": "~1.2.1",
"hasher": "~1.2.0",
"ignore": "~3.2.6",
"just-detect-adblock": "^1.0.0",
"keen.io": "~0.1.3",
"knockout": "~3.4.2",
"lodash": "~4.17.4",
Expand Down
16 changes: 1 addition & 15 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,7 @@
</head>
<body>

<!-- ko with: crash -->
<div class="container" data-ta-container="user-error-page">
<div class="panel panel-default crash">
<div class="panel-body">
<h1 data-bind="text: title"></h1>
<span data-bind="html: details"></span>
</div>
</div>
</div>
<!-- /ko -->
<!-- ko ifnot: crash -->
<!-- ko if: content -->
<!-- ko component: content --><!-- /ko -->
<!-- /ko -->
<!-- /ko -->
<!-- ko component: content --><!-- /ko -->

<script type="text/javascript">ungit = {}</script>
<script type="text/javascript" src="__ROOT_PATH__/serverdata.js"></script>
Expand Down
23 changes: 9 additions & 14 deletions public/source/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,11 @@ ko.bindingHandlers.autocomplete = {

function WindowTitle() {
this.path = 'ungit';
this.disconnected = false;
this.crash = false;
}
WindowTitle.prototype.update = function() {
var title = this.path.replace('\\', '/').split('/').filter(function(x) { return x; }).reverse().join(' < ');
if (this.disconnected) title = ':( ' + title;
if (this.crash) title = ':( ungit crash ' + title;
document.title = title;
}

Expand All @@ -125,7 +125,6 @@ windowTitle.update();
var AppContainerViewModel = function() {
var self = this;
this.content = ko.observable();
this.crash = ko.observable();
}
exports.AppContainerViewModel = AppContainerViewModel;
AppContainerViewModel.prototype.templateChooser = function(data) {
Expand All @@ -134,24 +133,20 @@ AppContainerViewModel.prototype.templateChooser = function(data) {
};

var app, appContainer, server;
var DEFAULT_UNKOWN_CRASH = { title: 'Whooops', details: 'Something went wrong, reload the page to start over.' };

exports.start = function() {

server = new Server();
appContainer = new AppContainerViewModel();
app = components.create('app', { appContainer: appContainer, server: server });
programEvents.add(function(event) {
if (event.event == 'git-crash-error') {
appContainer.crash(DEFAULT_UNKOWN_CRASH);
} else if (event.event == 'disconnected') {
appContainer.crash({ title: 'Connection lost', details: 'Refresh the page to try to reconnect' });
windowTitle.disconnected = true;
if (event.event == 'disconnected' || event.event == 'git-crash-error') {
appContainer.content(components.create('crash', event.event));
windowTitle.crash = true;
windowTitle.update();
} else if (event.event == 'connected') {
appContainer.crash(null);
} else if (event.event == 'connected') {
appContainer.content(app);
windowTitle.disconnected = false;
windowTitle.crash = false;
windowTitle.update();
}

Expand All @@ -169,8 +164,8 @@ exports.start = function() {
server.initSocket();
}

Raven.TraceKit.report.subscribe(function(err) {
appContainer.crash(DEFAULT_UNKOWN_CRASH);
Raven.TraceKit.report.subscribe(function(event, err) {
appContainer.content(components.create('crash', event.event, err));
});

var prevTimestamp = 0;
Expand Down

0 comments on commit 8045a73

Please sign in to comment.