Skip to content

Commit

Permalink
enh: Allow to disable automatically open the wizard
Browse files Browse the repository at this point in the history
Signed-off-by: Ferdinand Thiessen <[email protected]>
  • Loading branch information
susnux committed Feb 28, 2024
1 parent 8d33e0f commit b38d715
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 34 deletions.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,16 @@ A first run wizard that explains the usage of Nextcloud to new users

![](https://user-images.githubusercontent.com/3404133/51537050-bcc73e00-1e4d-11e9-8de0-29e6951c2b29.png)

## Configuration

No configuration is needed, but it is possible to prevent the wizard from opening for users by default.
When disabled users can only open it from manually clicking "About" in the user menu.

This can be done by setting an app setting value:

```
occ config:app:set --value false firstrunwizard wizard_enabled
```

## Development setup

Expand Down
50 changes: 16 additions & 34 deletions lib/Listener/BeforeTemplateRenderedListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
use OCA\FirstRunWizard\AppInfo\Application;
use OCA\FirstRunWizard\Notification\AppHint;
use OCP\AppFramework\Http\Events\BeforeTemplateRenderedEvent;
use OCP\AppFramework\Services\IAppConfig;
use OCP\AppFramework\Services\IInitialState;
use OCP\BackgroundJob\IJobList;
use OCP\Defaults;
Expand All @@ -43,36 +44,15 @@
* @template-implements IEventListener<BeforeTemplateRenderedEvent>
*/
class BeforeTemplateRenderedListener implements IEventListener {
/**
* @var IUserSession
*/
private $userSession;
/**
* @var IConfig
*/
private $config;
/**
* @var AppHint
*/
private $appHint;
/**
* @var IJobList
*/
private $jobList;

/** @var IInitialState */
protected $initialState;

/** @var Defaults */
protected $theming;

public function __construct(
IConfig $config,
IUserSession $userSession,
IJobList $jobList,
AppHint $appHint,
IInitialState $initialState,
Defaults $theming,
private IConfig $config,
private IAppConfig $appConfig,
private IUserSession $userSession,
private IJobList $jobList,
private AppHint $appHint,
private IInitialState $initialState,
private Defaults $theming,
) {
$this->userSession = $userSession;
$this->config = $config;
Expand All @@ -92,14 +72,16 @@ public function handle(Event $event): void {
return;
}

if ($this->config->getUserValue($user->getUID(), Application::APP_ID, 'show', '1') !== '0') {
Util::addScript(Application::APP_ID, Application::APP_ID . '-activate');
if ($this->appConfig->getAppValueBool('wizard_enabled', true)) {
if ($this->config->getUserValue($user->getUID(), Application::APP_ID, 'show', '1') !== '0') {
Util::addScript(Application::APP_ID, Application::APP_ID . '-activate');

$this->jobList->add('OCA\FirstRunWizard\Notification\BackgroundJob', ['uid' => $this->userSession->getUser()->getUID()]);
}
$this->jobList->add('OCA\FirstRunWizard\Notification\BackgroundJob', ['uid' => $this->userSession->getUser()->getUID()]);
}

if ($this->config->getSystemValueBool('appstoreenabled', true)) {
$this->appHint->sendAppHintNotifications();
if ($this->config->getSystemValueBool('appstoreenabled', true)) {
$this->appHint->sendAppHintNotifications();
}
}

Util::addScript(Application::APP_ID, Application::APP_ID . '-about');
Expand Down

0 comments on commit b38d715

Please sign in to comment.