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
44feb1d5
Commit
44feb1d5
authored
Dec 22, 2017
by
Tim Zallmann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
EE Port of IDE File Icons
parent
3f54d5d6
Changes
10
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
810 additions
and
30 deletions
+810
-30
app/assets/images/file_icons.svg
app/assets/images/file_icons.svg
+1
-0
app/assets/javascripts/ide/components/repo_file.vue
app/assets/javascripts/ide/components/repo_file.vue
+11
-14
app/assets/javascripts/ide/components/repo_tab.vue
app/assets/javascripts/ide/components/repo_tab.vue
+7
-0
app/assets/javascripts/vue_shared/components/file_icon.vue
app/assets/javascripts/vue_shared/components/file_icon.vue
+92
-0
app/assets/javascripts/vue_shared/components/file_icon/file_icon_map.js
...ascripts/vue_shared/components/file_icon/file_icon_map.js
+590
-0
app/assets/stylesheets/pages/repo.scss
app/assets/stylesheets/pages/repo.scss
+11
-1
app/helpers/icons_helper.rb
app/helpers/icons_helper.rb
+7
-0
lib/gitlab/gon_helper.rb
lib/gitlab/gon_helper.rb
+1
-0
spec/javascripts/repo/components/repo_file_spec.js
spec/javascripts/repo/components/repo_file_spec.js
+0
-15
spec/javascripts/vue_shared/components/file_icon_spec.js
spec/javascripts/vue_shared/components/file_icon_spec.js
+90
-0
No files found.
app/assets/images/file_icons.svg
0 → 100644
View file @
44feb1d5
This source diff could not be displayed because it is too large. You can
view the blob
instead.
app/assets/javascripts/ide/components/repo_file.vue
View file @
44feb1d5
...
...
@@ -4,6 +4,7 @@
import
skeletonLoadingContainer
from
'
../../vue_shared/components/skeleton_loading_container.vue
'
;
import
fileStatusIcon
from
'
./repo_file_status_icon.vue
'
;
import
newDropdown
from
'
./new_dropdown/index.vue
'
;
import
fileIcon
from
'
../../vue_shared/components/file_icon.vue
'
;
export
default
{
mixins
:
[
...
...
@@ -13,6 +14,7 @@
skeletonLoadingContainer
,
newDropdown
,
fileStatusIcon
,
fileIcon
,
},
props
:
{
file
:
{
...
...
@@ -28,13 +30,6 @@
...
mapState
([
'
leftPanelCollapsed
'
,
]),
fileIcon
()
{
return
{
'
fa-spinner fa-spin
'
:
this
.
file
.
loading
,
[
this
.
file
.
icon
]:
!
this
.
file
.
loading
,
'
fa-folder-open
'
:
!
this
.
file
.
loading
&&
this
.
file
.
opened
,
};
},
isSubmodule
()
{
return
this
.
file
.
type
===
'
submodule
'
;
},
...
...
@@ -96,16 +91,18 @@
class=
"multi-file-table-name"
:colspan=
"submoduleColSpan"
>
<i
class=
"fa fa-fw file-icon"
:class=
"fileIcon"
:style=
"levelIndentation"
aria-hidden=
"true"
>
</i>
<a
class=
"repo-file-name"
>
<file-icon
:fileName=
"file.name"
:loading=
"file.loading"
:folder=
"file.type === 'tree'"
:opened=
"file.opened"
:style=
"levelIndentation"
:size=
"16"
>
</file-icon>
{{
file
.
name
}}
<fileStatusIcon
:file=
"file"
>
...
...
app/assets/javascripts/ide/components/repo_tab.vue
View file @
44feb1d5
<
script
>
import
{
mapActions
}
from
'
vuex
'
;
import
fileStatusIcon
from
'
./repo_file_status_icon.vue
'
;
import
fileIcon
from
'
../../vue_shared/components/file_icon.vue
'
;
export
default
{
props
:
{
...
...
@@ -12,6 +13,7 @@ export default {
components
:
{
fileStatusIcon
,
fileIcon
,
},
computed
:
{
...
...
@@ -68,6 +70,11 @@ export default {
:class=
"
{active : tab.active }"
:title="tab.url"
>
<file-icon
:fileName=
"tab.name"
:size=
"16"
>
</file-icon>
{{
tab
.
name
}}
<file-status-icon
:file=
"tab"
...
...
app/assets/javascripts/vue_shared/components/file_icon.vue
0 → 100644
View file @
44feb1d5
<
script
>
import
{
getIconForFile
}
from
'
./file_icon/file_icon_map
'
;
import
loadingIcon
from
'
../../vue_shared/components/loading_icon.vue
'
;
import
icon
from
'
../../vue_shared/components/icon.vue
'
;
/* This is a re-usable vue component for rendering a svg sprite
icon
Sample configuration:
<file-icon
name="retry"
:size="32"
css-classes="top"
/>
*/
export
default
{
props
:
{
fileName
:
{
type
:
String
,
required
:
true
,
},
folder
:
{
type
:
Boolean
,
required
:
false
,
default
:
false
,
},
opened
:
{
type
:
Boolean
,
required
:
false
,
default
:
false
,
},
loading
:
{
type
:
Boolean
,
required
:
false
,
default
:
false
,
},
size
:
{
type
:
Number
,
required
:
false
,
default
:
0
,
},
cssClasses
:
{
type
:
String
,
required
:
false
,
default
:
''
,
},
},
components
:
{
loadingIcon
,
icon
,
},
computed
:
{
spriteHref
()
{
const
iconName
=
getIconForFile
(
this
.
fileName
)
||
'
file
'
;
return
`
${
gon
.
sprite_file_icons
}
#
${
iconName
}
`
;
},
folderIconName
()
{
// We don't have a open folder icon yet
return
this
.
opened
?
'
folder
'
:
'
folder
'
;
},
iconSizeClass
()
{
return
this
.
size
?
`s
${
this
.
size
}
`
:
''
;
},
},
};
</
script
>
<
template
>
<span>
<svg
:class=
"[iconSizeClass, cssClasses]"
v-if=
"!loading && !folder"
>
<use
v-bind=
"
{'xlink:href':spriteHref}"/>
</svg>
<icon
v-if=
"!loading && folder"
:name=
"folderIconName"
:size=
"size || 16"
/>
<loading-icon
v-if=
"loading"
:inline=
"true"
/>
</span>
</
template
>
app/assets/javascripts/vue_shared/components/file_icon/file_icon_map.js
0 → 100644
View file @
44feb1d5
This diff is collapsed.
Click to expand it.
app/assets/stylesheets/pages/repo.scss
View file @
44feb1d5
...
...
@@ -101,8 +101,14 @@
padding
:
6px
12px
;
}
.multi-file-table-name
{
table
.table
tr
td
.multi-file-table-name
{
width
:
350px
;
padding
:
6px
12px
;
svg
{
vertical-align
:
middle
;
margin-right
:
2px
;
}
}
.multi-file-table-col-commit-message
{
...
...
@@ -137,6 +143,10 @@
border-bottom
:
1px
solid
$white-dark
;
cursor
:
pointer
;
svg
{
vertical-align
:
middle
;
}
&
.active
{
background-color
:
$white-light
;
border-bottom-color
:
$white-light
;
...
...
app/helpers/icons_helper.rb
View file @
44feb1d5
...
...
@@ -30,6 +30,13 @@ module IconsHelper
ActionController
::
Base
.
helpers
.
image_path
(
'icons.svg'
,
host:
sprite_base_url
)
end
def
sprite_file_icons_path
# SVG Sprites currently don't work across domains, so in the case of a CDN
# we have to set the current path deliberately to prevent addition of asset_host
sprite_base_url
=
Gitlab
.
config
.
gitlab
.
url
if
ActionController
::
Base
.
asset_host
ActionController
::
Base
.
helpers
.
image_path
(
'file_icons.svg'
,
host:
sprite_base_url
)
end
def
sprite_icon
(
icon_name
,
size:
nil
,
css_class:
nil
)
css_classes
=
size
?
"s
#{
size
}
"
:
""
css_classes
<<
"
#{
css_class
}
"
unless
css_class
.
blank?
...
...
lib/gitlab/gon_helper.rb
View file @
44feb1d5
...
...
@@ -21,6 +21,7 @@ module Gitlab
gon
.
revision
=
Gitlab
::
REVISION
gon
.
gitlab_logo
=
ActionController
::
Base
.
helpers
.
asset_path
(
'gitlab_logo.png'
)
gon
.
sprite_icons
=
IconsHelper
.
sprite_icon_path
gon
.
sprite_file_icons
=
IconsHelper
.
sprite_file_icons_path
if
current_user
gon
.
current_user_id
=
current_user
.
id
...
...
spec/javascripts/repo/components/repo_file_spec.js
View file @
44feb1d5
...
...
@@ -32,13 +32,9 @@ describe('RepoFile', () => {
vm
.
$mount
();
const
name
=
vm
.
$el
.
querySelector
(
'
.repo-file-name
'
);
const
fileIcon
=
vm
.
$el
.
querySelector
(
'
.file-icon
'
);
expect
(
vm
.
$el
.
querySelector
(
`.
${
vm
.
file
.
icon
}
`
).
style
.
marginLeft
).
toEqual
(
'
0px
'
);
expect
(
name
.
href
).
toMatch
(
''
);
expect
(
name
.
textContent
.
trim
()).
toEqual
(
vm
.
file
.
name
);
expect
(
fileIcon
.
classList
.
contains
(
vm
.
file
.
icon
)).
toBeTruthy
();
expect
(
fileIcon
.
style
.
marginLeft
).
toEqual
(
`
${
vm
.
file
.
level
*
10
}
px`
);
});
it
(
'
does render if hasFiles is true and is loading tree
'
,
()
=>
{
...
...
@@ -49,17 +45,6 @@ describe('RepoFile', () => {
expect
(
vm
.
$el
.
querySelector
(
'
.fa-spin.fa-spinner
'
)).
toBeFalsy
();
});
it
(
'
renders a spinner if the file is loading
'
,
()
=>
{
const
f
=
file
();
f
.
loading
=
true
;
vm
=
createComponent
({
file
:
f
,
});
expect
(
vm
.
$el
.
querySelector
(
'
.fa-spin.fa-spinner
'
)).
not
.
toBeNull
();
expect
(
vm
.
$el
.
querySelector
(
'
.fa-spin.fa-spinner
'
).
style
.
marginLeft
).
toEqual
(
`
${
vm
.
file
.
level
*
16
}
px`
);
});
it
(
'
does not render commit message and datetime if mini
'
,
(
done
)
=>
{
vm
=
createComponent
({
file
:
file
(),
...
...
spec/javascripts/vue_shared/components/file_icon_spec.js
0 → 100644
View file @
44feb1d5
import
Vue
from
'
vue
'
;
import
fileIcon
from
'
~/vue_shared/components/file_icon.vue
'
;
describe
(
'
File Icon component
'
,
()
=>
{
let
FileIcon
;
beforeEach
(()
=>
{
FileIcon
=
Vue
.
extend
(
fileIcon
);
});
it
(
'
should render a span element with an svg
'
,
()
=>
{
const
component
=
new
FileIcon
({
propsData
:
{
fileName
:
'
test.js
'
,
},
}).
$mount
();
expect
(
component
.
$el
.
tagName
).
toEqual
(
'
SPAN
'
);
expect
(
component
.
$el
.
querySelector
(
'
span > svg
'
)).
toBeDefined
();
});
it
(
'
should render a javascript icon based on file ending
'
,
()
=>
{
const
component
=
new
FileIcon
({
propsData
:
{
fileName
:
'
test.js
'
,
},
}).
$mount
();
expect
(
component
.
$el
.
firstChild
.
firstChild
.
getAttribute
(
'
xlink:href
'
)).
toBe
(
`
${
gon
.
sprite_file_icons
}
#javascript`
);
});
it
(
'
should render a image icon based on file ending
'
,
()
=>
{
const
component
=
new
FileIcon
({
propsData
:
{
fileName
:
'
test.png
'
,
},
}).
$mount
();
expect
(
component
.
$el
.
firstChild
.
firstChild
.
getAttribute
(
'
xlink:href
'
)).
toBe
(
`
${
gon
.
sprite_file_icons
}
#image`
);
});
it
(
'
should render a webpack icon based on file namer
'
,
()
=>
{
const
component
=
new
FileIcon
({
propsData
:
{
fileName
:
'
webpack.js
'
,
},
}).
$mount
();
expect
(
component
.
$el
.
firstChild
.
firstChild
.
getAttribute
(
'
xlink:href
'
)).
toBe
(
`
${
gon
.
sprite_file_icons
}
#webpack`
);
});
it
(
'
should render a standard folder icon
'
,
()
=>
{
const
component
=
new
FileIcon
({
propsData
:
{
fileName
:
'
js
'
,
folder
:
true
,
},
}).
$mount
();
expect
(
component
.
$el
.
querySelector
(
'
span > svg > use
'
).
getAttribute
(
'
xlink:href
'
)).
toBe
(
`
${
gon
.
sprite_file_icons
}
#folder`
);
});
it
(
'
should render a loading icon
'
,
()
=>
{
const
component
=
new
FileIcon
({
propsData
:
{
fileName
:
'
test.js
'
,
loading
:
true
,
},
}).
$mount
();
expect
(
component
.
$el
.
querySelector
(
'
i
'
).
getAttribute
(
'
class
'
),
).
toEqual
(
'
fa fa-spin fa-spinner fa-1x
'
);
});
it
(
'
should add a special class and a size class
'
,
()
=>
{
const
component
=
new
FileIcon
({
propsData
:
{
fileName
:
'
test.js
'
,
cssClasses
:
'
extraclasses
'
,
size
:
120
,
},
}).
$mount
();
const
classList
=
component
.
$el
.
firstChild
.
classList
;
const
containsSizeClass
=
classList
.
contains
(
'
s120
'
);
const
containsCustomClass
=
classList
.
contains
(
'
extraclasses
'
);
expect
(
containsSizeClass
).
toBe
(
true
);
expect
(
containsCustomClass
).
toBe
(
true
);
});
});
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