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

Update notes components #419

Merged
merged 17 commits into from
Jul 3, 2018
Merged

Update notes components #419

merged 17 commits into from
Jul 3, 2018

Conversation

joshuasbates
Copy link
Contributor

@joshuasbates joshuasbates commented Jun 15, 2018

#408

Sorry for the large change set, but there were lots of changes needed to make this usable for a generic use case, but also add some flexibility for the custom ones (e.g., where notes had attachments).

Copy link
Contributor Author

@joshuasbates joshuasbates left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes to the components look good overall (one small comment there). The main feedback is in regard to the Stories.

stories/Note.js Outdated
onDelete={action('onDelete')}
onEdit={action('onEdit')}
onSave={action('onSave')}
onUndelete={action('onUndelete')}
>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be good to add the rows and saving knob here too.

stories/Notes.js Outdated
onSave={n => alert(`Save Add: ${JSON.stringify(n)}`)}
onCancel={action('onCancel')}
onChange={action('onChange')}
onSave={action('onSave')}
/>}
adding={adding}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The adding prop was removed by your recent changes, so this prop and the knob should be removed.

stories/Notes.js Outdated
onSave={n => alert(`Save Add: ${JSON.stringify(n)}`)}
onCancel={action('onCancel')}
onChange={action('onChange')}
onSave={action('onSave')}
/>}
adding={adding}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The adding prop was removed by your recent changes, so this prop and the knob should be removed.

stories/Notes.js Outdated
@@ -78,27 +78,26 @@ storiesOf('Notes', module)
<Notes
addControl={<EditableNote
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The addControl prop was removed by your recent changes, so should be removed from the example.

stories/Notes.js Outdated
@@ -1,5 +1,5 @@
import React from 'react';
import { storiesOf } from '@storybook/react';
import { action, storiesOf } from '@storybook/react';
import { boolean, text } from '@storybook/addon-knobs';
import { EditableNote, Note, Notes } from '../src';

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The description below should have the last sentence (the one referring to addControl) removed.

stories/Notes.js Outdated
@@ -43,20 +44,18 @@ storiesOf('Notes', module)
<Notes
addControl={<EditableNote
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The addControl prop was removed by your recent changes, so should be removed from the example.

stories/Notes.js Outdated
onDelete={action('onDelete')}
onEdit={action('onEdit')}
onSave={action('onSave')}
onUndelete={action('onUndelete')}
Copy link
Contributor Author

@joshuasbates joshuasbates Jul 2, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For some reason, when I view the Storybook, select the "deleted" knob, then click on the "undo" link in the DeletedNote view, it reroutes the page rather than recording the onUndelete action. Are you seeing this too?

stories/Notes.js Outdated
@@ -78,27 +78,26 @@ storiesOf('Notes', module)
<Notes
Copy link
Contributor Author

@joshuasbates joshuasbates Jul 2, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This example can be simplified. With children, we can remove all props that would have been forwarded to internally-created Note components. Since these props are explicitly passed to each Note in the child body, there's no need to pass them into Notes (now that it has no unique props itself), e.g.,

<Notes>
  {notes.map(note => (
    <Note
      note={note}
      onCancel={action('onCancel')}
      onChange={action('onChange')}
      onDelete={action('onDelete')}
      onEdit={action('onEdit')}
      onSave={action('onSave')}
      onUndelete={action('onUndelete')}
      saving={note.saving}
    />
  ))}
</Notes>

(plus you can get rid of the <div> in the map body)

<div
className="d-inline-flex align-items-center"
ref="title"
>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The text-muted property seems to have been dropped. It appears to be a part of the Saffron standard.

In use: https://qa.qa.appfolio.com/maintenance/mobile?assignedUserId=any#/133920/notes

const saving = boolean('saving', false);

const note = withNote ? noteToEdit : { text: '' };
note.saving = saving;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since saving is a component prop now, this should be removed and the knob should be added to the EditableNote inputs. (same for the next doc block)

<Input
autoFocus
disabled={saving}
ref="text"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is this ref for?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These were left over from the original impl. The unit test uses these refs to find elements. We should get away from that, IMHO, but I didn't go that far.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No worries, just curious

@@ -35,7 +35,7 @@ class EditableNote extends React.Component {
const { date, errors, text } = note;

return (
<Card className={className}>
<Card outline color="info" className={className}>
Copy link
Contributor Author

@joshuasbates joshuasbates Jul 2, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Explanation of change: Editable note card should have white background; info border

className="d-inline-flex align-items-center"
ref="title"
>
<div className="d-inline-flex align-items-center text-muted">
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Explanation of change: remove unused ref, add text-muted

<span className="m-0 my-1 mr-auto">
<span className="hidden-xs-down">
{edited ? 'Last edited' : 'Posted'}
{from ? <span className="js-note-header__from">{` by ${from}`}</span> : ' '} on <span className="js-note-header__date">{dateFormat(date, 'ddd, MMMM D, YYYY "at" h:mm A')}</span>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a bit odd to me that there are different date formats for Edited and non-edited notes, but that's the way it is in APM. Perhaps it makes sense to have these customizable. Not a big deal though

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to be clear, the date format is the same, only the labeling of that date changes:

"Posted by Gary Thomas on Mon, July 2, 2018 at 2:33 PM"
vs.
"Last edited by Gary Thomas on Mon, July 2, 2018 at 2:33 PM"

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I meant compared to short dateformat below on line 52: dateFormat(date, 'M/D/YY h:mm A') but I see now that's for small viewport widths.

@joshuasbates joshuasbates force-pushed the update-notes-components branch from 30b132e to c680435 Compare July 2, 2018 21:29
@joshuasbates joshuasbates force-pushed the update-notes-components branch from c680435 to 66e68c4 Compare July 2, 2018 21:29
Copy link
Contributor

@gthomas-appfolio gthomas-appfolio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@gthomas-appfolio gthomas-appfolio merged commit 8b530c6 into master Jul 3, 2018
@phwebi phwebi deleted the update-notes-components branch January 29, 2020 01:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants