Skip to content

Commit b59743d

Browse files
committed
Improved behavior of:
* word-wrapping in navigation when collapsed * switch button, when extension is off * navigation being clicked on while collapsed Increased version number.
1 parent 3979ac1 commit b59743d

File tree

5 files changed

+76
-27
lines changed

5 files changed

+76
-27
lines changed

manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "GitLab - Tree view for code",
33
"homepage_url": "https://github.com/tomasbonco/gitlabtree",
44
"author": "Tomáš Bončo",
5-
"version": "0.0.10",
5+
"version": "1.0.0",
66
"manifest_version": 2,
77
"description": "Provides folder structure view for code in GitLab.",
88
"icons": {

src/inject/folder.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -216,10 +216,14 @@ export class Folder
216216
return (
217217
<div class={`${CSS_PREFIX}__folder ${ expandedClass } ${ this.state.isRoot ? CSS_PREFIX + '__folder--is-root' : '' }`}>
218218

219-
<div class={CSS_PREFIX + '__holder'} title={this.state.name} onclick={ () => this.toggleIsFolderExpanded() }> {this.state.name} </div>
220-
{ this.getFolders( parseInt( this.settingsStore.get( 'file-sort' )) ).map( fdr => fdr.render() ) }
221-
{ this.getFiles( parseInt( this.settingsStore.get( 'file-sort' )) ).map( fls => fls.render() ) }
219+
<div class={CSS_PREFIX + '__folder__holder'} title={this.state.name} onclick={ () => this.toggleIsFolderExpanded() }> {this.state.name} </div>
222220

221+
<div class={CSS_PREFIX + '__folder__content'}>
222+
223+
{ this.getFolders( parseInt( this.settingsStore.get( 'file-sort' )) ).map( fdr => fdr.render() ) }
224+
{ this.getFiles( parseInt( this.settingsStore.get( 'file-sort' )) ).map( fls => fls.render() ) }
225+
226+
</div>
223227
</div>
224228
)
225229
}

src/inject/main.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ export class GitLabTree
5151

5252
this.pubsub.subscribe( EVENT_SETTINGS_CHANGED, ( action, data ) => this.settingsChanged( action, data ))
5353
this.pubsub.subscribe( EVENT_TOGGLE_NAVIGATION, ( action, isOpen ) => this.performNavigationIsOpen( isOpen ))
54-
this.pubsub.subscribe( EVENT_TOGGLE_EXTENSION, () => this.toggleExtensionIsOn() );
54+
this.pubsub.subscribe( EVENT_TOGGLE_EXTENSION, (action, isOn ) => this.toggleExtensionIsOn( isOn ) );
5555

5656

5757
// Obtain metadata

src/inject/navigation.tsx

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ export class Navigation
1111
{
1212
private isNavigationOpened: boolean = true;
1313
private lastSort;
14+
private isExtensionOn: boolean = true;
15+
1416

1517
constructor( private structure: Structure, private pubsub: PubSub, private views: Views, private settingsStore: SettingsStore )
1618
{
@@ -63,6 +65,7 @@ export class Navigation
6365
*/
6466
onToggleNavigationIsOpen( isOpen?: boolean )
6567
{
68+
console.log('wut')
6669
this.isNavigationOpened = isOpen !== undefined ? isOpen : ! this.isNavigationOpened
6770

6871
this.pubsub.publish( EVENT_TOGGLE_NAVIGATION, this.isNavigationOpened ); // changes on top level are required
@@ -75,14 +78,30 @@ export class Navigation
7578
*/
7679
onToggleExtensionIsOn()
7780
{
78-
this.pubsub.publish( EVENT_TOGGLE_EXTENSION );
81+
this.isExtensionOn = ! this.isExtensionOn
82+
this.pubsub.publish( EVENT_TOGGLE_EXTENSION, this.isExtensionOn );
83+
this.views.redrawView( 'navigation' );
84+
}
85+
86+
87+
/**
88+
* Once navigation is collapsed, pointer-events are turned off.
89+
* This callback is attached to top-level element that accepts pointer events.
90+
* So once click is registred, this should open expend navigation.
91+
*/
92+
onMaybeOpenNavigation( e: MouseEvent )
93+
{
94+
if ( (e.target as HTMLElement).classList.contains( 'gitlab-tree-plugin__navigation' ) && ! this.isNavigationOpened )
95+
{
96+
this.onToggleNavigationIsOpen();
97+
}
7998
}
8099

81100

82101
render(): any
83102
{
84103
return (
85-
<div>
104+
<div class="gitlab-tree-plugin__navigation" onclick={(e) => this.onMaybeOpenNavigation( e )}>
86105

87106
<div class="gitlab-tree-plugin__files">
88107

@@ -92,7 +111,7 @@ export class Navigation
92111

93112
<div class="gitlab-tree-plugin__menu">
94113

95-
<div class={`gitlab-tree-plugin__menu__item ${ this.isNavigationOpened ? '' : 'gitlab-tree-plugin--is-hidden' }`} title="Turn extension off" onclick={ () => this.onToggleExtensionIsOn() }>
114+
<div id="gitlab-tree-plugin__toggle-on" class={`gitlab-tree-plugin__menu__item ${ this.isNavigationOpened ? '' : 'gitlab-tree-plugin--is-hidden' } ${ this.isExtensionOn ? '' : 'gitlab-tree-plugin--is-off' }`} title={ this.isExtensionOn ? "Turn extension off" : "Turn extension on" } onclick={ () => this.onToggleExtensionIsOn() }>
96115

97116
<i class="fa fa-power-off"></i>
98117

src/inject/style.styl

Lines changed: 45 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,8 @@
5454
margin-bottom: 10px;
5555

5656

57-
.gitlab-tree-plugin__holder
58-
{
59-
white-space: nowrap;
60-
text-overflow: ellipsis;
61-
overflow: hidden;
62-
57+
.gitlab-tree-plugin__folder__holder
58+
{
6359

6460
&:before
6561
{
@@ -75,25 +71,44 @@
7571
padding-left: 0px;
7672

7773

78-
> .gitlab-tree-plugin__holder
74+
> .gitlab-tree-plugin__folder__holder
7975
{
76+
white-space: nowrap;
77+
text-overflow: ellipsis;
78+
overflow: hidden;
79+
8080
background-color: #fafafa;
8181
border-bottom: 1px solid #e5e5e5;
8282
margin: 0;
8383
text-align: left;
8484
padding: 10px 16px;
85-
word-wrap: break-word;
8685
font-weight: bold;
8786

8887
margin-bottom: 5px;
8988
}
9089

91-
> .gitlab-tree-plugin__folder
90+
> .gitlab-tree-plugin__folder__content
9291
{
93-
padding-left: 15px;
92+
overflow: auto;
93+
padding-bottom: 5px;
94+
95+
.gitlab-tree-plugin__file
96+
{
97+
white-space: nowrap;
98+
}
99+
100+
.gitlab-tree-plugin__folder__holder
101+
{
102+
white-space: nowrap;
103+
}
104+
105+
> .gitlab-tree-plugin__folder
106+
{
107+
padding-left: 15px;
108+
}
94109
}
95110

96-
> .gitlab-tree-plugin__holder:before
111+
> .gitlab-tree-plugin__folder__holder:before
97112
{
98113
content: "\f07c";
99114
}
@@ -102,17 +117,12 @@
102117

103118
&--is-collapsed
104119
{
105-
> .gitlab-tree-plugin__holder:before
120+
> .gitlab-tree-plugin__folder__holder:before
106121
{
107122
content: "\f114";
108123
}
109124

110-
> .gitlab-tree-plugin__folder
111-
{
112-
display: none;
113-
}
114-
115-
> .gitlab-tree-plugin__file
125+
> .gitlab-tree-plugin__folder__content
116126
{
117127
display: none;
118128
}
@@ -206,10 +216,18 @@
206216
}
207217

208218

209-
#gitlab-tree-plugin__toggle-hide
219+
&#gitlab-tree-plugin__toggle-hide
210220
{
211221
border-left: 1px solid #e5e5e5;
212222
}
223+
224+
&#gitlab-tree-plugin__toggle-on
225+
{
226+
&.gitlab-tree-plugin--is-off
227+
{
228+
background: rgba(220, 53, 69, 0.75);
229+
}
230+
}
213231
}
214232
}
215233

@@ -227,6 +245,14 @@
227245
pointer-events: none;
228246
}
229247

248+
.gitlab-tree-plugin__folder--is-root
249+
{
250+
> .gitlab-tree-plugin__folder__content
251+
{
252+
overflow: hidden !important;
253+
}
254+
}
255+
230256
#gitlab-tree-plugin__toggle-hide
231257
{
232258
width: 100%;

0 commit comments

Comments
 (0)