mirror of
https://github.com/mattermost/focalboard.git
synced 2025-02-07 19:30:18 +02:00
add readtoken when in readonly mode (#1382)
This commit is contained in:
parent
992ad833d1
commit
35bb3e9024
@ -158,7 +158,7 @@ const App = React.memo((): JSX.Element => {
|
|||||||
<Route path='/change_password'>
|
<Route path='/change_password'>
|
||||||
<ChangePasswordPage/>
|
<ChangePasswordPage/>
|
||||||
</Route>
|
</Route>
|
||||||
<Route path='/shared/:boardId?/:viewId?'>
|
<Route path='/shared/:boardId?/:viewId?/:cardId?'>
|
||||||
<BoardPage readonly={true}/>
|
<BoardPage readonly={true}/>
|
||||||
</Route>
|
</Route>
|
||||||
<Route
|
<Route
|
||||||
@ -180,7 +180,7 @@ const App = React.memo((): JSX.Element => {
|
|||||||
return null
|
return null
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<Route path='/workspace/:workspaceId/shared/:boardId?/:viewId?'>
|
<Route path='/workspace/:workspaceId/shared/:boardId?/:viewId?/:cardId?'>
|
||||||
<BoardPage readonly={true}/>
|
<BoardPage readonly={true}/>
|
||||||
</Route>
|
</Route>
|
||||||
<Route
|
<Route
|
||||||
|
@ -30,7 +30,10 @@ const ViewMenu = React.memo((props: Props) => {
|
|||||||
const match = useRouteMatch()
|
const match = useRouteMatch()
|
||||||
|
|
||||||
const showView = useCallback((viewId) => {
|
const showView = useCallback((viewId) => {
|
||||||
const newPath = generatePath(match.path, {...match.params, viewId: viewId || ''})
|
let newPath = generatePath(match.path, {...match.params, viewId: viewId || ''})
|
||||||
|
if (props.readonly) {
|
||||||
|
newPath += `?r=${Utils.getReadToken()}`
|
||||||
|
}
|
||||||
history.push(newPath)
|
history.push(newPath)
|
||||||
}, [match, history])
|
}, [match, history])
|
||||||
|
|
||||||
|
@ -13,6 +13,7 @@ import {getClientConfig, setClientConfig} from '../store/clientConfig'
|
|||||||
|
|
||||||
import wsClient, {WSClient} from '../wsclient'
|
import wsClient, {WSClient} from '../wsclient'
|
||||||
import {ClientConfig} from '../config/clientConfig'
|
import {ClientConfig} from '../config/clientConfig'
|
||||||
|
import {Utils} from '../utils'
|
||||||
|
|
||||||
import CenterPanel from './centerPanel'
|
import CenterPanel from './centerPanel'
|
||||||
import EmptyCenterPanel from './emptyCenterPanel'
|
import EmptyCenterPanel from './emptyCenterPanel'
|
||||||
@ -37,7 +38,10 @@ function CenterContent(props: Props) {
|
|||||||
|
|
||||||
const showCard = useCallback((cardId?: string) => {
|
const showCard = useCallback((cardId?: string) => {
|
||||||
const params = {...match.params, cardId}
|
const params = {...match.params, cardId}
|
||||||
const newPath = generatePath(match.path, params)
|
let newPath = generatePath(match.path, params)
|
||||||
|
if (props.readonly) {
|
||||||
|
newPath += `?r=${Utils.getReadToken()}`
|
||||||
|
}
|
||||||
history.push(newPath)
|
history.push(newPath)
|
||||||
}, [match, history])
|
}, [match, history])
|
||||||
|
|
||||||
|
@ -41,12 +41,6 @@ class OctoClient {
|
|||||||
localStorage.setItem('focalboardSessionId', value)
|
localStorage.setItem('focalboardSessionId', value)
|
||||||
}
|
}
|
||||||
|
|
||||||
private readToken(): string {
|
|
||||||
const queryString = new URLSearchParams(window.location.search)
|
|
||||||
const readToken = queryString.get('r') || ''
|
|
||||||
return readToken
|
|
||||||
}
|
|
||||||
|
|
||||||
constructor(serverUrl?: string, public workspaceId = '0') {
|
constructor(serverUrl?: string, public workspaceId = '0') {
|
||||||
this.serverUrl = serverUrl
|
this.serverUrl = serverUrl
|
||||||
}
|
}
|
||||||
@ -168,7 +162,7 @@ class OctoClient {
|
|||||||
|
|
||||||
async getSubtree(rootId?: string, levels = 2, workspaceID?: string): Promise<Block[]> {
|
async getSubtree(rootId?: string, levels = 2, workspaceID?: string): Promise<Block[]> {
|
||||||
let path = this.workspacePath(workspaceID) + `/blocks/${encodeURIComponent(rootId || '')}/subtree?l=${levels}`
|
let path = this.workspacePath(workspaceID) + `/blocks/${encodeURIComponent(rootId || '')}/subtree?l=${levels}`
|
||||||
const readToken = this.readToken()
|
const readToken = Utils.getReadToken()
|
||||||
if (readToken) {
|
if (readToken) {
|
||||||
path += `&read_token=${readToken}`
|
path += `&read_token=${readToken}`
|
||||||
}
|
}
|
||||||
@ -406,7 +400,7 @@ class OctoClient {
|
|||||||
|
|
||||||
async getFileAsDataUrl(rootId: string, fileId: string): Promise<string> {
|
async getFileAsDataUrl(rootId: string, fileId: string): Promise<string> {
|
||||||
let path = '/files/workspaces/' + this.workspaceId + '/' + rootId + '/' + fileId
|
let path = '/files/workspaces/' + this.workspaceId + '/' + rootId + '/' + fileId
|
||||||
const readToken = this.readToken()
|
const readToken = Utils.getReadToken()
|
||||||
if (readToken) {
|
if (readToken) {
|
||||||
path += `?read_token=${readToken}`
|
path += `?read_token=${readToken}`
|
||||||
}
|
}
|
||||||
|
@ -504,6 +504,12 @@ class Utils {
|
|||||||
static isDesktop(): boolean {
|
static isDesktop(): boolean {
|
||||||
return Utils.isDesktopApp() && Utils.isVersionGreaterThanOrEqualTo(Utils.getDesktopVersion(), '5.0.0')
|
return Utils.isDesktopApp() && Utils.isVersionGreaterThanOrEqualTo(Utils.getDesktopVersion(), '5.0.0')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static getReadToken(): string {
|
||||||
|
const queryString = new URLSearchParams(window.location.search)
|
||||||
|
const readToken = queryString.get('r') || ''
|
||||||
|
return readToken
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export {Utils}
|
export {Utils}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user