blob: dbd32faaed53d08ae1065b78b6a663a410da82ad (
about) (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
|
;;; build-farm-project.el --- Interface for projects -*- lexical-binding: t -*-
;; Copyright © 2018 Alex Kost <alezost@gmail.com>
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;;
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
;;; Commentary:
;; This file provides an interface for displaying projects of a build
;; farm in 'list' and 'info' buffers.
;;; Code:
(require 'bui)
(require 'build-farm)
(require 'build-farm-url)
(build-farm-define-entry-type project
:search-types '((all . build-farm-project-url))
:filter-names '((name . id)
(displayname . name))
;; Also there is `hidden' boolean field, but it is useless because it
;; is the same thing as `enabled': when `hidden' is 1, `enabled' is 0,
;; and vice versa. So `hidden' is not going to be used anywhere.
:filter-boolean-params '(enabled))
(defun build-farm-project-get-display (search-type &rest args)
"Search for projects and show results.
See `build-farm-search-url' for the meaning of SEARCH-TYPE and ARGS."
(apply #'bui-list-get-display-entries
'build-farm-project search-type args))
;;; Project 'info'
(build-farm-define-interface project info
:mode-name "Farm-Project-Info"
:buffer-name "*Farm Project Info*"
:format '((name nil (simple bui-info-heading))
nil
(description nil (simple build-farm-project-info-description))
nil
(id format (format))
(owner format (format build-farm-project-info-owner))
(enabled format build-farm-project-info-insert-enabled)
(releases format (format))
(jobsets simple build-farm-project-info-insert-jobsets)))
(defface build-farm-project-info-description
'((t :inherit font-lock-doc-face))
"Face used for a project description."
:group 'build-farm-project-info-faces)
(defface build-farm-project-info-owner
'((t :inherit font-lock-constant-face))
"Face used for the owner of a project."
:group 'build-farm-project-info-faces)
(defface build-farm-project-info-enabled
'((t :inherit success))
"Face used for enabled projects."
:group 'build-farm-project-info-faces)
(defface build-farm-project-info-disabled
'((t :inherit shadow))
"Face used for disabled projects."
:group 'build-farm-project-info-faces)
(defun build-farm-project-info-insert-enabled (value _entry)
"Insert boolean VALUE showing whether this project is enabled."
(if value
(bui-info-insert-value-format "Yes" 'build-farm-project-info-enabled)
(bui-info-insert-value-format "No" 'build-farm-project-info-disabled)))
(defun build-farm-project-info-insert-jobsets (jobsets entry)
"Insert JOBSETS of the project ENTRY."
(let ((project (bui-entry-id entry)))
(dolist (jobset jobsets)
(bui-newline)
(bui-insert-indent)
(build-farm-project-info-insert-jobset project jobset))))
(defun build-farm-project-info-insert-jobset (project jobset)
"Insert info about JOBSET of the PROJECT at point."
(let ((url (build-farm-jobset-url project jobset)))
(bui-insert-button jobset 'bui-url
'url url
'help-echo (format "Browse %s" url))))
;;; Project 'list'
(build-farm-define-interface project list
:describe-function 'build-farm-list-describe
:mode-name "Farm-Project-List"
:buffer-name "*Farm Projects*"
:format '((name build-farm-project-list-get-name 25 t)
(owner nil 22 t)
(description bui-list-get-one-line 30 t))
:hint 'build-farm-project-list-hint)
(let ((map build-farm-project-list-mode-map))
(define-key map (kbd "J") 'build-farm-project-list-jobsets))
(defface build-farm-project-list-disabled
'((t :inherit build-farm-project-info-disabled))
"Face used for disabled projects."
:group 'build-farm-project-list-faces)
(defvar build-farm-project-list-default-hint
'(("\\[build-farm-project-list-jobsets]")
" show jobsets of the current project;\n"))
(defun build-farm-project-list-hint ()
"Return hint string for a project-list buffer."
(bui-format-hints
build-farm-project-list-default-hint
(bui-default-hint)))
(defun build-farm-project-list-get-name (name entry)
"Return NAME of the project ENTRY.
Colorize it with an appropriate face if needed."
(bui-get-string
name
(unless (bui-entry-non-void-value entry 'enabled)
'build-farm-project-list-disabled)))
(declare-function build-farm-jobsets "build-farm-jobset")
(defun build-farm-project-list-jobsets ()
"Display jobsets of the current project."
(interactive)
(build-farm-jobsets (bui-list-current-id)))
;;; Interactive commands
;;;###autoload
(defun build-farm-projects ()
"Display build farm projects."
(interactive)
(build-farm-project-get-display 'all))
(provide 'build-farm-project)
;;; build-farm-project.el ends here
|