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

Adding backward compatibility for 5.38 #922

Merged
merged 3 commits into from
Aug 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
42 changes: 28 additions & 14 deletions mattermost-plugin/webapp/src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import React, {useEffect, useState} from 'react'
import React, {useEffect} from 'react'
import {Store, Action} from 'redux'
import {Provider as ReduxProvider} from 'react-redux'
import {useHistory} from 'react-router-dom'
import {useHistory} from 'mm-react-router-dom'

import {GlobalState} from 'mattermost-redux/types/store'

Expand Down Expand Up @@ -80,21 +80,35 @@ export default class Plugin {
// eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/no-empty-function
public async initialize(registry: PluginRegistry, store: Store<GlobalState, Action<Record<string, unknown>>>) {
this.registry = registry
const goToFocalboardWorkspace = () => {
const currentChannel = store.getState().entities.channels.currentChannelId
window.open(`${window.location.origin}/boards/workspace/${currentChannel}`)
}
this.channelHeaderButtonId = registry.registerChannelHeaderButtonAction(<FocalboardIcon/>, goToFocalboardWorkspace, '', 'Focalboard Workspace')

this.registry.registerCustomRoute('go-to-current-workspace', () => {
const history = useHistory()
const currentChannel = store.getState().entities.channels.currentChannelId
history.push(`/boards/workspace/${currentChannel}`)
return <></>
})

if (this.registry.registerProduct) {
windowAny.frontendBaseURL = '/boards'
const goToFocalboardWorkspace = () => {
const currentChannel = store.getState().entities.channels.currentChannelId
window.open(`${window.location.origin}/boards/workspace/${currentChannel}`)
}
this.channelHeaderButtonId = registry.registerChannelHeaderButtonAction(<FocalboardIcon/>, goToFocalboardWorkspace, '', 'Focalboard Workspace')

this.registry.registerCustomRoute('go-to-current-workspace', () => {
const history = useHistory()
useEffect(() => {
const currentChannel = store.getState().entities.channels.currentChannelId
if (currentChannel) {
history.push(`/boards/workspace/${currentChannel}`)
} else {
history.goBack()
}
}, [])
return <></>
})
this.registry.registerProduct('/boards', GlobalHeaderIcon, 'Boards', '/plug/focalboard/go-to-current-workspace', MainApp, HeaderComponent)
} else {
windowAny.frontendBaseURL = '/plug/focalboard'
this.channelHeaderButtonId = registry.registerChannelHeaderButtonAction(<FocalboardIcon/>, () => {
const currentChannel = store.getState().entities.channels.currentChannelId
window.open(`${window.location.origin}/plug/focalboard/workspace/${currentChannel}`)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this should be /plugins/focalboard/...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem was with other thing, see the commit that I included.

}, '', 'Focalboard Workspace')
this.registry.registerCustomRoute('/', MainApp)
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
declare module "mm-react-router-dom"
1 change: 1 addition & 0 deletions mattermost-plugin/webapp/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ module.exports = {
react: 'React',
redux: 'Redux',
'react-redux': 'ReactRedux',
'mm-react-router-dom': 'ReactRouterDom',
'prop-types': 'PropTypes',
'react-bootstrap': 'ReactBootstrap',
},
Expand Down