Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
gitlab-ce
Commits
adec9194
Commit
adec9194
authored
Mar 27, 2017
by
Filipa Lacerda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adds expandable folder back.
Makes request to get environments
parent
f6f56ddd
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
100 additions
and
19 deletions
+100
-19
app/assets/javascripts/environments/components/environment.js
...assets/javascripts/environments/components/environment.js
+27
-2
app/assets/javascripts/environments/components/environment_item.js
...s/javascripts/environments/components/environment_item.js
+23
-12
app/assets/javascripts/environments/components/environments_table.js
...javascripts/environments/components/environments_table.js
+1
-2
app/assets/javascripts/environments/services/environments_service.js
...javascripts/environments/services/environments_service.js
+13
-1
app/assets/javascripts/environments/stores/environments_store.js
...ets/javascripts/environments/stores/environments_store.js
+36
-2
No files found.
app/assets/javascripts/environments/components/environment.js
View file @
adec9194
...
@@ -24,6 +24,7 @@ export default Vue.component('environment-component', {
...
@@ -24,6 +24,7 @@ export default Vue.component('environment-component', {
state
:
store
.
state
,
state
:
store
.
state
,
visibility
:
'
available
'
,
visibility
:
'
available
'
,
isLoading
:
false
,
isLoading
:
false
,
isLoadingFolderContent
:
false
,
cssContainerClass
:
environmentsData
.
cssClass
,
cssContainerClass
:
environmentsData
.
cssClass
,
endpoint
:
environmentsData
.
environmentsDataEndpoint
,
endpoint
:
environmentsData
.
environmentsDataEndpoint
,
canCreateDeployment
:
environmentsData
.
canCreateDeployment
,
canCreateDeployment
:
environmentsData
.
canCreateDeployment
,
...
@@ -68,15 +69,21 @@ export default Vue.component('environment-component', {
...
@@ -68,15 +69,21 @@ export default Vue.component('environment-component', {
this
.
fetchEnvironments
();
this
.
fetchEnvironments
();
eventHub
.
$on
(
'
refreshEnvironments
'
,
this
.
fetchEnvironments
);
eventHub
.
$on
(
'
refreshEnvironments
'
,
this
.
fetchEnvironments
);
eventHub
.
$on
(
'
toggleFolder
'
,
this
.
toggleFolder
);
},
},
beforeDestroyed
()
{
beforeDestroyed
()
{
eventHub
.
$off
(
'
refreshEnvironments
'
);
eventHub
.
$off
(
'
refreshEnvironments
'
);
eventHub
.
$off
(
'
toggleFolder
'
);
},
},
methods
:
{
methods
:
{
toggleRow
(
model
)
{
toggleFolder
(
folder
)
{
return
this
.
store
.
toggleFolder
(
model
.
name
);
this
.
store
.
toggleFolder
(
folder
);
if
(
!
folder
.
isOpen
)
{
this
.
fetchChildEnvironments
(
folder
);
}
},
},
/**
/**
...
@@ -117,6 +124,24 @@ export default Vue.component('environment-component', {
...
@@ -117,6 +124,24 @@ export default Vue.component('environment-component', {
new
Flash
(
'
An error occurred while fetching the environments.
'
);
new
Flash
(
'
An error occurred while fetching the environments.
'
);
});
});
},
},
fetchChildEnvironments
(
folder
)
{
this
.
isLoadingFolderContent
=
true
;
this
.
service
.
getFolderContent
(
folder
.
folderName
)
.
then
(
resp
=>
resp
.
json
())
.
then
((
response
)
=>
{
console
.
log
(
response
);
this
.
store
.
folderContent
(
folder
,
response
.
environments
);
})
.
then
(()
=>
{
this
.
isLoadingFolderContent
=
false
;
})
.
catch
(()
=>
{
this
.
isLoadingFolderContent
=
false
;
new
Flash
(
'
An error occurred while fetching the environments.
'
);
});
},
},
},
template
:
`
template
:
`
...
...
app/assets/javascripts/environments/components/environment_item.js
View file @
adec9194
...
@@ -6,6 +6,7 @@ import StopComponent from './environment_stop';
...
@@ -6,6 +6,7 @@ import StopComponent from './environment_stop';
import
RollbackComponent
from
'
./environment_rollback
'
;
import
RollbackComponent
from
'
./environment_rollback
'
;
import
TerminalButtonComponent
from
'
./environment_terminal_button
'
;
import
TerminalButtonComponent
from
'
./environment_terminal_button
'
;
import
CommitComponent
from
'
../../vue_shared/components/commit
'
;
import
CommitComponent
from
'
../../vue_shared/components/commit
'
;
import
eventHub
from
'
../event_hub
'
;
/**
/**
* Envrionment Item Component
* Envrionment Item Component
...
@@ -391,16 +392,6 @@ export default {
...
@@ -391,16 +392,6 @@ export default {
return
''
;
return
''
;
},
},
/**
* Constructs folder URL based on the current location and the folder id.
*
* @return {String}
*/
folderUrl
()
{
return
`
${
window
.
location
.
pathname
}
/folders/
${
this
.
model
.
folderName
}
`
;
},
},
},
/**
/**
...
@@ -418,6 +409,12 @@ export default {
...
@@ -418,6 +409,12 @@ export default {
return
true
;
return
true
;
},
},
methods
:
{
onClickFolder
()
{
eventHub
.
$emit
(
'
toggleFolder
'
,
this
.
model
);
},
},
template
:
`
template
:
`
<tr>
<tr>
<td>
<td>
...
@@ -426,7 +423,21 @@ export default {
...
@@ -426,7 +423,21 @@ export default {
:href="environmentPath">
:href="environmentPath">
{{model.name}}
{{model.name}}
</a>
</a>
<a v-else class="folder-name" :href="folderUrl">
<span v-else
class="folder-name"
@click="onClickFolder">
<span class="folder-icon">
<i
v-show="model.isOpen"
class="fa fa-caret-down"
aria-hidden="true" />
<i
v-show="!model.isOpen"
class="fa fa-caret-right"
aria-hidden="true"/>
</span>
<span class="folder-icon">
<span class="folder-icon">
<i class="fa fa-folder" aria-hidden="true"></i>
<i class="fa fa-folder" aria-hidden="true"></i>
</span>
</span>
...
@@ -438,7 +449,7 @@ export default {
...
@@ -438,7 +449,7 @@ export default {
<span class="badge">
<span class="badge">
{{model.size}}
{{model.size}}
</span>
</span>
</
a
>
</
span
>
</td>
</td>
<td class="deployment-column">
<td class="deployment-column">
...
...
app/assets/javascripts/environments/components/environments_table.js
View file @
adec9194
...
@@ -54,11 +54,10 @@ export default {
...
@@ -54,11 +54,10 @@ export default {
:can-read-environment="canReadEnvironment"
:can-read-environment="canReadEnvironment"
:service="service"></tr>
:service="service"></tr>
<tr v-if="model.isOpen && model.children && model.children.length > 0"
<tr v-if="model.is
Folder && model.is
Open && model.children && model.children.length > 0"
is="environment-item"
is="environment-item"
v-for="children in model.children"
v-for="children in model.children"
:model="children"
:model="children"
:toggleRow="toggleRow.bind(children)"
:can-create-deployment="canCreateDeploymentParsed"
:can-create-deployment="canCreateDeploymentParsed"
:can-read-environment="canReadEnvironmentParsed"
:can-read-environment="canReadEnvironmentParsed"
:service="service"></tr>
:service="service"></tr>
...
...
app/assets/javascripts/environments/services/environments_service.js
View file @
adec9194
...
@@ -6,7 +6,14 @@ Vue.use(VueResource);
...
@@ -6,7 +6,14 @@ Vue.use(VueResource);
export
default
class
EnvironmentsService
{
export
default
class
EnvironmentsService
{
constructor
(
endpoint
)
{
constructor
(
endpoint
)
{
this
.
environments
=
Vue
.
resource
(
endpoint
);
/**
* FIX ME: This should be sent by backend.
*/
const
customActions
=
{
folderContent
:
{
method
:
'
GET
'
,
url
:
`
${
window
.
location
.
pathname
}
/folders{/name}?perPage=2`
},
};
this
.
environments
=
Vue
.
resource
(
endpoint
,
{},
customActions
);
}
}
get
(
scope
,
page
)
{
get
(
scope
,
page
)
{
...
@@ -16,4 +23,9 @@ export default class EnvironmentsService {
...
@@ -16,4 +23,9 @@ export default class EnvironmentsService {
postAction
(
endpoint
)
{
postAction
(
endpoint
)
{
return
Vue
.
http
.
post
(
endpoint
,
{},
{
emulateJSON
:
true
});
return
Vue
.
http
.
post
(
endpoint
,
{},
{
emulateJSON
:
true
});
}
}
getFolderContent
(
folderName
)
{
debugger
return
this
.
environments
.
folderContent
({
name
:
folderName
});
}
}
}
app/assets/javascripts/environments/stores/environments_store.js
View file @
adec9194
...
@@ -38,7 +38,12 @@ export default class EnvironmentsStore {
...
@@ -38,7 +38,12 @@ export default class EnvironmentsStore {
let
filtered
=
{};
let
filtered
=
{};
if
(
env
.
size
>
1
)
{
if
(
env
.
size
>
1
)
{
filtered
=
Object
.
assign
({},
env
,
{
isFolder
:
true
,
folderName
:
env
.
name
});
filtered
=
Object
.
assign
({},
env
,
{
isFolder
:
true
,
folderName
:
env
.
name
,
isOpen
:
false
,
children
:
[],
});
}
}
if
(
env
.
latest
)
{
if
(
env
.
latest
)
{
...
@@ -86,7 +91,36 @@ export default class EnvironmentsStore {
...
@@ -86,7 +91,36 @@ export default class EnvironmentsStore {
return
count
;
return
count
;
}
}
toggleRow
(
name
)
{
/**
* Toggles folder open property given the given folder.
*
* @param {String} envType
* @return {Array}
*/
toggleFolder
(
folder
)
{
return
this
.
updateFolder
(
folder
,
'
isOpen
'
,
!
folder
.
isOpen
);
}
folderContent
(
folder
,
environments
)
{
debugger
;
return
this
.
updateFolder
(
folder
,
'
children
'
,
environments
);
}
}
updateFolder
(
folder
,
prop
,
newValue
)
{
const
environments
=
this
.
state
.
environments
;
debugger
;
const
updatedEnvironments
=
environments
.
map
((
env
)
=>
{
const
updateEnv
=
Object
.
assign
({},
env
);
if
(
env
.
isFolder
&&
env
.
id
===
folder
.
id
)
{
updateEnv
[
prop
]
=
newValue
;
}
return
updateEnv
;
});
debugger
;
console
.
log
(
updatedEnvironments
);
this
.
state
.
environments
=
updatedEnvironments
;
}
}
}
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