diff --git a/.travis.yml b/.travis.yml index 08fe22d8..5da0c874 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,8 +18,7 @@ branches: - /^stable\d+(\.\d+)?$/ before_install: - - nvm install node - - npm install -g npm@latest + - nvm install --lts - composer install - wget https://raw.githubusercontent.com/owncloud/administration/master/travis-ci/before_install.sh - bash ./before_install.sh $APP_NAME $CORE_BRANCH $DB diff --git a/appinfo/routes.php b/appinfo/routes.php index cb44ea68..2edcd4b8 100644 --- a/appinfo/routes.php +++ b/appinfo/routes.php @@ -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 diff --git a/lib/Controller/MarketController.php b/lib/Controller/MarketController.php index 9b2fc569..c84029bf 100644 --- a/lib/Controller/MarketController.php +++ b/lib/Controller/MarketController.php @@ -29,6 +29,7 @@ use OCP\AppFramework\Http\DataResponse; use OCP\IL10N; use OCP\IRequest; +use OCP\IConfig; class MarketController extends Controller { @@ -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; } /** @@ -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->marketService->canInstall(), + 'hasInternetConnection' => $this->config->getSystemValue('has_internet_connection', true), + 'licenseKeyAvailable' => $licenseKeyAvailable, + 'licenseMessage' => $licenseMessage + ]; + + return new DataResponse($config, Http::STATUS_OK); } /** diff --git a/npm-shrinkwrap.json b/npm-shrinkwrap.json index dd10b872..fe1f6502 100644 --- a/npm-shrinkwrap.json +++ b/npm-shrinkwrap.json @@ -4596,9 +4596,9 @@ "resolved": "https://registry.npmjs.org/uglify-to-browserify/-/uglify-to-browserify-1.0.2.tgz" }, "uikit": { - "version": "3.0.0-beta.30", - "from": "uikit@3.0.0-beta.30", - "resolved": "https://registry.npmjs.org/uikit/-/uikit-3.0.0-beta.30.tgz" + "version": "3.0.0-beta.34", + "from": "uikit@latest", + "resolved": "https://registry.npmjs.org/uikit/-/uikit-3.0.0-beta.34.tgz" }, "undefsafe": { "version": "0.0.3", diff --git a/package.json b/package.json index 9e544802..0fba7c50 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,7 @@ "showdown": "^1.7.6", "style-loader": "0.16.1", "uglify-js": "3.1.3", - "uikit": "3.0.0-beta.30", + "uikit": "3.0.0-beta.34", "underscore": "1.8.3", "vue": "2.4.4", "vue-gettext": "2.0.23", diff --git a/src/App.vue b/src/App.vue index 6f8a67f8..1f186c71 100644 --- a/src/App.vue +++ b/src/App.vue @@ -1,35 +1,56 @@ \ No newline at end of file diff --git a/src/components/Trial.vue b/src/components/Trial.vue index 68f89224..83d6b6f0 100644 --- a/src/components/Trial.vue +++ b/src/components/Trial.vue @@ -1,6 +1,6 @@ @@ -59,15 +56,12 @@ .then(this.$router.push({ name: 'Bundles' })) .catch(() => { console.warn('REQUEST_LICENSE_KEY failed') - }) + }); } }, - mounted () { - this.$store.dispatch('CHECK_LICENSE_KEY'); - }, computed : { - licenseKeyExists () { - return this.$store.state.licenseKey.exists; + config() { + return this.$store.getters.config }, apiKeyExists () { @@ -75,15 +69,7 @@ return this.$store.state.apikey.key.length > 0; return false; - }, - - loading () { - return this.$store.state.licenseKey.loading; - }, - - unborn () { - return this.$store.state.licenseKey.unborn; - }, + } } } diff --git a/src/store.js b/src/store.js index 973316b8..d54071a0 100644 --- a/src/store.js +++ b/src/store.js @@ -6,6 +6,9 @@ import _ from "underscore"; Vue.use(Vuex); const state = { + + config: {}, + categories: { loading: false, failed: false, @@ -31,18 +34,17 @@ const state = { changeable : false }, - licenseKey : { - exists : false, - loading : false, - unborn: true - }, - processing: [], installed: [] }; // Retrieve computed values from state. const getters = { + + config (state) { + return state.config; + }, + categories (state) { return state.categories.records; }, @@ -98,6 +100,11 @@ const getters = { // Manipulate from the current state. const mutations = { + + CONFIG (state, changes) { + state["config"] = changes; + }, + LOADING_APPLICATIONS (state) { _.extend(state["applications"], { loading: true, @@ -120,10 +127,6 @@ const mutations = { }) }, - LICENSE_KEY (state, changes) { - _.extend(state["licenseKey"], changes); - }, - SET_APPLICATIONS (state, content) { _.extend(state["applications"], { records: content @@ -281,36 +284,19 @@ const actions = { }); }, - CHECK_LICENSE_KEY (context) { - Axios.get(OC.generateUrl("/apps/market/has-license-key")) - .then(() => { - context.commit("LICENSE_KEY", { "exists" : true, "unborn" : false }); - }) - .catch(() => { - context.commit("LICENSE_KEY", { "exists" : false, "unborn" : false }); - }); - }, - REQUEST_LICENSE_KEY (context) { - context.commit("LICENSE_KEY", {"loading": true }); - return Axios.get(OC.generateUrl("/apps/market/request-license-key-from-market")) .then((response) => { - context.commit("LICENSE_KEY", { - "loading": false, - "exists" : true, - "unborn" : false + context.dispatch('FETCH_CONFIG'); + UIkit.notification(error.response.data.message, { + status : "success", + pos : "bottom-right" }); }) .catch((error) => { - context.commit("LICENSE_KEY", { - "loading": false, - "exists" : false, - "unborn" : false - }); UIkit.notification(error.response.data.message, { - status:"danger", - pos: "bottom-right" + status : "danger", + pos : "bottom-right" }); return Promise.reject(error.response); @@ -389,6 +375,19 @@ const actions = { }); }, + FETCH_CONFIG (context) { + Axios.get(OC.generateUrl("/apps/market/config")) + .then((response) => { + context.commit("CONFIG", response.data); + }) + .catch((error) => { + UIkit.notification(error.response.data.message, { + status:"danger", + pos: "bottom-right" + }); + }); + }, + WRITE_APIKEY (context, payload) { let key = payload; context.commit("APIKEY", {"loading": true });