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 initial notice #184

Merged
merged 12 commits into from
Nov 10, 2017
2 changes: 1 addition & 1 deletion appinfo/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
['name' => 'market#uninstall', 'url' => '/apps/{appId}/uninstall', 'verb' => 'POST'],
['name' => 'market#getApiKey', 'url' => '/apikey', 'verb' => 'GET'],
['name' => 'market#changeApiKey', 'url' => '/apikey', 'verb' => 'PUT'],
['name' => 'market#hasLicenseKey', 'url' => '/has-license-key', 'verb' => 'GET'],
['name' => 'market#getConfig', 'url' => '/config', 'verb' => 'GET'],
['name' => 'market#requestDemoLicenseKeyFromMarket', 'url' => '/request-license-key-from-market', 'verb' => 'GET'],
['name' => 'market#invalidateCache', 'url' => '/cache/invalidate', 'verb' => 'POST'],
// local apps
Expand Down
36 changes: 21 additions & 15 deletions lib/Controller/MarketController.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
use OCP\AppFramework\Http\DataResponse;
use OCP\IL10N;
use OCP\IRequest;
use OCP\IConfig;

class MarketController extends Controller {

Expand All @@ -38,13 +39,18 @@ class MarketController extends Controller {
/** @var IL10N */
private $l10n;

/** @var IConfig */
private $config;

public function __construct($appName,
IRequest $request,
MarketService $marketService,
IL10N $l10n) {
IL10N $l10n,
IConfig $config) {
parent::__construct($appName, $request);
$this->marketService = $marketService;
$this->l10n = $l10n;
$this->config = $config;
}

/**
Expand Down Expand Up @@ -257,22 +263,22 @@ private function enrichApp($app) {
* @return string
* @NoCSRFRequired
*/
public function hasLicenseKey() {
if ($this->marketService->hasLicenseKey()) {
return new DataResponse(
[
'message' => $this->l10n->t('License key available.')
],
Http::STATUS_OK
);
public function getConfig() {
$licenseKeyAvailable = $this->marketService->hasLicenseKey();
if ($licenseKeyAvailable) {
$licenseMessage = $this->l10n->t('License key available.');
} else {
$licenseMessage = $this->l10n->t('No license key configured.');
}

return new DataResponse(
[
'message' => $this->l10n->t('No license key configured.')
],
Http::STATUS_NOT_FOUND
);
$config = [
'canInstall' => ($this->config->getSystemValue('operation.mode', 'single-instance') === 'single-instance'),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no - IAppManager::canInstall() is to be called - or better MarketService::canInstall

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

'hasInternetConnection' => ($this->config->getSystemValue('has_internet_connection', true)),
'licenseKeyAvailable' => $licenseKeyAvailable,
'licenseMessage' => $licenseMessage
];

return new DataResponse($config, Http::STATUS_OK);
}

/**
Expand Down
31 changes: 30 additions & 1 deletion src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,44 @@
navigation
trial

main.uk-width-expand
main.uk-width-expand(v-if="!showNotice")
router-view
section.uk-width-expand(v-else)
.uk-card.uk-card-default.uk-card-body.uk-width-xlarge.uk-align-center
h1.uk-card-title Notice
.uk-alert-danger(uk-alert)
p We recommend <strong>disabling the market app</strong> in a clustered environment.

p
| Installing and updating applications via the market app is not supportet.
br
| For more details, please visit&nbsp;
a.uk-text-primary(href="#") this Website
| .

hr.uk-hr
.uk-flex.uk-flex-middle
.uk-width-1-2.uk-text-left
label
input.uk-checkbox(type="checkbox", v-model="showNoticeOnStartup").uk-margin-small-right
| Show on startup

.uk-width-1-2.uk-text-right
button.uk-button.uk-button-default(type='button', @click="showNotice = false") Dissmiss

</template>

<script>
import Navigation from './components/Navigation.vue'
import Trial from './components/Trial.vue'

export default {
data () {
return {
"showNotice" : true,
"showNoticeOnStartup": true
}
},
mounted () {
this.$store.dispatch('FETCH_APPLICATIONS');
},
Expand Down