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
1fbed6dc
Commit
1fbed6dc
authored
Feb 09, 2020
by
Paul Slaughter
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add MR to Web IDE bottom status bar
- This is to prepare for removing the MR sidebar tab
parent
ad890526
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
188 additions
and
55 deletions
+188
-55
app/assets/javascripts/ide/components/ide_status_bar.vue
app/assets/javascripts/ide/components/ide_status_bar.vue
+9
-1
app/assets/javascripts/ide/components/ide_status_mr.vue
app/assets/javascripts/ide/components/ide_status_mr.vue
+28
-0
locale/gitlab.pot
locale/gitlab.pot
+3
-0
spec/frontend/ide/components/ide_status_mr_spec.js
spec/frontend/ide/components/ide_status_mr_spec.js
+59
-0
spec/javascripts/ide/components/ide_status_bar_spec.js
spec/javascripts/ide/components/ide_status_bar_spec.js
+89
-54
No files found.
app/assets/javascripts/ide/components/ide_status_bar.vue
View file @
1fbed6dc
...
...
@@ -2,6 +2,7 @@
/* eslint-disable @gitlab/vue-i18n/no-bare-strings */
import
{
mapActions
,
mapState
,
mapGetters
}
from
'
vuex
'
;
import
IdeStatusList
from
'
ee_else_ce/ide/components/ide_status_list.vue
'
;
import
IdeStatusMr
from
'
./ide_status_mr.vue
'
;
import
icon
from
'
~/vue_shared/components/icon.vue
'
;
import
tooltip
from
'
~/vue_shared/directives/tooltip
'
;
import
timeAgoMixin
from
'
~/vue_shared/mixins/timeago
'
;
...
...
@@ -15,6 +16,7 @@ export default {
userAvatarImage
,
CiIcon
,
IdeStatusList
,
IdeStatusMr
,
},
directives
:
{
tooltip
,
...
...
@@ -27,7 +29,7 @@ export default {
},
computed
:
{
...
mapState
([
'
currentBranchId
'
,
'
currentProjectId
'
]),
...
mapGetters
([
'
currentProject
'
,
'
lastCommit
'
]),
...
mapGetters
([
'
currentProject
'
,
'
lastCommit
'
,
'
currentMergeRequest
'
]),
...
mapState
(
'
pipelines
'
,
[
'
latestPipeline
'
]),
},
watch
:
{
...
...
@@ -121,6 +123,12 @@ export default {
>
{{
lastCommitFormattedAge
}}
</time
>
</div>
<ide-status-mr
v-if=
"currentMergeRequest"
class=
"mx-3"
:url=
"currentMergeRequest.web_url"
:text=
"currentMergeRequest.references.short"
/>
<ide-status-list
class=
"ml-auto"
/>
</footer>
</
template
>
app/assets/javascripts/ide/components/ide_status_mr.vue
0 → 100644
View file @
1fbed6dc
<
script
>
import
{
GlIcon
,
GlLink
}
from
'
@gitlab/ui
'
;
export
default
{
components
:
{
GlIcon
,
GlLink
,
},
props
:
{
text
:
{
type
:
String
,
required
:
true
,
},
url
:
{
type
:
String
,
required
:
true
,
},
},
};
</
script
>
<
template
>
<div
class=
"d-flex-center flex-nowrap text-nowrap js-ide-status-mr"
>
<gl-icon
name=
"merge-request"
/>
<span
class=
"ml-1 d-none d-sm-block"
>
{{
s__
(
'
WebIDE|Merge request
'
)
}}
</span>
<gl-link
class=
"ml-1"
:href=
"url"
>
{{
text
}}
</gl-link>
</div>
</
template
>
locale/gitlab.pot
View file @
1fbed6dc
...
...
@@ -21405,6 +21405,9 @@ msgstr ""
msgid "Web terminal"
msgstr ""
msgid "WebIDE|Merge request"
msgstr ""
msgid "Webhooks"
msgstr ""
...
...
spec/frontend/ide/components/ide_status_mr_spec.js
0 → 100644
View file @
1fbed6dc
import
{
shallowMount
}
from
'
@vue/test-utils
'
;
import
{
GlIcon
,
GlLink
}
from
'
@gitlab/ui
'
;
import
{
TEST_HOST
}
from
'
helpers/test_constants
'
;
import
IdeStatusMr
from
'
~/ide/components/ide_status_mr.vue
'
;
const
TEST_TEXT
=
'
!9001
'
;
const
TEST_URL
=
`
${
TEST_HOST
}
merge-requests/9001`
;
describe
(
'
ide/components/ide_status_mr
'
,
()
=>
{
let
wrapper
;
const
createComponent
=
props
=>
{
wrapper
=
shallowMount
(
IdeStatusMr
,
{
propsData
:
props
,
});
};
const
findIcon
=
()
=>
wrapper
.
find
(
GlIcon
);
const
findLink
=
()
=>
wrapper
.
find
(
GlLink
);
afterEach
(()
=>
{
wrapper
.
destroy
();
});
describe
(
'
when mounted
'
,
()
=>
{
beforeEach
(()
=>
{
createComponent
({
text
:
TEST_TEXT
,
url
:
TEST_URL
,
});
});
it
(
'
renders icon
'
,
()
=>
{
const
icon
=
findIcon
();
expect
(
icon
.
exists
()).
toBe
(
true
);
expect
(
icon
.
props
()).
toEqual
(
expect
.
objectContaining
({
name
:
'
merge-request
'
,
}),
);
});
it
(
'
renders link
'
,
()
=>
{
const
link
=
findLink
();
expect
(
link
.
exists
()).
toBe
(
true
);
expect
(
link
.
attributes
()).
toEqual
(
expect
.
objectContaining
({
href
:
TEST_URL
,
}),
);
expect
(
link
.
text
()).
toEqual
(
TEST_TEXT
);
});
it
(
'
renders text
'
,
()
=>
{
expect
(
wrapper
.
text
()).
toBe
(
`Merge request
${
TEST_TEXT
}
`
);
});
});
});
spec/javascripts/ide/components/ide_status_bar_spec.js
View file @
1fbed6dc
import
Vue
from
'
vue
'
;
import
_
from
'
lodash
'
;
import
{
createComponentWithStore
}
from
'
spec/helpers/vue_mount_component_helper
'
;
import
store
from
'
~/ide/stores
'
;
import
ideStatusBar
from
'
~/ide/components/ide_status_bar.vue
'
;
import
{
TEST_HOST
}
from
'
spec/test_constants
'
;
import
{
createStore
}
from
'
~/ide/stores
'
;
import
IdeStatusBar
from
'
~/ide/components/ide_status_bar.vue
'
;
import
{
rightSidebarViews
}
from
'
~/ide/constants
'
;
import
{
resetStore
}
from
'
../helpers
'
;
import
{
projectData
}
from
'
../mock_data
'
;
const
TEST_PROJECT_ID
=
'
abcproject
'
;
const
TEST_MERGE_REQUEST_ID
=
'
9001
'
;
const
TEST_MERGE_REQUEST_URL
=
`
${
TEST_HOST
}
merge-requests/
${
TEST_MERGE_REQUEST_ID
}
`
;
describe
(
'
ideStatusBar
'
,
()
=>
{
let
store
;
let
vm
;
beforeEach
(()
=>
{
const
Component
=
Vue
.
extend
(
ideStatusBar
);
const
createComponent
=
()
=>
{
vm
=
createComponentWithStore
(
Vue
.
extend
(
IdeStatusBar
),
store
).
$mount
();
};
const
findMRStatus
=
()
=>
vm
.
$el
.
querySelector
(
'
.js-ide-status-mr
'
);
store
.
state
.
currentProjectId
=
'
abcproject
'
;
store
.
state
.
projects
.
abcproject
=
projectData
;
beforeEach
(()
=>
{
store
=
createStore
();
store
.
state
.
currentProjectId
=
TEST_PROJECT_ID
;
store
.
state
.
projects
[
TEST_PROJECT_ID
]
=
_
.
clone
(
projectData
);
store
.
state
.
currentBranchId
=
'
master
'
;
vm
=
createComponentWithStore
(
Component
,
store
).
$mount
();
});
afterEach
(()
=>
{
vm
.
$destroy
();
resetStore
(
vm
.
$store
);
});
it
(
'
renders the statusbar
'
,
()
=>
{
expect
(
vm
.
$el
.
className
).
toBe
(
'
ide-status-bar
'
);
});
describe
(
'
default
'
,
()
=>
{
beforeEach
(()
=>
{
createComponent
();
});
describe
(
'
mounted
'
,
()
=>
{
it
(
'
triggers a setInterval
'
,
()
=>
{
expect
(
vm
.
intervalId
).
not
.
toBe
(
null
);
});
});
describe
(
'
commitAgeUpdate
'
,
()
=>
{
beforeEach
(
function
()
{
jasmine
.
clock
().
install
();
spyOn
(
vm
,
'
commitAgeUpdate
'
).
and
.
callFake
(()
=>
{});
vm
.
startTimer
();
it
(
'
renders the statusbar
'
,
()
=>
{
expect
(
vm
.
$el
.
className
).
toBe
(
'
ide-status-bar
'
);
});
afterEach
(
function
()
{
jasmine
.
clock
().
uninstall
();
});
describe
(
'
commitAgeUpdate
'
,
()
=>
{
beforeEach
(
function
()
{
jasmine
.
clock
().
install
();
spyOn
(
vm
,
'
commitAgeUpdate
'
).
and
.
callFake
(()
=>
{});
vm
.
startTimer
();
});
it
(
'
gets called every second
'
,
()
=>
{
expect
(
vm
.
commitAgeUpdate
).
not
.
toHaveBeenCalled
();
afterEach
(
function
()
{
jasmine
.
clock
().
uninstall
();
});
jasmine
.
clock
().
tick
(
1100
);
it
(
'
gets called every second
'
,
()
=>
{
expect
(
vm
.
commitAgeUpdate
).
not
.
toHaveBeenCalled
();
expect
(
vm
.
commitAgeUpdate
.
calls
.
count
()).
toEqual
(
1
);
jasmine
.
clock
().
tick
(
1100
);
jasmine
.
clock
().
tick
(
1000
);
expect
(
vm
.
commitAgeUpdate
.
calls
.
count
()).
toEqual
(
1
);
expect
(
vm
.
commitAgeUpdate
.
calls
.
count
()).
toEqual
(
2
);
jasmine
.
clock
().
tick
(
1000
);
expect
(
vm
.
commitAgeUpdate
.
calls
.
count
()).
toEqual
(
2
);
});
});
});
describe
(
'
getCommitPath
'
,
()
=>
{
it
(
'
returns the path to the commit details
'
,
()
=>
{
expect
(
vm
.
getCommitPath
(
'
abc123de
'
)).
toBe
(
'
/commit/abc123de
'
);
describe
(
'
getCommitPath
'
,
()
=>
{
it
(
'
returns the path to the commit details
'
,
()
=>
{
expect
(
vm
.
getCommitPath
(
'
abc123de
'
)).
toBe
(
'
/commit/abc123de
'
);
});
});
describe
(
'
pipeline status
'
,
()
=>
{
it
(
'
opens right sidebar on clicking icon
'
,
done
=>
{
spyOn
(
vm
,
'
openRightPane
'
);
Vue
.
set
(
vm
.
$store
.
state
.
pipelines
,
'
latestPipeline
'
,
{
details
:
{
status
:
{
text
:
'
success
'
,
details_path
:
'
test
'
,
icon
:
'
status_success
'
,
},
},
commit
:
{
author_gravatar_url
:
'
www
'
,
},
});
vm
.
$nextTick
()
.
then
(()
=>
{
vm
.
$el
.
querySelector
(
'
.ide-status-pipeline button
'
).
click
();
expect
(
vm
.
openRightPane
).
toHaveBeenCalledWith
(
rightSidebarViews
.
pipelines
);
})
.
then
(
done
)
.
catch
(
done
.
fail
);
});
});
it
(
'
does not show merge request status
'
,
()
=>
{
expect
(
findMRStatus
()).
toBe
(
null
);
});
});
describe
(
'
pipeline status
'
,
()
=>
{
it
(
'
opens right sidebar on clicking icon
'
,
done
=>
{
spyOn
(
vm
,
'
openRightPane
'
);
Vue
.
set
(
vm
.
$store
.
state
.
pipelines
,
'
latestPipeline
'
,
{
details
:
{
status
:
{
text
:
'
success
'
,
details_path
:
'
test
'
,
icon
:
'
status_success
'
,
describe
(
'
with merge request in store
'
,
()
=>
{
beforeEach
(()
=>
{
store
.
state
.
projects
[
TEST_PROJECT_ID
].
mergeRequests
=
{
[
TEST_MERGE_REQUEST_ID
]:
{
web_url
:
TEST_MERGE_REQUEST_URL
,
references
:
{
short
:
`!
${
TEST_MERGE_REQUEST_ID
}
`
,
},
},
commit
:
{
author_gravatar_url
:
'
www
'
,
},
});
};
store
.
state
.
currentMergeRequestId
=
TEST_MERGE_REQUEST_ID
;
vm
.
$nextTick
()
.
then
(()
=>
{
vm
.
$el
.
querySelector
(
'
.ide-status-pipeline button
'
).
click
();
createComponent
();
});
expect
(
vm
.
openRightPane
).
toHaveBeenCalledWith
(
rightSidebarViews
.
pipelines
);
})
.
then
(
done
)
.
catch
(
done
.
fail
);
it
(
'
shows merge request status
'
,
()
=>
{
expect
(
findMRStatus
().
textContent
.
trim
()).
toEqual
(
`Merge request !
${
TEST_MERGE_REQUEST_ID
}
`
);
expect
(
findMRStatus
().
querySelector
(
'
a
'
).
href
).
toEqual
(
TEST_MERGE_REQUEST_URL
);
});
});
});
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