mirror of
https://github.com/czhu12/canine.git
synced 2026-01-06 11:40:44 -06:00
select github repository
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
import { Controller } from "@hotwired/stimulus"
|
||||
|
||||
export default class extends Controller {
|
||||
static targets = ["frame", "repository", "button", "publicRepository", "modal"]
|
||||
|
||||
connect() {
|
||||
this.frameTarget.addEventListener("turbo:frame-load", this.onFrameLoad.bind(this))
|
||||
}
|
||||
|
||||
selectPublicRepository() {
|
||||
this.repositoryTarget.value = this.publicRepositoryTarget.value
|
||||
|
||||
// Close the modal
|
||||
this.modalTarget.removeAttribute("open")
|
||||
}
|
||||
|
||||
onFrameLoad(event) {
|
||||
this.buttonTarget.removeAttribute("disabled")
|
||||
}
|
||||
|
||||
selectRepository(e) {
|
||||
this.repositoryTarget.value = e.target.dataset.repositoryName;
|
||||
this.modalTarget.removeAttribute("open")
|
||||
}
|
||||
|
||||
connectToGithub(e) {
|
||||
// Set attribute of src to the url of the frame
|
||||
console.log(this.frameTarget)
|
||||
this.frameTarget.setAttribute("src", "/integrations/github/repositories")
|
||||
|
||||
// Disable the button after clicking
|
||||
this.buttonTarget.setAttribute("disabled", "true")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user