Skip to content

Commit

Permalink
Merge pull request nextcloud#23173 from nextcloud/feat/comments-sideb…
Browse files Browse the repository at this point in the history
…ar-vue
  • Loading branch information
skjnldsv authored Oct 20, 2020
2 parents dbaafcf + 6cd7549 commit 766590d
Show file tree
Hide file tree
Showing 155 changed files with 1,850 additions and 2,621 deletions.
2 changes: 2 additions & 0 deletions apps/comments/js/comments-app.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions apps/comments/js/comments-app.js.map

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions apps/comments/js/comments-tab.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions apps/comments/js/comments-tab.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion apps/comments/js/comments.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion apps/comments/js/comments.js.map

Large diffs are not rendered by default.

12 changes: 12 additions & 0 deletions apps/comments/lib/Listener/LoadSidebarScripts.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,30 @@

use OCA\Comments\AppInfo\Application;
use OCA\Files\Event\LoadSidebar;
use OCP\Comments\ICommentsManager;
use OCP\EventDispatcher\Event;
use OCP\EventDispatcher\IEventListener;
use OCP\Util;

class LoadSidebarScripts implements IEventListener {

/** @var ICommentsManager */
private $commentsManager;

public function __construct(ICommentsManager $commentsManager) {
$this->commentsManager = $commentsManager;
}

public function handle(Event $event): void {
if (!($event instanceof LoadSidebar)) {
return;
}

$this->commentsManager->load();

// TODO: make sure to only include the sidebar script when
// we properly split it between files list and sidebar
Util::addScript(Application::APP_ID, 'comments');
Util::addScript(Application::APP_ID, 'comments-tab');
}
}
167 changes: 0 additions & 167 deletions apps/comments/src/commentcollection.js

This file was deleted.

93 changes: 0 additions & 93 deletions apps/comments/src/commentmodel.js

This file was deleted.

32 changes: 32 additions & 0 deletions apps/comments/src/comments-app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/**
* @copyright Copyright (c) 2020 John Molakvoæ <[email protected]>
*
* @author John Molakvoæ <[email protected]>
*
* @license GNU AGPL version 3 or any later version
*
* 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/>.
*
*/

import CommentsInstance from './services/CommentsInstance'

// Init Comments
if (window.OCA && !window.OCA.Comments) {
Object.assign(window.OCA, { Comments: {} })
}

// Init Comments App view
Object.assign(window.OCA.Comments, { View: CommentsInstance })
console.debug('OCA.Comments.View initialized')
58 changes: 58 additions & 0 deletions apps/comments/src/comments-tab.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/**
* @copyright Copyright (c) 2020 John Molakvoæ <[email protected]>
*
* @author John Molakvoæ <[email protected]>
*
* @license GNU AGPL version 3 or any later version
*
* 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/>.
*
*/

// Init Comments tab component
let TabInstance = null
const commentTab = new OCA.Files.Sidebar.Tab({
id: 'comments',
name: t('comments', 'Comments'),
icon: 'icon-comment',

async mount(el, fileInfo, context) {
if (TabInstance) {
TabInstance.$destroy()
}
TabInstance = new OCA.Comments.View('files', {
// Better integration with vue parent component
parent: context,
})
// Only mount after we have all the info we need
await TabInstance.update(fileInfo.id)
TabInstance.$mount(el)
},
update(fileInfo) {
TabInstance.update(fileInfo.id)
},
destroy() {
TabInstance.$destroy()
TabInstance = null
},
scrollBottomReached() {
TabInstance.onScrollBottomReached()
},
})

window.addEventListener('DOMContentLoaded', function() {
if (OCA.Files && OCA.Files.Sidebar) {
OCA.Files.Sidebar.registerTab(commentTab)
}
})
Loading

0 comments on commit 766590d

Please sign in to comment.