Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Nextcloud
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Monitor
Service Desk
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TeDomum
Nextcloud
Commits
7c69c117
Unverified
Commit
7c69c117
authored
7 years ago
by
Julius Härtl
Committed by
Morris Jobke
7 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Delete theming images when logo/background is reset to default
Signed-off-by:
Julius Härtl
<
jus@bitgrid.net
>
parent
4518f6dc
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
apps/theming/lib/Controller/ThemingController.php
+19
-0
19 additions, 0 deletions
apps/theming/lib/Controller/ThemingController.php
apps/theming/tests/Controller/ThemingControllerTest.php
+50
-0
50 additions, 0 deletions
apps/theming/tests/Controller/ThemingControllerTest.php
with
69 additions
and
0 deletions
apps/theming/lib/Controller/ThemingController.php
+
19
−
0
View file @
7c69c117
...
...
@@ -40,6 +40,7 @@ use OCP\AppFramework\Utility\ITimeFactory;
use
OCP\Files\File
;
use
OCP\Files\IAppData
;
use
OCP\Files\NotFoundException
;
use
OCP\Files\NotPermittedException
;
use
OCP\IConfig
;
use
OCP\IL10N
;
use
OCP\ILogger
;
...
...
@@ -265,6 +266,24 @@ class ThemingController extends Controller {
$value
=
$this
->
themingDefaults
->
undo
(
$setting
);
// reprocess server scss for preview
$cssCached
=
$this
->
scssCacher
->
process
(
\OC
::
$SERVERROOT
,
'/core/css/server.scss'
,
'core'
);
if
(
$setting
===
'logoMime'
)
{
try
{
$file
=
$this
->
appData
->
getFolder
(
'images'
)
->
getFile
(
'logo'
);
$file
->
delete
();
}
catch
(
NotFoundException
$e
)
{
}
catch
(
NotPermittedException
$e
)
{
}
}
if
(
$setting
===
'backgroundMime'
)
{
try
{
$file
=
$this
->
appData
->
getFolder
(
'images'
)
->
getFile
(
'background'
);
$file
->
delete
();
}
catch
(
NotFoundException
$e
)
{
}
catch
(
NotPermittedException
$e
)
{
}
}
return
new
DataResponse
(
[
'data'
=>
...
...
This diff is collapsed.
Click to expand it.
apps/theming/tests/Controller/ThemingControllerTest.php
+
50
−
0
View file @
7c69c117
...
...
@@ -385,6 +385,56 @@ class ThemingControllerTest extends TestCase {
$this
->
assertEquals
(
$expected
,
$this
->
themingController
->
undo
(
'MySetting'
));
}
public
function
dataUndoDelete
()
{
return
[
[
'backgroundMime'
,
'background'
],
[
'logoMime'
,
'logo'
]
];
}
/** @dataProvider dataUndoDelete */
public
function
testUndoDelete
(
$value
,
$filename
)
{
$this
->
l10n
->
expects
(
$this
->
once
())
->
method
(
't'
)
->
with
(
'Saved'
)
->
willReturn
(
'Saved'
);
$this
->
themingDefaults
->
expects
(
$this
->
once
())
->
method
(
'undo'
)
->
with
(
$value
)
->
willReturn
(
$value
);
$folder
=
$this
->
createMock
(
ISimpleFolder
::
class
);
$file
=
$this
->
createMock
(
ISimpleFile
::
class
);
$this
->
appData
->
expects
(
$this
->
once
())
->
method
(
'getFolder'
)
->
with
(
'images'
)
->
willReturn
(
$folder
);
$folder
->
expects
(
$this
->
once
())
->
method
(
'getFile'
)
->
with
(
$filename
)
->
willReturn
(
$file
);
$file
->
expects
(
$this
->
once
())
->
method
(
'delete'
);
$expected
=
new
DataResponse
(
[
'data'
=>
[
'value'
=>
$value
,
'message'
=>
'Saved'
,
],
'status'
=>
'success'
]
);
$this
->
assertEquals
(
$expected
,
$this
->
themingController
->
undo
(
$value
));
}
public
function
testGetLogoNotExistent
()
{
$this
->
appData
->
method
(
'getFolder'
)
->
with
(
$this
->
equalTo
(
'images'
))
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment