Skip to content
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

Add Matrix webhook #10831

Merged
merged 14 commits into from
Mar 28, 2020
Prev Previous commit
Next Next commit
Add template and related translations for Matrix hook
Signed-off-by: Till Faelligen <[email protected]>
  • Loading branch information
S7evinK committed Mar 26, 2020
commit f40aabb0e91cff4a591a1c1f912dfb7bea70c5ca
5 changes: 5 additions & 0 deletions options/locale/locale_en-US.ini
Original file line number Diff line number Diff line change
Expand Up @@ -1436,6 +1436,7 @@ settings.slack_channel = Channel
settings.add_discord_hook_desc = Integrate <a href="%s">Discord</a> into your repository.
settings.add_dingtalk_hook_desc = Integrate <a href="%s">Dingtalk</a> into your repository.
settings.add_telegram_hook_desc = Integrate <a href="%s">Telegram</a> into your repository.
settings.add_matrix_hook_desc = Integrate <a href="%s">Matrix</a> into your repository.
settings.add_msteams_hook_desc = Integrate <a href="%s">Microsoft Teams</a> into your repository.
settings.add_feishu_hook_desc = Integrate <a href="%s">Feishu</a> into your repository.
settings.deploy_keys = Deploy Keys
Expand Down Expand Up @@ -1503,6 +1504,10 @@ settings.edit_protected_branch = Edit
settings.protected_branch_required_approvals_min = Required approvals cannot be negative.
settings.bot_token = Bot Token
settings.chat_id = Chat ID
settings.matrix.homeserver_url = Homeserver URL
settings.matrix.room_id = Room ID
settings.matrix.access_token = Access Token
settings.matrix.message_type = Message Type
settings.archive.button = Archive Repo
settings.archive.header = Archive This Repo
settings.archive.text = Archiving the repo will make it entirely read-only. It is hidden from the dashboard, cannot be committed to and no issues or pull-requests can be created.
Expand Down
14 changes: 14 additions & 0 deletions public/img/matrix.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions templates/repo/settings/webhook/list.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@
<a class="item" href="{{.BaseLink}}/feishu/new">
<img class="img-10" src="{{StaticUrlPrefix}}/img/feishu.png">Feishu
</a>
<a class="item" href="{{.BaseLink}}/matrix/new">
<img class="img-10" src="{{StaticUrlPrefix}}/img/matrix.svg">Matrix
</a>
</div>
</div>
</div>
Expand Down
31 changes: 31 additions & 0 deletions templates/repo/settings/webhook/matrix.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{{if eq .HookType "matrix"}}
<p>{{.i18n.Tr "repo.settings.add_matrix_hook_desc" "https://matrix.org/" | Str2html}}</p>
<form class="ui form" action="{{.BaseLink}}/matrix/{{or .Webhook.ID "new"}}" method="post">
{{.CsrfTokenHtml}}
<div class="required field {{if .Err_HomeserverURL}}error{{end}}">
<label for="homeserver_url">{{.i18n.Tr "repo.settings.matrix.homeserver_url"}}</label>
<input id="homeserver_url" name="homeserver_url" type="text" value="{{.MatrixHook.HomeserverURL}}" autofocus required>
</div>
<div class="required field {{if .Err_Room}}error{{end}}">
<label for="room_id">{{.i18n.Tr "repo.settings.matrix.room_id"}}</label>
<input id="room_id" name="room_id" type="text" value="{{.MatrixHook.Room}}" required>
</div>
<div class="required field {{if .Err_AccessToken}}error{{end}}">
<label for="access_token">{{.i18n.Tr "repo.settings.matrix.access_token"}}</label>
<input id="access_token" name="access_token" type="text" value="{{.MatrixHook.AccessToken}}" required>
</div>
<div class="field">
<label>{{.i18n.Tr "repo.settings.matrix.message_type"}}</label>
<div class="ui selection dropdown">
<input type="hidden" id="message_type" name="message_type" value="{{if .MatrixHook.MessageType}}{{.MatrixHook.MessageType}}{{else}}1{{end}}">
<div class="default text"></div>
<i class="dropdown icon"></i>
<div class="menu">
<div class="item" data-value="1">m.notice</div>
<div class="item" data-value="2">m.text</div>
</div>
</div>
</div>
{{template "repo/settings/webhook/settings" .}}
</form>
{{end}}
3 changes: 3 additions & 0 deletions templates/repo/settings/webhook/new.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
<img class="img-13" src="{{StaticUrlPrefix}}/img/msteams.png">
{{else if eq .HookType "feishu"}}
<img class="img-13" src="{{StaticUrlPrefix}}/img/feishu.png">
{{else if eq .HookType "matrix"}}
<img class="img-13" src="{{StaticUrlPrefix}}/img/matrix.svg">
S7evinK marked this conversation as resolved.
Show resolved Hide resolved
{{end}}
</div>
</h4>
Expand All @@ -35,6 +37,7 @@
{{template "repo/settings/webhook/telegram" .}}
{{template "repo/settings/webhook/msteams" .}}
{{template "repo/settings/webhook/feishu" .}}
{{template "repo/settings/webhook/matrix" .}}
</div>

{{template "repo/settings/webhook/history" .}}
Expand Down