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
a25a8c93
Commit
a25a8c93
authored
Apr 02, 2018
by
Kushal Pandya
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Shared code for Epics list and timeline sections
parent
2768fd26
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
92 additions
and
0 deletions
+92
-0
ee/app/assets/javascripts/roadmap/mixins/section_mixin.js
ee/app/assets/javascripts/roadmap/mixins/section_mixin.js
+32
-0
spec/javascripts/roadmap/mixins/section_mixin_spec.js
spec/javascripts/roadmap/mixins/section_mixin_spec.js
+60
-0
No files found.
ee/app/assets/javascripts/roadmap/mixins/section_mixin.js
0 → 100644
View file @
a25a8c93
import
{
EPIC_DETAILS_CELL_WIDTH
,
TIMELINE_CELL_MIN_WIDTH
,
SCROLL_BAR_SIZE
}
from
'
../constants
'
;
export
default
{
computed
:
{
/**
* Return section width after reducing scrollbar size
* based on listScrollable such that Epic item cells
* do not consider scrollbar presence in shellWidth
*/
sectionShellWidth
()
{
return
this
.
shellWidth
-
(
this
.
listScrollable
?
SCROLL_BAR_SIZE
:
0
);
},
sectionItemWidth
()
{
const
timeframeLength
=
this
.
timeframe
.
length
;
// Calculate minimum width for single cell
// based on total number of months in current timeframe
// and available shellWidth
const
width
=
(
this
.
sectionShellWidth
-
EPIC_DETAILS_CELL_WIDTH
)
/
timeframeLength
;
// When shellWidth is too low, we need to obey global
// minimum cell width.
return
Math
.
max
(
width
,
TIMELINE_CELL_MIN_WIDTH
);
},
sectionContainerStyles
()
{
const
width
=
EPIC_DETAILS_CELL_WIDTH
+
(
this
.
sectionItemWidth
*
this
.
timeframe
.
length
);
return
{
width
:
`
${
width
}
px`
,
};
},
},
};
spec/javascripts/roadmap/mixins/section_mixin_spec.js
0 → 100644
View file @
a25a8c93
import
Vue
from
'
vue
'
;
import
roadmapTimelineSectionComponent
from
'
ee/roadmap/components/roadmap_timeline_section.vue
'
;
import
mountComponent
from
'
spec/helpers/vue_mount_component_helper
'
;
import
{
mockEpic
,
mockTimeframe
,
mockShellWidth
,
mockScrollBarSize
}
from
'
../mock_data
'
;
const
createComponent
=
({
epics
=
[
mockEpic
],
timeframe
=
mockTimeframe
,
shellWidth
=
mockShellWidth
,
listScrollable
=
false
,
})
=>
{
const
Component
=
Vue
.
extend
(
roadmapTimelineSectionComponent
);
return
mountComponent
(
Component
,
{
epics
,
timeframe
,
shellWidth
,
listScrollable
,
});
};
describe
(
'
SectionMixin
'
,
()
=>
{
let
vm
;
beforeEach
(()
=>
{
vm
=
createComponent
({});
});
afterEach
(()
=>
{
vm
.
$destroy
();
});
describe
(
'
computed
'
,
()
=>
{
describe
(
'
sectionShellWidth
'
,
()
=>
{
it
(
'
returns shellWidth as it is when `listScrollable` prop is false
'
,
()
=>
{
expect
(
vm
.
sectionShellWidth
).
toBe
(
mockShellWidth
);
});
it
(
'
returns shellWidth after deducating value of SCROLL_BAR_SIZE when `listScrollable` prop is true
'
,
()
=>
{
const
vmScrollable
=
createComponent
({
listScrollable
:
true
});
expect
(
vmScrollable
.
sectionShellWidth
).
toBe
(
mockShellWidth
-
mockScrollBarSize
);
vmScrollable
.
$destroy
();
});
});
describe
(
'
sectionItemWidth
'
,
()
=>
{
it
(
'
returns calculated item width based on sectionShellWidth and timeframe size
'
,
()
=>
{
expect
(
vm
.
sectionItemWidth
).
toBe
(
280
);
});
});
describe
(
'
sectionContainerStyles
'
,
()
=>
{
it
(
'
returns style string for container element based on sectionShellWidth
'
,
()
=>
{
expect
(
vm
.
sectionContainerStyles
.
width
).
toBe
(
`
${
mockShellWidth
}
px`
);
});
});
});
});
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