Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add initialstate provider #1004

Merged
merged 2 commits into from
Nov 17, 2023
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
4 changes: 2 additions & 2 deletions js/firstrunwizard-main.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/firstrunwizard-main.js.map

Large diffs are not rendered by default.

29 changes: 28 additions & 1 deletion lib/Listener/BeforeTemplateRenderedListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,11 @@
use OCA\FirstRunWizard\Notification\AppHint;
use OCP\AppFramework\Http\Events\BeforeTemplateRenderedEvent;
use OCP\BackgroundJob\IJobList;
use OCP\Defaults;
use OCP\EventDispatcher\Event;
use OCP\EventDispatcher\IEventListener;
use OCP\IConfig;
use OCP\AppFramework\Services\IInitialState;
use OCP\IUser;
use OCP\IUserSession;
use OCP\Util;
Expand All @@ -55,16 +57,26 @@ class BeforeTemplateRenderedListener implements IEventListener {
*/
private $jobList;

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

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

public function __construct(
IConfig $config,
IUserSession $userSession,
IJobList $jobList,
AppHint $appHint
AppHint $appHint,
IInitialState $initialState,
Defaults $theming,
) {
$this->userSession = $userSession;
$this->config = $config;
$this->appHint = $appHint;
$this->jobList = $jobList;
$this->initialState = $initialState;
$this->theming = $theming;
}

public function handle(Event $event): void {
Expand All @@ -88,5 +100,20 @@ public function handle(Event $event): void {
}

Util::addScript(Application::APP_ID, 'about');

$this->initialState->provideInitialState(
'desktop',
$this->config->getSystemValue('customclient_desktop', $this->theming->getSyncClientUrl())
);

$this->initialState->provideInitialState(
'android',
$this->config->getSystemValue('customclient_android', $this->theming->getAndroidClientUrl())
);

$this->initialState->provideInitialState(
'ios',
$this->config->getSystemValue('customclient_ios', $this->theming->getiOSClientUrl())
);
}
}
15 changes: 13 additions & 2 deletions src/components/AppStoreBadge.vue
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,22 @@

<script>
import { imagePath } from '@nextcloud/router'
import { loadState } from '@nextcloud/initial-state'

const android = loadState('firstrunwizard', 'android')
const ios = loadState('firstrunwizard', 'ios')

export default {
name: 'AppStoreBadge',

data() {
return {
android,
ios,
}
},

props: {

Check warning on line 50 in src/components/AppStoreBadge.vue

View workflow job for this annotation

GitHub Actions / eslint

The "props" property should be above the "data" property on line 43
type: {
type: String,
required: true,
Expand All @@ -60,9 +71,9 @@

href() {
if (this.type === 'ios') {
return 'https://geo.itunes.apple.com/us/app/nextcloud/id1125420102?mt=8'
return this.ios
} else if (this.type === 'android') {
return 'https://play.google.com/store/apps/details?id=com.nextcloud.client'
return this.android
}
return undefined
},
Expand Down
6 changes: 5 additions & 1 deletion src/components/Page2.vue
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
<div class="page__content">
<AppStoreBadge type="android" />
<AppStoreBadge type="ios" />
<Card href="https://nextcloud.com/install/#install-clients"
<Card :href="desktop"
:title="t('firstrunwizard', 'Desktop app ↗')"
:subtitle="t('firstrunwizard', 'Download For Windows, Mac OS and Linux.')" />
<Card :href="syncClientsUrl"
Expand All @@ -58,6 +58,9 @@ import AppStoreBadge from './AppStoreBadge.vue'
import ArrowRight from 'vue-material-design-icons/ArrowRight.vue'
import { NcButton } from '@nextcloud/vue'
import { generateUrl } from '@nextcloud/router'
import { loadState } from '@nextcloud/initial-state'

const desktop = loadState('firstrunwizard', 'desktop')

export default {
name: 'Page2',
Expand All @@ -73,6 +76,7 @@ export default {
return {
subtitleText: t('firstrunwizard', 'Sync your files across your devices with the desktop and mobile apps, and connect your calendar and contacts.'),
syncClientsUrl: generateUrl('settings/user/sync-clients'),
desktop,
}
},

Expand Down
Loading