Skip to content
This repository has been archived by the owner on Jul 12, 2023. It is now read-only.

Allow the issuer to select an SMS template #1352

Merged
merged 10 commits into from
Dec 15, 2020

Conversation

whaught
Copy link
Contributor

@whaught whaught commented Dec 15, 2020

Issue #1320

Proposed Changes

  • If more than one SMS template is defined, allow the user to pick one
  • Add a field to the issue API and compose with the given template

Release Note

Allow user to select an SMS template on code-issue. Add template label field to issueAPI.

@google-cla google-cla bot added the cla: yes Auto: added by CLA bot when all committers have signed a CLA. label Dec 15, 2020
@whaught whaught changed the title [WIP ]Allow the issuer to select an SMS template [WIP] Allow the issuer to select an SMS template Dec 15, 2020
@whaught whaught changed the title [WIP] Allow the issuer to select an SMS template Allow the issuer to select an SMS template Dec 15, 2020
<select class="form-control" name="sms-template">
<option value="Default SMS template">Default SMS template</option>
{{range $k, $v := $currentRealm.SMSTextAlternateTemplates}}
<option value="{{$k}}">{{$k}}</option>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: indent

<select class="form-control" name="sms-template">
<option value="Default SMS template">Default SMS template</option>
{{range $k, $v := $currentRealm.SMSTextAlternateTemplates}}
<option value="{{$k}}">{{$k}}</option>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be {{$v}}? If not, why is $v scoped?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

templates can't do $k, _ and single var is just values. I need just the keys (labels)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but then can do $k := range

Copy link
Contributor Author

@whaught whaught Dec 15, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but range $k := .someMap iterates the map values, not the keys. Maybe I'm misunderstanding

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My b - apparently this is backwards in Go templates from the Go language /tableflip

pkg/api/api.go Outdated
Phone string `json:"phone"`
TZOffset float32 `json:"tzOffset"`
Phone string `json:"phone"`
SMSTemplateLabel string `json:"SMSTemplateLabel"`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be smsTemplateLabel (I don't make the rules)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yea that's consistent with tzOffset. Weird though.

pkg/controller/issueapi/logic.go Outdated Show resolved Hide resolved
pkg/database/realm_test.go Outdated Show resolved Hide resolved
internal/i18n/locales/en/default.po Show resolved Hide resolved
Copy link
Member

@sethvargo sethvargo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

@whaught can do you do a followup to update the docs on the failure modes?

* `smsTemplateLabel`
* If the realm has more than one SMS template defined, this may be optionally specify
the label of the message template which the server should compose. If omitted, the
default template will be used.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens if they supply a label that does not exist?

@google-oss-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: sethvargo, whaught

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@google-oss-robot google-oss-robot merged commit 798f9ff into google:main Dec 15, 2020
@whaught whaught deleted the use-sms-template branch December 17, 2020 00:01
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 18, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
cla: yes Auto: added by CLA bot when all committers have signed a CLA.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants