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

[MI-2061]: Refactoring and optimisations around Forms, RTK query, and types and constants management #45

Merged
merged 32 commits into from
Sep 5, 2022
Merged
Show file tree
Hide file tree
Changes from 30 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
9f65a10
[MI-1986]: Create plugin API to fetch linked projects list
avas27JTG Aug 11, 2022
e1793e4
[MI-1987]: Integrated project list UI
avas27JTG Aug 11, 2022
0110bdc
[MI-1987]: Review fixes
avas27JTG Aug 11, 2022
ff267f5
Merge branch 'master' of github.com:Brightscout/mattermost-plugin-azu…
avas27JTG Aug 12, 2022
8dc6f80
[MI-2001]: [MI-2001]: Create plugin API to unlink project and integra…
avas27JTG Aug 12, 2022
9637e82
[MI-2001]: Review fixes
avas27JTG Aug 12, 2022
15cee42
[MI-2002]: Created plugin API to fetch user details and UI integratio…
avas27JTG Aug 12, 2022
84397d0
[MI-2002]: Updated API paths
avas27JTG Aug 12, 2022
5fb9155
[MI-2049]: Added websocket support to detect user connection details …
avas27JTG Aug 12, 2022
268bc79
[MI-2010]: API to create subscriptions
ayusht2810 Aug 16, 2022
bb12691
[MI-2010] Fix lint errors
ayusht2810 Aug 16, 2022
283e1c2
[MI-2035]: Integrated unlinking project from details page
avas27JTG Aug 16, 2022
f7ff1b6
[MI-1939]: Added refresh token logic
avas27JTG Aug 16, 2022
8bc372b
[MI-2009] API to get list of subscriptions
ayusht2810 Aug 16, 2022
37bc024
[MI-2011] Add API to listen notifications
ayusht2810 Aug 16, 2022
4af24be
[MI-2023] API to delete subscriptions
ayusht2810 Aug 16, 2022
f516a00
[MI-2023] Remove print statement
ayusht2810 Aug 16, 2022
63a3628
[MI-1939]: Fixed statusCode
avas27JTG Aug 16, 2022
a61dd77
[MI-2029] Add feature to create subscription from modal
ayusht2810 Aug 16, 2022
df6ce21
[MI-2030] Add filter to fetch subscriptions related to project
ayusht2810 Aug 16, 2022
4ecb8e7
[MI-2056]: Fixed create task flow and added user connection check on …
avas27JTG Aug 16, 2022
ca65519
[MI-2029_1] Update subscription modal
ayusht2810 Aug 16, 2022
50b04db
Pull from 'MI-2029_1'
ayusht2810 Aug 17, 2022
ee631b6
[MI-2057] Integrate subscription list page
ayusht2810 Aug 17, 2022
111fe53
Release-2
ayusht2810 Aug 17, 2022
c9b6257
Remove nolint comment
ayusht2810 Aug 17, 2022
7d35921
[MI-2060]: Refactor code for release and make required changes
avas27JTG Aug 17, 2022
c8e94b6
[MI-2061]: Refactor code base and Explore and implement RTK error han…
avas27JTG Aug 22, 2022
86d00f8
[MI-2061]: Added logic to handle error/success for multiple API calls…
avas27JTG Aug 22, 2022
99ce634
[MI-2061]: Review fix
avas27JTG Sep 5, 2022
519dca2
Merge branch 'master' of github.com:Brightscout/mattermost-plugin-azu…
avas27JTG Sep 5, 2022
387b039
[MI-2061]: lint fixes
avas27JTG Sep 5, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 27 additions & 11 deletions server/constants/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,23 @@ package constants
const (
// Bot configs
BotUsername = "azuredevops"
BotDisplayName = "Azure Devops"
BotDescription = "A bot account created by the Azure Devops plugin."
BotDisplayName = "Azure DevOps"
BotDescription = "A bot account created by the Azure DevOps plugin."

// Plugin configs
PluginID = "mattermost-plugin-azure-devops"
ChannelID = "channel_id"
HeaderMattermostUserID = "Mattermost-User-ID"
// TODO: Change later according to the needs.
HeaderMattermostUserIDAPI = "User-ID"

// Command configs
CommandTriggerName = "azuredevops"
HelpText = "###### Mattermost Azure Devops Plugin - Slash Command Help\n"
InvalidCommand = "Invalid command parameters. Please use `/azuredevops help` for more information."

// Azure API Routes
CreateTask = "/%s/%s/_apis/wit/workitems/$%s?api-version=7.1-preview.3"
GetTask = "%s/_apis/wit/workitems/%s?api-version=7.1-preview.3"
GetProject = "/%s/_apis/projects/%s?api-version=7.1-preview.4"
HelpText = "###### Mattermost Azure DevOps Plugin - Slash Command Help\n" +
"* `/azuredevops connect` - Connect your Mattermost account to your Azure DevOps account.\n" +
"* `/azuredevops disconnect` - Disconnect your Mattermost account from your Azure DevOps account.\n" +
"* `/azuredevops link [projectURL]` - Link your project to a current channel.\n" +
"* `/azuredevops boards create [title] [description]` - Create a new task for your project.\n" +
"* `/azuredevops subscribe` - Create subscriptions to track changes in tasks for your linked projects.\n"
InvalidCommand = "Invalid command parameters. Please use `/azuredevops help` for more information."

// Get task link preview constants
HTTPS = "https:"
Expand All @@ -35,6 +33,20 @@ const (
TasksIDAPIVersion = "5.1"
TasksAPIVersion = "6.0"

// Subscription constants
PublisherID = "tfs"
ConsumerID = "webHooks"
ConsumerActionID = "httpRequest"
Create = "create"
Update = "update"
Delete = "delete"

// Path params
PathParamTeamID = "team_id"

// URL query params constants
ProjectParam = "project"

// Authorization constants
Bearer = "Bearer"
Authorization = "Authorization"
Expand All @@ -45,4 +57,8 @@ const (
PageQueryParam = "$top"
APIVersionQueryParam = "api-version"
IDsQueryParam = "ids"

// Websocket events
WSEventConnect = "connect"
WSEventDisconnect = "disconnect"
)
47 changes: 33 additions & 14 deletions server/constants/messages.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,46 @@ package constants

const (
// TODO: all these messages are to be verified from Mike at the end
GenericErrorMessage = "Something went wrong, please try again later"
// Generic
GenericErrorMessage = "Something went wrong, please try again later"
ConnectAccount = "[Click here to connect your Azure DevOps account](%s%s)"
ConnectAccountFirst = "Your Azure DevOps account is not connected \n%s"
UserConnected = "Your Azure DevOps account is successfully connected!"
UserAlreadyConnected = "Your Azure DevOps account is already connected"
UserDisconnected = "Your Azure DevOps account is now disconnected"
CreatedTask = "Link for newly created task: %s"
TaskTitle = "[%s #%d: %s](%s)"
TaskPreviewMessage = "State: %s\nAssigned To: %s\nDescription: %s"
AlreadyLinkedProject = "This project is already linked."
NoProjectLinked = "No project is linked, please link a project."

// Validations Errors
OrganizationRequired = "organization is required"
ProjectRequired = "project is required"
TaskTypeRequired = "task type is required"
TaskTitleRequired = "task title is required"
EventTypeRequired = "event type is required"
ChannelIDRequired = "channel ID is required"
)

const (
// Error messages
Error = "error"
NotAuthorized = "not authorized"
OrganizationRequired = "organization is required"
ProjectRequired = "project is required"
TaskTypeRequired = "task type is required"
TaskTitleRequired = "task title is required"
ConnectAccount = "[Click here to link your Azure DevOps account](%s%s)"
ConnectAccountFirst = "You do not have any Azure Devops account connected. Kindly link the account first"
UserConnected = "Your Azure Devops account is succesfully connected!"
UserAlreadyConnected = "Your Azure Devops account is already connected"
UserDisconnected = "Your Azure Devops account is now disconnected"
UnableToDisconnectUser = "Unable to disconnect user"
UnableToCheckIfAlreadyConnected = "Unable to check if user account is already connected"
UnableToStoreOauthState = "Unable to store oAuth state for the userID %s"
AuthAttemptExpired = "Authentication attempt expired, please try again"
InvalidAuthState = "Invalid oauth state, please try again"
CreatedTask = "Link for newly created task: %s"
TaskTitle = "[%s #%d: %s](%s)"
TaskPreviewMessage = "**State:** %s\n**Assigned To:** %s\n**Description:** %s"
AlreadyLinkedProject = "This project is already linked."
GetProjectListError = "Error getting Project List"
ErrorFetchProjectList = "Error in fetching project list"
ErrorDecodingBody = "Error in decoding body"
ProjectNotFound = "Requested project does not exists"
ErrorUnlinkProject = "Error in unlinking the project"
FetchSubscriptionListError = "Error in fetching subscription list"
CreateSubscriptionError = "Error in creating subscription"
ProjectNotLinked = "Requested project is not linked"
GetSubscriptionListError = "Error getting Subscription List"
SubscriptionAlreadyPresent = "Requested subscription already exists"
SubscriptionNotFound = "Requested subscription does not exists"
)
1 change: 1 addition & 0 deletions server/constants/oauth_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const (
Scopes = "vso.code vso.work_full"
ClientAssertionType = "urn:ietf:params:oauth:client-assertion-type:jwt-bearer"
GrantType = "urn:ietf:params:oauth:grant-type:jwt-bearer"
GrantTypeRefresh = "refresh_token"

// URL
BaseOauthURL = "https://app.vssps.visualstudio.com"
Expand Down
25 changes: 20 additions & 5 deletions server/constants/routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,24 @@ package constants

const (
// Plugin API Routes
APIPrefix = "/api/v1"
WildRoute = "{anything:.*}"
PathOAuthConnect = "/oauth/connect"
PathOAuthCallback = "/oauth/complete"
PathGetAllLinkedProjects = "/link/project"
APIPrefix = "/api/v1"
WildRoute = "{anything:.*}"
PathOAuthConnect = "/oauth/connect"
PathOAuthCallback = "/oauth/complete"
PathLinkedProjects = "/project/link"
PathGetAllLinkedProjects = "/project/link"
PathUnlinkProject = "/project/unlink"
PathUser = "/user"
PathCreateTasks = "/tasks"
PathLinkProject = "/link"
PathSubscriptions = "/subscriptions"
PathSubscriptionNotifications = "/notification"
PathGetUserChannelsForTeam = "/channels/{team_id:[A-Za-z0-9]+}"

// Azure API paths
CreateTask = "/%s/%s/_apis/wit/workitems/$%s?api-version=7.1-preview.3"
GetTask = "%s/_apis/wit/workitems/%s?api-version=7.1-preview.3"
GetProject = "/%s/_apis/projects/%s?api-version=7.1-preview.4"
CreateSubscription = "/%s/_apis/hooks/subscriptions?api-version=6.0"
DeleteSubscription = "/%s/_apis/hooks/subscriptions/%s?api-version=6.0"
)
7 changes: 4 additions & 3 deletions server/constants/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ const (
TTLSecondsForOAuthState int64 = 60

// KV store prefix keys
OAuthPrefix = "oAuth_%s"
ProjectKey = "%s_%s"
ProjectPrefix = "project_list"
OAuthPrefix = "oAuth_%s"
ProjectKey = "%s_%s"
ProjectPrefix = "project_list"
SubscriptionPrefix = "subscription_list"
)
Loading