-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14 from Brightscout/MI-806
MI-806 move logic to open edit subscription modal from server to webapp
- Loading branch information
Showing
16 changed files
with
137 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package controller | ||
|
||
import ( | ||
"net/http" | ||
|
||
"github.com/Brightscout/mattermost-plugin-confluence/server/service" | ||
) | ||
|
||
var getChannelSubscription = &Endpoint{ | ||
RequiresAuth: true, | ||
Path: "/subscription", | ||
Method: http.MethodGet, | ||
Execute: handleGetChannelSubscription, | ||
} | ||
|
||
func handleGetChannelSubscription(w http.ResponseWriter, r *http.Request) { | ||
channelID := r.FormValue("channelID") | ||
alias := r.FormValue("alias") | ||
subscription, errCode, err := service.GetChannelSubscription(channelID, alias) | ||
if err != nil { | ||
http.Error(w, err.Error(), errCode) | ||
return | ||
} | ||
w.Header().Set("Content-Type", "application/json") | ||
_, _ = w.Write([]byte(subscription.ToJSON())) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package service | ||
|
||
import ( | ||
"fmt" | ||
"net/http" | ||
|
||
"github.com/pkg/errors" | ||
|
||
"github.com/Brightscout/mattermost-plugin-confluence/server/serializer" | ||
) | ||
|
||
const generalError = "Some error occurred. Please try again after sometime." | ||
|
||
func GetChannelSubscription(channelID, alias string) (serializer.Subscription, int, error) { | ||
channelSubscriptions, _, gErr := GetChannelSubscriptions(channelID) | ||
if gErr != nil { | ||
return serializer.Subscription{}, http.StatusInternalServerError, errors.New(generalError) | ||
} | ||
subscription, found := channelSubscriptions[alias] | ||
if !found { | ||
return serializer.Subscription{}, http.StatusBadRequest, errors.New(fmt.Sprintf(subscriptionNotFound, alias)) | ||
} | ||
return subscription, http.StatusOK, nil | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
import { | ||
closeSubscriptionModal, openSubscriptionModal, saveChannelSubscription, receivedSubscription, editChannelSubscription, | ||
closeSubscriptionModal, openSubscriptionModal, saveChannelSubscription, editChannelSubscription, getChannelSubscription, | ||
} from './subscription_modal'; | ||
|
||
export { | ||
saveChannelSubscription, | ||
openSubscriptionModal, | ||
closeSubscriptionModal, | ||
receivedSubscription, | ||
editChannelSubscription, | ||
getChannelSubscription, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
export const splitArgs = (command) => { | ||
const myRegexp = /[^\s"]+|"([^"]*)"/gi; | ||
const myArray = []; | ||
let match; | ||
do { | ||
match = myRegexp.exec(command); | ||
if (match != null) { | ||
myArray.push(match[1] ? match[1] : match[0]); | ||
} | ||
} while (match != null); | ||
return myArray; | ||
}; |