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

Add meta info to cards in editorial workflow #293

Merged
merged 3 commits into from
Mar 21, 2017

Conversation

Benaiah
Copy link
Contributor

@Benaiah Benaiah commented Mar 16, 2017

Fixes #270

- Summary

Adds meta information to the cards in the editorial workflow. Currently this includes the following:

  • Which collection an entry is part of
  • Whether an entry is new or an update to an already published entry

In order to retrieve the new/update info, it adds the field state.editorialWorkflow.entities[i].isModification, which is retrieved using the GitHub API whenever unpublished entries are loaded.

- Test plan

Tested manually (no automated tests exist for the editorial workflow).

- Description for the changelog

  • Add meta info to cards in editorial workflow

- A picture of a cute animal (not mandatory but encouraged)

image


.meta {}
.label {
padding: 5px .75em 4px .75em;
Copy link
Contributor

Choose a reason for hiding this comment

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

Just use pixels for everything, browsers now handle them pretty well across display densities.

.meta {}
.label {
padding: 5px .75em 4px .75em;
border-radius: 1em;
Copy link
Contributor

Choose a reason for hiding this comment

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

Use the borderRadius variable from UI/theme.

@@ -0,0 +1,23 @@
.cardMeta {
Copy link
Contributor

Choose a reason for hiding this comment

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

Import ../UI/theme and use variables where it makes sense, especially for colors (add new ones where necessary). Doesn't have to be over-thought - lots of change is coming. Just want to establish the pattern of general re-use for these kinds of values.

import React, { PropTypes } from 'react';
import styles from './UnpublishedListingCardMeta.css';

const UnpublishedListingCardMeta = ({ meta, label }) =>
Copy link
Contributor

Choose a reason for hiding this comment

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

👍 for splitting this into a new component.

@@ -8,5 +8,8 @@ export function createEntry(collection, slug = '', path = '', options = {}) {
returnObj.data = options.data || {};
returnObj.label = options.label || null;
returnObj.metaData = options.metaData || null;
returnObj.isModification = (options.isModification === true || options.isModification === false)
Copy link
Contributor

Choose a reason for hiding this comment

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

We can improve clarity and length using _.isBoolean, make it a one-liner.

@Benaiah Benaiah force-pushed the label-cards-in-editorial-workflow branch 2 times, most recently from 84ebafd to 7ce1032 Compare March 20, 2017 19:58
@Benaiah
Copy link
Contributor Author

Benaiah commented Mar 20, 2017

@erquhart I've added the resolvePromiseProperties code to this branch. How do you want the history to look? I'm thinking about merging the last two.

@Benaiah Benaiah force-pushed the label-cards-in-editorial-workflow branch from 7ce1032 to 9deb15f Compare March 20, 2017 20:29
@Benaiah
Copy link
Contributor Author

Benaiah commented Mar 20, 2017

@erquhart I've addressed your change requests - how does this look now?

@Benaiah Benaiah changed the title (WIP) Add meta info to cards in editorial workflow Add meta info to cards in editorial workflow Mar 20, 2017
@Benaiah Benaiah force-pushed the label-cards-in-editorial-workflow branch from 9deb15f to ba76de4 Compare March 20, 2017 20:32
Copy link
Contributor

@erquhart erquhart left a comment

Choose a reason for hiding this comment

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

This should be the last round, great work :)

@@ -77,6 +80,10 @@ class UnpublishedListing extends React.Component {
>
<div className={styles.draggable}>
<Card className={styles.card}>
<UnpublishedListingCardMeta
meta={pluralize(collection.charAt(0).toUpperCase() + collection.slice(1), 1)}
Copy link
Contributor

Choose a reason for hiding this comment

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

Just use lodash.capitalize here.

@@ -1,3 +1,23 @@
import _ from 'lodash';
Copy link
Contributor

Choose a reason for hiding this comment

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

We can keep module size down by importing the specific functions that we need.

@@ -1,3 +1,5 @@
import _ from "lodash";
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here, just grab the one function.

return unpublishedPromise;
}

isUnpublishedEntryModification(path) {
Copy link
Contributor

Choose a reason for hiding this comment

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

We should be passing the path and the branch in.

Benaiah added 2 commits March 20, 2017 17:02
`resolvePromiseProperties` takes on object and returns a promise which
resolves to a copy of the object. This copy has all its immediate
properties which were Promises replaced with the resolved value of
those promises. Promises are run with `Promise.all`. Errors are passed
up to the outer promise chain.

Example usage:

```js
resolvePromiseProperties({
  promise: Promise.resolve("this property will resolve to this string"),
  nonPromise: "this will remain the same",

  // you can nest the function
  nestedPromiseInside: resolvePromiseProperties({
    nestedPromise: Promise.resolve("this will resolve"),
    nestedNonPromise: "this stays the same",
  }),
})
.then(obj => console.log(obj))

```

That will produce the following output:

```js
{
  promise: "this property will resolve to this string",
  nonPromise: "this will remain the same",
  nestedPromiseInside: {
    nestedPromise: "this will resolve",
    nestedNonPromise: "this stays the same",
  },
}
```
@Benaiah Benaiah force-pushed the label-cards-in-editorial-workflow branch from ba76de4 to df89b50 Compare March 21, 2017 00:05
@Benaiah Benaiah force-pushed the label-cards-in-editorial-workflow branch from df89b50 to 1aa02eb Compare March 21, 2017 00:17
Copy link
Contributor

@erquhart erquhart left a comment

Choose a reason for hiding this comment

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

LGTM

@erquhart erquhart merged commit 96d6242 into decaporg:master Mar 21, 2017
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