aboutsummaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorChristopher Ng <chrng8@gmail.com>2023-04-19 16:52:06 -0700
committerChristopher Ng <chrng8@gmail.com>2023-04-19 16:52:06 -0700
commit177849cd3ce2f5ff3964ef0a1053d4ac8cf423c6 (patch)
treef4d6020c1bd23e02e75c9161baf90f4ca03bad21 /apps
parentee81e2cef8242d06b05e3f8e459f78aceb325be8 (diff)
downloadnextcloud-server-177849cd3ce2f5ff3964ef0a1053d4ac8cf423c6.tar.gz
nextcloud-server-177849cd3ce2f5ff3964ef0a1053d4ac8cf423c6.zip
Remove legacy systemtags code
Signed-off-by: Christopher Ng <chrng8@gmail.com>
Diffstat (limited to 'apps')
-rw-r--r--apps/systemtags/src/filesplugin.js61
-rw-r--r--apps/systemtags/src/systemtags.js2
-rw-r--r--apps/systemtags/src/systemtagsinfoview.js194
-rw-r--r--apps/systemtags/tests/js/systemtagsinfoviewSpec.js252
4 files changed, 0 insertions, 509 deletions
diff --git a/apps/systemtags/src/filesplugin.js b/apps/systemtags/src/filesplugin.js
deleted file mode 100644
index 067a059093e..00000000000
--- a/apps/systemtags/src/filesplugin.js
+++ /dev/null
@@ -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)
diff --git a/apps/systemtags/src/systemtags.js b/apps/systemtags/src/systemtags.js
index a96d78a5dea..ab2f8ff4126 100644
--- a/apps/systemtags/src/systemtags.js
+++ b/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
diff --git a/apps/systemtags/src/systemtagsinfoview.js b/apps/systemtags/src/systemtagsinfoview.js
deleted file mode 100644
index b9a55a8e283..00000000000
--- a/apps/systemtags/src/systemtagsinfoview.js
+++ /dev/null
@@ -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)
diff --git a/apps/systemtags/tests/js/systemtagsinfoviewSpec.js b/apps/systemtags/tests/js/systemtagsinfoviewSpec.js
deleted file mode 100644
index 5c4b5bf6bd1..00000000000
--- a/apps/systemtags/tests/js/systemtagsinfoviewSpec.js
+++ /dev/null
@@ -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();
- });
- });
-});