@@ -145,6 +148,7 @@ const SketchList = ({
context: mobile ? 'mobile' : ''
})
)}
+ {userIsOwner && renderFieldHeader('visibility', 'Visibility')}
|
@@ -187,7 +191,8 @@ SketchList.propTypes = {
id: PropTypes.string.isRequired,
name: PropTypes.string.isRequired,
createdAt: PropTypes.string.isRequired,
- updatedAt: PropTypes.string.isRequired
+ updatedAt: PropTypes.string.isRequired,
+ visibility: PropTypes.string
})
).isRequired,
username: PropTypes.string,
diff --git a/client/modules/IDE/components/SketchList.unit.test.jsx b/client/modules/IDE/components/SketchList.unit.test.jsx
index 9110c43951..b0015a38aa 100644
--- a/client/modules/IDE/components/SketchList.unit.test.jsx
+++ b/client/modules/IDE/components/SketchList.unit.test.jsx
@@ -79,9 +79,22 @@ describe('', () => {
expect(screen.queryByText('Delete')).toBeInTheDocument();
});
- it('snapshot testing', () => {
- const { asFragment } = subject();
- expect(asFragment()).toMatchSnapshot();
+ it('renders component correctly', () => {
+ const { container } = subject();
+
+ expect(
+ container.querySelector('.sketches-table-container')
+ ).toBeInTheDocument();
+ expect(container.querySelector('.sketches-table')).toBeInTheDocument();
+ expect(container.querySelector('thead')).toBeInTheDocument();
+ expect(container.querySelector('tbody')).toBeInTheDocument();
+
+ // expect(screen.getByText(/Sketch/i)).toBeInTheDocument();
+ // expect(screen.getByText(/Date created/i)).toBeInTheDocument();
+ // expect(screen.getByText(/Last updated/i)).toBeInTheDocument();
+
+ const sketchRows = container.querySelectorAll('tbody tr');
+ expect(sketchRows.length).toBeGreaterThan(0);
});
describe('different user than the one who created the sketches', () => {
diff --git a/client/modules/IDE/components/SketchListRowBase.jsx b/client/modules/IDE/components/SketchListRowBase.jsx
index 08dc185885..cfb85a52c6 100644
--- a/client/modules/IDE/components/SketchListRowBase.jsx
+++ b/client/modules/IDE/components/SketchListRowBase.jsx
@@ -10,6 +10,7 @@ import TableDropdown from '../../../components/Dropdown/TableDropdown';
import MenuItem from '../../../components/Dropdown/MenuItem';
import dates from '../../../utils/formatDate';
import getConfig from '../../../utils/getConfig';
+import VisibilityDropdown from '../../User/components/VisibilityDropdown';
const ROOT_URL = getConfig('API_URL');
@@ -23,6 +24,8 @@ const SketchListRowBase = ({
changeProjectName,
cloneProject,
deleteProject,
+ showShareModal,
+ changeVisibility,
t,
mobile,
onAddToCollection
@@ -75,12 +78,24 @@ const SketchListRowBase = ({
};
const handleSketchDuplicate = () => cloneProject(sketch);
+
+ // const handleSketchShare = () => {
+ // showShareModal(sketch.id, sketch.name, username);
+ // };
+
const handleSketchDelete = () => {
if (window.confirm(t('Common.DeleteConfirmation', { name: sketch.name }))) {
deleteProject(sketch.id);
}
};
+ const handleVisibilityChange = useCallback(
+ (sketchId, sketchName, newVisibility) => {
+ changeVisibility(sketchId, sketchName, newVisibility);
+ },
+ [changeVisibility]
+ );
+
const userIsOwner = user.username === username;
let url = `/${username}/sketches/${sketch.id}`;
@@ -110,6 +125,12 @@ const SketchListRowBase = ({
{name} |
{formatDateCell(sketch.createdAt, mobile)} |
{formatDateCell(sketch.updatedAt, mobile)} |
+
+
+ | {' '}
|