Skip to content

Commit

Permalink
Fix onActivate hook
Browse files Browse the repository at this point in the history
  • Loading branch information
Dschoordsch committed Nov 11, 2024
1 parent 0c04e75 commit 6024b15
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 11 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ This plugin is very much work in progress and not yet ready for testing.

## Requirements

- Mattermost version 8.1 or later
- Mattermost version 10.1 or later
- `SiteURL` If the `SiteURL` is not set correctly, some functions like notifications will not work.
- SSO identity provider for both Mattermost and Parabol

Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ services:
mattermost:
depends_on:
- postgres
image: mattermost/mattermost-team-edition:8.1.9
image: mattermost/mattermost-team-edition:10.2.0
restart: unless-stopped
#security_opt:
# - no-new-privileges:true
Expand Down
6 changes: 5 additions & 1 deletion server/activate_hooks.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,11 @@ func (p *Plugin) OnActivate() error {
}
}

return p.API.KVSet(botUserID, []byte(botID))
err2 := p.API.KVSet(botUserID, []byte(botID))
if err2 != nil {
return errors.Wrap(err2, "failed to store bot user ID")
}
return nil
}

// OnDeactivate is invoked when the plugin is deactivated. This is the plugin's last chance to use
Expand Down
4 changes: 2 additions & 2 deletions server/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,7 @@ If we want to verify the path of the request, we need to add it back.
https://github.com/mattermost/mattermost/blob/751d84bf13aa63f4706843318e45e8ca8401eba5/server/channels/app/plugin_requests.go#L226
*/
func (p *Plugin) fixedPath(handler http.HandlerFunc) http.HandlerFunc {
// from 10.1 we can use p.API.GetPluginID()
pluginID := "co.parabol.action"
pluginID := p.API.GetPluginID()
path := "/plugins/" + pluginID
return func(w http.ResponseWriter, r *http.Request) {
r.URL.Path = path + r.URL.Path
Expand Down Expand Up @@ -145,6 +144,7 @@ func (p *Plugin) query(c *Context, w http.ResponseWriter, r *http.Request) {

config := p.getConfiguration()
url := config.ParabolURL + "/mattermost"
fmt.Print("query", queryRequest, variables, url)
privKey := []byte(config.ParabolToken)
client, err := NewSigningClient(privKey)
if err != nil {
Expand Down
24 changes: 18 additions & 6 deletions webapp/src/components/sidepanel/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,16 @@ import React from 'react'
import {useDispatch, useSelector} from 'react-redux'
import {getCurrentChannelId} from 'mattermost-redux/selectors/entities/common'

import {useGetActiveMeetingsQuery, useLinkedTeamsQuery} from '../../api'
import {useGetActiveMeetingsQuery, useGetTemplatesQuery, useLinkedTeamsQuery} from '../../api'
import {openLinkTeamModal, openStartActivityModal} from '../../reducers'

const SidePanelRoot = () => {
const {data: meetings, isLoading} = useGetActiveMeetingsQuery()
const channelId = useSelector(getCurrentChannelId)
const {data: teams} = useLinkedTeamsQuery({channelId})
const {data: linkedTeams} = useLinkedTeamsQuery({channelId})
const {data} = useGetTemplatesQuery()
const {teams} = data ?? {}

const dispatch = useDispatch()

const [selectedTab, setSelectedTab] = React.useState('linked-teams')
Expand All @@ -22,8 +25,12 @@ const SidePanelRoot = () => {
dispatch(openStartActivityModal())
}

console.log('linkedTeams', linkedTeams)
console.log('teams', teams)

return (
<div>
{/*
<div className='form-group'>
<label
className='control-label'
Expand All @@ -42,17 +49,22 @@ const SidePanelRoot = () => {
>Linked Parabol Teams</option>
</select>
</div>
Foo
</div>
*/}

<h2>Linked Parabol Teams</h2>
<button onClick={handleLink}>Add Team</button>
{teams?.map((team) => (linkedTeams?.includes(team.id) ? (
<div key={team.id}>
<h3>{team.name}</h3>
</div>
) : <div key={team.id}>Unlinked {team.name}</div>),
)}
<h2>Active Meetings</h2>
<button onClick={handleStartActivity}>Start Activity</button>
{teams}
<h2>Channel: {channelId}</h2>
{meetings?.map((meeting) => (
<div key={meeting.id}>
<h2>{meeting.name}</h2>
<h3>{meeting.name}</h3>
</div>
))}
</div>
Expand Down

0 comments on commit 6024b15

Please sign in to comment.