Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Walk and sort todo images #432

Merged
merged 20 commits into from
Jun 21, 2020
Merged
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
1450df2
feat(Walk): Standardize directory listing to GenericList
danactive Jun 13, 2020
e6bd324
feat(Walk): Resize to current folder API only; Remove stale CORS port…
danactive Jun 13, 2020
852258f
feat(DX): Add Storybook
danactive Jun 11, 2020
cb81afd
feat(Walk): Display image filename in OrganizePreviews
danactive Jun 13, 2020
b72391f
fix(Admin): Display navigation as GenericList
danactive Jun 13, 2020
e9f919b
feat(Walk): Rename Button renames image files based on calendar
danactive Jun 13, 2020
523e089
chore(package): Update webpack deps
danactive Jun 14, 2020
efcc795
chore(package): Update webpack url-loader
danactive Jun 14, 2020
dd369c9
chore(package): Remove tuxharness
danactive Jun 14, 2020
f67f5d4
feat(Walk): Add Up Folder navigation
danactive Jun 14, 2020
3d91dbc
feat(Walk): Display name in List is grouped by associated
danactive Jun 15, 2020
93e5dc8
fix(Walk): Group with jpg too
danactive Jun 16, 2020
956e8fc
feat(Walk): Show full dimension images
danactive Jun 16, 2020
14b2884
chore(Walk): Move textarea & Rename to Menu
danactive Jun 16, 2020
85139e7
feat(Walk): Rename button calls XHR for all
danactive Jun 17, 2020
306c6e1
fix(Legacy): Remove admin page
danactive Jun 18, 2020
3370db0
feat(App): Redux use hooks; Upgrade testing dep; Lint to allow dynami…
danactive Jun 19, 2020
63ac5b4
feat(Walk): Avoid QS for Hash to avoid page reload
danactive Jun 19, 2020
222b3a9
chore(Walk): Lint and test fix
danactive Jun 20, 2020
6e1c74e
fix(Walk): Display error message; Prevent 404 images
danactive Jun 21, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
feat(Walk): Display image filename in OrganizePreviews
  • Loading branch information
danactive committed Jun 13, 2020
commit cb81afdff054a40b87205790cc307279947ad2b8
84 changes: 84 additions & 0 deletions ui/app/components/OrganizePreviews/index.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
import React, { useState } from 'react';
import { DragDropContext, Droppable, Draggable } from 'react-beautiful-dnd';

// a little function to help us with reordering the result
const reorder = (list, startIndex, endIndex) => {
const result = Array.from(list);
const [removed] = result.splice(startIndex, 1);
result.splice(endIndex, 0, removed);

return result;
};

const grid = 8;

const getItemStyle = (isDragging, draggableStyle) => ({
// some basic styles to make the items look a bit nicer
userSelect: 'none',
padding: grid * 2,
margin: `0 0 ${grid}px 0`,

// change background colour if dragging
background: isDragging ? 'lightgreen' : 'grey',

// styles we need to apply on draggables
...draggableStyle,
});

const getListStyle = (isDraggingOver) => ({
background: isDraggingOver ? 'lightblue' : 'lightgrey',
padding: grid,
width: 250,
});

function OrganizePreviews({ items: initialItems }) {
const [items, setItems] = useState(initialItems);

function onDragEnd(result) {
// dropped outside the list
if (!result.destination) {
return;
}

setItems(reorder(
items,
result.source.index,
result.destination.index,
));
}

return (
<DragDropContext onDragEnd={onDragEnd}>
<Droppable droppableId="droppable">
{(providedDrop, snapshotDrop) => (
<div
{...providedDrop.droppableProps}
ref={providedDrop.innerRef}
style={getListStyle(snapshotDrop.isDraggingOver)}
>
{items.map((item, index) => (
<Draggable key={item.id} draggableId={item.id} index={index}>
{(providedDrag, snapshotDrag) => (
<div
ref={providedDrag.innerRef}
{...providedDrag.draggableProps}
{...providedDrag.dragHandleProps}
style={getItemStyle(
snapshotDrag.isDragging,
providedDrag.draggableProps.style,
)}
>
{item.content}
</div>
)}
</Draggable>
))}
{providedDrop.placeholder}
</div>
)}
</Droppable>
</DragDropContext>
);
}

export default OrganizePreviews;
3 changes: 3 additions & 0 deletions ui/app/components/OrganizePreviews/tests/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
extends: '../../../../test.eslintrc.js',
};
24 changes: 24 additions & 0 deletions ui/app/components/OrganizePreviews/tests/index.stories.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import React from 'react';

import OrganizePreviews from '../index';

export default {
title: 'OrganizePreviews',
component: OrganizePreviews,
};

export const OrganizePreviewStories = () => {
// fake data generator
const getItems = (count) => Array.from({ length: count }, (v, k) => k).map((k) => ({
id: `item-${k}`,
content: `item ${k + 1}`,
}));

return (
<OrganizePreviews items={getItems(7)} />
);
};

OrganizePreviewStories.story = {
name: 'with text',
};
4 changes: 2 additions & 2 deletions ui/app/containers/Walk/ListFolders.jsx
Original file line number Diff line number Diff line change
@@ -5,10 +5,10 @@ import ListItem from '../../components/ListItem';

import walkUtils from './util';

const { areImages } = walkUtils;
const { isImage } = walkUtils;

function Contents({ item: file }) {
if (areImages(file)) {
if (isImage(file)) {
return null;
}

22 changes: 19 additions & 3 deletions ui/app/containers/Walk/index.jsx
Original file line number Diff line number Diff line change
@@ -10,9 +10,13 @@ import saga from './saga';
import { makeSelectFiles, makeSelectPath } from './selectors';
import { useInjectSaga } from '../../utils/injectSaga';
import { useInjectReducer } from '../../utils/injectReducer';
import walkUtils from './util';

import ListFolders from './ListFolders';
import GenericList from '../../components/GenericList';
import ListFolders from './ListFolders';
import OrganizePreviews from '../../components/OrganizePreviews';

const { isImage } = walkUtils;

function parseQueryString(find, from) {
if (!find || !from) return '';
@@ -35,7 +39,9 @@ function Walk({
doListDirectory(path);
}, [doListDirectory, path]);

return [
const loading = !files || files.length === 0;

const Components = [
<Helmet key="walk-Helmet">
<title>Walk</title>
<meta name="description" content="Description of Walk" />
@@ -44,10 +50,20 @@ function Walk({
key="walk-GenericList"
component={ListFolders}
items={files.map((f) => ({ id: f.path, ...f }))}
loading={!files || files.length === 0}
loading={loading}
error={false}
/>,
];

const images = files.filter((f) => isImage(f));
if (!loading && images.length > 0) {
Components.push(<OrganizePreviews
key="walk-OrganizePreviews"
items={images.map((f) => ({ id: f.path, content: f.filename, ...f }))}
/>);
}

return Components;
}

const mapStateToProps = createStructuredSelector({
4 changes: 2 additions & 2 deletions ui/app/containers/Walk/util.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
const config = require('../../../../config.json');

function areImages(file) {
function isImage(file) {
return (file.mediumType === 'image' && config.supportedFileTypes.photo.includes(file.ext.toLowerCase()));
}

export default {
areImages,
isImage,
};
9 changes: 0 additions & 9 deletions ui/internals/generators/component/index.js.hbs
Original file line number Diff line number Diff line change
@@ -1,15 +1,8 @@
/**
*
* {{ properCase name }}
*
*/

{{#if memo}}
import React, { memo } from 'react';
{{else}}
import React from 'react';
{{/if}}
// import PropTypes from 'prop-types';
// import styled from 'styled-components';

{{#if wantMessages}}
@@ -27,8 +20,6 @@ function {{ properCase name }}() {
);
}

{{ properCase name }}.propTypes = {};

{{#if memo}}
export default memo({{ properCase name }});
{{else}}
71 changes: 71 additions & 0 deletions ui/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions ui/package.json
Original file line number Diff line number Diff line change
@@ -87,6 +87,7 @@
"moment": "^2.20.1",
"ngrok": "3.1.1",
"react": "16.8.6",
"react-beautiful-dnd": "^13.0.0",
"react-dates": "^20.2.1",
"react-dom": "16.8.6",
"react-helmet": "6.0.0-beta",
3 changes: 0 additions & 3 deletions ui/stories/.eslintrc.js

This file was deleted.

14 changes: 0 additions & 14 deletions ui/stories/0-Welcome.stories.jsx

This file was deleted.

23 changes: 0 additions & 23 deletions ui/stories/1-Button.stories.jsx

This file was deleted.