Repository navigation
Conversation
Codecov Report
@@ Coverage Diff @@
## master #29747 +/- ##
============================================
+ Coverage 60.46% 60.51% +0.05%
- Complexity 18360 18370 +10
============================================
Files 1089 1090 +1
Lines 60893 60931 +38
============================================
+ Hits 36818 36872 +54
+ Misses 24075 24059 -16
Continue to review full report at Codecov.
|
|
@DeepDiver1975 in the current state it works and passes all the tests. |
|
@DeepDiver1975 plz disregard the previous comment. |
|
@PVince81 IMHO it's better to disable the currently active theme instead of blocking a new one. Another thing: as soon as it is not possible to have multiple themes, we should consider adding |
@VicDeo in any case we need a warning to tell the admin whatever happened. |
it's done. For now I did it as suggested: second theme can't be enabled with a warning. |
|
Failing tests are related to CI itself: |
fcdc5d9 to
df3848a
Compare
PVince81
left a comment
There was a problem hiding this comment.
Looks good overall, see comments for a few minor things.
Great to see so many tests!
| $output->writeln($appId . ' enabled for groups: ' . implode(', ', $groups)); | ||
| } | ||
| } catch (\Exception $e) { | ||
| $output->writeln($e->getMessage()); |
There was a problem hiding this comment.
log the stack trace to avoid future headaches ?
There was a problem hiding this comment.
@PVince81 Possible. But is t really needed for CLI command?
There was a problem hiding this comment.
Once people start reporting bugs and you don't have the stack trace at all, this will become painful...
There was a problem hiding this comment.
just dont catch the exception then - afaik the symfony console will print the stack ...
| OC::handleRequest(); | ||
|
|
||
| } catch(\OC\ServiceUnavailableException $ex) { | ||
| \OC::loadDefaultEnabledAppTheme(); |
| if(OC_App::getAppPath($appId) === false) { | ||
| throw new \Exception("$appId can't be enabled since it is not installed."); | ||
| } | ||
| $this->canEnableTheme($appId); |
There was a problem hiding this comment.
return boolean and throw here ? just reading this line makes it look like a mistake as it asks can but doesn't check the result.
Since you're using this function only once I think it's better to do the boolean thing.
There was a problem hiding this comment.
@PVince81 This is what I was going to do initially. TBH I don't remember why I decided to do it this way finally.
May be due to Scrutinizer's pessimization for methods with too many decision points. (Yes, I look into the code analisys results :) )
There was a problem hiding this comment.
@PVince81 a-ha. It allows to produce more descriptive exception message (with the blocking app-theme appid). Just by returning false this appid would be lost
There was a problem hiding this comment.
I mean the current message contains both blocking and blocked appIds: new-shiny-theme can't be enabled until old-bloody-theme is disabled.
| $apps = $this->getInstalledApps(); | ||
| foreach ($apps as $installedAppId) { | ||
| if ($this->isTheme($installedAppId)) { | ||
| throw new \Exception("$appId can't be enabled until $installedAppId is disabled."); |
There was a problem hiding this comment.
We might have some fantastic app manager specific exceptions, maybe one would suit here ?
There was a problem hiding this comment.
@PVince81 There is no specific subclass. Would generic AppManagerException be enough?
There was a problem hiding this comment.
that would already be better
587eae2 to
1ac6f9e
Compare
|
@PVince81 all except |
| * @param ILogger $logger | ||
| */ | ||
| public function __construct(IAppManager $manager) { | ||
| public function __construct(IAppManager $manager, ILogger $logger) { |
There was a problem hiding this comment.
from my pov a occ command shall not use the logger but print anything to the console
There was a problem hiding this comment.
@DeepDiver1975 please discuss this with @PVince81 as he requested logging :)
There was a problem hiding this comment.
@PVince81 whats the background here? its actually easier for the user to see any error/exception in the console and not to look it up in the log file.
There was a problem hiding this comment.
as long as the stack trace appears somewhere we're fine
There was a problem hiding this comment.
thanks, removing logging along with try/catch
| protected function canEnableTheme($appId) { | ||
| $info = $this->getAppInfo($appId); | ||
| if ( | ||
| isset($info['types']) |
There was a problem hiding this comment.
isset($info['types']['theme']) - keep is simple
There was a problem hiding this comment.
@DeepDiver1975 it'snot possible this way because 'theme' is not a key but a value:
array(20) {
'id' => string(16) "theme-enterprise"
'name' => string(27) "ownCloud X Enterprise Theme"
'types' =>
array(1) {
[0] => string(5) "theme"
}
$info['types'][0] = 'theme', not $info['types']['theme'] = 'something'
| protected function canEnableTheme($appId) { | ||
| $info = $this->getAppInfo($appId); | ||
| if ( | ||
| isset($info['types']) |
There was a problem hiding this comment.
isset($info['types']['theme']) - keep is simple
| $relativePath = substr($dir, strlen($this->serverRoot)); | ||
| $themeDir = $this->getActiveThemeDirectory(); | ||
| if ($themeDir !== '') { | ||
| $themeDir .= $relativePath; |
There was a problem hiding this comment.
/ is guaranteed to be in place here?
There was a problem hiding this comment.
yep $relativePath = substr($dir, strlen($this->serverRoot)); where $this->serverRoot is actually OC::$SERVERROOT. As soon as OC::$SERVERROOT has no trailing slash $relativePath always starts with a slash.
In addition it is covered by a newly added FactoryTest::testFindAvailableLanguagesWithAppThemes test.
| protected $config; | ||
|
|
||
| /** @var IAppConfig */ | ||
| protected $appConfig; |
There was a problem hiding this comment.
since you already have IConfig - there is not need for appConfig
There was a problem hiding this comment.
@DeepDiver1975 I do need appConfig to get all appIds along with their types (appIds are filtered by type theme afterwards) https://github.com/owncloud/core/pull/29747/files#diff-cdbcd54405a2b5684c9aed2c1824d7f8R94
$appTypes = $this->appConfig->getValues(false, 'types');
There was a problem hiding this comment.
this does not exist in IConfig? brilliant ...
|
@DeepDiver1975 thanks, addressed/responded |
|
Stable10: #29854 |
|
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Description
Fixes custom translations inside app-themes.
TODO:
default_enabledattributeA migration step that
->setSystemValue('theme', '')currently the last (alphabetically) app-theme wins. So the latest theme should stay active.
Related Issue
Fixes
#28167
https://github.com/owncloud/theme-enterprise/issues/16
Motivation and Context
How Has This Been Tested?
Test 1
mkdir -p apps/theme-example/core/l10ncp core/l10n/en_GB.json apps/theme-example/core/l10n/en_GB.json"Log out" : "Log out",to
"Log out" : "Go away!",Expected
Log out is renamed in menu
Actual
it is not
Tested as a guest
Please note that guest user uses a language based on browser locale settings.
You'll need to override another file (es.json, de.json, whatever...) instead of en_GB.json if your browser is not in en_GB
Accessing an unexisting share - translation works
Accessing a login page - translation works
Test 2
Expected
It can't be enabled until the current theme is active
Actual
Both themes are enabled, theme that is the last according to the alphabet is loaded.
Types of changes
Checklist: