Skip to content

Commit

Permalink
Add support for plugins to add buttons to MessageInfo.vue
Browse files Browse the repository at this point in the history
  • Loading branch information
ItsOnlyBinary committed Aug 20, 2024
1 parent 27a1fed commit 013731e
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
22 changes: 21 additions & 1 deletion src/components/MessageInfo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,28 @@
:class="{'kiwi-messageinfo-actions--open': requestingInput}"
class="kiwi-messageinfo-actions"
>
<template v-if="!requestingInput">
<a
v-for="plugin in pluginUiSections"
:key="plugin.id"
v-rawElement="{
el: plugin.el,
props: {
kiwi: {
buffer: buffer,
message: message,
}
}
}"
class="u-link kiwi-messageinfo-reply kiwi-messageinfo-plugin"
/>
</template>
<a
v-if="!requestingInput && message.nick && buffer.name !== message.nick && !isSelf()"
class="u-link kiwi-messageinfo-reply"
@click="openQuery"
>
{{ $t('reply_in_private') }}
Reply in private
</a>

<div v-if="message.user && areWeAnOp() && !isSelf()" class="kiwi-messageinfo-opbuttons">
Expand Down Expand Up @@ -55,11 +71,14 @@
<script>
'kiwi public';
import GlobalApi from '@/libs/GlobalApi';
export default {
props: ['buffer', 'message'],
data() {
return {
requestingInput: false,
pluginUiSections: GlobalApi.singleton().messageInfoPlugins,
};
},
computed: {
Expand Down Expand Up @@ -168,6 +187,7 @@ export default {
padding: 5px 10px;
display: inline-block;
border-radius: 4px;
margin-right: 4px;
}
@media screen and (max-width: 490px) {
Expand Down
4 changes: 4 additions & 0 deletions src/libs/GlobalApi.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export default class GlobalApi extends EventEmitter {
this.appSettingsPlugins = [];
this.serverViewPlugins = [];
this.aboutBufferPlugins = [];
this.messageInfoPlugins = [];
this.tabs = Object.create(null);
this.isReady = false;
/* eslint-disable no-underscore-dangle */
Expand Down Expand Up @@ -198,6 +199,9 @@ export default class GlobalApi extends EventEmitter {
case 'about_buffer':
this.aboutBufferPlugins.push(plugin);
break;
case 'message_info':
this.messageInfoPlugins.push(plugin);
break;
default:
break;
}
Expand Down

0 comments on commit 013731e

Please sign in to comment.