Port to new Dashboard api

Signed-off-by: Carl Schwan <carl@carlschwan.eu>
pull/1162/head
Carl Schwan 2022-09-14 15:39:47 +02:00
rodzic b009d25e13
commit c683f9135a
4 zmienionych plików z 30 dodań i 19 usunięć

Wyświetl plik

@ -23,19 +23,21 @@
namespace OCA\Social\Dashboard;
use OCP\IURLGenerator;
use OCP\Dashboard\IWidget;
use OCP\IL10N;
use OCA\Social\AppInfo\Application;
class SocialWidget implements IWidget {
/** @var IL10N */
private $l10n;
private IL10N $l10n;
private IURLGenerator $urlGenerator;
public function __construct(
IL10N $l10n
IL10N $l10n,
IURLGenerator $urlGenerator
) {
$this->l10n = $l10n;
$this->urlGenerator = $urlGenerator;
}
/**
@ -70,14 +72,13 @@ class SocialWidget implements IWidget {
* @inheritDoc
*/
public function getUrl(): ?string {
return \OC::$server->getURLGenerator()->linkToRoute('social.local.streamNotifications', []);
return ''; //$this->uRLGenerator->linkToRoute('social.local.streamNotifications', []);
}
/**
* @inheritDoc
*/
public function load(): void {
\OC_Util::addScript(Application::APP_NAME, 'dashboard');
\OC_Util::addStyle(Application::APP_NAME, 'dashboard');
\OCP\Util::addScript(Application::APP_NAME, 'social-dashboard');
}
}
}

Wyświetl plik

@ -14,18 +14,20 @@
import Vue from 'vue'
import Dashboard from './views/Dashboard.vue'
// eslint-disable-next-line
__webpack_nonce__ = btoa(OC.requestToken);
// eslint-disable-next-line
__webpack_public_path__ = OC.linkTo('social', 'js/');
Vue.prototype.t = t
Vue.prototype.n = n
Vue.prototype.OC = window.OC
Vue.prototype.OCA = window.OCA
document.addEventListener('DOMContentLoaded', function() {
OCA.Dashboard.register('social_notifications', (el, { widget }) => {
const View = Vue.extend(Dashboard)
new View({
propsData: { title: widget.title }
}).$mount(el)
})
})

Wyświetl plik

@ -1,10 +1,10 @@
<template>
<DashboardWidget :items="items"
<NcDashboardWidget :items="items"
:show-more-url="showMoreUrl"
:show-more-text="title"
:loading="state === 'loading'">
<template #empty-content>
<EmptyContent
<NcEmptyContent
v-if="emptyContentMessage"
:icon="emptyContentIcon">
<template #desc>
@ -15,24 +15,24 @@
</a>
</div>
</template>
</EmptyContent>
</NcEmptyContent>
</template>
</DashboardWidget>
</NcDashboardWidget>
</template>
<script>
import axios from '@nextcloud/axios'
import { generateUrl } from '@nextcloud/router'
import { showError } from '@nextcloud/dialogs'
import { DashboardWidget } from '@nextcloud/vue-dashboard'
import EmptyContent from '@nextcloud/vue/dist/Components/EmptyContent'
import NcDashboardWidget from '@nextcloud/vue/dist/Components/NcDashboardWidget.js'
import NcEmptyContent from '@nextcloud/vue/dist/Components/NcEmptyContent.js'
export default {
name: 'Dashboard',
components: {
DashboardWidget,
EmptyContent
NcDashboardWidget,
NcEmptyContent
},
props: {
@ -152,6 +152,9 @@ export default {
if (n.subtype === 'Follow') {
return t('social', '{account} is following you', { account: this.getActorName(n) })
}
if (n.subtype === 'Like') {
return t('social', '{account} liked your post', { account: this.getActorName(n) })
}
},
getAvatarUrl(n) {
return undefined
@ -180,6 +183,9 @@ export default {
if (n.subtype === 'Follow') {
return this.getActorAccountName(n)
}
if (n.subtype === 'Like') {
return this.getActorAccountName(n)
}
return ''
},
getNotificationTypeImage(n) {

Wyświetl plik

@ -10,3 +10,5 @@ webpackConfig.entry = {
profilePage: path.join(__dirname, 'src', 'profile.js'),
dashboard: path.join(__dirname, 'src', 'dashboard.js'),
}
module.exports = webpackConfig