Skip to content

Commit

Permalink
Only show chat if authorised to use
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidMStraub committed Sep 15, 2024
1 parent ea19f64 commit cebf839
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 30 deletions.
20 changes: 8 additions & 12 deletions src/GrampsJs.js
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,7 @@ export class GrampsJs extends LitElement {
<grampsjs-main-menu
.strings="${this._strings}"
?canViewPrivate="${this.canViewPrivate}"
?canUseChat="${this.canUseChat}"
></grampsjs-main-menu>
</div>
<div slot="appContent">
Expand All @@ -547,6 +548,7 @@ export class GrampsJs extends LitElement {
.canEdit="${this.canEdit}"
.canViewPrivate="${this.canViewPrivate}"
.canManageUsers="${this.canManageUsers}"
.canUseChat="${this.canUseChat}"
>
</grampsjs-pages>
</main>
Expand Down Expand Up @@ -994,18 +996,12 @@ export class GrampsJs extends LitElement {
setPermissions() {
const permissions = getPermissions()
// If permissions is null, authorization is disabled and anything goes
if (permissions === null) {
this.canAdd = true
this.canEdit = true
this.canViewPrivate = true
// managing users not meaningful in this case
this.canManageUsers = false
} else {
this.canAdd = permissions.includes('AddObject')
this.canEdit = permissions.includes('EditObject')
this.canViewPrivate = permissions.includes('ViewPrivate')
this.canManageUsers = permissions.includes('EditOtherUser')
}
this.canAdd = permissions.includes('AddObject')
this.canEdit = permissions.includes('EditObject')
this.canViewPrivate = permissions.includes('ViewPrivate')
this.canManageUsers = permissions.includes('EditOtherUser')
this.canUseChat =
permissions.includes('UseChat') && this._dbInfo?.server?.chat
}

_(s) {
Expand Down
2 changes: 1 addition & 1 deletion src/components/GrampsjsChat.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ class GrampsjsChat extends GrampsjsTranslateMixin(LitElement) {
<div class="clear-btn">
<mwc-button
raised
label="${this._('Clear')}"
label="${this._('New')}"
icon="clear_all"
@click="${this._handleClear}"
?disabled=${this.messages.length === 0}
Expand Down
31 changes: 21 additions & 10 deletions src/components/GrampsjsMainMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class GrampsjsAppBar extends GrampsjsTranslateMixin(LitElement) {
editDialogContent: {type: String},
saveButton: {type: Boolean},
canViewPrivate: {type: Boolean},
canUseChat: {type: Boolean},
}
}

Expand All @@ -45,6 +46,7 @@ class GrampsjsAppBar extends GrampsjsTranslateMixin(LitElement) {
this.editDialogContent = ''
this.saveButton = false
this.canViewPrivate = false
this.canUseChat = false
}

render() {
Expand All @@ -69,8 +71,15 @@ class GrampsjsAppBar extends GrampsjsTranslateMixin(LitElement) {
<span>${this._('Family Tree')}</span>
<mwc-icon slot="graphic">${renderIcon(mdiFamilyTree)}</mwc-icon>
</grampsjs-list-item>
<grampsjs-list-item href="${BASE_DIR}/chat" graphic="icon">
<span>${this._('Chat')}</span>
${
this.canUseChat
? html`
<grampsjs-list-item href="${BASE_DIR}/chat" graphic="icon">
<span>${this._('Chat')}</span>
</grampsjs-list-item>
`
: ''
}
<mwc-icon slot="graphic">${renderIcon(mdiChat)}</mwc-icon>
</grampsjs-list-item>
<li divider padded role="separator"></li>
Expand All @@ -94,14 +103,16 @@ class GrampsjsAppBar extends GrampsjsTranslateMixin(LitElement) {
<span>${this._('_Reports').replace('_', '')}</span>
<mwc-icon slot="graphic">menu_book</mwc-icon>
</grampsjs-list-item>
${this.canViewPrivate
? html`
<grampsjs-list-item href="${BASE_DIR}/revisions" graphic="icon">
<span>${this._('Revisions')}</span>
<mwc-icon slot="graphic">commit</mwc-icon>
</grampsjs-list-item>
`
: ''}
${
this.canViewPrivate
? html`
<grampsjs-list-item href="${BASE_DIR}/revisions" graphic="icon">
<span>${this._('Revisions')}</span>
<mwc-icon slot="graphic">commit</mwc-icon>
</grampsjs-list-item>
`
: ''
}
</mwc-list>`
}
}
Expand Down
18 changes: 11 additions & 7 deletions src/components/GrampsjsPages.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ class GrampsjsPages extends GrampsjsTranslateMixin(LitElement) {
canEdit: {type: Boolean},
canManageUsers: {type: Boolean},
canViewPrivate: {type: Boolean},
canUseChat: {type: Boolean},
homePersonDetails: {type: Object},
strings: {type: Object},
dbInfo: {type: Object},
Expand All @@ -89,6 +90,7 @@ class GrampsjsPages extends GrampsjsTranslateMixin(LitElement) {
this.canAdd = false
this.canEdit = false
this.canManageUsers = false
this.canUseChat = false
this.homePersonDetails = {}
this.strings = {}
this.dbInfo = {}
Expand Down Expand Up @@ -250,13 +252,15 @@ class GrampsjsPages extends GrampsjsTranslateMixin(LitElement) {
?canEdit="${this.canEdit}"
.dbInfo="${this.dbInfo}"
></grampsjs-view-media>
<grampsjs-view-chat
class="page"
?active=${this.page === 'chat'}
.strings="${this.strings}"
></grampsjs-view-chat>
${this.canUseChat
? html`
<grampsjs-view-chat
class="page"
?active=${this.page === 'chat'}
.strings="${this.strings}"
></grampsjs-view-chat>
`
: ''}
<grampsjs-view-export
class="page"
?active=${this.page === 'export'}
Expand Down

0 comments on commit cebf839

Please sign in to comment.