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

[WIP] feat: commit media with post #2823

Closed
wants to merge 5 commits into from

Conversation

erezrokah
Copy link
Contributor

@erezrokah erezrokah commented Oct 30, 2019

Fixes #1344

STILL WORK IN PROGRESS.

I just wanted to share my approach as it is different than the one here #2397.

The GitHub backend already supports pushing multiple files with one commit and the draft entry has some initial support to link media files to assets.

As a result I decided to handle everything in the client until the entry is saved. It is done using the draft entry mediaFiles field that can be used to link the media file to its corresponding asset.

When a user opens the media gallery while creating/editing an entry in editorial workflow any new uploaded media file will not be persisted immediately, but added to the mediaFiles list.

Once the entry is saved everything will be pushed in a single commit.

I also needed to make sure the media files and their assets are stored in the local backup.

Items left:

  • A lot of manual regression testing
  • Write more tests
  • Add an indication in the media gallery for a draft media file
  • Decide if this should be the default behaviour
  • Fix test backend to work in the same way (it is the only other backend that supports editorial workflow)
  • Backwards compatibility


const entry = state.entryDraft.get('entry');
const useWorkflow = state.config.getIn(['publish_mode']) === EDITORIAL_WORKFLOW;
const draft = entry && !entry.isEmpty() && useWorkflow;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is this the best way to check if we're in edit mode?

@erquhart
Copy link
Contributor

Approach sounds dead on 👍🏼👍🏼

Sent with GitHawk

const files = [...metadataFiles, ...filesList];
await Promise.all(
metadataFiles.map(file =>
this.deleteFile(file.path, options.commitMessage, { branch: branchName }),
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of the re-uploading changes and deleting previously-stored media files, which will still occur if the draft change didn't add any new media file. Why don't we make use of the uploaded flag that is set here and then filter the loaded draft media files using this flag to get newly added media file(s), and then push the new media file(s) on draft update and concat here with previous ones.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks @barthc I haven't finished the part of deleting media files from the pr. I'll look into the uploaded flag.

@erezrokah erezrokah changed the title feat: commit media with post - WIP [WIP]feat: commit media with post Nov 5, 2019
@erezrokah erezrokah changed the title [WIP]feat: commit media with post [WIP] feat: commit media with post Nov 5, 2019
@erezrokah
Copy link
Contributor Author

closing for now to avoid unnecessary builds - will re-open when ready.

@erezrokah erezrokah closed this Nov 5, 2019
@wakeless
Copy link

wakeless commented Nov 7, 2019

@erezrokah Would be good to not have this PR closed so that people can have visibility of it.
I'm really interested in this, I'm sure other people are as well.

Great work thus far!

@erezrokah
Copy link
Contributor Author

erezrokah commented Nov 7, 2019

I'm opening a new one soon (can't re-open since I did a force merge). I just didn't want to hog build minutes on every new commit I push since I knew the tests were failing (specifically the cypress tests take longer to fail)

@erezrokah erezrokah mentioned this pull request Nov 7, 2019
6 tasks
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.

Feature Request: Media committed with Post / Collection Item
4 participants