Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
scratch-www
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
scratch-www
Commits
1cace60e
Commit
1cace60e
authored
Jun 21, 2021
by
Paul Kaplan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix admin panel space remaining after logging out
parent
03ce4470
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
2 deletions
+19
-2
src/views/studio/studio-admin-panel.jsx
src/views/studio/studio-admin-panel.jsx
+5
-2
test/unit/components/studio-admin-panel.test.jsx
test/unit/components/studio-admin-panel.test.jsx
+14
-0
No files found.
src/views/studio/studio-admin-panel.jsx
View file @
1cace60e
...
...
@@ -48,8 +48,11 @@ const StudioAdminPanel = ({studioId, showAdminPanel}) => {
const
[
adminPanelOpen
,
setAdminPanelOpen
]
=
useState
(
getAdminPanelOpen
());
useEffect
(()
=>
{
storeAdminPanelOpen
(
adminPanelOpen
);
},
[
adminPanelOpen
]);
// This effect will both keep localStorage up-to-date AND cause
// the spacing to change to allow for the open admin panel, so make
// sure the admin panel should be visible at all before making any changes.
if
(
showAdminPanel
)
storeAdminPanelOpen
(
adminPanelOpen
);
},
[
showAdminPanel
,
adminPanelOpen
]);
useEffect
(()
=>
{
if
(
!
showAdminPanel
)
return
;
...
...
test/unit/components/studio-admin-panel.test.jsx
View file @
1cace60e
...
...
@@ -39,6 +39,20 @@ describe('Studio comments', () => {
expect
(
child
.
prop
(
'
isOpen
'
)).
toBe
(
false
);
});
});
describe
(
'
non admins
'
,
()
=>
{
test
(
'
should not have localStorage set with a false value
'
,
()
=>
{
mountWithIntl
(<
StudioAdminPanel
showAdminPanel=
{
false
}
/>);
expect
(
global
.
localStorage
.
getItem
(
adminPanelOpenKey
)).
toBe
(
null
);
});
test
(
'
should not have css class set even if localStorage contains open key
'
,
()
=>
{
// Regression test for situation where admin logs out but localStorage still
// contains "open", causing extra space to appear
global
.
localStorage
.
setItem
(
adminPanelOpenKey
,
'
open
'
);
const
component
=
mountWithIntl
(<
StudioAdminPanel
showAdminPanel=
{
false
}
/>);
const
child
=
component
.
find
(
AdminPanel
);
expect
(
viewEl
.
classList
.
contains
(
adminPanelOpenClass
)).
toBe
(
false
);
});
});
test
(
'
calling onOpen sets a class on the #viewEl and records in local storage
'
,
()
=>
{
const
component
=
mountWithIntl
(<
StudioAdminPanel
showAdminPanel
/>);
let
child
=
component
.
find
(
AdminPanel
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment