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

only rebase EW PR if no asset store #804

Merged
merged 1 commit into from
Nov 11, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion src/actions/editorialWorkflow.js
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ export function persistUnpublishedEntry(collection, existingUnpublishedEntry) {

dispatch(unpublishedEntryPersisting(collection, serializedEntry, transactionID));
const persistAction = existingUnpublishedEntry ? backend.persistUnpublishedEntry : backend.persistEntry;
return persistAction.call(backend, state.config, collection, serializedEntryDraft, assetProxies.toJS())
return persistAction.call(backend, state.config, collection, serializedEntryDraft, assetProxies.toJS(), state.integrations)
.then(() => {
dispatch(notifSend({
message: 'Entry saved',
Expand Down
15 changes: 11 additions & 4 deletions src/backends/backend.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import TestRepoBackend from "./test-repo/implementation";
import GitHubBackend from "./github/implementation";
import GitGatewayBackend from "./git-gateway/implementation";
import { resolveFormat } from "../formats/formats";
import { selectIntegration } from '../reducers/integrations';
import { selectListMethod, selectEntrySlug, selectEntryPath, selectAllowNewEntries, selectAllowDeletion, selectFolderEntryExtension } from "../reducers/collections";
import { createEntry } from "../valueObjects/Entry";
import { sanitizeSlug } from "../lib/urlHelper";
Expand Down Expand Up @@ -205,7 +206,7 @@ class Backend {
.then(this.entryWithFormat(collection, slug));
}

persistEntry(config, collection, entryDraft, MediaFiles, options) {
persistEntry(config, collection, entryDraft, MediaFiles, integrations, options = {}) {
const newEntry = entryDraft.getIn(["entry", "newRecord"]) || false;

const parsedData = {
Expand Down Expand Up @@ -243,8 +244,14 @@ class Backend {

const collectionName = collection.get("name");

/**
* Determine whether an asset store integration is in use.
*/
const hasAssetStore = !!selectIntegration(integrations, null, 'assetStore');
const updatedOptions = { ...options, hasAssetStore };

return this.implementation.persistEntry(entryObj, MediaFiles, {
newEntry, parsedData, commitMessage, collectionName, mode, ...options,
newEntry, parsedData, commitMessage, collectionName, mode, ...updatedOptions,
});
}

Expand All @@ -271,8 +278,8 @@ class Backend {
return this.implementation.deleteFile(path, commitMessage);
}

persistUnpublishedEntry(config, collection, entryDraft, MediaFiles) {
return this.persistEntry(config, collection, entryDraft, MediaFiles, { unpublished: true });
persistUnpublishedEntry(...args) {
return this.persistEntry(...args, { unpublished: true });
}

updateUnpublishedEntryStatus(collection, slug, newStatus) {
Expand Down
15 changes: 15 additions & 0 deletions src/backends/github/API.js
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,21 @@ export default class API {
files: uniq(files),
};
const updatedMetadata = { ...metadata, pr, title, description, objects };

/**
* If an asset store is in use, assets are always accessible, so we
* can just finish the persist operation here.
*/
if (options.hasAssetStore) {
return this.storeMetadata(contentKey, updatedMetadata)
.then(() => this.patchBranch(branchName, newHead.sha));
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was the original behavior prior to the media library PR.


/**
* If no asset store is in use, assets are being stored in the content
* repo, which means pull requests opened for editorial workflow
* entries must be rebased if assets have been added or removed.
*/
return this.rebasePullRequest(pr.number, branchName, contentKey, metadata, newHead);
});
}
Expand Down