-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
New BitBucket implementation #1504
Conversation
Deploy preview for netlify-cms-www ready! Built with commit 63806f3 |
Deploy preview for cms-demo ready! Built with commit 63806f3 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work @Benaiah! Found one issue in local testing beyond the handful of code review comments: if you open an entry and then go back to the collections screen, pagination no longer works.
We're very close, excited to get this merged.
sem.leave(); | ||
}).catch((error = true) => { | ||
sem.leave(); | ||
console.error(`failed to load file from GitLab: ${ file.path }`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was a confusing message to see in my console lol
authenticate(user) { | ||
this.tokenPromise = user.jwt.bind(user); | ||
// this.tokenPromise = user.jwt.bind(user); | ||
this.tokenPromise = () => Promise.resolve("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX21ldGFkYXRhIjp7fSwiYXBwX21ldGFkYXRhIjp7InJvbGVzIjpbImFkbWluIl19fQ.5W7AGwZ8h5Y1YfHXhaMO1ysviOrKJhcCHGd4SSZ316E"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to switch this one back.
} | ||
} else if (bitbucket_enabled) { | ||
this.backendType = "bitbucket"; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpick: fix indentation
@@ -98,6 +109,14 @@ export default class GitGateway { | |||
} else if (this.backendType === "gitlab") { | |||
this.api = new GitLabAPI(apiConfig); | |||
this.backend = new GitLabBackend(this.config, { proxied: true, API: this.api }); | |||
} else if (this.backendType === "bitbucket") { | |||
this.api = new BitBucketAPI({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
indentation
hasWriteAccess: async () => true, | ||
}); | ||
console.log(this.api); | ||
this.backend = new BitBucketBackend(this.config, { proxied: true, API: this.api }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
indentation lol. obviously due to your stubborn use of emacs . also we need prettier.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 to getting prettier in
src/lib/backendHelper.js
Outdated
const responseFormatters = fromJS({ | ||
json: async res => { | ||
const contentType = res.headers.get("Content-Type"); | ||
if (!contentType.startsWith("application/json") && contentType.startsWith("text/json")) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be switched to just check for startsWith('text/json')
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should actually be !contentType.startsWith("application/json") && !contentType.startsWith("text/json")
, but the second !
was missing. Parsing a Content-Type
of "text/json"
as JSON shouldn't produce an error.
return flow([ | ||
unsentRequest.withMethod("POST"), | ||
unsentRequest.withBody(body), | ||
this.request, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Love this pattern for building requests, awesome stuff.
export const parseResponse = async (res, { expectingOk = true, format = "text" } = {}) => { | ||
if (expectingOk && !res.ok) { | ||
throw new Error(`Expected an ok response, but received an error status: ${ res.status }.`); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just noting that this triggers UI errors in situations that don't currently show errors in other backends. For example, a collection in the configuration whose folder does not exist in the repo shows this error, while failing silently in other backends.
9250265
to
63806f3
Compare
Closes #234.
- Summary
Adds support for BitBucket as a backend, both with and without git-gateway. (git-gateway support depends on the merge and deployment of netlify/git-gateway#20). Includes token refresh logic, so users won't have to log in every couple hours to keep using the CMS.
- Test plan
Tested manually.
- Description for the changelog
Add BitBucket backend
- A picture of a cute animal (not mandatory but encouraged)