From 443b79f37f1528ca88d7f36ada27433570560a24 Mon Sep 17 00:00:00 2001 From: Michael Kochell <6913320+mickmister@users.noreply.github.com> Date: Tue, 5 May 2020 00:37:34 -0400 Subject: [PATCH] Change "alias" to "subscription name" in user-facing strings (#41) --- server/command/command.go | 32 ++++++++++++------- server/plugin_test.go | 8 ++--- server/serializer/channel_subscription.go | 6 ++-- server/serializer/page_subscription.go | 2 +- server/serializer/space_subscription.go | 2 +- server/service/delete_subscription.go | 4 +-- server/service/save_subscription.go | 2 +- .../subscription_modal.test.jsx.snap | 4 +-- .../subscription_modal/subscription_modal.jsx | 4 +-- webapp/src/constants/index.js | 2 +- 10 files changed, 37 insertions(+), 29 deletions(-) diff --git a/server/command/command.go b/server/command/command.go index a1afdde..7c76e4f 100644 --- a/server/command/command.go +++ b/server/command/command.go @@ -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 \"\"` - Unsubscribe the current channel from notifications associated with the given alias.\n" + + "* `/confluence unsubscribe \"\"` - 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 \"\"` - Edit the subscription settings associated with the given alias.\n" + "* `/confluence edit \"\"` - 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." ) @@ -66,7 +66,7 @@ var ConfluenceCommandHandler = Handler{ "unsubscribe": deleteSubscription, "install/cloud": showInstallCloudHelp, "install/server": showInstallServerHelp, - "help": confluenceHelp, + "help": confluenceHelpCommand, }, defaultHandler: executeConfluenceDefault, } @@ -77,15 +77,18 @@ func GetCommand() *model.Command { DisplayName: "Confluence", Description: "Integration with Confluence.", AutoComplete: true, - AutoCompleteDesc: "Available commands: subscribe, list, unsubscribe \"\", edit \"\", install cloud/server, help.", + AutoCompleteDesc: "Available commands: subscribe, list, unsubscribe \"\", edit \"\", 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, } } @@ -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 } diff --git a/server/plugin_test.go b/server/plugin_test.go index 6e15232..d7a32ba 100644 --- a/server/plugin_test.go +++ b/server/plugin_test.go @@ -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 \"\"` - Unsubscribe the current channel from notifications associated with the given alias.\n" + + "* `/confluence unsubscribe \"\"` - 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 \"\"` - Edit the subscription settings associated with the given alias.\n" + "* `/confluence edit \"\"` - 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" + diff --git a/server/serializer/channel_subscription.go b/server/serializer/channel_subscription.go index 4694b4c..b22aff6 100644 --- a/server/serializer/channel_subscription.go +++ b/server/serializer/channel_subscription.go @@ -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." ) @@ -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() diff --git a/server/serializer/page_subscription.go b/server/serializer/page_subscription.go index 92cbb0d..55b4190 100644 --- a/server/serializer/page_subscription.go +++ b/server/serializer/page_subscription.go @@ -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") diff --git a/server/serializer/space_subscription.go b/server/serializer/space_subscription.go index 35d69ec..fc8ce6e 100644 --- a/server/serializer/space_subscription.go +++ b/server/serializer/space_subscription.go @@ -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") diff --git a/server/service/delete_subscription.go b/server/service/delete_subscription.go index 71150e0..b016975 100644 --- a/server/service/delete_subscription.go +++ b/server/service/delete_subscription.go @@ -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 { diff --git a/server/service/save_subscription.go b/server/service/save_subscription.go index 91d9437..57ff58a 100644 --- a/server/service/save_subscription.go +++ b/server/service/save_subscription.go @@ -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." ) diff --git a/webapp/src/components/subscription_modal/__snapshots__/subscription_modal.test.jsx.snap b/webapp/src/components/subscription_modal/__snapshots__/subscription_modal.test.jsx.snap index 0a568c7..e8cffd7 100644 --- a/webapp/src/components/subscription_modal/__snapshots__/subscription_modal.test.jsx.snap +++ b/webapp/src/components/subscription_modal/__snapshots__/subscription_modal.test.jsx.snap @@ -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} diff --git a/webapp/src/components/subscription_modal/subscription_modal.jsx b/webapp/src/components/subscription_modal/subscription_modal.jsx index ca3df55..1828c7e 100644 --- a/webapp/src/components/subscription_modal/subscription_modal.jsx +++ b/webapp/src/components/subscription_modal/subscription_modal.jsx @@ -240,12 +240,12 @@ export default class SubscriptionModal extends React.PureComponent {