Skip to content

Commit

Permalink
fix(3rd-party apps): do not link to maps/recognize install page if th…
Browse files Browse the repository at this point in the history
…e appstore isn't enabled

Even if the user is admin, they might not have access to the app store.

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
  • Loading branch information
tcitworld committed Apr 12, 2024
1 parent c08710c commit f2fcfb4
Show file tree
Hide file tree
Showing 19 changed files with 80 additions and 25 deletions.
4 changes: 2 additions & 2 deletions js/photos-dashboard.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/photos-dashboard.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions js/photos-main.js

Large diffs are not rendered by default.

23 changes: 23 additions & 0 deletions js/photos-main.js.LICENSE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,29 @@
*
*/

/**
* @copyright Copyright (c) 2018 John Molakvoæ <skjnldsv@protonmail.com>
*
* @author John Molakvoæ <skjnldsv@protonmail.com>
* @author Thomas Citharel <nextcloud@tcit.fr>
*
* @license AGPL-3.0-or-later
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/

/**
* @copyright Copyright (c) 2019 Georg Ehrke
*
Expand Down
2 changes: 1 addition & 1 deletion js/photos-main.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions js/photos-public.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/photos-public.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions js/photos-sidebar.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/photos-sidebar.js.map

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions lib/Controller/PageController.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* @copyright Copyright (c) 2019 John Molakvoæ <skjnldsv@protonmail.com>
*
* @author John Molakvoæ <skjnldsv@protonmail.com>
* @author Thomas Citharel <nextcloud@tcit.fr>
*
* @license AGPL-3.0-or-later
*
Expand Down Expand Up @@ -113,6 +114,7 @@ public function index(): TemplateResponse {
$this->initialState->provideInitialState('recognize', $this->appManager->isEnabledForUser('recognize') === true);
$this->initialState->provideInitialState('systemtags', $this->appManager->isEnabledForUser('systemtags') === true);
$this->initialState->provideInitialState('showPeopleMenuEntry', $this->config->getAppValue('photos', 'showPeopleMenuEntry', 'true') === 'true');
$this->initialState->provideInitialState('appStoreEnabled', $this->config->getSystemValueBool('appstoreenabled', true));

// Provide user config
foreach (array_keys(UserConfigService::DEFAULT_CONFIGS) as $key) {
Expand Down
6 changes: 4 additions & 2 deletions src/Photos.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
- @copyright Copyright (c) 2019 John Molakvoæ <skjnldsv@protonmail.com>
-
- @author John Molakvoæ <skjnldsv@protonmail.com>
- @author Thomas Citharel <nextcloud@tcit.fr>
-
- @license AGPL-3.0-or-later
-
Expand Down Expand Up @@ -158,6 +159,7 @@ import videoplaceholder from './assets/video.svg'
import areTagsInstalled from './services/AreTagsInstalled.js'
import isMapsInstalled from './services/IsMapsInstalled.js'
import isRecognizeInstalled from './services/IsRecognizeInstalled.js'
import isAppStoreEnabled from './services/IsAppStoreEnabled.js'
import logger from './services/logger.js'
export default {
Expand Down Expand Up @@ -193,10 +195,10 @@ export default {
showLocationMenuEntry: getCurrentUser() === null
? false
: getCurrentUser().isAdmin || isMapsInstalled,
: getCurrentUser().isAdmin && isAppStoreEnabled || isMapsInstalled,

Check failure on line 198 in src/Photos.vue

View workflow job for this annotation

GitHub Actions / NPM lint

Unexpected mix of '&&' and '||'. Use parentheses to clarify the intended order of operations

Check failure on line 198 in src/Photos.vue

View workflow job for this annotation

GitHub Actions / NPM lint

Unexpected mix of '&&' and '||'. Use parentheses to clarify the intended order of operations
showPeopleMenuEntry: getCurrentUser() === null
? false
: (getCurrentUser().isAdmin && loadState('photos', 'showPeopleMenuEntry', true)) || isRecognizeInstalled,
: (getCurrentUser().isAdmin && loadState('photos', 'showPeopleMenuEntry', true)) && isAppStoreEnabled || isRecognizeInstalled,

Check failure on line 201 in src/Photos.vue

View workflow job for this annotation

GitHub Actions / NPM lint

Unexpected mix of '&&' and '||'. Use parentheses to clarify the intended order of operations

Check failure on line 201 in src/Photos.vue

View workflow job for this annotation

GitHub Actions / NPM lint

Unexpected mix of '&&' and '||'. Use parentheses to clarify the intended order of operations
openedSettings: false,
}
Expand Down
6 changes: 4 additions & 2 deletions src/router/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* @copyright Copyright (c) 2018 John Molakvoæ <skjnldsv@protonmail.com>
*
* @author John Molakvoæ <skjnldsv@protonmail.com>
* @author Thomas Citharel <nextcloud@tcit.fr>
*
* @license AGPL-3.0-or-later
*
Expand Down Expand Up @@ -29,6 +30,7 @@ import areTagsInstalled from '../services/AreTagsInstalled.js'
import { imageMimes, videoMimes } from '../services/AllowedMimes.js'

import isRecognizeInstalled from '../services/IsRecognizeInstalled.js'
import isAppStoreEnabled from '../services/IsAppStoreEnabled.js'

const Folders = () => import('../views/Folders.vue')
const Albums = () => import('../views/Albums.vue')
Expand All @@ -51,7 +53,7 @@ const baseTitle = document.title
Vue.use(Router)

let mapsPath = generateUrl('/apps/maps')
if (!isMapsInstalled) {
if (!isMapsInstalled && isAppStoreEnabled) {
mapsPath = generateUrl('/settings/apps/integration/maps')
}

Expand Down Expand Up @@ -289,7 +291,7 @@ const router = new Router({
path: '/faces',
name: 'faces',
component: Faces,
...((!isRecognizeInstalled) && {
...((!isRecognizeInstalled && isAppStoreEnabled) && {
beforeEnter() {
const recognizeInstallLink = generateUrl('/settings/apps/installed/recognize')
window.open(recognizeInstallLink, '_blank')
Expand Down
26 changes: 26 additions & 0 deletions src/services/IsAppStoreEnabled.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/**
* @copyright Copyright (c) 2024 Thomas Citharel <nextcloud@tcit.fr>
*
* @author Thomas Citharel <nextcloud@tcit.fr>
*
* @license AGPL-3.0-or-later
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/

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

const appStoreEnabled = loadState('photos', 'appStoreEnabled')
export default appStoreEnabled

0 comments on commit f2fcfb4

Please sign in to comment.