Browse Source

Remove legacy systemtags code

Signed-off-by: Christopher Ng <chrng8@gmail.com>
Christopher Ng 1 year ago
parent
commit
177849cd3c

+ 0 - 61
apps/systemtags/src/filesplugin.js

@@ -1,61 +0,0 @@
-/**
- * Copyright (c) 2015 Vincent Petry <pvince81@owncloud.com>
- *
- * @author Joas Schilling <coding@schilljs.com>
- * @author John Molakvoæ <skjnldsv@protonmail.com>
- * @author Vincent Petry <vincent@nextcloud.com>
- *
- * @license AGPL-3.0-or-later
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-(function() {
-	OCA.SystemTags = _.extend({}, OCA.SystemTags)
-	if (!OCA.SystemTags) {
-		/**
-		 * @namespace
-		 */
-		OCA.SystemTags = {}
-	}
-
-	/**
-	 * @namespace
-	 */
-	OCA.SystemTags.FilesPlugin = {
-		ignoreLists: [
-			'trashbin',
-			'files.public',
-		],
-
-		attach(fileList) {
-			if (this.ignoreLists.indexOf(fileList.id) >= 0) {
-				return
-			}
-
-			// only create and attach once
-			// FIXME: this should likely be done on a different code path now
-			// for the sidebar to only have it registered once
-			if (!OCA.SystemTags.View) {
-				const systemTagsInfoView = new OCA.SystemTags.SystemTagsInfoView()
-				fileList.registerDetailView(systemTagsInfoView)
-				OCA.SystemTags.View = systemTagsInfoView
-			}
-		},
-	}
-
-})()
-
-OC.Plugins.register('OCA.Files.FileList', OCA.SystemTags.FilesPlugin)

+ 0 - 2
apps/systemtags/src/systemtags.js

@@ -23,8 +23,6 @@
 
 import './app.js'
 import './systemtagsfilelist.js'
-import './filesplugin.js'
-import './systemtagsinfoview.js'
 import './css/systemtagsfilelist.scss'
 
 window.OCA.SystemTags = OCA.SystemTags

+ 0 - 194
apps/systemtags/src/systemtagsinfoview.js

@@ -1,194 +0,0 @@
-/**
- * Copyright (c) 2015
- *
- * @author Daniel Calviño Sánchez <danxuliu@gmail.com>
- * @author Joas Schilling <coding@schilljs.com>
- * @author John Molakvoæ <skjnldsv@protonmail.com>
- * @author Julius Härtl <jus@bitgrid.net>
- * @author Vincent Petry <vincent@nextcloud.com>
- *
- * @license AGPL-3.0-or-later
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-(function(OCA) {
-
-	/**
-	 * @param {any} model -
-	 */
-	function modelToSelection(model) {
-		const data = model.toJSON()
-		if (!OC.isUserAdmin() && !data.canAssign) {
-			data.locked = true
-		}
-		return data
-	}
-
-	/**
-	 * @class OCA.SystemTags.SystemTagsInfoView
-	 * @classdesc
-	 *
-	 * Displays a file's system tags
-	 *
-	 */
-	const SystemTagsInfoView = OCA.Files.DetailFileInfoView.extend(
-		/** @lends OCA.SystemTags.SystemTagsInfoView.prototype */ {
-
-			_rendered: false,
-
-			className: 'systemTagsInfoView',
-			name: 'systemTags',
-
-			/* required by the new files sidebar to check if the view is unique */
-			id: 'systemTagsInfoView',
-
-			/**
-			 * @type {OC.SystemTags.SystemTagsInputField}
-			 */
-			_inputView: null,
-
-			initialize(options) {
-				const self = this
-				options = options || {}
-
-				this._inputView = new OC.SystemTags.SystemTagsInputField({
-					multiple: true,
-					allowActions: true,
-					allowCreate: true,
-					isAdmin: OC.isUserAdmin(),
-					initSelection(element, callback) {
-						callback(self.selectedTagsCollection.map(modelToSelection))
-					},
-				})
-
-				this.selectedTagsCollection = new OC.SystemTags.SystemTagsMappingCollection([], { objectType: 'files' })
-
-				this._inputView.collection.on('change:name', this._onTagRenamedGlobally, this)
-				this._inputView.collection.on('remove', this._onTagDeletedGlobally, this)
-
-				this._inputView.on('select', this._onSelectTag, this)
-				this._inputView.on('deselect', this._onDeselectTag, this)
-			},
-
-			/**
-			 * Event handler whenever a tag was selected
-			 *
-			 * @param {object} tag the tag to create
-			 */
-			_onSelectTag(tag) {
-			// create a mapping entry for this tag
-				this.selectedTagsCollection.create(tag.toJSON())
-			},
-
-			/**
-			 * Event handler whenever a tag gets deselected.
-			 * Removes the selected tag from the mapping collection.
-			 *
-			 * @param {string} tagId tag id
-			 */
-			_onDeselectTag(tagId) {
-				this.selectedTagsCollection.get(tagId).destroy()
-			},
-
-			/**
-			 * Event handler whenever a tag was renamed globally.
-			 *
-			 * This will automatically adjust the tag mapping collection to
-			 * container the new name.
-			 *
-			 * @param {OC.Backbone.Model} changedTag tag model that has changed
-			 */
-			_onTagRenamedGlobally(changedTag) {
-			// also rename it in the selection, if applicable
-				const selectedTagMapping = this.selectedTagsCollection.get(changedTag.id)
-				if (selectedTagMapping) {
-					selectedTagMapping.set(changedTag.toJSON())
-				}
-			},
-
-			/**
-			 * Event handler whenever a tag was deleted globally.
-			 *
-			 * This will automatically adjust the tag mapping collection to
-			 * container the new name.
-			 *
-			 * @param {OC.Backbone.Model} tagId tag model that has changed
-			 */
-			_onTagDeletedGlobally(tagId) {
-			// also rename it in the selection, if applicable
-				this.selectedTagsCollection.remove(tagId)
-			},
-
-			setFileInfo(fileInfo) {
-				const self = this
-				if (!this._rendered) {
-					this.render()
-				}
-
-				if (fileInfo) {
-					this.selectedTagsCollection.setObjectId(fileInfo.id)
-					this.selectedTagsCollection.fetch({
-						success(collection) {
-							collection.fetched = true
-
-							const appliedTags = collection.map(modelToSelection)
-							self._inputView.setData(appliedTags)
-							if (appliedTags.length > 0) {
-								self.show()
-							}
-						},
-					})
-				}
-
-				this.hide()
-			},
-
-			/**
-			 * Renders this details view
-			 */
-			render() {
-				this.$el.append(this._inputView.$el)
-				this._inputView.render()
-			},
-
-			isVisible() {
-				return !this.$el.hasClass('hidden')
-			},
-
-			show() {
-				this.$el.removeClass('hidden')
-			},
-
-			hide() {
-				this.$el.addClass('hidden')
-			},
-
-			toggle() {
-				this.$el.toggleClass('hidden')
-			},
-
-			openDropdown() {
-				this.$el.find('.systemTagsInputField').select2('open')
-			},
-
-			remove() {
-				this._inputView.remove()
-			},
-		})
-
-	OCA.SystemTags.SystemTagsInfoView = SystemTagsInfoView
-
-})(OCA)

+ 0 - 252
apps/systemtags/tests/js/systemtagsinfoviewSpec.js

@@ -1,252 +0,0 @@
-/**
-* @copyright 2016 Vincent Petry <pvince81@owncloud.com>
- *
- * @author Daniel Calviño Sánchez <danxuliu@gmail.com>
- * @author John Molakvoæ <skjnldsv@protonmail.com>
- * @author Vincent Petry <vincent@nextcloud.com>
- *
- * @license AGPL-3.0-or-later
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-describe('OCA.SystemTags.SystemTagsInfoView tests', function() {
-	var isAdminStub;
-	var view;
-	var clock;
-
-	beforeEach(function() {
-		clock = sinon.useFakeTimers();
-		view = new OCA.SystemTags.SystemTagsInfoView();
-		$('#testArea').append(view.$el);
-		isAdminStub = sinon.stub(OC, 'isUserAdmin').returns(true);
-	});
-	afterEach(function() {
-		isAdminStub.restore();
-		clock.restore();
-		view.remove();
-		view = undefined;
-	});
-	describe('rendering', function() {
-		it('renders input field view', function() {
-			view.render();
-			expect(view.$el.find('input[name=tags]').length).toEqual(1);
-		});
-		it('fetches selected tags then renders when setting file info', function() {
-			var fetchStub = sinon.stub(OC.SystemTags.SystemTagsMappingCollection.prototype, 'fetch');
-			var setDataStub = sinon.stub(OC.SystemTags.SystemTagsInputField.prototype, 'setData');
-
-			expect(view.$el.hasClass('hidden')).toEqual(false);
-
-			view.setFileInfo({id: '123'});
-			expect(view.$el.find('input[name=tags]').length).toEqual(1);
-
-			expect(fetchStub.calledOnce).toEqual(true);
-			expect(view.selectedTagsCollection.url())
-				.toEqual(OC.linkToRemote('dav') + '/systemtags-relations/files/123');
-
-			view.selectedTagsCollection.add([
-				{id: '1', name: 'test1'},
-				{id: '3', name: 'test3'}
-			]);
-
-			fetchStub.yieldTo('success', view.selectedTagsCollection);
-			expect(setDataStub.calledOnce).toEqual(true);
-			expect(setDataStub.getCall(0).args[0]).toEqual([{
-				id: '1', name: 'test1', userVisible: true, userAssignable: true, canAssign: true
-			}, {
-				id: '3', name: 'test3', userVisible: true, userAssignable: true, canAssign: true
-			}]);
-
-			expect(view.$el.hasClass('hidden')).toEqual(false);
-
-			fetchStub.restore();
-			setDataStub.restore();
-		});
-		it('overrides initSelection to use the local collection', function() {
-			var inputViewSpy = sinon.spy(OC.SystemTags, 'SystemTagsInputField');
-			var element = $('<input type="hidden" val="1,3"/>');
-			view.remove();
-			view = new OCA.SystemTags.SystemTagsInfoView();
-			view.selectedTagsCollection.add([
-				{id: '1', name: 'test1'},
-				{id: '3', name: 'test3', userVisible: false, userAssignable: false, canAssign: false}
-			]);
-
-			var callback = sinon.stub();
-			inputViewSpy.getCall(0).args[0].initSelection(element, callback);
-
-			expect(callback.calledOnce).toEqual(true);
-			expect(callback.getCall(0).args[0]).toEqual([{
-				id: '1', name: 'test1', userVisible: true, userAssignable: true, canAssign: true
-			}, {
-				id: '3', name: 'test3', userVisible: false, userAssignable: false, canAssign: false
-			}]);
-
-			inputViewSpy.restore();
-		});
-		it('sets locked flag on non-assignable tags when user is not an admin', function() {
-			isAdminStub.returns(false);
-
-			var inputViewSpy = sinon.spy(OC.SystemTags, 'SystemTagsInputField');
-			var element = $('<input type="hidden" val="1,3"/>');
-			view.remove();
-			view = new OCA.SystemTags.SystemTagsInfoView();
-			view.selectedTagsCollection.add([
-				{id: '1', name: 'test1'},
-				{id: '3', name: 'test3', userAssignable: false, canAssign: false}
-			]);
-
-			var callback = sinon.stub();
-			inputViewSpy.getCall(0).args[0].initSelection(element, callback);
-
-			expect(callback.calledOnce).toEqual(true);
-			expect(callback.getCall(0).args[0]).toEqual([{
-				id: '1', name: 'test1', userVisible: true, userAssignable: true, canAssign: true
-			}, {
-				id: '3', name: 'test3', userVisible: true, userAssignable: false, canAssign: false, locked: true
-			}]);
-
-			inputViewSpy.restore();
-		});
-		it('does not set locked flag on non-assignable tags when canAssign overrides it with true', function() {
-			isAdminStub.returns(false);
-
-			var inputViewSpy = sinon.spy(OC.SystemTags, 'SystemTagsInputField');
-			var element = $('<input type="hidden" val="1,4"/>');
-			view.remove();
-			view = new OCA.SystemTags.SystemTagsInfoView();
-			view.selectedTagsCollection.add([
-				{id: '1', name: 'test1'},
-				{id: '4', name: 'test4', userAssignable: false, canAssign: true}
-			]);
-
-			var callback = sinon.stub();
-			inputViewSpy.getCall(0).args[0].initSelection(element, callback);
-
-			expect(callback.calledOnce).toEqual(true);
-			expect(callback.getCall(0).args[0]).toEqual([{
-				id: '1', name: 'test1', userVisible: true, userAssignable: true, canAssign: true
-			}, {
-				id: '4', name: 'test4', userVisible: true, userAssignable: false, canAssign: true
-			}]);
-
-			inputViewSpy.restore();
-		});
-	});
-	describe('events', function() {
-		var allTagsCollection;
-		beforeEach(function() {
-			allTagsCollection = view._inputView.collection;
-
-			allTagsCollection.add([
-				{id: '1', name: 'test1'},
-				{id: '2', name: 'test2'},
-				{id: '3', name: 'test3'}
-			]);
-
-			view.selectedTagsCollection.add([
-				{id: '1', name: 'test1'},
-				{id: '3', name: 'test3'}
-			]);
-			view.render();
-		});
-
-		it('renames model in selection collection on rename', function() {
-			allTagsCollection.get('3').set('name', 'test3_renamed');
-
-			expect(view.selectedTagsCollection.get('3').get('name')).toEqual('test3_renamed');
-		});
-
-		it('adds tag to selection collection when selected by input', function() {
-			var createStub = sinon.stub(OC.SystemTags.SystemTagsMappingCollection.prototype, 'create');
-			view._inputView.trigger('select', allTagsCollection.get('2'));
-
-			expect(createStub.calledOnce).toEqual(true);
-			expect(createStub.getCall(0).args[0]).toEqual({
-				id: '2',
-				name: 'test2',
-				userVisible: true,
-				userAssignable: true,
-				canAssign: true
-			});
-
-			createStub.restore();
-		});
-		it('removes tag from selection collection when deselected by input', function() {
-			var destroyStub = sinon.stub(OC.SystemTags.SystemTagModel.prototype, 'destroy');
-			view._inputView.trigger('deselect', '3');
-
-			expect(destroyStub.calledOnce).toEqual(true);
-			expect(destroyStub.calledOn(view.selectedTagsCollection.get('3'))).toEqual(true);
-
-			destroyStub.restore();
-		});
-
-		it('removes tag from selection whenever the tag was deleted globally', function() {
-			expect(view.selectedTagsCollection.get('3')).not.toBeFalsy();
-
-			allTagsCollection.remove('3');
-
-			expect(view.selectedTagsCollection.get('3')).toBeFalsy();
-
-		});
-	});
-	describe('visibility', function() {
-		it('reports visibility based on the "hidden" class name', function() {
-			view.$el.addClass('hidden');
-
-			expect(view.isVisible()).toBeFalsy();
-
-			view.$el.removeClass('hidden');
-
-			expect(view.isVisible()).toBeTruthy();
-		});
-		it('is visible after rendering', function() {
-			view.render();
-
-			expect(view.isVisible()).toBeTruthy();
-		});
-		it('shows and hides the element', function() {
-			view.show();
-
-			expect(view.isVisible()).toBeTruthy();
-
-			view.hide();
-
-			expect(view.isVisible()).toBeFalsy();
-
-			view.show();
-
-			expect(view.isVisible()).toBeTruthy();
-		});
-	});
-	describe('select2', function() {
-		var select2Stub;
-
-		beforeEach(function() {
-			select2Stub = sinon.stub($.fn, 'select2');
-		});
-		afterEach(function() {
-			select2Stub.restore();
-		});
-		it('opens dropdown', function() {
-			view.openDropdown();
-
-			expect(select2Stub.calledOnce).toBeTruthy();
-			expect(select2Stub.withArgs('open')).toBeTruthy();
-		});
-	});
-});

+ 1 - 1
core/css/systemtags.css

@@ -1 +1 @@
-.systemtags-select2-dropdown .select2-result-label .checkmark{visibility:hidden;margin-left:-5px;margin-right:5px;padding:4px}.systemtags-select2-dropdown .select2-result-label .new-item .systemtags-actions{display:none}.systemtags-select2-dropdown .select2-selected .select2-result-label .checkmark{visibility:visible}.systemtags-select2-dropdown .select2-result-label .icon{display:inline-block;opacity:.5}.systemtags-select2-dropdown .select2-result-label .icon.rename{padding:4px}.systemtags-select2-dropdown .systemtags-actions{position:absolute;right:5px}.systemtags-select2-dropdown .systemtags-rename-form{display:inline-block;width:calc(100% - 20px);top:-6px;position:relative}.systemtags-select2-dropdown .systemtags-rename-form input{display:inline-block;height:30px;width:calc(100% - 40px)}.systemtags-select2-dropdown .label{width:85%;display:inline-block;overflow:hidden;text-overflow:ellipsis}.systemtags-select2-dropdown .label.hidden{display:none}.systemtags-select2-dropdown span{line-height:25px}.systemtags-select2-dropdown .systemtags-item{display:inline-block;height:25px;width:100%}.systemtags-select2-dropdown .select2-result-label{height:25px}.systemTagsInfoView,.systemtags-select2-container{width:100%}.systemTagsInfoView .select2-choices,.systemtags-select2-container .select2-choices{flex-wrap:nowrap !important;max-height:44px}.systemTagsInfoView .select2-choices .select2-search-choice.select2-locked .label,.systemtags-select2-container .select2-choices .select2-search-choice.select2-locked .label{opacity:.5}#select2-drop.systemtags-select2-dropdown .select2-results li.select2-result{padding:5px}/*# sourceMappingURL=systemtags.css.map */
+.systemtags-select2-dropdown .select2-result-label .checkmark{visibility:hidden;margin-left:-5px;margin-right:5px;padding:4px}.systemtags-select2-dropdown .select2-result-label .new-item .systemtags-actions{display:none}.systemtags-select2-dropdown .select2-selected .select2-result-label .checkmark{visibility:visible}.systemtags-select2-dropdown .select2-result-label .icon{display:inline-block;opacity:.5}.systemtags-select2-dropdown .select2-result-label .icon.rename{padding:4px}.systemtags-select2-dropdown .systemtags-actions{position:absolute;right:5px}.systemtags-select2-dropdown .systemtags-rename-form{display:inline-block;width:calc(100% - 20px);top:-6px;position:relative}.systemtags-select2-dropdown .systemtags-rename-form input{display:inline-block;height:30px;width:calc(100% - 40px)}.systemtags-select2-dropdown .label{width:85%;display:inline-block;overflow:hidden;text-overflow:ellipsis}.systemtags-select2-dropdown .label.hidden{display:none}.systemtags-select2-dropdown span{line-height:25px}.systemtags-select2-dropdown .systemtags-item{display:inline-block;height:25px;width:100%}.systemtags-select2-dropdown .select2-result-label{height:25px}.systemtags-select2-container{width:100%}.systemtags-select2-container .select2-choices{flex-wrap:nowrap !important;max-height:44px}.systemtags-select2-container .select2-choices .select2-search-choice.select2-locked .label{opacity:.5}#select2-drop.systemtags-select2-dropdown .select2-results li.select2-result{padding:5px}/*# sourceMappingURL=systemtags.css.map */

+ 1 - 1
core/css/systemtags.css.map

@@ -1 +1 @@
-{"version":3,"sourceRoot":"","sources":["systemtags.scss"],"names":[],"mappings":"AAcE,8DACC,kBACA,iBACA,iBACA,YAED,iFACC,aAGF,gFACC,mBAED,yDACC,qBACA,WACA,gEACC,YAGF,iDACC,kBACA,UAED,qDACC,qBACA,wBACA,SACA,kBACA,2DACC,qBACA,YACA,wBAGF,oCACC,UACA,qBACA,gBACA,uBACA,2CACC,aAGF,kCACC,iBAED,8CACC,qBACA,YACA,WAED,mDACC,YAIF,kDAEC,WAEA,oFACC,4BACA,gBAGD,8KACC,WAIF,6EACC","file":"systemtags.css"}
+{"version":3,"sourceRoot":"","sources":["systemtags.scss"],"names":[],"mappings":"AAcE,8DACC,kBACA,iBACA,iBACA,YAED,iFACC,aAGF,gFACC,mBAED,yDACC,qBACA,WACA,gEACC,YAGF,iDACC,kBACA,UAED,qDACC,qBACA,wBACA,SACA,kBACA,2DACC,qBACA,YACA,wBAGF,oCACC,UACA,qBACA,gBACA,uBACA,2CACC,aAGF,kCACC,iBAED,8CACC,qBACA,YACA,WAED,mDACC,YAIF,8BACC,WAEA,+CACC,4BACA,gBAGD,4FACC,WAIF,6EACC","file":"systemtags.css"}

+ 0 - 1
core/css/systemtags.scss

@@ -69,7 +69,6 @@
 	}
 }
 
-.systemTagsInfoView,
 .systemtags-select2-container {
 	width: 100%;
 

File diff suppressed because it is too large
+ 0 - 0
dist/core-systemtags.js


File diff suppressed because it is too large
+ 0 - 0
dist/core-systemtags.js.map


File diff suppressed because it is too large
+ 0 - 0
dist/systemtags-systemtags.js


+ 0 - 26
dist/systemtags-systemtags.js.LICENSE.txt

@@ -21,32 +21,6 @@
  *
  */
 
-/**
- * Copyright (c) 2015
- *
- * @author Daniel Calviño Sánchez <danxuliu@gmail.com>
- * @author Joas Schilling <coding@schilljs.com>
- * @author John Molakvoæ <skjnldsv@protonmail.com>
- * @author Julius Härtl <jus@bitgrid.net>
- * @author Vincent Petry <vincent@nextcloud.com>
- *
- * @license AGPL-3.0-or-later
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
 /**
  * Copyright (c) 2016 Vincent Petry <pvince81@owncloud.com>
  *

File diff suppressed because it is too large
+ 0 - 0
dist/systemtags-systemtags.js.map


Some files were not shown because too many files changed in this diff