only rebase EW PR if no asset store

Editorial workflow pull requests are rebased if the base has
changed to ensure that asset changes on the base branch are
reflected in the PR branch, but if an asset store is in use,
no rebasing is necessary because assets are stored outside
of the content repo.
This commit is contained in:
Shawn Erquhart 2017-11-11 09:48:47 -05:00
parent 3ea56ca60c
commit 0f8a74be13
3 changed files with 27 additions and 5 deletions

View File

@ -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',

View File

@ -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";
@ -208,7 +209,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 = {
@ -246,8 +247,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,
});
}
@ -274,8 +281,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) {

View File

@ -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));
}
/**
* 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);
});
}