diff --git a/CHANGELOG.md b/CHANGELOG.md index 69a22d37..36121b9e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Changelog +TODO: add documentation link for the task-list in the CHANGELOG. + +## ??? (Not Released Yet) + +### New features + +* #177: streamer's task/to-do lists: streamers, and their room's moderators, can handle task lists directly. This can be used to handle viewers questions, moderation actions, ... More info in the documentation. + ## 9.0.3 ### Minor changes and fixes diff --git a/conversejs/build-conversejs.sh b/conversejs/build-conversejs.sh index 6a1bfc2c..cdb005e2 100644 --- a/conversejs/build-conversejs.sh +++ b/conversejs/build-conversejs.sh @@ -85,6 +85,8 @@ rm -rf "$converse_build_dir/custom/" echo "Adding the custom files..." cp -r "$src_dir/custom/" "$converse_build_dir/custom/" mv "$converse_build_dir/custom/webpack.livechat.js" "$converse_build_dir/" +# overriding original index.js file: +mv "$converse_build_dir/custom/index.js" "$converse_build_dir/src/" cp "$src_dir/loc.keys.js" "$converse_build_dir/" echo "Patching i18n files to add custom labels..." diff --git a/conversejs/custom/index.js b/conversejs/custom/index.js new file mode 100644 index 00000000..f7562102 --- /dev/null +++ b/conversejs/custom/index.js @@ -0,0 +1,61 @@ +/** + * @description This files will override the original ConverseJS index.js file. + */ + +import '@converse/headless' +import './i18n/index.js' +import 'shared/registry.js' +import { CustomElement } from 'shared/components/element' +import { VIEW_PLUGINS } from './shared/constants.js' +import { _converse, converse } from '@converse/headless/core' + +import 'shared/styles/index.scss' + +/* START: Removable plugins + * ------------------------ + * Any of the following plugin imports may be removed if the plugin is not needed + * + * Comments line were removed for the peertube-plugin-livechat. + */ +import './plugins/modal/index.js' +import './plugins/adhoc-views/index.js' // Views for XEP-0050 Ad-Hoc commands +import './plugins/bookmark-views/index.js' // Views for XEP-0048 Bookmarks +import './plugins/chatview/index.js' // Renders standalone chat boxes for single user chat +import './plugins/controlbox/index.js' // The control box +import './plugins/headlines-view/index.js' +import './plugins/mam-views/index.js' +import './plugins/muc-views/index.js' // Views related to MUC +// import './plugins/minimize/index.js' // Allows chat boxes to be minimized +// import './plugins/notifications/index.js' +// import './plugins/profile/index.js' +// import './plugins/omemo/index.js' +// import './plugins/push/index.js' // XEP-0357 Push Notifications +import './plugins/register/index.js' // XEP-0077 In-band registration +// import './plugins/roomslist/index.js' // Show currently open chat rooms +import './plugins/rootview/index.js' +import './plugins/rosterview/index.js' +import './plugins/singleton/index.js' +// import './plugins/dragresize/index.js' // Allows chat boxes to be resized by dragging them +import './plugins/fullscreen/index.js' + +import '../custom/plugins/tasks/index.js' +/* END: Removable components */ + +// We must add our custom plugins to CORE_PLUGINS (so it is white listed): +import { CORE_PLUGINS } from './headless/shared/constants.js' +CORE_PLUGINS.push('livechat-converse-tasks') + +_converse.CustomElement = CustomElement + +const initialize = converse.initialize + +converse.initialize = function (settings, callback) { + if (Array.isArray(settings.whitelisted_plugins)) { + settings.whitelisted_plugins = settings.whitelisted_plugins.concat(VIEW_PLUGINS) + } else { + settings.whitelisted_plugins = VIEW_PLUGINS + } + return initialize(settings, callback) +} + +export default converse diff --git a/conversejs/custom/plugins/tasks/index.js b/conversejs/custom/plugins/tasks/index.js new file mode 100644 index 00000000..9f3602e0 --- /dev/null +++ b/conversejs/custom/plugins/tasks/index.js @@ -0,0 +1,15 @@ +import { _converse, converse } from '../../../src/headless/core.js' +import { ChatRoomTaskLists } from './task-lists.js' +import { ChatRoomTaskList } from './task-list.js' +import { getHeadingButtons } from './utils.js' + +converse.plugins.add('livechat-converse-tasks', { + dependencies: ['converse-muc', 'converse-disco'], // TODO: add converse-pubsub + + initialize () { + _converse.ChatRoomTaskLists = ChatRoomTaskLists + _converse.ChatRoomTaskList = ChatRoomTaskList + + _converse.api.listen.on('getHeadingButtons', getHeadingButtons) + } +}) diff --git a/conversejs/custom/plugins/tasks/task-list.js b/conversejs/custom/plugins/tasks/task-list.js new file mode 100644 index 00000000..99184828 --- /dev/null +++ b/conversejs/custom/plugins/tasks/task-list.js @@ -0,0 +1,15 @@ +import { Model } from '@converse/skeletor/src/model.js' + +/** + * A chat room task list. + * @class + * @namespace _converse.ChatRoomTaskList + * @memberof _converse + */ +class ChatRoomTaskList extends Model { + +} + +export { + ChatRoomTaskList +} diff --git a/conversejs/custom/plugins/tasks/task-lists.js b/conversejs/custom/plugins/tasks/task-lists.js new file mode 100644 index 00000000..44fa1b4a --- /dev/null +++ b/conversejs/custom/plugins/tasks/task-lists.js @@ -0,0 +1,16 @@ +import { Collection } from '@converse/skeletor/src/collection.js' +import { ChatRoomTaskList } from './task-list' + +/** + * A list of {@link _converse.ChatRoomTaskList} instances, representing task lists associated to a MUC. + * @class + * @namespace _converse.ChatRoomTaskLists + * @memberOf _converse + */ +class ChatRoomTaskLists extends Collection { + model = ChatRoomTaskList +} + +export { + ChatRoomTaskLists +} diff --git a/conversejs/custom/plugins/tasks/utils.js b/conversejs/custom/plugins/tasks/utils.js new file mode 100644 index 00000000..cb4abe00 --- /dev/null +++ b/conversejs/custom/plugins/tasks/utils.js @@ -0,0 +1,32 @@ +import { _converse } from '../../../src/headless/core.js' +import { __ } from 'i18n' + +export function getHeadingButtons (view, buttons) { + const muc = view.model + if (muc.get('type') !== _converse.CHATROOMS_TYPE) { + // only on MUC. + return buttons + } + + const myself = muc.getOwnOccupant() + if (!myself || !myself.isModerator()) { + // User must be moderator + return buttons + } + + // Adding a "Open task list" button. + buttons.unshift({ + i18n_text: __('Tasks'), + handler: async (ev) => { + ev.preventDefault() + ev.stopPropagation() + + // TODO. + }, + a_class: '', + icon_class: 'fa-list', // FIXME + name: 'muc-tasks' + }) + + return buttons +} diff --git a/conversejs/custom/shared/components/font-awesome.js b/conversejs/custom/shared/components/font-awesome.js new file mode 100644 index 00000000..fe544efc --- /dev/null +++ b/conversejs/custom/shared/components/font-awesome.js @@ -0,0 +1,22 @@ +/* eslint-disable max-len */ +import { html } from 'lit' +import tplIcons from '../../../src/shared/templates/icons.js' + +export default () => { + // Here we are adding some additonal icons to ConverseJS defaults + const converseJsIcons = tplIcons() + + return html` + ${converseJsIcons} + + + + + + + + ` +} diff --git a/conversejs/custom/webpack.livechat.js b/conversejs/custom/webpack.livechat.js index 9354a9e4..930edbb7 100644 --- a/conversejs/custom/webpack.livechat.js +++ b/conversejs/custom/webpack.livechat.js @@ -38,6 +38,8 @@ module.exports = merge(prod, { './templates/muc-head.js': path.resolve(__dirname, 'custom/templates/muc-head.js'), '../../templates/background_logo.js$': path.resolve(__dirname, 'custom/templates/background_logo.js'), + '../templates/icons.js': path.resolve(__dirname, 'custom/shared/components/font-awesome.js'), + 'shared/styles/index.scss$': path.resolve(__dirname, 'custom/shared/styles/livechat.scss'), 'shared/modals/livechat-external-login.js': path.resolve( diff --git a/conversejs/loc.keys.js b/conversejs/loc.keys.js index 0c7f25d8..f09f3cea 100644 --- a/conversejs/loc.keys.js +++ b/conversejs/loc.keys.js @@ -15,7 +15,8 @@ const locKeys = [ 'login_remote_peertube_video_not_found_try_anyway', 'login_remote_peertube_video_not_found_try_anyway_button', 'login_remote_peertube_video_open_failed', - 'login_external_auth_alert_message' + 'login_external_auth_alert_message', + 'tasks' ] module.exports = locKeys diff --git a/languages/en.yml b/languages/en.yml index 5f731be6..8e031fe0 100644 --- a/languages/en.yml +++ b/languages/en.yml @@ -434,3 +434,5 @@ login_remote_peertube_video_not_found_try_anyway: "In some cases, the video can login_remote_peertube_video_not_found_try_anyway_button: "Try anyway to open the video on the Peertube instance" login_remote_peertube_video_open_failed: "Your browser has blocked the opening on the remote instance, please try to open manually this link:" login_external_auth_alert_message: "Authentication failed" + +tasks: Tasks