Skip to content

Commit 64f1cfa

Browse files
committed
initial commit
0 parents  commit 64f1cfa

14 files changed

+262
-0
lines changed

.editorconfig

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Visit https://editorconfig.org for information.
2+
3+
[*]
4+
charset = utf-8
5+
end_of_line = lf
6+
indent_size = 2
7+
indent_style = space
8+
insert_final_newline = true
9+
trim_trailing_whitespace = true

.gitattributes

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Visit https://git-scm.com/docs/gitattributes for information.
2+
3+
* text=auto

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Visit https://git-scm.com/docs/gitignore for information.
2+
3+
.DS_Store
4+
npm-debug.log
5+
node_modules

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
## 0.1.0 - First Release
2+
* Every feature added
3+
* Every bug fixed

LICENSE.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
Copyright (c) 2021 John A. Stritch
2+
3+
Permission is hereby granted, free of charge, to any person obtaining
4+
a copy of this software and associated documentation files (the
5+
"Software"), to deal in the Software without restriction, including
6+
without limitation the rights to use, copy, modify, merge, publish,
7+
distribute, sublicense, and/or sell copies of the Software, and to
8+
permit persons to whom the Software is furnished to do so, subject to
9+
the following conditions:
10+
11+
The above copyright notice and this permission notice shall be
12+
included in all copies or substantial portions of the Software.
13+
14+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# git-tabular-diff package
2+
3+
A short description of your package.
4+
5+
![A screenshot of your package](https://f.cloud.github.com/assets/69169/2290250/c35d867a-a017-11e3-86be-cd7c5bf3ff9b.gif)

keymaps/git-tabular-diff.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"atom-workspace": {
3+
"ctrl-alt-o": "git-tabular-diff:toggle"
4+
}
5+
}

lib/git-tabular-diff-view.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
'use babel';
2+
3+
export default class GitTabularDiffView {
4+
5+
constructor(serializedState) {
6+
// Create root element
7+
this.element = document.createElement('div');
8+
this.element.classList.add('git-tabular-diff');
9+
10+
// Create message element
11+
const message = document.createElement('div');
12+
message.textContent = 'The GitTabularDiff package is Alive! It\'s ALIVE!';
13+
message.classList.add('message');
14+
this.element.appendChild(message);
15+
}
16+
17+
// Returns an object that can be retrieved when package is activated
18+
serialize() {}
19+
20+
// Tear down any state and detach
21+
destroy() {
22+
this.element.remove();
23+
}
24+
25+
getElement() {
26+
return this.element;
27+
}
28+
29+
}

lib/git-tabular-diff.js

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
'use babel';
2+
3+
import GitTabularDiffView from './git-tabular-diff-view';
4+
import { CompositeDisposable } from 'atom';
5+
6+
export default {
7+
8+
gitTabularDiffView: null,
9+
modalPanel: null,
10+
subscriptions: null,
11+
12+
activate(state) {
13+
this.gitTabularDiffView = new GitTabularDiffView(state.gitTabularDiffViewState);
14+
this.modalPanel = atom.workspace.addModalPanel({
15+
item: this.gitTabularDiffView.getElement(),
16+
visible: false
17+
});
18+
19+
// Events subscribed to in atom's system can be easily cleaned up with a CompositeDisposable
20+
this.subscriptions = new CompositeDisposable();
21+
22+
// Register command that toggles this view
23+
this.subscriptions.add(atom.commands.add('atom-workspace', {
24+
'git-tabular-diff:toggle': () => this.toggle()
25+
}));
26+
},
27+
28+
deactivate() {
29+
this.modalPanel.destroy();
30+
this.subscriptions.dispose();
31+
this.gitTabularDiffView.destroy();
32+
},
33+
34+
serialize() {
35+
return {
36+
gitTabularDiffViewState: this.gitTabularDiffView.serialize()
37+
};
38+
},
39+
40+
toggle() {
41+
console.log('GitTabularDiff was toggled!');
42+
return (
43+
this.modalPanel.isVisible() ?
44+
this.modalPanel.hide() :
45+
this.modalPanel.show()
46+
);
47+
}
48+
49+
};

menus/git-tabular-diff.json

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"context-menu": {
3+
"atom-text-editor": [
4+
{
5+
"label": "Toggle git-tabular-diff",
6+
"command": "git-tabular-diff:toggle"
7+
}
8+
]
9+
},
10+
"menu": [
11+
{
12+
"label": "Packages",
13+
"submenu": [
14+
{
15+
"label": "git-tabular-diff",
16+
"submenu": [
17+
{
18+
"label": "Toggle",
19+
"command": "git-tabular-diff:toggle"
20+
}
21+
]
22+
}
23+
]
24+
}
25+
]
26+
}

package.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"name": "git-tabular-diff",
3+
"main": "./lib/git-tabular-diff",
4+
"version": "0.0.0",
5+
"description": "A short description of your package",
6+
"keywords": [
7+
],
8+
"activationCommands": {
9+
"atom-workspace": "git-tabular-diff:toggle"
10+
},
11+
"repository": "https://github.com/jstritch/git-tabular-diff",
12+
"license": "MIT",
13+
"engines": {
14+
"atom": ">=1.0.0 <2.0.0"
15+
},
16+
"dependencies": {
17+
}
18+
}

spec/git-tabular-diff-spec.js

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
'use babel';
2+
3+
import GitTabularDiff from '../lib/git-tabular-diff';
4+
5+
// Use the command `window:run-package-specs` (cmd-alt-ctrl-p) to run specs.
6+
//
7+
// To run a specific `it` or `describe` block add an `f` to the front (e.g. `fit`
8+
// or `fdescribe`). Remove the `f` to unfocus the block.
9+
10+
describe('GitTabularDiff', () => {
11+
let workspaceElement, activationPromise;
12+
13+
beforeEach(() => {
14+
workspaceElement = atom.views.getView(atom.workspace);
15+
activationPromise = atom.packages.activatePackage('git-tabular-diff');
16+
});
17+
18+
describe('when the git-tabular-diff:toggle event is triggered', () => {
19+
it('hides and shows the modal panel', () => {
20+
// Before the activation event the view is not on the DOM, and no panel
21+
// has been created
22+
expect(workspaceElement.querySelector('.git-tabular-diff')).not.toExist();
23+
24+
// This is an activation event, triggering it will cause the package to be
25+
// activated.
26+
atom.commands.dispatch(workspaceElement, 'git-tabular-diff:toggle');
27+
28+
waitsForPromise(() => {
29+
return activationPromise;
30+
});
31+
32+
runs(() => {
33+
expect(workspaceElement.querySelector('.git-tabular-diff')).toExist();
34+
35+
let gitTabularDiffElement = workspaceElement.querySelector('.git-tabular-diff');
36+
expect(gitTabularDiffElement).toExist();
37+
38+
let gitTabularDiffPanel = atom.workspace.panelForItem(gitTabularDiffElement);
39+
expect(gitTabularDiffPanel.isVisible()).toBe(true);
40+
atom.commands.dispatch(workspaceElement, 'git-tabular-diff:toggle');
41+
expect(gitTabularDiffPanel.isVisible()).toBe(false);
42+
});
43+
});
44+
45+
it('hides and shows the view', () => {
46+
// This test shows you an integration test testing at the view level.
47+
48+
// Attaching the workspaceElement to the DOM is required to allow the
49+
// `toBeVisible()` matchers to work. Anything testing visibility or focus
50+
// requires that the workspaceElement is on the DOM. Tests that attach the
51+
// workspaceElement to the DOM are generally slower than those off DOM.
52+
jasmine.attachToDOM(workspaceElement);
53+
54+
expect(workspaceElement.querySelector('.git-tabular-diff')).not.toExist();
55+
56+
// This is an activation event, triggering it causes the package to be
57+
// activated.
58+
atom.commands.dispatch(workspaceElement, 'git-tabular-diff:toggle');
59+
60+
waitsForPromise(() => {
61+
return activationPromise;
62+
});
63+
64+
runs(() => {
65+
// Now we can test for view visibility
66+
let gitTabularDiffElement = workspaceElement.querySelector('.git-tabular-diff');
67+
expect(gitTabularDiffElement).toBeVisible();
68+
atom.commands.dispatch(workspaceElement, 'git-tabular-diff:toggle');
69+
expect(gitTabularDiffElement).not.toBeVisible();
70+
});
71+
});
72+
});
73+
});

spec/git-tabular-diff-view-spec.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
'use babel';
2+
3+
import GitTabularDiffView from '../lib/git-tabular-diff-view';
4+
5+
describe('GitTabularDiffView', () => {
6+
it('has one valid test', () => {
7+
expect('life').toBe('easy');
8+
});
9+
});

styles/git-tabular-diff.less

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// The ui-variables file is provided by base themes provided by Atom.
2+
//
3+
// See https://github.com/atom/atom-dark-ui/blob/master/styles/ui-variables.less
4+
// for a full listing of what's available.
5+
@import "ui-variables";
6+
7+
.git-tabular-diff {
8+
}

0 commit comments

Comments
 (0)