Skip to content

Commit 96e33b9

Browse files
authored
feat: Add view edit icon to views list in sidebar (#2901)
1 parent 29f20bd commit 96e33b9

File tree

3 files changed

+30
-1
lines changed

3 files changed

+30
-1
lines changed

src/components/CategoryList/CategoryList.react.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import generatePath from 'lib/generatePath';
1111
import PropTypes from 'lib/PropTypes';
1212
import React from 'react';
1313
import { Link } from 'react-router-dom';
14+
import Icon from 'components/Icon/Icon.react';
1415

1516
export default class CategoryList extends React.Component {
1617
static contextType = CurrentApp;
@@ -128,6 +129,17 @@ export default class CategoryList extends React.Component {
128129
<span>{count}</span>
129130
<span>{c.name}</span>
130131
</Link>
132+
{c.onEdit && (
133+
<a
134+
className={styles.edit}
135+
onClick={e => {
136+
e.preventDefault();
137+
c.onEdit();
138+
}}
139+
>
140+
<Icon name="edit-solid" width={14} height={14} />
141+
</a>
142+
)}
131143
{(c.filters || []).length !== 0 && (
132144
<a
133145
className={styles.expand}

src/components/CategoryList/CategoryList.scss

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,20 @@
8686
flex-grow: 1
8787
}
8888
}
89+
.edit {
90+
display: flex;
91+
align-items: center;
92+
margin-right: 6px;
93+
cursor: pointer;
94+
svg {
95+
fill: #8fb9cf;
96+
}
97+
&:hover {
98+
svg {
99+
fill: white;
100+
}
101+
}
102+
}
89103
}
90104

91105
.childLink {

src/dashboard/Data/Views/Views.react.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -401,10 +401,13 @@ class Views extends TableView {
401401
}
402402

403403
renderSidebar() {
404-
const categories = this.state.views.map(view => ({
404+
const categories = this.state.views.map((view, index) => ({
405405
name: view.name,
406406
id: view.name,
407407
count: this.state.counts[view.name],
408+
onEdit: () => {
409+
this.setState({ editView: view, editIndex: index });
410+
},
408411
}));
409412
const current = this.props.params.name || '';
410413
return (

0 commit comments

Comments
 (0)