Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
38431c8f
Commit
38431c8f
authored
Dec 07, 2018
by
Paul Slaughter
Committed by
Phil Hughes
Dec 07, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
CE Port of "Web Terminal FE"
parent
498e34c6
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
134 additions
and
20 deletions
+134
-20
app/assets/javascripts/lib/utils/dom_utils.js
app/assets/javascripts/lib/utils/dom_utils.js
+5
-0
app/assets/javascripts/terminal/index.js
app/assets/javascripts/terminal/index.js
+1
-1
app/assets/javascripts/terminal/terminal.js
app/assets/javascripts/terminal/terminal.js
+53
-4
app/assets/stylesheets/framework/common.scss
app/assets/stylesheets/framework/common.scss
+1
-0
app/assets/stylesheets/page_bundles/_ide_mixins.scss
app/assets/stylesheets/page_bundles/_ide_mixins.scss
+18
-0
app/assets/stylesheets/page_bundles/ide.scss
app/assets/stylesheets/page_bundles/ide.scss
+3
-14
spec/javascripts/lib/utils/dom_utils_spec.js
spec/javascripts/lib/utils/dom_utils_spec.js
+53
-1
No files found.
app/assets/javascripts/lib/utils/dom_utils.js
View file @
38431c8f
...
@@ -7,3 +7,8 @@ export const addClassIfElementExists = (element, className) => {
...
@@ -7,3 +7,8 @@ export const addClassIfElementExists = (element, className) => {
};
};
export
const
isInVueNoteablePage
=
()
=>
isInIssuePage
()
||
isInEpicPage
()
||
isInMRPage
();
export
const
isInVueNoteablePage
=
()
=>
isInIssuePage
()
||
isInEpicPage
()
||
isInMRPage
();
export
const
canScrollUp
=
({
scrollTop
},
margin
=
0
)
=>
scrollTop
>
margin
;
export
const
canScrollDown
=
({
scrollTop
,
offsetHeight
,
scrollHeight
},
margin
=
0
)
=>
scrollTop
+
offsetHeight
<
scrollHeight
-
margin
;
app/assets/javascripts/terminal/index.js
View file @
38431c8f
import
Terminal
from
'
./terminal
'
;
import
Terminal
from
'
./terminal
'
;
export
default
()
=>
new
Terminal
(
{
selector
:
'
#terminal
'
}
);
export
default
()
=>
new
Terminal
(
document
.
getElementById
(
'
terminal
'
)
);
app/assets/javascripts/terminal/terminal.js
View file @
38431c8f
import
_
from
'
underscore
'
;
import
$
from
'
jquery
'
;
import
$
from
'
jquery
'
;
import
{
Terminal
}
from
'
xterm
'
;
import
{
Terminal
}
from
'
xterm
'
;
import
*
as
fit
from
'
xterm/lib/addons/fit/fit
'
;
import
*
as
fit
from
'
xterm/lib/addons/fit/fit
'
;
import
{
canScrollUp
,
canScrollDown
}
from
'
~/lib/utils/dom_utils
'
;
const
SCROLL_MARGIN
=
5
;
Terminal
.
applyAddon
(
fit
);
export
default
class
GLTerminal
{
export
default
class
GLTerminal
{
constructor
(
options
=
{})
{
constructor
(
element
,
options
=
{})
{
this
.
options
=
Object
.
assign
(
this
.
options
=
Object
.
assign
(
{},
{},
{
{
...
@@ -13,7 +19,8 @@ export default class GLTerminal {
...
@@ -13,7 +19,8 @@ export default class GLTerminal {
options
,
options
,
);
);
this
.
container
=
document
.
querySelector
(
options
.
selector
);
this
.
container
=
element
;
this
.
onDispose
=
[];
this
.
setSocketUrl
();
this
.
setSocketUrl
();
this
.
createTerminal
();
this
.
createTerminal
();
...
@@ -34,8 +41,6 @@ export default class GLTerminal {
...
@@ -34,8 +41,6 @@ export default class GLTerminal {
}
}
createTerminal
()
{
createTerminal
()
{
Terminal
.
applyAddon
(
fit
);
this
.
terminal
=
new
Terminal
(
this
.
options
);
this
.
terminal
=
new
Terminal
(
this
.
options
);
this
.
socket
=
new
WebSocket
(
this
.
socketUrl
,
[
'
terminal.gitlab.com
'
]);
this
.
socket
=
new
WebSocket
(
this
.
socketUrl
,
[
'
terminal.gitlab.com
'
]);
...
@@ -72,4 +77,48 @@ export default class GLTerminal {
...
@@ -72,4 +77,48 @@ export default class GLTerminal {
handleSocketFailure
()
{
handleSocketFailure
()
{
this
.
terminal
.
write
(
'
\r\n
Connection failure
'
);
this
.
terminal
.
write
(
'
\r\n
Connection failure
'
);
}
}
addScrollListener
(
onScrollLimit
)
{
const
viewport
=
this
.
container
.
querySelector
(
'
.xterm-viewport
'
);
const
listener
=
_
.
throttle
(()
=>
{
onScrollLimit
({
canScrollUp
:
canScrollUp
(
viewport
,
SCROLL_MARGIN
),
canScrollDown
:
canScrollDown
(
viewport
,
SCROLL_MARGIN
),
});
});
this
.
onDispose
.
push
(()
=>
viewport
.
removeEventListener
(
'
scroll
'
,
listener
));
viewport
.
addEventListener
(
'
scroll
'
,
listener
);
// don't forget to initialize value before scroll!
listener
({
target
:
viewport
});
}
disable
()
{
this
.
terminal
.
setOption
(
'
cursorBlink
'
,
false
);
this
.
terminal
.
setOption
(
'
theme
'
,
{
foreground
:
'
#707070
'
});
this
.
terminal
.
setOption
(
'
disableStdin
'
,
true
);
this
.
socket
.
close
();
}
dispose
()
{
this
.
terminal
.
off
(
'
data
'
);
this
.
terminal
.
dispose
();
this
.
socket
.
close
();
this
.
onDispose
.
forEach
(
fn
=>
fn
());
this
.
onDispose
.
length
=
0
;
}
scrollToTop
()
{
this
.
terminal
.
scrollToTop
();
}
scrollToBottom
()
{
this
.
terminal
.
scrollToBottom
();
}
fit
()
{
this
.
terminal
.
fit
();
}
}
}
app/assets/stylesheets/framework/common.scss
View file @
38431c8f
...
@@ -386,3 +386,4 @@ img.emoji {
...
@@ -386,3 +386,4 @@ img.emoji {
.flex-no-shrink
{
flex-shrink
:
0
;
}
.flex-no-shrink
{
flex-shrink
:
0
;
}
.mw-460
{
max-width
:
460px
;
}
.mw-460
{
max-width
:
460px
;
}
.ws-initial
{
white-space
:
initial
;
}
.ws-initial
{
white-space
:
initial
;
}
.min-height-0
{
min-height
:
0
;
}
app/assets/stylesheets/page_bundles/_ide_mixins.scss
0 → 100644
View file @
38431c8f
@mixin
ide-trace-view
{
display
:
flex
;
flex-direction
:
column
;
height
:
100%
;
margin-top
:
-
$grid-size
;
margin-bottom
:
-
$grid-size
;
&
.build-page
.top-bar
{
top
:
0
;
height
:
auto
;
font-size
:
12px
;
border-top-right-radius
:
$border-radius-default
;
}
.top-bar
{
margin-left
:
-
$gl-padding
;
}
}
app/assets/stylesheets/page_bundles/ide.scss
View file @
38431c8f
@import
'framework/variables'
;
@import
'framework/variables'
;
@import
'framework/mixins'
;
@import
'framework/mixins'
;
@import
'./ide_mixins'
;
$search-list-icon-width
:
18px
;
$search-list-icon-width
:
18px
;
$ide-activity-bar-width
:
60px
;
$ide-activity-bar-width
:
60px
;
...
@@ -1111,11 +1112,7 @@ $ide-commit-header-height: 48px;
...
@@ -1111,11 +1112,7 @@ $ide-commit-header-height: 48px;
}
}
.ide-pipeline
{
.ide-pipeline
{
display
:
flex
;
@include
ide-trace-view
();
flex-direction
:
column
;
height
:
100%
;
margin-top
:
-
$grid-size
;
margin-bottom
:
-
$grid-size
;
.empty-state
{
.empty-state
{
margin-top
:
auto
;
margin-top
:
auto
;
...
@@ -1133,17 +1130,9 @@ $ide-commit-header-height: 48px;
...
@@ -1133,17 +1130,9 @@ $ide-commit-header-height: 48px;
}
}
}
}
.build-trace
,
.build-trace
{
.top-bar
{
margin-left
:
-
$gl-padding
;
margin-left
:
-
$gl-padding
;
}
}
&
.build-page
.top-bar
{
top
:
0
;
height
:
auto
;
font-size
:
12px
;
border-top-right-radius
:
$border-radius-default
;
}
}
}
.ide-pipeline-list
{
.ide-pipeline-list
{
...
...
spec/javascripts/lib/utils/dom_utils_spec.js
View file @
38431c8f
import
{
addClassIfElementExists
}
from
'
~/lib/utils/dom_utils
'
;
import
{
addClassIfElementExists
,
canScrollUp
,
canScrollDown
}
from
'
~/lib/utils/dom_utils
'
;
const
TEST_MARGIN
=
5
;
describe
(
'
DOM Utils
'
,
()
=>
{
describe
(
'
DOM Utils
'
,
()
=>
{
describe
(
'
addClassIfElementExists
'
,
()
=>
{
describe
(
'
addClassIfElementExists
'
,
()
=>
{
...
@@ -34,4 +36,54 @@ describe('DOM Utils', () => {
...
@@ -34,4 +36,54 @@ describe('DOM Utils', () => {
addClassIfElementExists
(
childElement
,
className
);
addClassIfElementExists
(
childElement
,
className
);
});
});
});
});
describe
(
'
canScrollUp
'
,
()
=>
{
[
1
,
100
].
forEach
(
scrollTop
=>
{
it
(
`is true if scrollTop is > 0 (
${
scrollTop
}
)`
,
()
=>
{
expect
(
canScrollUp
({
scrollTop
})).
toBe
(
true
);
});
});
[
0
,
-
10
].
forEach
(
scrollTop
=>
{
it
(
`is false if scrollTop is <= 0 (
${
scrollTop
}
)`
,
()
=>
{
expect
(
canScrollUp
({
scrollTop
})).
toBe
(
false
);
});
});
it
(
'
is true if scrollTop is > margin
'
,
()
=>
{
expect
(
canScrollUp
({
scrollTop
:
TEST_MARGIN
+
1
},
TEST_MARGIN
)).
toBe
(
true
);
});
it
(
'
is false if scrollTop is <= margin
'
,
()
=>
{
expect
(
canScrollUp
({
scrollTop
:
TEST_MARGIN
},
TEST_MARGIN
)).
toBe
(
false
);
});
});
describe
(
'
canScrollDown
'
,
()
=>
{
let
element
;
beforeEach
(()
=>
{
element
=
{
scrollTop
:
7
,
offsetHeight
:
22
,
scrollHeight
:
30
};
});
it
(
'
is true if element can be scrolled down
'
,
()
=>
{
expect
(
canScrollDown
(
element
)).
toBe
(
true
);
});
it
(
'
is false if element cannot be scrolled down
'
,
()
=>
{
element
.
scrollHeight
-=
1
;
expect
(
canScrollDown
(
element
)).
toBe
(
false
);
});
it
(
'
is true if element can be scrolled down, with margin given
'
,
()
=>
{
element
.
scrollHeight
+=
TEST_MARGIN
;
expect
(
canScrollDown
(
element
,
TEST_MARGIN
)).
toBe
(
true
);
});
it
(
'
is false if element cannot be scrolled down, with margin given
'
,
()
=>
{
expect
(
canScrollDown
(
element
,
TEST_MARGIN
)).
toBe
(
false
);
});
});
});
});
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment