Conversation
| @@ -53,4 +53,6 @@ public function getPriority(); | |||
| */ | |||
| public function getIconName(); | |||
There was a problem hiding this comment.
I think let's kill the name and just keep the url and we'll make it backwards compatible
| 'name' => ucfirst($section->getName()), | ||
| 'active' => $section->getID() === $currentSectionID, | ||
| 'icon' => $section->getIconName() | ||
| 'icon' => $section->getIconName(), |
There was a problem hiding this comment.
so we can get rid of this also
lib/private/legacy/app.php
Outdated
| $url = strstr($fileAbsolutePath, \OC::$WEBROOT); | ||
| return $url; | ||
| } | ||
|
|
There was a problem hiding this comment.
nooooo more static ;) Why do we need to do this copying stuff?
There was a problem hiding this comment.
The intention behind this change was to fetch the data from the web url and download to apps/img folder. Anything wrong?
lib/private/Settings/Section.php
Outdated
|
|
||
| public function getIconUrl() { | ||
| return \OC_App::getIconFromUrl($this->url, $this->getID()); | ||
| } |
There was a problem hiding this comment.
I think we could use the urlgenerator here, injected in properly
d8b4dde to
5050bcb
Compare
5050bcb to
d7306ae
Compare
lib/private/Settings/Section.php
Outdated
There was a problem hiding this comment.
we can pass in the urlgenerator here - then adjust the constructor to pass it in in \OC\Settings\SettingsManager
lib/private/Settings/Section.php
Outdated
There was a problem hiding this comment.
use passed in urlgenerator. Also, the Id is not necessarily the app id so might need some thought here
settings/templates/settingsPage.php
Outdated
There was a problem hiding this comment.
we may as well standardise the core icons. So always pass a url. In the controller figure out if its a core icon or not. Then we can remove these crappy css rules for the icons
d7306ae to
570cb64
Compare
lib/public/Settings/ISection.php
Outdated
There was a problem hiding this comment.
and we should keep the old method, but add @deprecated from 10.0.4. But this shoudl also be backwards compatible. So inside the section implementation, set $this->url using the url generator - don't need to worry about injection for this backwards compat
There was a problem hiding this comment.
So if we add @deprecated for getIconName in ISection then, I think we will end up having both getIconName and getIconUrl. Because the apps which will be implementing ISection would need to implement both the methods.
So ideally if we don't want to deprecate it, then may be we can have getIconName. And make it app developers responsibility to get the url to be generated and returned from getIconName(), instead of just returning the icon name which it does currently.
570cb64 to
8835320
Compare
lib/public/Settings/ISection.php
Outdated
| /** | ||
| * @since 10.0 | ||
| * @return string | ||
| * @deprecated since 10.0.4 |
|
fff6f2a to
2b5898f
Compare
lib/public/Settings/ISection.php
Outdated
| * @return string | ||
| */ | ||
| public function getIconName(); | ||
| public function getIconUrl(); |
There was a problem hiding this comment.
I don't like this - this will break all existing implementations 👎
There was a problem hiding this comment.
We should implement this more in sense where the returned icon name can either be a css class (as done until today) or an image name of the app which hosts the svg.
this way we don't need to change apis and implementation all over the place.
$icon = $section->getIconName();
if (file_exists("$appPath/img/$icon.svg")) {
$url = $urlGenerator->imagePath("$icon.svg");
// TODO: add background styling hack
} else {
// TODO: add icon css class
}2b5898f to
b66a621
Compare
b66a621 to
5225596
Compare
| $appPath = \OC_App::getAppPath($section->getID()); | ||
|
|
||
| if (file_exists($appPath . '/img/' . $icon)) { | ||
| $icon = \OC::$server->getURLGenerator()->imagePath($section->getID(), $icon); |
There was a problem hiding this comment.
The URLGenerator should be injected in the constructor
| // Iterate through sections and get id, name and see if currently active | ||
| foreach($sections as $section) { | ||
|
|
||
| $icon = $section->getIconName() . '.svg'; |
There was a problem hiding this comment.
Move this "getIcon" code to another function and call it here. This logic should be probably out of this class so we can unittest it properly. If there is no place for this, it should be fine to create a private function here in the short term.
In addition, I think there is already a function to retrieve icons for apps (I might be wrong) Any reason to not use it?
In the phpdoc of the new function (whenever is placed) include how the function should behave. Right now I'm not sure what is the expected behaviour if several icons are provided: if I want to use "marvellous_icon.png", why I'm checking "marvellous_icon.png.svg"?
If only .svg files are supported, make sure this is known, including in the comments of the function.
Since I have no idea what is the expected behaviour here, I'm more inclined to think the current behaviour is buggy.
There was a problem hiding this comment.
A couple of extra things:
- Unless the icon name is already sanitized, make sure it doesn't contain
/../or something similar - I'm not sure what is the "default" expectation: I guess it should be using the filename without extension as icon name (which is fine). In any case, optimize for this default case. If the default is to include the extension you'd be checking for a missing file constantly. Just something to take care of.
settings/templates/settingsPage.php
Outdated
| <?php foreach($_['personalNav'] as $item) { | ||
| $active = $item['active'] ? ' active ' : ''; | ||
|
|
||
| $ocUrlorIcon = \OCP\Util::sanitizeHTML($item['icon']); |
There was a problem hiding this comment.
This could be a good time to rewrite this piece to just use this as a template and avoid adding logic here.
There was a problem hiding this comment.
Agreed. Can we do this as a separate PR?
There was a problem hiding this comment.
I don't really mind, but there will be conflicts with this PR if t isn't merged soon because that code will depend on this branch... @tomneedham @DeepDiver1975 opinions?
There was a problem hiding this comment.
do it in here - own commit for now to see the diff ... later we squash
There was a problem hiding this comment.
Moved the logic from here to https://github.com/owncloud/core/pull/29013/files#diff-3393e43384d070ab12865348f9279030R123. I hope this makes sense now.
b2d04f0 to
204fff3
Compare
|
The rewrite I had in mind was more like: Maybe we can make it smaller injecting "active" or an empty string instead of checking if the |
204fff3 to
b85a585
Compare
|
@jvillafanez I have updated the change let me know if this ok. |
b85a585 to
d40e54d
Compare
settings/templates/settingsPage.php
Outdated
There was a problem hiding this comment.
\OCP\Util::sanitizeHTML(...) isn't needed with the p function
There was a problem hiding this comment.
Removed the call to sanitizeHTML
settings/templates/settingsPage.php
Outdated
There was a problem hiding this comment.
indentation here seems misplaced
d40e54d to
28f74bd
Compare
|
@jvillafanez Corrected indentation and removed call to |
jvillafanez
left a comment
There was a problem hiding this comment.
Code looks good to me, not tested.
|
Tested the code by replacing icon |
28f74bd to
0e0d71e
Compare
Codecov Report
@@ Coverage Diff @@
## master #29013 +/- ##
============================================
+ Coverage 60.21% 60.23% +0.01%
- Complexity 17182 17184 +2
============================================
Files 1030 1030
Lines 57271 57263 -8
============================================
+ Hits 34485 34491 +6
+ Misses 22786 22772 -14
Continue to review full report at Codecov.
|
This change helps users to provide their own custom icons for the apps which work with ownCloud. Signed-off-by: Sujith H <sharidasan@owncloud.com>
0e0d71e to
cdd2692
Compare
| new Section('workflow', $this->l->t('Workflows & Tags'), 85, 'workflows'), | ||
| new Section('sharing', $this->l->t('Sharing'), 80, 'share'), | ||
| new Section('search', $this->l->t('Search'), 75, 'search'), | ||
| new Section('updates', $this->l->t('Updates'), 20, 'update'), |
There was a problem hiding this comment.
While searching for update.svg, I couldn't find at core. That made me remove this line. I can revert back the change, if my finding was wrong.
There was a problem hiding this comment.
Thanks for the explanation, I just wanted to double check that this wasn't a mistake. Let's keep it.
|
@sharidas please backport |
|
Created backport PR: #29358 |
|
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. |



This change helps users to provide their own
custom icons for the apps which work with
ownCloud.
Signed-off-by: Sujith H sharidasan@owncloud.com
Description
This change helps contributors to use non-hardcoded icons. That is every app developer or contributor can now have their own separate icons which can be used with core.
Related Issue
#28751
Motivation and Context
At present the icons are hard coded and are located at core. This prohibits the usage of custom icons for apps. With this change, contributors of apps, can have their own custom app which can be used along with core. No more saving of svg files in the core.
How Has This Been Tested?
I have verified it against 2 apps. One is encryption app ( the change was made in the SettingsManager.php) and another app was firewall app. For the firewall app I modified the AdminSection.php to test.
Screenshots (if appropriate):
Types of changes
Checklist: