/shared for shared boards
This commit is contained in:
parent
0450a03971
commit
eecf134b3f
3 changed files with 12 additions and 7 deletions
|
@ -65,6 +65,12 @@ export default class App extends React.PureComponent<unknown, State> {
|
|||
<Route path='/register'>
|
||||
<RegisterPage/>
|
||||
</Route>
|
||||
<Route path='/shared'>
|
||||
<BoardPage
|
||||
readonly={true}
|
||||
setLanguage={this.setAndStoreLanguage}
|
||||
/>
|
||||
</Route>
|
||||
<Route path='/board'>
|
||||
{this.state.initialLoad && !this.state.user && <Redirect to='login'/>}
|
||||
<BoardPage setLanguage={this.setAndStoreLanguage}/>
|
||||
|
|
|
@ -47,6 +47,7 @@ class ShareBoardComponent extends React.PureComponent<Props, State> {
|
|||
const readToken = (sharing && isSharing) ? sharing.token : ''
|
||||
const shareUrl = new URL(window.location.toString())
|
||||
shareUrl.searchParams.set('r', readToken)
|
||||
shareUrl.pathname = '/shared'
|
||||
|
||||
let stateDescription: string
|
||||
if (isSharing) {
|
||||
|
|
|
@ -12,6 +12,7 @@ import {BoardTree, MutableBoardTree} from '../viewModel/boardTree'
|
|||
import {MutableWorkspaceTree, WorkspaceTree} from '../viewModel/workspaceTree'
|
||||
|
||||
type Props = {
|
||||
readonly?: boolean
|
||||
setLanguage: (lang: string) => void
|
||||
}
|
||||
|
||||
|
@ -20,7 +21,6 @@ type State = {
|
|||
viewId: string
|
||||
workspaceTree: WorkspaceTree
|
||||
boardTree?: BoardTree
|
||||
readonly: boolean
|
||||
}
|
||||
|
||||
export default class BoardPage extends React.Component<Props, State> {
|
||||
|
@ -31,13 +31,11 @@ export default class BoardPage extends React.Component<Props, State> {
|
|||
const queryString = new URLSearchParams(window.location.search)
|
||||
const boardId = queryString.get('id') || ''
|
||||
const viewId = queryString.get('v') || ''
|
||||
const readonly = Boolean(queryString.get('r'))
|
||||
|
||||
this.state = {
|
||||
boardId,
|
||||
viewId,
|
||||
workspaceTree: new MutableWorkspaceTree(),
|
||||
readonly,
|
||||
}
|
||||
|
||||
Utils.log(`BoardPage. boardId: ${boardId}`)
|
||||
|
@ -76,7 +74,7 @@ export default class BoardPage extends React.Component<Props, State> {
|
|||
return
|
||||
}
|
||||
|
||||
if (this.state.readonly) {
|
||||
if (this.props.readonly) {
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -143,7 +141,7 @@ export default class BoardPage extends React.Component<Props, State> {
|
|||
this.setSearchText(text)
|
||||
}}
|
||||
setLanguage={this.props.setLanguage}
|
||||
readonly={this.state.readonly}
|
||||
readonly={this.props.readonly || false}
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
|
@ -255,7 +253,7 @@ export default class BoardPage extends React.Component<Props, State> {
|
|||
if (boardId) {
|
||||
newUrl += `?id=${encodeURIComponent(boardId)}`
|
||||
|
||||
if (this.state.readonly) {
|
||||
if (this.props.readonly) {
|
||||
newUrl += '&r=1'
|
||||
}
|
||||
}
|
||||
|
@ -273,7 +271,7 @@ export default class BoardPage extends React.Component<Props, State> {
|
|||
}
|
||||
|
||||
let newUrl = window.location.protocol + '//' + window.location.host + window.location.pathname + `?id=${encodeURIComponent(boardId)}&v=${encodeURIComponent(viewId)}`
|
||||
if (this.state.readonly) {
|
||||
if (this.props.readonly) {
|
||||
newUrl += '&r=1'
|
||||
}
|
||||
window.history.pushState({path: newUrl}, '', newUrl)
|
||||
|
|
Loading…
Reference in a new issue