Skip to content

Commit

Permalink
changed to simpler editorial workflow check in api constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
zanedev committed Aug 30, 2017
1 parent 4cf3f46 commit b413033
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 29 deletions.
16 changes: 5 additions & 11 deletions src/actions/editorialWorkflow.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { currentBackend } from '../backends/backend';
import { getAsset } from '../reducers';
import { loadEntry } from './entries';
import { status, EDITORIAL_WORKFLOW } from '../constants/publishModes';
import { EditorialWorkflowError } from "../valueObjects/errors";

const { notifSend } = notifActions;

Expand Down Expand Up @@ -211,16 +210,11 @@ export function loadUnpublishedEntries() {
const state = getState();
if (state.config.get('publish_mode') !== EDITORIAL_WORKFLOW) return;
const backend = currentBackend(state.config);
if (backend.supportsWorkflow()) {
dispatch(unpublishedEntriesLoading());
backend.unpublishedEntries().then(
response => dispatch(unpublishedEntriesLoaded(response.entries, response.pagination)),
error => dispatch(unpublishedEntriesFailed(error))
);
}
else {
throw new EditorialWorkflowError('Backend does not support editorial workflow', true);
}
dispatch(unpublishedEntriesLoading());
backend.unpublishedEntries().then(
response => dispatch(unpublishedEntriesLoaded(response.entries, response.pagination)),
error => dispatch(unpublishedEntriesFailed(error))
);
};
}

Expand Down
7 changes: 0 additions & 7 deletions src/backends/backend.js
Original file line number Diff line number Diff line change
Expand Up @@ -278,13 +278,6 @@ class Backend {
entry.data[filterRule.get('field')] === filterRule.get('value')
));
}

supportsWorkflow() {
if(typeof this.implementation.supportsWorkflow === "function")
return this.implementation.supportsWorkflow();
else
return true;
}
}

export function resolveBackend(config) {
Expand Down
6 changes: 1 addition & 5 deletions src/backends/bitbucket/API.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import LocalForage from "localforage";
import { Base64 } from "js-base64";
import FormData from "form-data";
import AssetProxy from "../../valueObjects/AssetProxy";
import { SIMPLE, EDITORIAL_WORKFLOW, } from "../../constants/publishModes";
import { SIMPLE } from "../../constants/publishModes";
import { APIError } from "../../valueObjects/errors";

export default class API {
Expand Down Expand Up @@ -155,10 +155,6 @@ export default class API {
uploadPromises.push(this.uploadBlob(file));
});

if (options.mode && options.mode === EDITORIAL_WORKFLOW) {
console.warn("Editorial worflow is not supported yet with Bitbucket API.")
}

return Promise.all(uploadPromises).then(() => {
if (!options.mode || (options.mode && options.mode === SIMPLE)) {
return this.getBranch();
Expand Down
12 changes: 6 additions & 6 deletions src/backends/bitbucket/implementation.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
import semaphore from "semaphore";
import AuthenticationPage from "./AuthenticationPage";
import API from "./API";
import { fileExtension } from '../../lib/pathHelper'
import { fileExtension } from '../../lib/pathHelper';
import { EDITORIAL_WORKFLOW } from "../../constants/publishModes";

const MAX_CONCURRENT_DOWNLOADS = 10;
const SUPPORTS_WORKFLOW = false;

export default class Bitbucket {
constructor(config, proxied = false) {
this.config = config;

if (config.getIn(["publish_mode"]) === EDITORIAL_WORKFLOW) {
throw new Error("The Bitbucket backend does not support the Editorial Workflow.")
}

if (!proxied && config.getIn(["backend", "repo"]) == null) {
throw new Error("The Bitbucket backend needs a \"repo\" in the backend configuration.");
}
Expand Down Expand Up @@ -95,8 +99,4 @@ export default class Bitbucket {
deleteFile(path, commitMessage, options) {
return this.api.deleteFile(path, commitMessage, options);
}

supportsWorkflow() {
return SUPPORTS_WORKFLOW;
}
}

0 comments on commit b413033

Please sign in to comment.