From 4fbf0983f39d4c627c423fbb57c7dda588872cd3 Mon Sep 17 00:00:00 2001 From: Wout Mertens Date: Sun, 3 May 2020 22:43:47 +0200 Subject: [PATCH] prettier --- .travis.yml | 8 +- Gruntfile.js | 405 +++++---- appveyor.yml | 6 +- components/app/app.html | 57 +- components/app/app.js | 83 +- components/branches/branches.html | 39 +- components/branches/branches.js | 112 ++- components/branches/branches.less | 2 +- components/commit/commit.html | 58 +- components/commit/commit.js | 33 +- components/commit/commit.less | 10 +- components/commitdiff/commitdiff.html | 29 +- components/commitdiff/commitdiff.js | 10 +- components/commitdiff/commitdiff.less | 17 +- components/commitdiff/commitlinediff.js | 2 +- components/commitdiff/ungit-plugin.json | 2 +- components/crash/crash.html | 62 +- components/crash/crash.js | 2 +- components/dialogs/dialogs.js | 136 ++- components/dialogs/formDialog.html | 25 +- components/dialogs/prompt.html | 13 +- components/dialogs/ungit-plugin.json | 2 +- components/gitErrors/gitErrors.html | 3 +- components/gitErrors/gitErrors.js | 11 +- components/gitErrors/ungit-plugin.json | 2 +- components/graph/animateable.js | 23 +- components/graph/edge.js | 26 +- components/graph/git-graph-actions.js | 170 ++-- components/graph/git-node.js | 81 +- components/graph/git-ref.js | 127 ++- components/graph/graph-graphics.html | 125 ++- components/graph/graph.html | 99 +- components/graph/graph.js | 113 ++- components/graph/graph.less | 7 +- components/graph/hover-actions.js | 63 +- components/graph/selectable.js | 2 +- components/header/header.html | 36 +- components/header/header.js | 10 +- components/header/header.less | 2 +- components/header/ungit-plugin.json | 2 +- components/home/home.html | 11 +- components/home/home.js | 50 +- components/home/home.less | 3 +- components/home/ungit-plugin.json | 2 +- components/imagediff/imagediff.html | 28 +- components/imagediff/imagediff.js | 16 +- components/imagediff/ungit-plugin.json | 2 +- components/login/login.html | 20 +- components/login/login.js | 34 +- components/login/ungit-plugin.json | 2 +- components/path/path.html | 26 +- components/path/path.js | 38 +- components/refreshbutton/refreshbutton.html | 9 +- components/refreshbutton/refreshbutton.js | 4 +- components/remotes/remotes.html | 30 +- components/remotes/remotes.js | 148 +-- components/remotes/ungit-plugin.json | 2 +- components/repository/repository.html | 9 +- components/repository/repository.js | 75 +- components/repository/ungit-plugin.json | 2 +- components/staging/staging.html | 192 +++- components/staging/staging.js | 255 ++++-- components/staging/staging.less | 34 +- components/staging/ungit-plugin.json | 2 +- components/stash/stash.html | 27 +- components/stash/stash.js | 60 +- components/stash/stash.less | 4 +- components/stash/ungit-plugin.json | 2 +- components/submodules/submodules.html | 34 +- components/submodules/submodules.js | 60 +- components/textdiff/textdiff.html | 4 +- components/textdiff/textdiff.js | 148 +-- nmclicktests/environment.js | 227 +++-- nmclicktests/spec.authentication.js | 13 +- nmclicktests/spec.bare.js | 6 +- nmclicktests/spec.branches.js | 79 +- nmclicktests/spec.commands.js | 48 +- nmclicktests/spec.discard.js | 36 +- nmclicktests/spec.generic.js | 102 ++- nmclicktests/spec.load-ahead.js | 21 +- nmclicktests/spec.no-header.js | 17 +- nmclicktests/spec.remotes.js | 64 +- nmclicktests/spec.screens.js | 60 +- nmclicktests/spec.stash.js | 19 +- nmclicktests/spec.submodules.js | 18 +- public/index.html | 88 +- public/less/d2h.less | 21 +- public/less/generic.less | 17 +- public/less/styles.less | 3 +- public/less/variables.less | 7 +- public/main.js | 53 +- public/source/components.js | 10 +- public/source/knockout-bindings.js | 124 ++- public/source/main.js | 139 +-- public/source/navigation.js | 17 +- public/source/program-events.js | 3 +- public/source/server.js | 133 +-- public/source/storage.js | 26 +- source/address-parser.js | 47 +- source/bugtracker.js | 10 +- source/config.js | 258 ++++-- source/git-api.js | 948 +++++++++++++------- source/git-parser.js | 199 ++-- source/git-promise.js | 599 ++++++++----- source/server.js | 185 ++-- source/sysinfo.js | 13 +- source/ungit-plugin.js | 134 +-- source/utils/cache.js | 22 +- source/utils/file-type.js | 3 +- source/utils/fs-async.js | 9 +- source/utils/winston.js | 34 +- test/common-es6.js | 72 +- test/spec.cache.js | 118 ++- test/spec.credentials-helper.js | 6 +- test/spec.git-api.branching.js | 65 +- test/spec.git-api.conflict-no-auto-stash.js | 29 +- test/spec.git-api.conflict.js | 153 +++- test/spec.git-api.diff.js | 116 ++- test/spec.git-api.discardchanges.js | 58 +- test/spec.git-api.ignorefile.js | 42 +- test/spec.git-api.js | 106 ++- test/spec.git-api.patch.js | 195 +++- test/spec.git-api.remote.js | 199 ++-- test/spec.git-api.squash.js | 54 +- test/spec.git-api.stash.js | 22 +- test/spec.git-api.submodule.js | 126 +-- test/spec.git-parser.js | 792 ++++++++-------- teststabilitytester.js | 37 +- 128 files changed, 5934 insertions(+), 3416 deletions(-) diff --git a/.travis.yml b/.travis.yml index a5ff2f77f..0fc554d4b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,8 +5,8 @@ os: language: node_js node_js: - node - - "12" - - "10" + - '12' + - '10' branches: only: - master @@ -17,9 +17,9 @@ env: - GIT_VERSION=default jobs: exclude: - - node_js: "12" + - node_js: '12' env: GIT_VERSION=edge - - node_js: "10" + - node_js: '10' env: GIT_VERSION=edge - os: windows env: GIT_VERSION=edge diff --git a/Gruntfile.js b/Gruntfile.js index 602008a74..d71cba377 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -12,15 +12,20 @@ const maxConcurrency = 5; module.exports = (grunt) => { const packageJson = grunt.file.readJSON('package.json'); const lessFiles = { - 'public/css/styles.css': ['public/less/styles.less', 'public/vendor/css/animate.css', 'public/less/d2h.less'] + 'public/css/styles.css': [ + 'public/less/styles.less', + 'public/vendor/css/animate.css', + 'public/less/d2h.less', + ], }; - fs.readdirSync('./components').map((component) => `components/${component}/${component}`) - .forEach((str) => lessFiles[`${str}.css`] = `${str}.less`); + fs.readdirSync('./components') + .map((component) => `components/${component}/${component}`) + .forEach((str) => (lessFiles[`${str}.css`] = `${str}.less`)); grunt.initConfig({ pkg: packageJson, less: { - production: { files: lessFiles } + production: { files: lessFiles }, }, watch: { scripts: { @@ -36,12 +41,12 @@ module.exports = (grunt) => { options: { spawn: false, }, - } + }, }, release: { options: { commitMessage: 'Release <%= version %>', - } + }, }, // Run mocha tests mochaTest: { @@ -49,49 +54,51 @@ module.exports = (grunt) => { options: { reporter: 'spec', require: './source/utils/winston.js', - timeout: 5000 + timeout: 5000, }, - src: 'test/*.js' + src: 'test/*.js', }, click: { options: { reporter: 'spec', require: './source/utils/winston.js', timeout: 15000, - bail: true + bail: true, }, - src: 'nmclicktests/spec.*.js' - } + src: 'nmclicktests/spec.*.js', + }, }, // Minify images (basically just lossless compression) imagemin: { default: { options: { - optimizationLevel: 3 + optimizationLevel: 3, }, - files: [{ - expand: true, - cwd: 'assets/client/images/', - src: ['**/*.png'], - dest: 'public/images/' - }] - } + files: [ + { + expand: true, + cwd: 'assets/client/images/', + src: ['**/*.png'], + dest: 'public/images/', + }, + ], + }, }, // Embed images in css imageEmbed: { default: { files: { - 'public/css/styles.css': [ 'public/css/styles.css' ], + 'public/css/styles.css': ['public/css/styles.css'], 'components/graph/graph.css': ['components/graph/graph.css'], 'components/header/header.css': ['components/header/header.css'], 'components/staging/staging.css': ['components/staging/staging.css'], }, options: { - deleteAfterEncoding: false - } - } + deleteAfterEncoding: false, + }, + }, }, jshint: { options: { @@ -109,70 +116,74 @@ module.exports = (grunt) => { node: true, browser: true, globals: { - 'ungit': true, - 'io': true, - 'Raven': true, - '$': true, - 'jQuery': true, - 'nprogress': true - } + ungit: true, + io: true, + Raven: true, + $: true, + jQuery: true, + nprogress: true, + }, }, files: [ { src: ['public/source/**/*.js', 'components/**/*.js'], // Filter out the "compiled" components files; see the browserify task for components - filter: (src) => src.indexOf('bundle.js') == -1 - } - ] + filter: (src) => src.indexOf('bundle.js') == -1, + }, + ], }, node: { options: { - node: true + node: true, }, - src: ['source/**/*.js'] + src: ['source/**/*.js'], }, bin: { options: { - node: true + node: true, }, - src: [ - 'Gruntfile.js', - 'bin/*' - ] + src: ['Gruntfile.js', 'bin/*'], }, mocha: { options: { node: true, globals: { - 'it': true, - 'describe': true, - 'before': true, - 'after': true, - 'window': true, - 'document': true, - 'navigator': true, - 'ungit': true - } + it: true, + describe: true, + before: true, + after: true, + window: true, + document: true, + navigator: true, + ungit: true, + }, }, - src: [ - 'test/**/*.js', - 'nmclicktests/**/*.js' - ] - } + src: ['test/**/*.js', 'nmclicktests/**/*.js'], + }, }, copy: { main: { files: [ // includes files within path - { expand: true, flatten: true, src: ['node_modules/raven-js/dist/raven.min.js'], dest: 'public/js/' }, - { expand: true, flatten: true, src: ['node_modules/raven-js/dist/raven.min.js.map'], dest: 'public/js/' } - ] - } + { + expand: true, + flatten: true, + src: ['node_modules/raven-js/dist/raven.min.js'], + dest: 'public/js/', + }, + { + expand: true, + flatten: true, + src: ['node_modules/raven-js/dist/raven.min.js.map'], + dest: 'public/js/', + }, + ], + }, }, clean: { electron: ['./build'], coverage: ['./coverage'], - 'coverage-unit': ['./coverage/coverage-unit'] + 'coverage-unit': ['./coverage/coverage-unit'], }, electron: { package: { @@ -181,37 +192,39 @@ module.exports = (grunt) => { out: './build', icon: './icon', all: true, - asar: true - } - } + asar: true, + }, + }, }, zip_directories: { electron: { - files: [{ - filter: 'isDirectory', - expand: true, - cwd: './build', - dest: './dist', - src: '*' - }] - } + files: [ + { + filter: 'isDirectory', + expand: true, + cwd: './build', + dest: './dist', + src: '*', + }, + ], + }, }, mocha_istanbul: { unit: { src: './test', options: { coverageFolder: './coverage/coverage-unit', - mask: 'spec.*.js' - } - } - } + mask: 'spec.*.js', + }, + }, + }, }); - grunt.registerTask('browserify-common', '', function() { + grunt.registerTask('browserify-common', '', function () { const done = this.async(); const b = browserify({ noParse: ['public/vendor/js/superagent.js'], - debug: true + debug: true, }); b.add('./public/source/main.js'); b.require('./public/source/main.js', { expose: 'ungit-main' }); @@ -244,32 +257,36 @@ module.exports = (grunt) => { b.bundle().pipe(outFile); }); - grunt.registerTask('browserify-components', '', function() { + grunt.registerTask('browserify-components', '', function () { Bluebird.each(fs.readdirSync('components'), (component) => { return new Bluebird((resolve, reject) => { const b = browserify({ bundleExternal: false, - debug: true + debug: true, }); const src = `./components/${component}/${component}.js`; if (!fs.existsSync(src)) { - grunt.log.error(`${src} does not exist. If this component is obsolete, please remove that directory or perform a clean build.`); + grunt.log.error( + `${src} does not exist. If this component is obsolete, please remove that directory or perform a clean build.` + ); return; } b.add(src); - b.external(['ungit-components', - 'ungit-program-events', - 'ungit-navigation', - 'ungit-storage', - 'ungit-main', - 'ungit-address-parser', - 'knockout', - 'lodash', - 'hasher', - 'crossroads', - 'async', - 'moment', - 'blueimp-md5']); + b.external([ + 'ungit-components', + 'ungit-program-events', + 'ungit-navigation', + 'ungit-storage', + 'ungit-main', + 'ungit-address-parser', + 'knockout', + 'lodash', + 'hasher', + 'crossroads', + 'async', + 'moment', + 'blueimp-md5', + ]); const outFile = fs.createWriteStream(`./components/${component}/${component}.bundle.js`); outFile.on('close', () => resolve()); @@ -279,9 +296,12 @@ module.exports = (grunt) => { }); const bumpDependency = (packageJson, packageName) => { - const dependencyType = packageJson['dependencies'][packageName] ? 'dependencies' : 'devDependencies'; + const dependencyType = packageJson['dependencies'][packageName] + ? 'dependencies' + : 'devDependencies'; let currentVersion = packageJson[dependencyType][packageName]; - if (currentVersion[0] == '~' || currentVersion[0] == '^') currentVersion = currentVersion.slice(1); + if (currentVersion[0] == '~' || currentVersion[0] == '^') + currentVersion = currentVersion.slice(1); return pkgVersions(packageName).then((versionSet) => { const versions = Array.from(versionSet); const latestVersion = semver.maxSatisfying(versions, '*'); @@ -291,25 +311,38 @@ module.exports = (grunt) => { }); }; - grunt.registerTask('travisnpmpublish', 'Automatically publish to NPM via travis and create git tag.', function() { - const done = this.async(); - if (process.env.TRAVIS_BRANCH != 'master' || (process.env.TRAVIS_PULL_REQUEST && process.env.TRAVIS_PULL_REQUEST != 'false')) { - grunt.log.writeln('Skipping travis npm publish'); - return done(); - } - childProcess.exec('git rev-parse --short HEAD', (err, stdout, stderr) => { - const hash = stdout.trim(); - const packageJson = JSON.parse(fs.readFileSync('package.json')); - const version = packageJson.version; - packageJson.version += `+${hash}`; - fs.writeFileSync('package.json', `${JSON.stringify(packageJson, null, 2)}\n`); - fs.writeFileSync('.npmrc', '//registry.npmjs.org/:_authToken=' + process.env.NPM_TOKEN); - childProcess.exec('npm publish', (err) => { - if (err) done(err); - else childProcess.exec(`git tag v${version} && git push -q https://${process.env.GITHUB_TOKEN}@github.com/FredrikNoren/ungit.git v${version}`, (err) => { done(err); }); + grunt.registerTask( + 'travisnpmpublish', + 'Automatically publish to NPM via travis and create git tag.', + function () { + const done = this.async(); + if ( + process.env.TRAVIS_BRANCH != 'master' || + (process.env.TRAVIS_PULL_REQUEST && process.env.TRAVIS_PULL_REQUEST != 'false') + ) { + grunt.log.writeln('Skipping travis npm publish'); + return done(); + } + childProcess.exec('git rev-parse --short HEAD', (err, stdout, stderr) => { + const hash = stdout.trim(); + const packageJson = JSON.parse(fs.readFileSync('package.json')); + const version = packageJson.version; + packageJson.version += `+${hash}`; + fs.writeFileSync('package.json', `${JSON.stringify(packageJson, null, 2)}\n`); + fs.writeFileSync('.npmrc', '//registry.npmjs.org/:_authToken=' + process.env.NPM_TOKEN); + childProcess.exec('npm publish', (err) => { + if (err) done(err); + else + childProcess.exec( + `git tag v${version} && git push -q https://${process.env.GITHUB_TOKEN}@github.com/FredrikNoren/ungit.git v${version}`, + (err) => { + done(err); + } + ); + }); }); - }); - }); + } + ); grunt.registerTask('electronpublish', ['zip_directories:electron']); @@ -320,7 +353,7 @@ module.exports = (grunt) => { * triggers timeouts. * Use at own discretion. */ - grunt.registerTask('clickParallel', 'Parallelized click tests.', function() { + grunt.registerTask('clickParallel', 'Parallelized click tests.', function () { const done = this.async(); fs.readdirAsync('./nmclicktests') @@ -331,30 +364,42 @@ module.exports = (grunt) => { tests.splice(0, 0, tests.splice(genericIndx, 1)[0]); } return tests; - }).then((tests) => { + }) + .then((tests) => { grunt.log.writeln('Running click tests in parallel... (this will take a while...)'); - return Bluebird.map(tests, (file) => { - let output = ''; - const outStream = (data) => output += data; + return Bluebird.map( + tests, + (file) => { + let output = ''; + const outStream = (data) => (output += data); - grunt.log.writeln(cliColor.set(`Clicktest started! \t${file}`, 'blue')); - return new Bluebird((resolve, reject) => { - const child = childProcess.execFile('./node_modules/mocha/bin/mocha', [path.join(__dirname, 'nmclicktests', file), '--timeout=20000', '-b'], { maxBuffer: 10*1024*1024 }); - child.stdout.on('data', outStream); - child.stderr.on('data', outStream); - child.on('exit', (code) => { - if (code == 0) resolve(file); - else reject(); - }); - }).then(() => { - grunt.log.writeln(cliColor.set(`'Clicktest success! \t${file}`, 'green')); - return { name: file, output: output, isSuccess: true }; - }).catch(() => { - grunt.log.writeln(cliColor.set(`'Clicktest fail! \t'${file}`, 'red')); - return { name: file, output: output, isSuccess: false }; - }); - }, { concurrency: maxConcurrency }); - }).then((results) => { + grunt.log.writeln(cliColor.set(`Clicktest started! \t${file}`, 'blue')); + return new Bluebird((resolve, reject) => { + const child = childProcess.execFile( + './node_modules/mocha/bin/mocha', + [path.join(__dirname, 'nmclicktests', file), '--timeout=20000', '-b'], + { maxBuffer: 10 * 1024 * 1024 } + ); + child.stdout.on('data', outStream); + child.stderr.on('data', outStream); + child.on('exit', (code) => { + if (code == 0) resolve(file); + else reject(); + }); + }) + .then(() => { + grunt.log.writeln(cliColor.set(`'Clicktest success! \t${file}`, 'green')); + return { name: file, output: output, isSuccess: true }; + }) + .catch(() => { + grunt.log.writeln(cliColor.set(`'Clicktest fail! \t'${file}`, 'red')); + return { name: file, output: output, isSuccess: false }; + }); + }, + { concurrency: maxConcurrency } + ); + }) + .then((results) => { let isSuccess = true; results.forEach((result) => { if (!result.isSuccess) { @@ -368,41 +413,62 @@ module.exports = (grunt) => { }); }); - grunt.registerTask('bumpdependencies', 'Bump dependencies to their latest versions.', function() { - const done = this.async(); - grunt.log.writeln('Bumping dependencies...'); - const tempPackageJson = JSON.parse(JSON.stringify(packageJson)); - const keys = Object.keys(tempPackageJson.dependencies).concat(Object.keys(tempPackageJson.devDependencies)); + grunt.registerTask( + 'bumpdependencies', + 'Bump dependencies to their latest versions.', + function () { + const done = this.async(); + grunt.log.writeln('Bumping dependencies...'); + const tempPackageJson = JSON.parse(JSON.stringify(packageJson)); + const keys = Object.keys(tempPackageJson.dependencies).concat( + Object.keys(tempPackageJson.devDependencies) + ); - const bumps = Bluebird.map(keys, (dep) => { - return bumpDependency(tempPackageJson, dep); - }); + const bumps = Bluebird.map(keys, (dep) => { + return bumpDependency(tempPackageJson, dep); + }); - Bluebird.all(bumps).then(() => { - fs.writeFileSync('package.json', `${JSON.stringify(tempPackageJson, null, 2)}\n`); - grunt.log.writeln('Dependencies bumped, run npm install to install latest versions.'); - }).then(() => { done(); }).catch(done); - }); + Bluebird.all(bumps) + .then(() => { + fs.writeFileSync('package.json', `${JSON.stringify(tempPackageJson, null, 2)}\n`); + grunt.log.writeln('Dependencies bumped, run npm install to install latest versions.'); + }) + .then(() => { + done(); + }) + .catch(done); + } + ); - grunt.registerMultiTask('electron', 'Package Electron apps', function() { + grunt.registerMultiTask('electron', 'Package Electron apps', function () { const done = this.async(); - electronPackager(this.options()).then(() => { done(); }, done); + electronPackager(this.options()).then(() => { + done(); + }, done); }); - grunt.registerTask('checkPrettier', 'Verify that all files are correctly formatted.', function() { - const done = this.async(); - childProcess.exec('prettier -l .', (err, stdout, stderr) => { - const files = stdout.trim(); - if (files) { - return done(new Error(`Files with incorrect formatting (run "npm run format" and consider a Prettier plugin for your editor):\n${files}\n`)) - } - if (err) { - console.error(stderr) - return done(err) - } - done() - }); - }); + grunt.registerTask( + 'checkPrettier', + 'Verify that all files are correctly formatted.', + function () { + const done = this.async(); + childProcess.exec('prettier -l .', (err, stdout, stderr) => { + const files = stdout.trim(); + if (files) { + return done( + new Error( + `Files with incorrect formatting (run "npm run format" and consider a Prettier plugin for your editor):\n${files}\n` + ) + ); + } + if (err) { + console.error(stderr); + return done(err); + } + done(); + }); + } + ); grunt.event.on('coverage', (lcovFileContents) => { // Check below on the section "The coverage event" @@ -423,7 +489,16 @@ module.exports = (grunt) => { grunt.loadNpmTasks('grunt-zip-directories'); // Default task, builds everything needed - grunt.registerTask('default', ['checkPrettier', 'less:production', 'jshint', 'browserify-common', 'browserify-components', 'imageEmbed:default', 'copy:main', 'imagemin:default']); + grunt.registerTask('default', [ + 'checkPrettier', + 'less:production', + 'jshint', + 'browserify-common', + 'browserify-components', + 'imageEmbed:default', + 'copy:main', + 'imagemin:default', + ]); // Run tests without compile (use watcher or manually build) grunt.registerTask('unittest', ['mochaTest:unit']); diff --git a/appveyor.yml b/appveyor.yml index 74499f7da..068a9ce89 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -2,9 +2,9 @@ skip_branch_with_pr: true environment: matrix: - - nodejs_version: "" # latest - - nodejs_version: "12" - - nodejs_version: "10" + - nodejs_version: '' # latest + - nodejs_version: '12' + - nodejs_version: '10' branches: only: diff --git a/components/app/app.html b/components/app/app.html index 63d0ac470..965bb4ea7 100644 --- a/components/app/app.html +++ b/components/app/app.html @@ -1,35 +1,38 @@
- -
-
- - -
- -
- A new version of ungit () is - available! Run - to install. - See what's new in the - changelog. - +
+
+ + +
+ +
+ A new version of ungit () is + available! Run + to install. See what's new in the + changelog. + +
+ +
+ +

Help make ungit better with the press of a button!

+ + + +
-
- -

Help make ungit better with the press of a button!

- - - -
-
- - -
- - + +
+
diff --git a/components/app/app.js b/components/app/app.js index 91caf3e35..861f2b92e 100644 --- a/components/app/app.js +++ b/components/app/app.js @@ -1,4 +1,3 @@ - const ko = require('knockout'); const components = require('ungit-components'); const programEvents = require('ungit-program-events'); @@ -18,26 +17,38 @@ class AppViewModel { } this.dialog = ko.observable(null); this.repoList = ko.observableArray(this.getRepoList()); // visitedRepositories is legacy, remove in the next version - this.repoList.subscribe((newValue) => { storage.setItem('repositories', JSON.stringify(newValue)); }); + this.repoList.subscribe((newValue) => { + storage.setItem('repositories', JSON.stringify(newValue)); + }); this.content = ko.observable(components.create('home', { app: this })); this.currentVersion = ko.observable(); this.latestVersion = ko.observable(); this.showNewVersionAvailable = ko.observable(); - this.newVersionInstallCommand = (ungit.platform == 'win32' ? '' : 'sudo -H ') + 'npm update -g ungit'; + this.newVersionInstallCommand = + (ungit.platform == 'win32' ? '' : 'sudo -H ') + 'npm update -g ungit'; this.bugtrackingEnabled = ko.observable(ungit.config.bugtracking); - this.bugtrackingNagscreenDismissed = ko.observable(storage.getItem('bugtrackingNagscreenDismissed')); + this.bugtrackingNagscreenDismissed = ko.observable( + storage.getItem('bugtrackingNagscreenDismissed') + ); this.showBugtrackingNagscreen = ko.computed(() => { return !this.bugtrackingEnabled() && !this.bugtrackingNagscreenDismissed(); }); this.gitVersionErrorDismissed = ko.observable(storage.getItem('gitVersionErrorDismissed')); this.gitVersionError = ko.observable(); this.gitVersionErrorVisible = ko.computed(() => { - return !ungit.config.gitVersionCheckOverride && this.gitVersionError() && !this.gitVersionErrorDismissed(); + return ( + !ungit.config.gitVersionCheckOverride && + this.gitVersionError() && + !this.gitVersionErrorDismissed() + ); }); } getRepoList() { - const localStorageRepo = JSON.parse(storage.getItem('repositories') || storage.getItem('visitedRepositories') || '[]'); - const newRepos = localStorageRepo.concat(ungit.config.defaultRepositories || []) + const localStorageRepo = JSON.parse( + storage.getItem('repositories') || storage.getItem('visitedRepositories') || '[]' + ); + const newRepos = localStorageRepo + .concat(ungit.config.defaultRepositories || []) .filter((v, i, a) => a.indexOf(v) === i) .sort(); storage.setItem('repositories', JSON.stringify(newRepos)); @@ -49,40 +60,45 @@ class AppViewModel { shown() { // The ungit.config constiable collections configuration from all different paths and only updates when // ungit is restarted - if(!ungit.config.bugtracking) { + if (!ungit.config.bugtracking) { // Whereas the userconfig only reflects what's in the ~/.ungitrc and updates directly, // but is only used for changing around the configuration. We need to check this here // since ungit may have crashed without the server crashing since we enabled bugtracking, // and we don't want to show the nagscreen twice in that case. - this.server.getPromise('/userconfig') + this.server + .getPromise('/userconfig') .then((userConfig) => this.bugtrackingEnabled(userConfig.bugtracking)) .catch((e) => this.server.unhandledRejection(e)); } - this.server.getPromise('/latestversion') + this.server + .getPromise('/latestversion') .then((version) => { if (!version) return; this.currentVersion(version.currentVersion); this.latestVersion(version.latestVersion); this.showNewVersionAvailable(!ungit.config.ungitVersionCheckOverride && version.outdated); - }).catch((e) => this.server.unhandledRejection(e)); - this.server.getPromise('/gitversion') + }) + .catch((e) => this.server.unhandledRejection(e)); + this.server + .getPromise('/gitversion') .then((gitversion) => { if (gitversion && !gitversion.satisfied) { this.gitVersionError(gitversion.error); } - }).catch((e) => this.server.unhandledRejection(e)); + }) + .catch((e) => this.server.unhandledRejection(e)); } updateAnimationFrame(deltaT) { - if (this.content() && this.content().updateAnimationFrame) this.content().updateAnimationFrame(deltaT); + if (this.content() && this.content().updateAnimationFrame) + this.content().updateAnimationFrame(deltaT); } onProgramEvent(event) { if (event.event == 'request-credentials') this._handleCredentialsRequested(event); else if (event.event == 'request-show-dialog') this.showDialog(event.dialog); else if (event.event == 'request-remember-repo') this._handleRequestRememberRepo(event); - if (this.content() && this.content().onProgramEvent) - this.content().onProgramEvent(event); + if (this.content() && this.content().onProgramEvent) this.content().onProgramEvent(event); if (this.header && this.header.onProgramEvent) this.header.onProgramEvent(event); } _handleRequestRememberRepo(event) { @@ -95,25 +111,34 @@ class AppViewModel { // This happens for instance when we fetch nodes and remote tags at the same time if (!this._isShowingCredentialsDialog) { this._isShowingCredentialsDialog = true; - components.create('credentialsdialog', {remote: event.remote}).show().closeThen((diag) => { - this._isShowingCredentialsDialog = false; - programEvents.dispatch({ event: 'request-credentials-response', username: diag.username(), password: diag.password() }); - }); + components + .create('credentialsdialog', { remote: event.remote }) + .show() + .closeThen((diag) => { + this._isShowingCredentialsDialog = false; + programEvents.dispatch({ + event: 'request-credentials-response', + username: diag.username(), + password: diag.password(), + }); + }); } } showDialog(dialog) { - this.dialog(dialog.closeThen(() => { - this.dialog(null); - return dialog; - })); + this.dialog( + dialog.closeThen(() => { + this.dialog(null); + return dialog; + }) + ); } gitSetUserConfig(bugTracking) { - this.server.getPromise('/userconfig') - .then((userConfig) => { - userConfig.bugtracking = bugTracking; - return this.server.postPromise('/userconfig', userConfig) - .then(() => { this.bugtrackingEnabled(bugTracking); }); + this.server.getPromise('/userconfig').then((userConfig) => { + userConfig.bugtracking = bugTracking; + return this.server.postPromise('/userconfig', userConfig).then(() => { + this.bugtrackingEnabled(bugTracking); }); + }); } enableBugtracking() { this.gitSetUserConfig(true); diff --git a/components/branches/branches.html b/components/branches/branches.html index 3fd53c15a..d17aeb461 100644 --- a/components/branches/branches.html +++ b/components/branches/branches.html @@ -3,30 +3,57 @@ - diff --git a/components/branches/branches.js b/components/branches/branches.js index 4c8c94a1d..8603751f6 100644 --- a/components/branches/branches.js +++ b/components/branches/branches.js @@ -32,55 +32,79 @@ class BranchesViewModel { this.isShowTag.subscribe(setLocalStorageAndUpdate.bind(null, showTag)); this.refsLabel = ko.computed(() => this.current() || 'master (no commits yet)'); this.listRefsEnabled = ko.computed(() => this.branchesAndLocalTags().length > 0); - this.branchIcon = octicons['git-branch'].toSVG({ 'height': 18 }); - this.closeIcon = octicons.x.toSVG({ 'height': 18 }); + this.branchIcon = octicons['git-branch'].toSVG({ height: 18 }); + this.closeIcon = octicons.x.toSVG({ height: 18 }); this.updateRefsDebounced = _.debounce(this.updateRefs, 500); } - checkoutBranch(branch) { branch.checkout(); } - updateNode(parentElement) { ko.renderTemplate('branches', this, {}, parentElement); } - clickFetch() { this.updateRefs(); } + checkoutBranch(branch) { + branch.checkout(); + } + updateNode(parentElement) { + ko.renderTemplate('branches', this, {}, parentElement); + } + clickFetch() { + this.updateRefs(); + } onProgramEvent(event) { - if (event.event === 'working-tree-changed' || event.event === 'request-app-content-refresh' || - event.event === 'branch-updated' || event.event === 'git-directory-changed') { + if ( + event.event === 'working-tree-changed' || + event.event === 'request-app-content-refresh' || + event.event === 'branch-updated' || + event.event === 'git-directory-changed' + ) { this.updateRefsDebounced(); } } updateRefs() { - const currentBranchProm = this.server.getPromise('/branches', { path: this.repoPath() }) - .then((branches) => branches.forEach((b) => { if (b.current) { this.current(b.name); } })) - .catch((err) => { this.current('~error'); }); + const currentBranchProm = this.server + .getPromise('/branches', { path: this.repoPath() }) + .then((branches) => + branches.forEach((b) => { + if (b.current) { + this.current(b.name); + } + }) + ) + .catch((err) => { + this.current('~error'); + }); // refreshes tags branches and remote branches - const refsProm = this.server.getPromise('/refs', { path: this.repoPath() }) + const refsProm = this.server + .getPromise('/refs', { path: this.repoPath() }) .then((refs) => { const version = Date.now(); - const sorted = refs.map((r) => { - const ref = this.graph.getRef(r.name.replace('refs/tags', 'tag: refs/tags')); - ref.node(this.graph.getNode(r.sha1)); - ref.version = version; - return ref; - }).sort((a, b) => { - if (a.current() || b.current()) { - return a.current() ? -1 : 1; - } else if (a.isRemoteBranch === b.isRemoteBranch) { - if (a.name < b.name) { - return -1; - } if (a.name > b.name) { - return 1; + const sorted = refs + .map((r) => { + const ref = this.graph.getRef(r.name.replace('refs/tags', 'tag: refs/tags')); + ref.node(this.graph.getNode(r.sha1)); + ref.version = version; + return ref; + }) + .sort((a, b) => { + if (a.current() || b.current()) { + return a.current() ? -1 : 1; + } else if (a.isRemoteBranch === b.isRemoteBranch) { + if (a.name < b.name) { + return -1; + } + if (a.name > b.name) { + return 1; + } + return 0; + } else { + return a.isRemoteBranch ? 1 : -1; } - return 0; - } else { - return a.isRemoteBranch ? 1 : -1; - } - }).filter((ref) => { - if (ref.localRefName == 'refs/stash') return false; - if (ref.localRefName.endsWith('/HEAD')) return false; - if (!this.isShowRemote() && ref.isRemote) return false; - if (!this.isShowBranch() && ref.isBranch) return false; - if (!this.isShowTag() && ref.isTag) return false; - return true; - }); + }) + .filter((ref) => { + if (ref.localRefName == 'refs/stash') return false; + if (ref.localRefName.endsWith('/HEAD')) return false; + if (!this.isShowRemote() && ref.isRemote) return false; + if (!this.isShowBranch() && ref.isBranch) return false; + if (!this.isShowTag() && ref.isTag) return false; + return true; + }); this.branchesAndLocalTags(sorted); this.graph.refs().forEach((ref) => { // ref was removed from another source @@ -88,7 +112,8 @@ class BranchesViewModel { ref.remove(true); } }); - }).catch((e) => this.server.unhandledRejection(e)); + }) + .catch((e) => this.server.unhandledRejection(e)); return Promise.all([currentBranchProm, refsProm]); } @@ -98,12 +123,21 @@ class BranchesViewModel { if (branch.isRemoteBranch) { details = `REMOTE ${details}`; } - components.create('yesnodialog', { title: 'Are you sure?', details: 'Deleting ' + details + ' branch cannot be undone with ungit.'}) + components + .create('yesnodialog', { + title: 'Are you sure?', + details: 'Deleting ' + details + ' branch cannot be undone with ungit.', + }) .show() .closeThen((diag) => { if (!diag.result()) return; const url = `${branch.isRemote ? '/remote' : ''}/branches`; - return this.server.delPromise(url, { path: this.graph.repoPath(), remote: branch.isRemote ? branch.remote : null, name: branch.refName }) + return this.server + .delPromise(url, { + path: this.graph.repoPath(), + remote: branch.isRemote ? branch.remote : null, + name: branch.refName, + }) .then(() => programEvents.dispatch({ event: 'working-tree-changed' })) .catch((e) => this.server.unhandledRejection(e)); }); diff --git a/components/branches/branches.less b/components/branches/branches.less index 5fa19f9a4..9ec83c420 100644 --- a/components/branches/branches.less +++ b/components/branches/branches.less @@ -1,4 +1,4 @@ -@import "public/less/variables.less"; +@import 'public/less/variables.less'; .branch { .options { diff --git a/components/commit/commit.html b/components/commit/commit.html index 81eb29dc0..73b8a284f 100644 --- a/components/commit/commit.html +++ b/components/commit/commit.html @@ -1,34 +1,66 @@ -
-
+
+
- + onerror="this.style.display='none';" + />
- - by + + by - +
- | - +, - - - | + + | +, - + |
-
+
-
+
diff --git a/components/commit/commit.js b/components/commit/commit.js index c27db5923..4a86e2513 100644 --- a/components/commit/commit.js +++ b/components/commit/commit.js @@ -4,7 +4,7 @@ const moment = require('moment'); const octicons = require('octicons'); const components = require('ungit-components'); -components.register('commit', args => new CommitViewModel(args)); +components.register('commit', (args) => new CommitViewModel(args)); class CommitViewModel { constructor(gitNode) { @@ -15,7 +15,7 @@ class CommitViewModel { this.nodeIsMousehover = gitNode.nodeIsMousehover; this.selected = gitNode.selected; this.pgpVerifiedString = gitNode.pgpVerifiedString; - this.pgpIcon = octicons.verified.toSVG({ 'height': 18 }); + this.pgpIcon = octicons.verified.toSVG({ height: 18 }); this.element = ko.observable(); this.commitTime = ko.observable(); this.authorTime = ko.observable(); @@ -31,11 +31,14 @@ class CommitViewModel { this.numberOfRemovedLines = ko.observable(); this.authorGravatar = ko.computed(() => md5((this.authorEmail() || '').trim().toLowerCase())); - this.showCommitDiff = ko.computed(() => this.fileLineDiffs() && this.fileLineDiffs().length > 0); + this.showCommitDiff = ko.computed( + () => this.fileLineDiffs() && this.fileLineDiffs().length > 0 + ); this.diffStyle = ko.computed(() => { - const marginLeft = Math.min((gitNode.branchOrder() * 70), 450) * -1; - if (this.selected() && this.element()) return { 'margin-left': `${marginLeft}px`, width: `${window.innerWidth - 220}px` }; + const marginLeft = Math.min(gitNode.branchOrder() * 70, 450) * -1; + if (this.selected() && this.element()) + return { 'margin-left': `${marginLeft}px`, width: `${window.innerWidth - 220}px` }; else return {}; }); } @@ -50,7 +53,7 @@ class CommitViewModel { const message = args.message.split('\n'); this.message(args.message); this.title(message[0]); - this.body(message.slice((message[1] ? 1 : 2)).join('\n')); + this.body(message.slice(message[1] ? 1 : 2).join('\n')); this.authorDate(moment(new Date(args.authorDate))); this.authorDateFromNow(this.authorDate().fromNow()); this.authorName(args.authorName); @@ -59,19 +62,21 @@ class CommitViewModel { this.numberOfRemovedLines(args.deletions); this.fileLineDiffs(args.fileLineDiffs); this.isInited = true; - this.commitDiff = ko.observable(components.create('commitDiff', { - fileLineDiffs: this.fileLineDiffs(), - sha1: this.sha1, - repoPath: this.repoPath, - server: this.server, - showDiffButtons: this.selected - })); + this.commitDiff = ko.observable( + components.create('commitDiff', { + fileLineDiffs: this.fileLineDiffs(), + sha1: this.sha1, + repoPath: this.repoPath, + server: this.server, + showDiffButtons: this.selected, + }) + ); } updateLastAuthorDateFromNow(deltaT) { this.lastUpdatedAuthorDateFromNow = this.lastUpdatedAuthorDateFromNow || 0; this.lastUpdatedAuthorDateFromNow += deltaT; - if(this.lastUpdatedAuthorDateFromNow > 60 * 1000) { + if (this.lastUpdatedAuthorDateFromNow > 60 * 1000) { this.lastUpdatedAuthorDateFromNow = 0; this.authorDateFromNow(this.authorDate().fromNow()); } diff --git a/components/commit/commit.less b/components/commit/commit.less index b551ac589..924bbb086 100644 --- a/components/commit/commit.less +++ b/components/commit/commit.less @@ -1,4 +1,4 @@ -@import "public/less/variables.less"; +@import 'public/less/variables.less'; .commit { position: relative; @@ -7,7 +7,7 @@ z-index: 2; .commit-box { box-shadow: 5px 5px 0px rgba(0, 0, 0, 0.2); - background: #4B5766; + background: #4b5766; left: -5px; .arrow { @@ -26,7 +26,7 @@ .details { .diff-wrapper { margin-bottom: 5px; - transition:width 0.1s, left 0.05s; + transition: width 0.1s, left 0.05s; box-shadow: 0px 0px 15px rgba(0, 0, 0, 0.15); .diff-inner { box-shadow: 5px 5px 0px rgba(0, 0, 0, 0.2); @@ -77,11 +77,11 @@ .body { white-space: pre-wrap; word-wrap: break-word; - color: #8F9FA6; + color: #8f9fa6; } .diff-wrapper { margin-top: 10px; - background: #4B5766; + background: #4b5766; border-radius: 3px; } } diff --git a/components/commitdiff/commitdiff.html b/components/commitdiff/commitdiff.html index 8cde60b26..7a1c12a96 100644 --- a/components/commitdiff/commitdiff.html +++ b/components/commitdiff/commitdiff.html @@ -1,16 +1,37 @@ -
+
-
-
-
diff --git a/components/commitdiff/commitdiff.js b/components/commitdiff/commitdiff.js index eabd7bdb2..9a3b49eaa 100644 --- a/components/commitdiff/commitdiff.js +++ b/components/commitdiff/commitdiff.js @@ -2,7 +2,7 @@ const ko = require('knockout'); const CommitLineDiff = require('./commitlinediff.js').CommitLineDiff; const components = require('ungit-components'); -components.register('commitDiff', args => new CommitDiff(args)); +components.register('commitDiff', (args) => new CommitDiff(args)); class CommitDiff { constructor(args) { @@ -25,9 +25,11 @@ class CommitDiff { const tempCommitLineDiffs = []; const lineDiffLength = this.commitLineDiffs().length; - args.fileLineDiffs.slice(lineDiffLength === 0 ? 0 : lineDiffLength + 1, this.maxNumberOfFilesShown).forEach(fileLineDiff => { - tempCommitLineDiffs.push(new CommitLineDiff(args, fileLineDiff)); - }); + args.fileLineDiffs + .slice(lineDiffLength === 0 ? 0 : lineDiffLength + 1, this.maxNumberOfFilesShown) + .forEach((fileLineDiff) => { + tempCommitLineDiffs.push(new CommitLineDiff(args, fileLineDiff)); + }); this.commitLineDiffs(this.commitLineDiffs().concat(tempCommitLineDiffs)); } diff --git a/components/commitdiff/commitdiff.less b/components/commitdiff/commitdiff.less index 60b23625c..4ee83e992 100644 --- a/components/commitdiff/commitdiff.less +++ b/components/commitdiff/commitdiff.less @@ -1,4 +1,3 @@ - .commitdiff { width: 100%; .file { @@ -14,13 +13,17 @@ color: rgba(255, 255, 255, 0.79); word-wrap: break-word; .file-stats { - span:nth-of-type(1)::Before{ content: "+" } - span:nth-of-type(1){ - color: #9BF3A9; + span:nth-of-type(1)::before { + content: '+'; } - span:nth-of-type(2)::Before{ content: "-" } - span:nth-of-type(2){ - color: #EC9D93; + span:nth-of-type(1) { + color: #9bf3a9; + } + span:nth-of-type(2)::before { + content: '-'; + } + span:nth-of-type(2) { + color: #ec9d93; } } } diff --git a/components/commitdiff/commitlinediff.js b/components/commitdiff/commitlinediff.js index 4a3ff374b..101ad43fb 100644 --- a/components/commitdiff/commitlinediff.js +++ b/components/commitdiff/commitlinediff.js @@ -30,7 +30,7 @@ class CommitLineDiff { textDiffType: this.textDiffType, isShowingDiffs: this.isShowingDiffs, whiteSpace: this.whiteSpace, - wordWrap: this.wordWrap + wordWrap: this.wordWrap, }); } diff --git a/components/commitdiff/ungit-plugin.json b/components/commitdiff/ungit-plugin.json index ded299a1c..543aa1134 100644 --- a/components/commitdiff/ungit-plugin.json +++ b/components/commitdiff/ungit-plugin.json @@ -6,4 +6,4 @@ "javascript": "commitdiff.bundle.js", "css": "commitdiff.css" } -} \ No newline at end of file +} diff --git a/components/crash/crash.html b/components/crash/crash.html index eca9dbbfb..61ef784e1 100644 --- a/components/crash/crash.html +++ b/components/crash/crash.html @@ -1,35 +1,59 @@ -
+

Whooops

- Unfortunately ungit interrupted its work because:
+ Unfortunately ungit interrupted its work because:
The following tips will help solve this problem depending on the error: -

+

    -
  • General: +
  • + General:
      -
    • something went wrong, reload the page to start over -
    • check server out or logs for errors -
    • ~/.ungitrc must contain valid JSON. Minimal valid json is "{}" +
    • something went wrong, reload the page to start over
    • +
    • check server out or logs for errors
    • +
    • ~/.ungitrc must contain valid JSON. Minimal valid json is "{}"
    -
  • Connection Lost: +
  • + +
  • + Connection Lost:
      -
    • check status of server or network connection to the ungit server +
    • check status of server or network connection to the ungit server
    -
  • Ad Blockers and Privacy Extensions: -
      -
    • add ungit server url to adblocker exception (with port definition) or disable for a while -
    -
  • Git does not have enough permissions: +
  • + +
  • + Ad Blockers and Privacy Extensions:
      -
    • check if you could write to .git directory (preferably on unix systems) +
    • + add ungit server url to adblocker exception (with port definition) or disable for a + while +
    -
  • Other: +
  • + +
  • + Git does not have enough permissions:
      -
    • Find or report bug at ungit github.
      - Just common sense; do a quick search before posting, someone might already have created an issue (or resolved the problem!).
      - 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). +
    • check if you could write to .git directory (preferably on unix systems)
    +
  • + +
  • + Other: +
      +
    • + Find or report bug at + ungit github.
      + Just common sense; do a quick search before posting, someone might already have + created an issue (or resolved the problem!).
      + 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). +
    • +
    +
diff --git a/components/crash/crash.js b/components/crash/crash.js index 8ecb1727a..45132d4e9 100644 --- a/components/crash/crash.js +++ b/components/crash/crash.js @@ -5,7 +5,7 @@ components.register('crash', (err) => new CrashViewModel(err)); class CrashViewModel { constructor(err) { - this.eventcause = err ? err : 'unknown error' + this.eventcause = err ? err : 'unknown error'; } updateNode(parentElement) { diff --git a/components/dialogs/dialogs.js b/components/dialogs/dialogs.js index fa14f6bb2..be2fb7845 100644 --- a/components/dialogs/dialogs.js +++ b/components/dialogs/dialogs.js @@ -1,25 +1,33 @@ - const ko = require('knockout'); const components = require('ungit-components'); const Bluebird = require('bluebird'); const programEvents = require('ungit-program-events'); -components.register('formdialog', args => new FormDialogViewModel(args.title)); -components.register('credentialsdialog', args => new CredentialsDialogViewModel({remote: args.remote})); -components.register('addremotedialog', args => new AddRemoteDialogViewModel()); -components.register('addsubmoduledialog', args => new AddSubmoduleDialogViewModel()); -components.register('promptdialog', args => new PromptDialogViewModel(args.title, args.details)); -components.register('yesnodialog', args => new YesNoDialogViewModel(args.title, args.details)); -components.register('yesnomutedialog', args => new YesNoMuteDialogViewModel(args.title, args.details)); -components.register('toomanyfilesdialogviewmodel', args => new TooManyFilesDialogViewModel(args.title, args.details)); -components.register('texteditdialog', args => new TextEditDialog(args.title, args.content)); +components.register('formdialog', (args) => new FormDialogViewModel(args.title)); +components.register( + 'credentialsdialog', + (args) => new CredentialsDialogViewModel({ remote: args.remote }) +); +components.register('addremotedialog', (args) => new AddRemoteDialogViewModel()); +components.register('addsubmoduledialog', (args) => new AddSubmoduleDialogViewModel()); +components.register('promptdialog', (args) => new PromptDialogViewModel(args.title, args.details)); +components.register('yesnodialog', (args) => new YesNoDialogViewModel(args.title, args.details)); +components.register( + 'yesnomutedialog', + (args) => new YesNoMuteDialogViewModel(args.title, args.details) +); +components.register( + 'toomanyfilesdialogviewmodel', + (args) => new TooManyFilesDialogViewModel(args.title, args.details) +); +components.register('texteditdialog', (args) => new TextEditDialog(args.title, args.content)); class DialogViewModel { constructor(title) { this.onclose = null; this.title = ko.observable(title); this.taDialogName = ko.observable(''); - this.closePromise = new Bluebird(resolve => { + this.closePromise = new Bluebird((resolve) => { this.onclose = resolve; }); } @@ -51,7 +59,9 @@ class FormDialogViewModel extends DialogViewModel { this.showCancel = ko.observable(true); } - get template() { return 'formDialog'; } + get template() { + return 'formDialog'; + } submit() { this.isSubmitted(true); @@ -69,7 +79,7 @@ class CredentialsDialogViewModel extends FormDialogViewModel { const self = this; this.items([ { name: 'Username', value: self.username, type: 'text', autofocus: true }, - { name: 'Password', value: self.password, type: 'password', autofocus: false } + { name: 'Password', value: self.password, type: 'password', autofocus: false }, ]); } } @@ -83,7 +93,7 @@ class AddRemoteDialogViewModel extends FormDialogViewModel { const self = this; this.items([ { name: 'Name', value: self.name, type: 'text', autofocus: true }, - { name: 'Url', value: self.url, type: 'text', autofocus: false } + { name: 'Url', value: self.url, type: 'text', autofocus: false }, ]); } } @@ -97,7 +107,7 @@ class AddSubmoduleDialogViewModel extends FormDialogViewModel { const self = this; this.items([ { name: 'Path', value: self.path, type: 'text', autofocus: true }, - { name: 'Url', value: self.url, type: 'text', autofocus: false } + { name: 'Url', value: self.url, type: 'text', autofocus: false }, ]); } } @@ -109,7 +119,9 @@ class PromptDialogViewModel extends DialogViewModel { this.details = ko.observable(details); } - get template() { return 'prompt'; } + get template() { + return 'prompt'; + } } class YesNoDialogViewModel extends PromptDialogViewModel { @@ -119,8 +131,24 @@ class YesNoDialogViewModel extends PromptDialogViewModel { this.result = ko.observable(false); const self = this; this.alternatives([ - { label: 'Yes', primary: true, taId: 'yes', click() { self.result(true); self.close(); } }, - { label: 'No', primary: false, taId: 'no', click() { self.result(false); self.close(); } }, + { + label: 'Yes', + primary: true, + taId: 'yes', + click() { + self.result(true); + self.close(); + }, + }, + { + label: 'No', + primary: false, + taId: 'no', + click() { + self.result(false); + self.close(); + }, + }, ]); } } @@ -132,9 +160,33 @@ class YesNoMuteDialogViewModel extends PromptDialogViewModel { this.result = ko.observable(false); const self = this; this.alternatives([ - { label: 'Yes', primary: true, taId: 'yes', click() { self.result(true); self.close(); } }, - { label: 'Yes and mute for awhile', primary: false, taId: 'mute', click() { self.result("mute"); self.close() } }, - { label: 'No', primary: false, taId: 'no', click() { self.result(false); self.close(); } } + { + label: 'Yes', + primary: true, + taId: 'yes', + click() { + self.result(true); + self.close(); + }, + }, + { + label: 'Yes and mute for awhile', + primary: false, + taId: 'mute', + click() { + self.result('mute'); + self.close(); + }, + }, + { + label: 'No', + primary: false, + taId: 'no', + click() { + self.result(false); + self.close(); + }, + }, ]); } } @@ -146,27 +198,57 @@ class TooManyFilesDialogViewModel extends PromptDialogViewModel { this.result = ko.observable(false); const self = this; this.alternatives([ - { label: "Don't load", primary: true, taId: 'noLoad', click() { self.result(false); self.close(); } }, - { label: 'Load anyway', primary: false, taId: 'loadAnyway', click() { self.result(true); self.close(); } }, + { + label: "Don't load", + primary: true, + taId: 'noLoad', + click() { + self.result(false); + self.close(); + }, + }, + { + label: 'Load anyway', + primary: false, + taId: 'loadAnyway', + click() { + self.result(true); + self.close(); + }, + }, ]); } } class TextEditDialog extends PromptDialogViewModel { constructor(title, content) { - super(title, ``); + super( + title, + `` + ); this.taDialogName('text-edit-dialog'); this.result = ko.observable(false); const self = this; this.alternatives([ { - label: "Save", primary: true, taId: 'save', click() { + label: 'Save', + primary: true, + taId: 'save', + click() { self.textAreaContent = document.querySelector('.modal-body .text-area-content').value; self.result(true); self.close(); - } + }, + }, + { + label: 'Cancel', + primary: false, + taId: 'cancel', + click() { + self.result(false); + self.close(); + }, }, - { label: 'Cancel', primary: false, taId: 'cancel', click() { self.result(false); self.close(); } }, ]); } } diff --git a/components/dialogs/formDialog.html b/components/dialogs/formDialog.html index 3fd9a6f2b..aab5e62b0 100644 --- a/components/dialogs/formDialog.html +++ b/components/dialogs/formDialog.html @@ -1,4 +1,9 @@ -