Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions lib/AppInfo/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
use OCP\Share\Events\ShareCreatedEvent;
use OCP\User\Events\UserChangedEvent;
use OCP\User\Events\UserFirstTimeLoggedInEvent;
use OCP\Util;
use Psr\Container\ContainerInterface;

class Application extends App implements IBootstrap {
Expand Down Expand Up @@ -63,7 +62,6 @@ public function boot(IBootContext $context): void {
$this->setupGuestRestrictions($context->getAppContainer(), $context->getServerContainer());
$this->setupNotifications($context->getAppContainer());
$context->getAppContainer()->get(RestrictionManager::class)->lateSetupRestrictions();
Util::addScript('guests', 'guests-init');
}

private function setupGuestManagement(ContainerInterface $container, ContainerInterface $server): void {
Expand Down
13 changes: 9 additions & 4 deletions lib/Listener/BeforeTemplateRenderedListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

use OCA\Guests\Config;
use OCP\AppFramework\Http\Events\BeforeTemplateRenderedEvent;
use OCP\AppFramework\Services\IInitialState;
use OCP\EventDispatcher\Event;
use OCP\EventDispatcher\IEventListener;
use OCP\Util;
Expand All @@ -23,7 +22,6 @@
class BeforeTemplateRenderedListener implements IEventListener {
public function __construct(
private Config $config,
private IInitialState $initialState,
) {
}

Expand All @@ -32,10 +30,17 @@ public function handle(Event $event): void {
return;
}

$this->initialState->provideInitialState('canCreateGuests', $this->config->canCreateGuests());
if (!$event->isLoggedIn()) {
return;
}

if (!$this->config->canCreateGuests()) {
return;
}
Util::addScript('guests', 'guests-init');
Util::addScript('guests', 'guests-contactsmenu');

if (!$event->isLoggedIn() || $event->getResponse()->getTemplateName() !== 'index') {
if ($event->getResponse()->getTemplateName() !== 'index') {
return;
}

Expand Down
5 changes: 3 additions & 2 deletions src/contactsmenu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,16 @@

import AccountPlusOutlineSvg from '@mdi/svg/svg/account-plus-outline.svg?raw'
import { t } from '@nextcloud/l10n'
import { guestForm } from './init.ts'

window.addEventListener('DOMContentLoaded', () => {
if (OC.ContactsMenu && OCA.Guests?.openGuestDialog) {
if (OC.ContactsMenu) {
OC.ContactsMenu.addAction({
id: 'guests_addGuestAction',
icon: AccountPlusOutlineSvg,
label: t('guests', 'Add guest'),
onClick: () => {
OCA.Guests.openGuestDialog('core')
guestForm.populate({ app: 'core' })
},
})
}
Expand Down
6 changes: 2 additions & 4 deletions src/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ import Vue from 'vue'
import GuestForm from './views/GuestForm.vue'
import Nextcloud from './mixins/Nextcloud.js'

import { loadState } from '@nextcloud/initial-state'

Vue.mixin(Nextcloud)

if (!OCA.Guests) {
Expand All @@ -25,8 +23,8 @@ guestRoot.setAttribute('id', 'guest-root')
document.body.appendChild(guestRoot)
guestForm.$mount('#guest-root')

if (loadState('guests', 'canCreateGuests', false)) {
OCA.Guests.openGuestDialog = (app: string, shareWith?: string) => guestForm.populate({ app }, shareWith)
OCA.Guests.openGuestDialog = (app: string, shareWith?: string) => {
guestForm.populate({ app }, shareWith)
}

export { guestForm }
11 changes: 1 addition & 10 deletions src/views/GuestForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<!-- Name -->
<div class="form-group">
<label class="form-label" for="app-guests-input-name">
{{ t('guests', 'Name') }}
{{ t('guests', 'Guest Name') }}
</label>
<input id="app-guests-input-name"
ref="name"
Expand Down Expand Up @@ -360,15 +360,6 @@ export default {
span {
margin: 10px;
}
button {
height: 44px;
&.icon-loading-small {
padding-left: $modal-button-loading * 2;
&::after {
left: $modal-button-loading;
}
}
}
}
}
// to allow lang multiselect
Expand Down
3 changes: 3 additions & 0 deletions tests/unit/Storage/DirMaskTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
use OCP\Constants;
use Test\TestCase;

/**
* @group DB
*/
class DirMaskTest extends TestCase {
public function testReadonlyDir() {
$storage = new Temporary([]);
Expand Down
Loading