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 <[email protected]>
  • Loading branch information
tcitworld committed Apr 15, 2024
1 parent c08710c commit 4c2f100
Show file tree
Hide file tree
Showing 17 changed files with 53 additions and 23 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.

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æ <[email protected]>
*
* @author John Molakvoæ <[email protected]>
* @author Thomas Citharel <[email protected]>
*
* @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æ <[email protected]>
- @author Thomas Citharel <[email protected]>
-
- @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,
showPeopleMenuEntry: getCurrentUser() === null
? false
: (getCurrentUser().isAdmin && loadState('photos', 'showPeopleMenuEntry', true)) || isRecognizeInstalled,
: (getCurrentUser().isAdmin && loadState('photos', 'showPeopleMenuEntry', true) && isAppStoreEnabled) || isRecognizeInstalled,

openedSettings: false,
}
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 <[email protected]>
*
* @author Thomas Citharel <[email protected]>
*
* @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 4c2f100

Please sign in to comment.