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
450f6c19
Commit
450f6c19
authored
Oct 18, 2021
by
Ammar Alakkad
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add icons to project's storage table
Changelog: other
parent
1972ec41
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
115 additions
and
28 deletions
+115
-28
app/assets/javascripts/projects/storage_counter/components/storage_table.vue
...pts/projects/storage_counter/components/storage_table.vue
+36
-26
app/assets/javascripts/projects/storage_counter/components/storage_type_icon.vue
...projects/storage_counter/components/storage_type_icon.vue
+35
-0
spec/frontend/projects/storage_counter/components/storage_table_spec.js
...projects/storage_counter/components/storage_table_spec.js
+3
-2
spec/frontend/projects/storage_counter/components/storage_type_icon_spec.js
...ects/storage_counter/components/storage_type_icon_spec.js
+41
-0
No files found.
app/assets/javascripts/projects/storage_counter/components/storage_table.vue
View file @
450f6c19
<
script
>
import
{
GlLink
,
GlIcon
,
GlTable
,
GlSprintf
}
from
'
@gitlab/ui
'
;
import
{
GlLink
,
GlIcon
,
GlTable
Lite
as
GlTable
,
GlSprintf
}
from
'
@gitlab/ui
'
;
import
{
numberToHumanSize
}
from
'
~/lib/utils/number_utils
'
;
import
{
thWidthClass
}
from
'
~/lib/utils/table_utility
'
;
import
{
sprintf
}
from
'
~/locale
'
;
import
{
PROJECT_TABLE_LABELS
,
HELP_LINK_ARIA_LABEL
}
from
'
../constants
'
;
import
StorageTypeIcon
from
'
./storage_type_icon.vue
'
;
export
default
{
name
:
'
StorageTable
'
,
...
...
@@ -12,6 +13,7 @@ export default {
GlIcon
,
GlTable
,
GlSprintf
,
StorageTypeIcon
,
},
props
:
{
storageTypes
:
{
...
...
@@ -48,6 +50,12 @@ export default {
<
template
>
<gl-table
:items=
"storageTypes"
:fields=
"$options.projectTableFields"
>
<template
#cell(storageType)=
"
{ item }">
<div
class=
"gl-display-flex gl-flex-direction-row"
>
<storage-type-icon
:name=
"item.storageType.id"
:data-testid=
"`$
{item.storageType.id}-icon`"
/>
<div>
<p
class=
"gl-font-weight-bold gl-mb-0"
:data-testid=
"`$
{item.storageType.id}-name`">
{{
item
.
storageType
.
name
}}
<gl-link
...
...
@@ -73,6 +81,8 @@ export default {
</
template
>
</gl-sprintf>
</p>
</div>
</div>
</template>
</gl-table>
</template>
app/assets/javascripts/projects/storage_counter/components/storage_type_icon.vue
0 → 100644
View file @
450f6c19
<
script
>
import
{
GlIcon
}
from
'
@gitlab/ui
'
;
export
default
{
components
:
{
GlIcon
},
props
:
{
name
:
{
type
:
String
,
required
:
false
,
default
:
''
,
},
},
methods
:
{
iconName
(
storageTypeName
)
{
const
defaultStorageTypeIcon
=
'
disk
'
;
const
storageTypeIconMap
=
{
lfsObjectsSize
:
'
doc-image
'
,
snippetsSize
:
'
snippet
'
,
uploadsSize
:
'
upload
'
,
repositorySize
:
'
infrastructure-registry
'
,
packagesSize
:
'
package
'
,
};
return
storageTypeIconMap
[
`
${
storageTypeName
}
`
]
??
defaultStorageTypeIcon
;
},
},
};
</
script
>
<
template
>
<span
class=
"gl-display-inline-flex gl-align-items-flex-start gl-justify-content-center gl-min-w-8 gl-pr-2 gl-pt-1"
>
<gl-icon
:name=
"iconName(name)"
:size=
"16"
class=
"gl-mt-1"
/>
</span>
</
template
>
spec/frontend/projects/storage_counter/components/storage_table_spec.js
View file @
450f6c19
import
{
GlTable
}
from
'
@gitlab/ui
'
;
import
{
GlTable
Lite
}
from
'
@gitlab/ui
'
;
import
{
mount
}
from
'
@vue/test-utils
'
;
import
{
extendedWrapper
}
from
'
helpers/vue_test_utils_helper
'
;
import
StorageTable
from
'
~/projects/storage_counter/components/storage_table.vue
'
;
...
...
@@ -22,7 +22,7 @@ describe('StorageTable', () => {
);
};
const
findTable
=
()
=>
wrapper
.
findComponent
(
GlTable
);
const
findTable
=
()
=>
wrapper
.
findComponent
(
GlTable
Lite
);
beforeEach
(()
=>
{
createComponent
();
...
...
@@ -37,6 +37,7 @@ describe('StorageTable', () => {
({
storageType
:
{
id
,
name
,
description
}
})
=>
{
expect
(
wrapper
.
findByTestId
(
`
${
id
}
-name`
).
text
()).
toBe
(
name
);
expect
(
wrapper
.
findByTestId
(
`
${
id
}
-description`
).
text
()).
toBe
(
description
);
expect
(
wrapper
.
findByTestId
(
`
${
id
}
-icon`
).
props
(
'
name
'
)).
toBe
(
id
);
expect
(
wrapper
.
findByTestId
(
`
${
id
}
-help-link`
).
attributes
(
'
href
'
)).
toBe
(
defaultProvideValues
.
helpLinks
[
id
.
replace
(
`Size`
,
`HelpPagePath`
)]
.
replace
(
`Size`
,
``
)
...
...
spec/frontend/projects/storage_counter/components/storage_type_icon_spec.js
0 → 100644
View file @
450f6c19
import
{
mount
}
from
'
@vue/test-utils
'
;
import
{
GlIcon
}
from
'
@gitlab/ui
'
;
import
StorageTypeIcon
from
'
~/projects/storage_counter/components/storage_type_icon.vue
'
;
describe
(
'
StorageTypeIcon
'
,
()
=>
{
let
wrapper
;
const
createComponent
=
(
props
=
{})
=>
{
wrapper
=
mount
(
StorageTypeIcon
,
{
propsData
:
{
...
props
,
},
});
};
const
findGlIcon
=
()
=>
wrapper
.
findComponent
(
GlIcon
);
describe
(
'
rendering icon
'
,
()
=>
{
afterEach
(()
=>
{
wrapper
.
destroy
();
});
it
.
each
`
expected | provided
${
'
doc-image
'
}
|
${
'
lfsObjectsSize
'
}
${
'
snippet
'
}
|
${
'
snippetsSize
'
}
${
'
infrastructure-registry
'
}
|
${
'
repositorySize
'
}
${
'
package
'
}
|
${
'
packagesSize
'
}
${
'
upload
'
}
|
${
'
uploadsSize
'
}
${
'
disk
'
}
|
${
'
wikiSize
'
}
${
'
disk
'
}
|
${
'
anything-else
'
}
`
(
'
renders icon with name of $expected when name prop is $provided
'
,
({
expected
,
provided
})
=>
{
createComponent
({
name
:
provided
});
expect
(
findGlIcon
().
props
(
'
name
'
)).
toBe
(
expected
);
},
);
});
});
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