How remove/hide "Edit Locally" option in web interface?

Running NC 27.1.1 and I want to get rid of the “Edit Locally” menu alternative, which is visible in the web interface, by clicking “the three dots” in the right side of any file.

I’m eager to get rid of everything I won’t want to present to my users on the server. Most other things I have gotten rid of, I have either uninstalled from the apps menu or simply used custom CSS to hide that web element from being visible/clickable.

But with “Edit Locally”, I can’t seem to find any app function that I can control, which is related to the “edit locally” option. Nor can I find any direct code relation to it in the index.php file which I would be able to hide with CSS.

What would be your suggestion to disable/hide that option from the “three dots” menu in the web interface?

Thanks

That is easy to accomplish (if you are willing to tamper the code) by commenting out the action where it get registered in the files app, which is done in:
apps/files/js/fileactions.js
lines 729 -753:

this is the code in question:

			if (!/Android|iPhone|iPad|iPod/i.test(navigator.userAgent)) {
				this.registerAction({
					name: 'EditLocally',
					displayName: function(context) {
						var locked = context.$file.data('locked');
						if (!locked) {
							return t('files', 'Edit locally');
						}
					},
					mime: 'all',
					order: -23,
					icon: function(filename, context) {
						var locked = context.$file.data('locked');
						if (!locked) {
							return OC.imagePath('files', 'computer.svg')
						}
					},
					permissions: OC.PERMISSION_UPDATE,
					actionHandler: function (filename, context) {
						var dir = context.dir || context.fileList.getCurrentDirectory();
						var path = dir === '/' ? dir + filename : dir + '/' + filename;
						context.fileList.openLocalClient(path);
					},
				});
			}

And this is how you can comment it out:

/*
			if (!/Android|iPhone|iPad|iPod/i.test(navigator.userAgent)) {
				this.registerAction({
					name: 'EditLocally',
					displayName: function(context) {
						var locked = context.$file.data('locked');
						if (!locked) {
							return t('files', 'Edit locally');
						}
					},
					mime: 'all',
					order: -23,
					icon: function(filename, context) {
						var locked = context.$file.data('locked');
						if (!locked) {
							return OC.imagePath('files', 'computer.svg')
						}
					},
					permissions: OC.PERMISSION_UPDATE,
					actionHandler: function (filename, context) {
						var dir = context.dir || context.fileList.getCurrentDirectory();
						var path = dir === '/' ? dir + filename : dir + '/' + filename;
						context.fileList.openLocalClient(path);
					},
				});
			}
*/

so simply prepend this
/*
in line 728
and append this:
*/
in line 754

then you must reload your browser cache (Ctrl R in Chrome)

Please keep in mind, that such code manipulations are not permanent. After each update they will disappear and integrity tests wil fail on the tampered file. So you should create an sed script that comments out those lines and one that resets it back to default.
I myself do a lot of code manipulation in this way and have for each manipulation the set- and unset-scripts which are run in pre- and post-update- as well as integrity-fix-scripts, to keep everything clean and well registred, so that I cannot “forget” what I have changed.

And maybe you find a more elegant solution to solve this with custom-ccs later but until then, I only can suggest you this.

Much luck!
ernolf

1 Like

If you’re not comfortable changing the source code you can also install the Custom CSS app and use this directive

.action-editlocally-container {
  display: none !important;
}
2 Likes

This topic was automatically closed 8 days after the last reply. New replies are no longer allowed.