feat: Add org-clubhouse-claim
Add a standalone org-clubhouse-claim function for claiming the current story without making any other updates
This commit is contained in:
parent
9b92541239
commit
453e6dc36c
2 changed files with 46 additions and 25 deletions
10
README.org
10
README.org
|
@ -1,4 +1,4 @@
|
|||
* Org-Clubhouse
|
||||
#+TITLE: Org-Clubhouse
|
||||
|
||||
Simple, unopinionated integration between Emacs's [[https://orgmode.org/][org-mode]] and the [[https://clubhouse.io/][Clubhouse]] issue tracker
|
||||
|
||||
|
@ -34,11 +34,12 @@ Simple, unopinionated integration between Emacs's [[https://orgmode.org/][org-mo
|
|||
|
||||
* Setup
|
||||
|
||||
Once installed, you'll need to set two global config vars:
|
||||
Once installed, you'll need to set three global config vars:
|
||||
|
||||
#+BEGIN_SRC emacs-lisp
|
||||
(setq org-clubhouse-auth-token "<your-token>"
|
||||
org-clubhouse-team-name "<your-team-name>")
|
||||
org-clubhouse-team-name "<your-team-name>"
|
||||
org-clubhouse-username "<your-username>")
|
||||
#+END_SRC
|
||||
|
||||
You can generate a new personal API token by going to the "API Tokens" tab on
|
||||
|
@ -79,6 +80,9 @@ org-clubhouse provides the following commands:
|
|||
Create org-mode headlines from a clubhouse query at the cursor's current
|
||||
position, prompting for the headline indentation level and clubhouse query
|
||||
text
|
||||
- ~org-clubhouse-claim~
|
||||
Adds the user configured in ~org-clubhouse-username~ as the owner of the
|
||||
clubhouse story associated with the headline at point
|
||||
|
||||
* Configuration
|
||||
|
||||
|
|
|
@ -791,22 +791,6 @@ allows manually passing a clubhouse ID and list of org-element plists to write"
|
|||
;;; Story updates
|
||||
;;;
|
||||
|
||||
(defun org-clubhouse-update-story-title ()
|
||||
"Update the title of the Clubhouse story linked to the current headline.
|
||||
|
||||
Update the title of the story linked to the current headline with the text of
|
||||
the headline."
|
||||
(interactive)
|
||||
|
||||
(when-let (clubhouse-id (org-element-clubhouse-id))
|
||||
(let* ((elt (org-element-find-headline))
|
||||
(title (plist-get elt :title)))
|
||||
(org-clubhouse-update-story-internal
|
||||
clubhouse-id
|
||||
:name title)
|
||||
(message "Successfully updated story title to \"%s\""
|
||||
title))))
|
||||
|
||||
(cl-defun org-clubhouse-update-story-internal
|
||||
(story-id &rest attrs)
|
||||
(cl-assert (and (integerp story-id)
|
||||
|
@ -817,6 +801,29 @@ the headline."
|
|||
:data
|
||||
(json-encode attrs)))
|
||||
|
||||
(cl-defun org-clubhouse-update-story-at-point (&rest attrs)
|
||||
(when-let* ((clubhouse-id (org-element-clubhouse-id)))
|
||||
(apply
|
||||
#'org-clubhouse-update-story-internal
|
||||
(cons clubhouse-id attrs))
|
||||
t))
|
||||
|
||||
(defun org-clubhouse-update-story-title ()
|
||||
"Update the title of the Clubhouse story linked to the current headline.
|
||||
|
||||
Update the title of the story linked to the current headline with the text of
|
||||
the headline."
|
||||
(interactive)
|
||||
|
||||
(let* ((elt (org-element-find-headline))
|
||||
(title (plist-get elt :title)))
|
||||
(and
|
||||
(org-clubhouse-update-story-at-point
|
||||
clubhouse-id
|
||||
:name title)
|
||||
(message "Successfully updated story title to \"%s\""
|
||||
title))))
|
||||
|
||||
(defun org-clubhouse-update-status ()
|
||||
"Update the status of the Clubhouse story linked to the current element.
|
||||
|
||||
|
@ -880,12 +887,12 @@ element."
|
|||
Update the status of the Clubhouse story linked to the current element with the
|
||||
contents of a drawer inside the element called DESCRIPTION, if any."
|
||||
(interactive)
|
||||
(when-let* ((clubhouse-id (org-element-clubhouse-id))
|
||||
(new-description (org-clubhouse-find-description-drawer)))
|
||||
(org-clubhouse-update-story-internal
|
||||
(when-let* ((new-description (org-clubhouse-find-description-drawer)))
|
||||
(and
|
||||
(org-clubhouse-update-story-at-point
|
||||
clubhouse-id
|
||||
:description new-description)
|
||||
(message "Successfully updated story description")))
|
||||
(message "Successfully updated story description"))))
|
||||
|
||||
;;;
|
||||
;;; Creating headlines from existing stories
|
||||
|
@ -970,6 +977,16 @@ resulting stories at headline level LEVEL."
|
|||
(org-clubhouse-workflow-state-id-to-todo-keyword
|
||||
(alist-get 'workflow_state_id story))))))
|
||||
|
||||
(defun org-clubhouse-claim ()
|
||||
"Assign the clubhouse story associated with the headline at point to yourself."
|
||||
(interactive)
|
||||
(if org-clubhouse-username
|
||||
(and
|
||||
(org-clubhouse-update-story-at-point
|
||||
:owner_ids (list (org-clubhouse-whoami)))
|
||||
(message "Successfully claimed story"))
|
||||
(warn "Can't claim story if `org-clubhouse-username' is unset")))
|
||||
|
||||
(comment
|
||||
(org-clubhouse--search-stories "train")
|
||||
(org-clubhouse-request "GET" "search/stories" :params `((query ,"")))
|
||||
|
|
Loading…
Reference in a new issue