Skip to content

Commit

Permalink
Implement HideRepairOption in CheckFileInfo
Browse files Browse the repository at this point in the history
When present and equal to 'true', the 'Repair' button and/or menu entry
is hidden in the UI.

Signed-off-by: Jan Holesovsky <[email protected]>
Change-Id: If8075be479551e0d1a5fa03014aa5e4412578c31
  • Loading branch information
kendy authored and eszkadev committed Oct 18, 2022
1 parent 765ea17 commit 7f96d92
Show file tree
Hide file tree
Showing 10 changed files with 70 additions and 62 deletions.
3 changes: 3 additions & 0 deletions browser/src/control/Control.Menubar.js
Original file line number Diff line number Diff line change
Expand Up @@ -1976,6 +1976,9 @@ L.Control.Menubar = L.Control.extend({
if (menuItem.id && menuItem.id.startsWith('fullscreen-presentation') && this._map['wopi'].HideExportOption)
return false;

if (menuItem.id === 'repair' && this._map['wopi'].HideRepairOption)
return false;

if (menuItem.id === 'changesmenu' && this._map['wopi'].HideChangeTrackingControls)
return false;

Expand Down
31 changes: 17 additions & 14 deletions browser/src/control/Control.NotebookbarCalc.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ L.Control.NotebookbarCalc = L.Control.NotebookbarWriter.extend({
getFileTab: function() {
var hasRevisionHistory = L.Params.revHistoryEnabled;
var hasPrint = !this._map['wopi'].HidePrintOption;
var hasRepair = !this._map['wopi'].HideRepairOption;
var hasSaveAs = !this._map['wopi'].UserCanNotWriteRelative;
var hasShare = this._map['wopi'].EnableShare;
var hasGroupedDownloadAs = !!window.groupDownloadAsForNb;
Expand Down Expand Up @@ -171,18 +172,20 @@ L.Control.NotebookbarCalc = L.Control.NotebookbarWriter.extend({
'text': _('Download')
});

content.push({
'type': 'container',
'children': [
{
'id': 'repair',
'type': 'menubartoolitem',
'text': _('Repair'),
'command': _('Repair')
}
],
'vertical': 'true'
});
if (hasRepair) {
content.push({
'type': 'container',
'children': [
{
'id': 'repair',
'type': 'menubartoolitem',
'text': _('Repair'),
'command': _('Repair')
}
],
'vertical': 'true'
});
}
} else {
content = content.concat([
{
Expand Down Expand Up @@ -233,12 +236,12 @@ L.Control.NotebookbarCalc = L.Control.NotebookbarWriter.extend({
'text': _('PDF Document (.pdf)'),
'command': ''
},
{
hasRepair? {
'id': 'repair',
'type': 'menubartoolitem',
'text': _('Repair'),
'command': _('Repair')
}
} : {}
],
'vertical': 'true'
}
Expand Down
5 changes: 3 additions & 2 deletions browser/src/control/Control.NotebookbarDraw.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ L.Control.NotebookbarDraw = L.Control.NotebookbarImpress.extend({
getFileTab: function() {
var hasRevisionHistory = L.Params.revHistoryEnabled;
var hasPrint = !this._map['wopi'].HidePrintOption;
var hasRepair = !this._map['wopi'].HideRepairOption;
var hasSaveAs = !this._map['wopi'].UserCanNotWriteRelative;
var hasShare = this._map['wopi'].EnableShare;
var hasSave = !this._map['wopi'].HideSaveOption;
Expand Down Expand Up @@ -196,12 +197,12 @@ L.Control.NotebookbarDraw = L.Control.NotebookbarImpress.extend({
'text': _('PDF Document (.pdf)'),
'command': ''
},
{
hasRepair? {
'id': 'repair',
'type': 'menubartoolitem',
'text': _('Repair'),
'command': _('Repair')
}
} : {}
],
'vertical': 'true'
}
Expand Down
31 changes: 17 additions & 14 deletions browser/src/control/Control.NotebookbarImpress.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ L.Control.NotebookbarImpress = L.Control.NotebookbarWriter.extend({
getFileTab: function() {
var hasRevisionHistory = L.Params.revHistoryEnabled;
var hasPrint = !this._map['wopi'].HidePrintOption;
var hasRepair = !this._map['wopi'].HideRepairOption;
var hasSaveAs = !this._map['wopi'].UserCanNotWriteRelative;
var hasShare = this._map['wopi'].EnableShare;
var hasGroupedDownloadAs = !!window.groupDownloadAsForNb;
Expand Down Expand Up @@ -223,18 +224,20 @@ L.Control.NotebookbarImpress = L.Control.NotebookbarWriter.extend({
'text': _('Download')
});

content.push({
'type': 'container',
'children': [
{
'id': 'repair',
'type': 'menubartoolitem',
'text': _('Repair'),
'command': _('Repair')
}
],
'vertical': 'true'
});
if (hasRepair) {
content.push({
'type': 'container',
'children': [
{
'id': 'repair',
'type': 'menubartoolitem',
'text': _('Repair'),
'command': _('Repair')
}
],
'vertical': 'true'
});
}
} else {
content = content.concat([
{
Expand Down Expand Up @@ -285,12 +288,12 @@ L.Control.NotebookbarImpress = L.Control.NotebookbarWriter.extend({
'text': _('PDF Document (.pdf)'),
'command': ''
},
{
hasRepair? {
'id': 'repair',
'type': 'menubartoolitem',
'text': _('Repair'),
'command': _('Repair')
}
} : {}
],
'vertical': 'true'
}
Expand Down
51 changes: 19 additions & 32 deletions browser/src/control/Control.NotebookbarWriter.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ L.Control.NotebookbarWriter = L.Control.Notebookbar.extend({
var hasSigning = L.DomUtil.get('document-signing-bar') !== null;
var hasRevisionHistory = L.Params.revHistoryEnabled;
var hasPrint = !this._map['wopi'].HidePrintOption;
var hasRepair = !this._map['wopi'].HideRepairOption;
var hasSaveAs = !this._map['wopi'].UserCanNotWriteRelative;
var hasShare = this._map['wopi'].EnableShare;
var hasGroupedDownloadAs = !!window.groupDownloadAsForNb;
Expand Down Expand Up @@ -242,38 +243,24 @@ L.Control.NotebookbarWriter = L.Control.Notebookbar.extend({
]);
}

if (hasSigning === false) {
content.push({
'type': 'container',
'children': [
{
'id': 'repair',
'type': 'bigmenubartoolitem',
'text': _('Repair'),
'command': _('Repair')
}
]
});
} else {
content.push({
'type': 'container',
'children': [
{
'id': 'repair',
'type': 'menubartoolitem',
'text': _('Repair'),
'command': _('Repair')
},
{
'id': 'signdocument',
'type': 'menubartoolitem',
'text': _('Sign document'),
'command': ''
}
],
'vertical': 'true'
});
}
content.push({
'type': 'container',
'children': [
hasRepair? {
'id': 'repair',
'type': 'menubartoolitem',
'text': _('Repair'),
'command': _('Repair')
} : {},
hasSigning? {
'id': 'signdocument',
'type': 'menubartoolitem',
'text': _('Sign document'),
'command': ''
} : {}
],
'vertical': 'true'
});

content.push({
'type': 'container',
Expand Down
2 changes: 2 additions & 0 deletions browser/src/map/handler/Map.WOPI.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ L.Map.WOPI = L.Handler.extend({
HidePrintOption: false,
HideSaveOption: false,
HideExportOption: false,
HideRepairOption: false,
HideChangeTrackingControls: false,
DisablePrint: false,
DisableExport: false,
Expand Down Expand Up @@ -106,6 +107,7 @@ L.Map.WOPI = L.Handler.extend({
this.HidePrintOption = !!wopiInfo['HidePrintOption'];
this.HideSaveOption = !!wopiInfo['HideSaveOption'];
this.HideExportOption = !!wopiInfo['HideExportOption'];
this.HideRepairOption = !!wopiInfo['HideRepairOption'];
this.HideChangeTrackingControls = !!wopiInfo['HideChangeTrackingControls'];
this.DisablePrint = !!wopiInfo['DisablePrint'];
this.DisableExport = !!wopiInfo['DisableExport'];
Expand Down
1 change: 1 addition & 0 deletions wsd/DocumentBroker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -776,6 +776,7 @@ bool DocumentBroker::download(const std::shared_ptr<ClientSession>& session, con
wopiInfo->set("HidePrintOption", wopifileinfo->getHidePrintOption());
wopiInfo->set("HideSaveOption", wopifileinfo->getHideSaveOption());
wopiInfo->set("HideExportOption", wopifileinfo->getHideExportOption());
wopiInfo->set("HideRepairOption", wopifileinfo->getHideRepairOption());
wopiInfo->set("DisablePrint", wopifileinfo->getDisablePrint());
wopiInfo->set("DisableExport", wopifileinfo->getDisableExport());
wopiInfo->set("DisableCopy", wopifileinfo->getDisableCopy());
Expand Down
2 changes: 2 additions & 0 deletions wsd/Storage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -764,6 +764,7 @@ void WopiStorage::WOPIFileInfo::init()
_hidePrintOption = false;
_hideSaveOption = false;
_hideExportOption = false;
_hideRepairOption = false;
_disablePrint = false;
_disableExport = false;
_disableCopy = false;
Expand Down Expand Up @@ -850,6 +851,7 @@ WopiStorage::WOPIFileInfo::WOPIFileInfo(const FileInfo &fileInfo,
JsonUtil::findJSONValue(object, "HidePrintOption", _hidePrintOption);
JsonUtil::findJSONValue(object, "HideSaveOption", _hideSaveOption);
JsonUtil::findJSONValue(object, "HideExportOption", _hideExportOption);
JsonUtil::findJSONValue(object, "HideRepairOption", _hideRepairOption);
JsonUtil::findJSONValue(object, "EnableOwnerTermination", _enableOwnerTermination);
JsonUtil::findJSONValue(object, "DisablePrint", _disablePrint);
JsonUtil::findJSONValue(object, "DisableExport", _disableExport);
Expand Down
4 changes: 4 additions & 0 deletions wsd/Storage.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -529,6 +529,8 @@ class WopiStorage : public StorageBase
bool getHideSaveOption() const { return _hideSaveOption; }
void setHideExportOption(bool hideExportOption) { _hideExportOption = hideExportOption; }
bool getHideExportOption() const { return _hideExportOption; }
void setHideRepairOption(bool hideRepairOption) { _hideRepairOption = hideRepairOption; }
bool getHideRepairOption() const { return _hideRepairOption; }
bool getEnableOwnerTermination() const { return _enableOwnerTermination; }
bool getDisablePrint() const { return _disablePrint; }
bool getDisableExport() const { return _disableExport; }
Expand Down Expand Up @@ -574,6 +576,8 @@ class WopiStorage : public StorageBase
bool _hideSaveOption;
/// Hide 'Download as' button/menubar item from UI
bool _hideExportOption;
/// Hide the 'Repair' button/item from the UI
bool _hideRepairOption;
/// If WOPI host has enabled owner termination feature on
bool _enableOwnerTermination;
/// If WOPI host has allowed the user to print the document
Expand Down
2 changes: 2 additions & 0 deletions wsd/protocol.txt
Original file line number Diff line number Diff line change
Expand Up @@ -630,6 +630,8 @@ wopi: <JSON>
+ HidePrintOption: (boolean): If Collabora Online should hide print options
+ HideExportOption: (boolean): If Collabora Online should hide the export options
this implies 'Download as' options in file menu
+ HideRepairOption: (boolean): If Collabora Online should hide the Repair
undo functionality

versionrestore: <action>

Expand Down

0 comments on commit 7f96d92

Please sign in to comment.