Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
logging-scratch-gui
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
David Goessmann
logging-scratch-gui
Commits
f4bf2522
Unverified
Commit
f4bf2522
authored
6 years ago
by
Karishma Chadha
Committed by
GitHub
6 years ago
Browse files
Options
Downloads
Plain Diff
Merge pull request #3931 from kchadha/has-cloud-permission
Has cloud permission
parents
b270c1d2
6bdf8030
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/lib/cloud-manager-hoc.jsx
+4
-4
4 additions, 4 deletions
src/lib/cloud-manager-hoc.jsx
test/unit/util/cloud-manager-hoc.test.jsx
+32
-0
32 additions, 0 deletions
test/unit/util/cloud-manager-hoc.test.jsx
with
36 additions
and
4 deletions
src/lib/cloud-manager-hoc.jsx
+
4
−
4
View file @
f4bf2522
...
...
@@ -48,9 +48,7 @@ const cloudManagerHOC = function (WrappedComponent) {
this
.
disconnectFromCloud
();
}
canUseCloud
(
props
)
{
// TODO add a canUseCloud to pass down to this HOC (e.g. from www) and also check that here.
// This should cover info about the website specifically, like scrather status
return
!!
(
props
.
cloudHost
&&
props
.
username
&&
props
.
vm
&&
props
.
projectId
);
return
!!
(
props
.
cloudHost
&&
props
.
username
&&
props
.
vm
&&
props
.
projectId
&&
props
.
hasCloudPermission
);
}
shouldNotModifyCloudData
(
props
)
{
return
(
props
.
hasEverEnteredEditor
&&
!
props
.
canSave
);
...
...
@@ -92,7 +90,7 @@ const cloudManagerHOC = function (WrappedComponent) {
handleCloudDataUpdate
(
projectHasCloudData
)
{
if
(
this
.
isConnected
()
&&
!
projectHasCloudData
)
{
this
.
disconnectFromCloud
();
}
else
if
(
!
this
.
isConnected
()
&&
projectHasCloudData
)
{
}
else
if
(
!
this
.
isConnected
()
&&
this
.
canUseCloud
(
this
.
props
)
&&
projectHasCloudData
)
{
this
.
connectToCloud
();
}
}
...
...
@@ -102,6 +100,7 @@ const cloudManagerHOC = function (WrappedComponent) {
cloudHost
,
projectId
,
username
,
hasCloudPermission
,
hasEverEnteredEditor
,
isShowingWithId
,
/* eslint-enable no-unused-vars */
...
...
@@ -121,6 +120,7 @@ const cloudManagerHOC = function (WrappedComponent) {
CloudManager
.
propTypes
=
{
canSave
:
PropTypes
.
bool
.
isRequired
,
cloudHost
:
PropTypes
.
string
,
hasCloudPermission
:
PropTypes
.
bool
,
hasEverEnteredEditor
:
PropTypes
.
bool
,
isShowingWithId
:
PropTypes
.
bool
,
projectId
:
PropTypes
.
oneOfType
([
PropTypes
.
string
,
PropTypes
.
number
]),
...
...
This diff is collapsed.
Click to expand it.
test/unit/util/cloud-manager-hoc.test.jsx
+
32
−
0
View file @
f4bf2522
...
...
@@ -59,6 +59,7 @@ describe('CloudManagerHOC', () => {
mount
(
<
WrappedComponent
canSave
hasCloudPermission
cloudHost
=
"nonEmpty"
store
=
{
store
}
username
=
"user"
...
...
@@ -76,6 +77,7 @@ describe('CloudManagerHOC', () => {
mount
(
<
WrappedComponent
canSave
hasCloudPermission
store
=
{
store
}
username
=
"user"
vm
=
{
vm
}
...
...
@@ -93,6 +95,7 @@ describe('CloudManagerHOC', () => {
mount
(
<
WrappedComponent
canSave
hasCloudPermission
cloudHost
=
"nonEmpty"
store
=
{
store
}
vm
=
{
vm
}
...
...
@@ -109,6 +112,7 @@ describe('CloudManagerHOC', () => {
mount
(
<
WrappedComponent
canSave
hasCloudPermission
cloudHost
=
"nonEmpty"
store
=
{
stillLoadingStore
}
username
=
"user"
...
...
@@ -119,12 +123,31 @@ describe('CloudManagerHOC', () => {
expect
(
CloudProvider
).
not
.
toHaveBeenCalled
();
});
test
(
'
when hasCloudPermission is false, the cloud provider is not set on the vm
'
,
()
=>
{
const
Component
=
()
=>
<
div
/>;
const
WrappedComponent
=
cloudManagerHOC
(
Component
);
mount
(
<
WrappedComponent
canSave
cloudHost
=
"nonEmpty"
hasCloudPermission
=
{
false
}
store
=
{
store
}
username
=
"user"
vm
=
{
vm
}
/>
);
expect
(
vm
.
setCloudProvider
.
mock
.
calls
.
length
).
toBe
(
0
);
expect
(
CloudProvider
).
not
.
toHaveBeenCalled
();
});
test
(
'
if the isShowingWithId prop becomes true, it sets the cloud provider on the vm
'
,
()
=>
{
const
Component
=
()
=>
<
div
/>;
const
WrappedComponent
=
cloudManagerHOC
(
Component
);
const
mounted
=
mount
(
<
WrappedComponent
canSave
hasCloudPermission
cloudHost
=
"nonEmpty"
store
=
{
stillLoadingStore
}
username
=
"user"
...
...
@@ -146,6 +169,7 @@ describe('CloudManagerHOC', () => {
const
mounted
=
mount
(
<
WrappedComponent
canSave
hasCloudPermission
cloudHost
=
"nonEmpty"
store
=
{
stillLoadingStore
}
username
=
"user"
...
...
@@ -172,6 +196,7 @@ describe('CloudManagerHOC', () => {
const
mounted
=
mount
(
<
WrappedComponent
canSave
hasCloudPermission
cloudHost
=
"nonEmpty"
store
=
{
store
}
username
=
"user"
...
...
@@ -197,6 +222,7 @@ describe('CloudManagerHOC', () => {
const
mounted
=
mount
(
<
WrappedComponent
canSave
hasCloudPermission
cloudHost
=
"nonEmpty"
store
=
{
store
}
username
=
"user"
...
...
@@ -223,6 +249,7 @@ describe('CloudManagerHOC', () => {
const
mounted
=
mount
(
<
WrappedComponent
canSave
hasCloudPermission
cloudHost
=
"nonEmpty"
store
=
{
store
}
username
=
"user"
...
...
@@ -253,6 +280,7 @@ describe('CloudManagerHOC', () => {
mount
(
<
WrappedComponent
canSave
hasCloudPermission
cloudHost
=
"nonEmpty"
store
=
{
store
}
username
=
"user"
...
...
@@ -273,6 +301,7 @@ describe('CloudManagerHOC', () => {
mount
(
<
WrappedComponent
canSave
hasCloudPermission
cloudHost
=
"nonEmpty"
store
=
{
store
}
username
=
"user"
...
...
@@ -297,6 +326,7 @@ describe('CloudManagerHOC', () => {
mount
(
<
WrappedComponent
canSave
hasCloudPermission
cloudHost
=
"nonEmpty"
store
=
{
store
}
username
=
"user"
...
...
@@ -322,6 +352,7 @@ describe('CloudManagerHOC', () => {
const
mounted
=
mount
(
<
WrappedComponent
canSave
hasCloudPermission
cloudHost
=
"nonEmpty"
store
=
{
store
}
username
=
"user"
...
...
@@ -347,6 +378,7 @@ describe('CloudManagerHOC', () => {
const
WrappedComponent
=
cloudManagerHOC
(
Component
);
const
mounted
=
mount
(
<
WrappedComponent
hasCloudPermission
canSave
=
{
false
}
cloudHost
=
"nonEmpty"
store
=
{
store
}
...
...
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