Skip to content

Commit

Permalink
Change "alias" to "subscription name" in user-facing strings (#41)
Browse files Browse the repository at this point in the history
  • Loading branch information
mickmister authored May 5, 2020
1 parent afb5114 commit 443b79f
Show file tree
Hide file tree
Showing 10 changed files with 37 additions and 29 deletions.
32 changes: 20 additions & 12 deletions server/command/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,21 @@ type Handler struct {
}

const (
specifyAlias = "Please specify an alias."
subscriptionDeleteSuccess = "**%s** has been deleted."
specifyAlias = "Please specify a subscription name."
subscriptionDeleteSuccess = "Subscription **%s** has been deleted."
noChannelSubscription = "No subscriptions found for this channel."
commonHelpText = "###### Mattermost Confluence Plugin - Slash Command Help\n\n" +
"* `/confluence subscribe` - Subscribe the current channel to notifications from Confluence.\n" +
"* `/confluence unsubscribe \"<alias>\"` - Unsubscribe the current channel from notifications associated with the given alias.\n" +
"* `/confluence unsubscribe \"<name>\"` - Unsubscribe the current channel from notifications associated with the given subscription name.\n" +
"* `/confluence list` - List all subscriptions for the current channel.\n" +
"* `/confluence edit \"<alias>\"` - Edit the subscription settings associated with the given alias.\n"
"* `/confluence edit \"<name>\"` - Edit the subscription settings associated with the given subscription name.\n"

sysAdminHelpText = "\n###### For System Administrators:\n" +
"Setup Instructions:\n" +
"* `/confluence install cloud` - Connect Mattermost to a Confluence Cloud instance.\n" +
"* `/confluence install server` - Connect Mattermost to a Confluence Server or Data Center instance.\n"

invalidCommand = "Invalid command parameters. Please use `/confluence help` for more information."
invalidCommand = "Invalid command."
installOnlySystemAdmin = "`/confluence install` can only be run by a system administrator."
commandsOnlySystemAdmin = "`/confluence` commands can only be run by a system administrator."
)
Expand Down Expand Up @@ -66,7 +66,7 @@ var ConfluenceCommandHandler = Handler{
"unsubscribe": deleteSubscription,
"install/cloud": showInstallCloudHelp,
"install/server": showInstallServerHelp,
"help": confluenceHelp,
"help": confluenceHelpCommand,
},
defaultHandler: executeConfluenceDefault,
}
Expand All @@ -77,15 +77,18 @@ func GetCommand() *model.Command {
DisplayName: "Confluence",
Description: "Integration with Confluence.",
AutoComplete: true,
AutoCompleteDesc: "Available commands: subscribe, list, unsubscribe \"<alias>\", edit \"<alias>\", install cloud/server, help.",
AutoCompleteDesc: "Available commands: subscribe, list, unsubscribe \"<name>\", edit \"<name>\", install cloud/server, help.",
AutoCompleteHint: "[command]",
}
}

func executeConfluenceDefault(context *model.CommandArgs, args ...string) *model.CommandResponse {
out := invalidCommand + "\n\n"
out += getFullHelpText(context, args...)

return &model.CommandResponse{
ResponseType: model.COMMAND_RESPONSE_TYPE_EPHEMERAL,
Text: invalidCommand,
Text: out,
}
}

Expand Down Expand Up @@ -168,12 +171,17 @@ func listChannelSubscription(context *model.CommandArgs, args ...string) *model.
return &model.CommandResponse{}
}

func confluenceHelp(context *model.CommandArgs, args ...string) *model.CommandResponse {
func confluenceHelpCommand(context *model.CommandArgs, args ...string) *model.CommandResponse {
helpText := getFullHelpText(context, args...)

postCommandResponse(context, helpText)
return &model.CommandResponse{}
}

func getFullHelpText(context *model.CommandArgs, args ...string) string {
helpText := commonHelpText
if util.IsSystemAdmin(context.UserId) {
helpText += sysAdminHelpText
}

postCommandResponse(context, helpText)
return &model.CommandResponse{}
return helpText
}
8 changes: 4 additions & 4 deletions server/plugin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ import (
)

const (
specifyAlias = "Please specify an alias."
subscriptionDeleteSuccess = "**%s** has been deleted."
specifyAlias = "Please specify a subscription name."
subscriptionDeleteSuccess = "Subscription **%s** has been deleted."
helpText = "###### Mattermost Confluence Plugin - Slash Command Help\n\n" +
"* `/confluence subscribe` - Subscribe the current channel to notifications from Confluence.\n" +
"* `/confluence unsubscribe \"<alias>\"` - Unsubscribe the current channel from notifications associated with the given alias.\n" +
"* `/confluence unsubscribe \"<name>\"` - Unsubscribe the current channel from notifications associated with the given subscription name.\n" +
"* `/confluence list` - List all subscriptions for the current channel.\n" +
"* `/confluence edit \"<alias>\"` - Edit the subscription settings associated with the given alias.\n"
"* `/confluence edit \"<name>\"` - Edit the subscription settings associated with the given subscription name.\n"
sysAdminHelpText = "\n###### For System Administrators:\n" +
"Setup Instructions:\n" +
"* `/confluence install cloud` - Connect Mattermost to a Confluence Cloud instance.\n" +
Expand Down
6 changes: 3 additions & 3 deletions server/serializer/channel_subscription.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const (
SubscriptionTypeSpace = "space_subscription"
SubscriptionTypePage = "page_subscription"

aliasAlreadyExist = "A subscription with the same alias already exists."
aliasAlreadyExist = "A subscription with the same name already exists."
urlSpaceKeyAlreadyExist = "A subscription with the same url and space key already exists."
urlPageIDAlreadyExist = "A subscription with the same url and page id already exists."
)
Expand Down Expand Up @@ -136,8 +136,8 @@ func SubscriptionsFromJSON(bytes []byte) (*Subscriptions, error) {

func FormattedSubscriptionList(channelSubscriptions StringSubscription) string {
var pageSubscriptions, spaceSubscriptions, list string
pageSubscriptionsHeader := fmt.Sprintf("| Alias | Base Url | Page Id | Events|\n| :----|:--------| :--------| :-----|")
spaceSubscriptionsHeader := fmt.Sprintf("| Alias | Base Url | Space Key | Events|\n| :----|:--------| :--------| :-----|")
pageSubscriptionsHeader := fmt.Sprintf("| Name | Base Url | Page Id | Events|\n| :----|:--------| :--------| :-----|")
spaceSubscriptionsHeader := fmt.Sprintf("| Name | Base Url | Space Key | Events|\n| :----|:--------| :--------| :-----|")
for _, sub := range channelSubscriptions {
if sub.Name() == SubscriptionTypePage {
pageSubscriptions += sub.GetFormattedSubscription()
Expand Down
2 changes: 1 addition & 1 deletion server/serializer/page_subscription.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func (ps PageSubscription) GetFormattedSubscription() string {

func (ps PageSubscription) IsValid() error {
if ps.Alias == "" {
return errors.New("alias can not be empty")
return errors.New("subscription name can not be empty")
}
if ps.BaseURL == "" {
return errors.New("base url can not be empty")
Expand Down
2 changes: 1 addition & 1 deletion server/serializer/space_subscription.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func (ss SpaceSubscription) GetFormattedSubscription() string {

func (ss SpaceSubscription) IsValid() error {
if ss.Alias == "" {
return errors.New("alias can not be empty")
return errors.New("subscription name can not be empty")
}
if ss.BaseURL == "" {
return errors.New("base url can not be empty")
Expand Down
4 changes: 2 additions & 2 deletions server/service/delete_subscription.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import (
)

const (
generalDeleteError = "Error occurred while deleting subscription with alias **%s**."
subscriptionNotFound = "Subscription with alias **%s** not found."
generalDeleteError = "Error occurred while deleting subscription with name **%s**."
subscriptionNotFound = "Subscription with name **%s** not found."
)

func DeleteSubscription(channelID, alias string) error {
Expand Down
2 changes: 1 addition & 1 deletion server/service/save_subscription.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (

const (
generalSaveError = "An error occurred attempting to save a subscription."
aliasAlreadyExist = "A subscription with the same alias already exists."
aliasAlreadyExist = "A subscription with the same name already exists."
urlSpaceKeyAlreadyExist = "A subscription with the same url and space key already exists."
urlPageIDAlreadyExist = "A subscription with the same url and page id already exists."
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ exports[`components/ChannelSettingsModal subscription modal snapshot test 1`] =
fieldType="input"
formControlStyle={Object {}}
formGroupStyle={Object {}}
label="Alias"
label="Name"
onChange={[Function]}
placeholder="Enter an alias for this subscription."
placeholder="Enter a name for this subscription."
readOnly={false}
removeValidation={[Function]}
required={true}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,12 +240,12 @@ export default class SubscriptionModal extends React.PureComponent {
<Modal.Body>
<div>
<ConfluenceField
label={'Alias'}
label={'Name'}
type={'text'}
fieldType={'input'}
required={true}
readOnly={editSubscription}
placeholder={'Enter an alias for this subscription.'}
placeholder={'Enter a name for this subscription.'}
value={this.state.alias}
addValidation={this.validator.addValidation}
removeValidation={this.validator.removeValidation}
Expand Down
2 changes: 1 addition & 1 deletion webapp/src/constants/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ const SUBSCRIPTION_TYPE = [

const MATTERMOST_CSRF_COOKIE = 'MMCSRF';
const OPEN_EDIT_SUBSCRIPTION_MODAL_WEBSOCKET_EVENT = `custom_${PLUGIN_NAME}_open_edit_subscription_modal`;
const SPECIFY_ALIAS = 'Please specify alias.';
const SPECIFY_ALIAS = 'Please specify a name for the subscription.';

const COMMAND_ADMIN_ONLY = '`/confluence` commands can only be run by a system administrator.';
const SYSTEM_ADMIN_ROLE = 'system_admin';
Expand Down

0 comments on commit 443b79f

Please sign in to comment.