Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
ce-deploy-ui
Manage
Activity
Members
Labels
Plan
Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Operate
Environments
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ccce
dev
ce-deploy-ui
Commits
7d1d6c31
Commit
7d1d6c31
authored
3 years ago
by
John Sparger
Browse files
Options
Downloads
Patches
Plain Diff
updated user filtering in list views to use user context
parent
d82ecb45
No related branches found
No related tags found
2 merge requests
!25
IOCListView now has tabs to prefilter on all or currentUsers IOCs. The currentUser is hardcoded
,
!18
Merge current UI state
Pipeline
#74950
failed
3 years ago
Stage: build
Stage: test
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/views/IOC/IOCListView.js
+4
-4
4 additions, 4 deletions
src/views/IOC/IOCListView.js
src/views/deployments/DeploymentsView.js
+4
-6
4 additions, 6 deletions
src/views/deployments/DeploymentsView.js
with
8 additions
and
10 deletions
src/views/IOC/IOCListView.js
+
4
−
4
View file @
7d1d6c31
import
{
Container
,
Grid
,
Hidden
,
IconButton
,
Paper
,
Tab
,
Tabs
,
useTheme
}
from
"
@material-ui/core
"
;
import
{
AddBox
}
from
"
@material-ui/icons
"
;
import
React
,
{
useState
}
from
"
react
"
import
React
,
{
useContext
,
useState
}
from
"
react
"
import
{
useGlobalAppBar
}
from
"
../../components/navigation/GlobalAppBar/GlobalAppBar
"
;
import
{
SearchableIOCList
}
from
"
../../components/IOC/IOCList
"
;
import
{
CreateIOC
}
from
"
../../components/IOC/CreateIOC
"
;
import
{
SimpleModal
}
from
"
../../components/common/SimpleModal/SimpleModal
"
;
import
{
SearchableIOCTable
}
from
"
../../components/IOC/IOCTable
"
;
import
{
useCreateIOC
,
useIOCList
}
from
"
../../api/SwaggerApi
"
;
import
{
useCreateIOC
,
useIOCList
,
userContext
}
from
"
../../api/SwaggerApi
"
;
export
function
IOCListView
()
{
const
[
iocs
]
=
useIOCList
();
const
[
iocFormOpen
,
setIOCFormOpen
]
=
useState
(
false
);
const
[
selectedTab
,
setSelectedTab
]
=
React
.
useState
(
0
);
const
[
currentU
ser
]
=
use
State
(
"
ccceuser
"
);
const
{
u
ser
}
=
use
Context
(
userContext
);
console
.
log
(
"
rendering IOCListView
"
)
...
...
@@ -33,7 +33,7 @@ export function IOCListView() {
function
preFilter
(
tab
,
iocs
)
{
console
.
log
(
iocs
);
if
(
tab
===
0
)
{
iocs
=
iocs
.
filter
((
ioc
)
=>
ioc
.
owner
===
currentUser
);
iocs
=
iocs
.
filter
((
ioc
)
=>
ioc
.
owner
===
user
.
loginName
);
}
const
abcIOCs
=
iocs
.
sort
((
a
,
b
)
=>
a
.
name
.
localeCompare
(
b
.
name
));
...
...
This diff is collapsed.
Click to expand it.
src/views/deployments/DeploymentsView.js
+
4
−
6
View file @
7d1d6c31
import
React
,
{
useState
}
from
'
react
'
;
import
React
,
{
useContext
,
useState
}
from
'
react
'
;
import
{
makeStyles
}
from
'
@material-ui/core/styles
'
;
import
{
Paper
,
Container
,
Grid
,
FormControlLabel
,
Switch
,
Hidden
}
from
'
@material-ui/core
'
;
import
Tabs
from
'
@material-ui/core/Tabs
'
;
...
...
@@ -6,11 +6,8 @@ import Tab from '@material-ui/core/Tab';
import
{
SearchableDeploymentsTable
}
from
"
../../components/deployments/DeploymentsTable
"
;
import
{
SearchableDeploymentsList
}
from
"
../../components/deployments/DeploymentsList
"
;
import
{
useGlobalAppBar
}
from
"
../../components/navigation/GlobalAppBar/GlobalAppBar
"
;
import
{
useDeploymentList
}
from
'
../../api/SwaggerApi
'
;
import
{
useDeploymentList
,
userContext
}
from
'
../../api/SwaggerApi
'
;
// Static data for demo, will come from API
const
ownUser
=
"
zoltan.runyo
"
;
//------------------------------------------------------------------------------------------------------
const
useStyles
=
makeStyles
({
root
:
{
...
...
@@ -27,6 +24,7 @@ export function DeploymentsView() {
const
[
deployments
]
=
useDeploymentList
();
const
[
selectedTab
,
setSelectedTab
]
=
useState
(
0
);
const
[
ownOnly
,
setOwnOnly
]
=
useState
(
false
);
const
{
user
}
=
useContext
(
userContext
);
console
.
log
(
deployments
);
...
...
@@ -36,7 +34,7 @@ export function DeploymentsView() {
function
performFilter
(
tab
,
own
,
deploymentList
)
{
const
prefiltered
=
own
?
deploymentList
.
filter
(
deployment
=>
deployment
.
createdBy
===
ownUser
)
:
deployments
;
const
prefiltered
=
own
?
deploymentList
.
filter
(
deployment
=>
deployment
.
createdBy
===
user
.
loginName
)
:
deployments
;
if
(
tab
===
0
)
{
return
prefiltered
;
}
...
...
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