Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
Nos Hs2023
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Språksamlingane
stadnamn
Nos Hs2023
Commits
b8f673a5
Commit
b8f673a5
authored
4 years ago
by
esikkala
Browse files
Options
Downloads
Patches
Plain Diff
Instance home page: add expandable rows
parent
317b0247
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/client/components/main_layout/InstanceHomePageTable.js
+67
-1
67 additions, 1 deletion
src/client/components/main_layout/InstanceHomePageTable.js
with
67 additions
and
1 deletion
src/client/components/main_layout/InstanceHomePageTable.js
+
67
−
1
View file @
b8f673a5
...
...
@@ -2,6 +2,8 @@ import React from 'react'
import
PropTypes
from
'
prop-types
'
import
intl
from
'
react-intl-universal
'
import
{
withStyles
}
from
'
@material-ui/core/styles
'
import
clsx
from
'
clsx
'
import
ExpandMoreIcon
from
'
@material-ui/icons/ExpandMore
'
import
Table
from
'
@material-ui/core/Table
'
import
TableBody
from
'
@material-ui/core/TableBody
'
import
TableRow
from
'
@material-ui/core/TableRow
'
...
...
@@ -37,6 +39,22 @@ const styles = theme => ({
},
tooltip
:
{
marginTop
:
-
3
},
expandCell
:
{
paddingRight
:
0
,
paddingTop
:
0
,
paddingBottom
:
0
,
width
:
32
},
expand
:
{
transform
:
'
rotate(0deg)
'
,
marginLeft
:
'
auto
'
,
transition
:
theme
.
transitions
.
create
(
'
transform
'
,
{
duration
:
theme
.
transitions
.
duration
.
shortest
})
},
expandOpen
:
{
transform
:
'
rotate(180deg)
'
}
})
...
...
@@ -44,6 +62,13 @@ const styles = theme => ({
* A component for generating a table based on data about an entity.
*/
class
InstanceHomePageTable
extends
React
.
Component
{
constructor
(
props
)
{
super
(
props
)
this
.
state
=
{
expandedRows
:
new
Set
()
}
}
componentDidMount
=
()
=>
{
if
(
this
.
props
.
fetchResultsWhenMounted
)
{
this
.
props
.
fetchResults
({
...
...
@@ -54,6 +79,33 @@ class InstanceHomePageTable extends React.Component {
}
}
handleExpandRow
=
rowId
=>
()
=>
{
const
expandedRows
=
this
.
state
.
expandedRows
if
(
expandedRows
.
has
(
rowId
))
{
expandedRows
.
delete
(
rowId
)
}
else
{
expandedRows
.
add
(
rowId
)
}
this
.
setState
({
expandedRows
})
}
hasExpandableContent
=
({
data
,
config
})
=>
{
let
hasExpandableContent
=
false
const
isArray
=
Array
.
isArray
(
data
)
if
(
isArray
)
{
hasExpandableContent
=
true
}
if
(
!
isArray
&&
data
!==
'
-
'
&&
config
.
valueType
===
'
string
'
&&
config
.
collapsedMaxWords
&&
data
.
split
(
'
'
).
length
>
config
.
collapsedMaxWords
)
{
hasExpandableContent
=
true
}
return
hasExpandableContent
}
render
=
()
=>
{
const
{
classes
,
data
,
resultClass
,
properties
}
=
this
.
props
return
(
...
...
@@ -68,6 +120,7 @@ class InstanceHomePageTable extends React.Component {
id
,
valueType
,
makeLink
,
externalLink
,
sortValues
,
sortBy
,
numberedList
,
previewImageHeight
,
linkAsButton
,
collapsedMaxWords
,
showSource
,
sourceExternalLink
,
renderAsHTML
,
HTMLParserTask
}
=
row
const
expanded
=
this
.
state
.
expandedRows
.
has
(
row
.
id
)
return
(
<
TableRow
key
=
{
row
.
id
}
>
<
TableCell
className
=
{
classes
.
labelCell
}
>
...
...
@@ -82,6 +135,19 @@ class InstanceHomePageTable extends React.Component {
<
/IconButton
>
<
/Tooltip
>
<
/TableCell
>
<
TableCell
className
=
{
classes
.
expandCell
}
>
{
this
.
hasExpandableContent
({
data
:
data
[
id
],
config
:
row
})
&&
<
IconButton
className
=
{
clsx
(
classes
.
expand
,
{
[
classes
.
expandOpen
]:
expanded
})}
onClick
=
{
this
.
handleExpandRow
(
row
.
id
)}
aria
-
expanded
=
{
expanded
}
aria
-
label
=
'
Show more
'
>
<
ExpandMoreIcon
/>
<
/IconButton>
}
<
/TableCell
>
<
ResultTableCell
columnId
=
{
id
}
data
=
{
data
[
id
]}
...
...
@@ -92,7 +158,7 @@ class InstanceHomePageTable extends React.Component {
sortBy
=
{
sortBy
}
numberedList
=
{
numberedList
}
container
=
'
cell
'
expanded
expanded
=
{
expanded
}
previewImageHeight
=
{
previewImageHeight
}
linkAsButton
=
{
linkAsButton
}
collapsedMaxWords
=
{
collapsedMaxWords
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment