Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
F
Frontend V2
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
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Contributor analytics
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
GraphPolaris
Frontend V2
Commits
cd797244
Commit
cd797244
authored
7 months ago
by
Marcos Pieras
Browse files
Options
Downloads
Patches
Plain Diff
feat: adds state on checkboxes
parent
6ff3eff4
Branches
feat/visWithQuery
Branches containing commit
No related tags found
No related merge requests found
Pipeline
#138623
passed
7 months ago
Stage: tag-release
Stage: get-release-tag
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
libs/shared/lib/components/userManagementContent/UserManagementContent.tsx
+41
-13
41 additions, 13 deletions
...omponents/userManagementContent/UserManagementContent.tsx
with
41 additions
and
13 deletions
libs/shared/lib/components/userManagementContent/UserManagementContent.tsx
+
41
−
13
View file @
cd797244
...
...
@@ -9,6 +9,12 @@ interface UserManagementContentProps {
onCancel
:
()
=>
void
;
}
interface
ListItem
{
label
:
string
;
checked
:
boolean
;
children
?:
ListItem
[];
}
export
const
UserManagementContent
:
React
.
FC
<
UserManagementContentProps
>
=
({
sessionId
,
onConfirm
,
onCancel
})
=>
{
const
{
setOpen
}
=
useDialogContext
();
const
[
activeTab
,
setActiveTab
]
=
useState
<
'
users
'
|
'
content
'
|
null
>
(
'
users
'
);
...
...
@@ -80,50 +86,67 @@ export const UserManagementContent: React.FC<UserManagementContentProps> = ({ se
// dummy content
const
[
isChecked
,
setIsChecked
]
=
useState
<
boolean
>
(
false
);
const
listData
=
[
const
[
listData
,
setListData
]
=
useState
<
ListItem
[]
>
(
[
{
label
:
'
Database
'
,
checked
:
false
,
children
:
[
{
label
:
'
View
'
,
type
:
'
boolean
'
,
checked
:
false
,
},
{
label
:
'
Switch DB
'
},
{
label
:
'
Switch DB
'
,
checked
:
false
},
],
},
{
label
:
'
Schema
'
,
checked
:
false
,
children
:
[
{
label
:
'
View
'
,
type
:
'
boolean
'
,
tooltip
:
'
Toggle to enable or disable the feature
'
,
checked
:
false
,
},
{
label
:
'
Change layout
'
},
{
label
:
'
Change layout
'
,
checked
:
false
},
],
},
{
label
:
'
Query
'
,
checked
:
false
,
children
:
[
{
label
:
'
View
'
,
type
:
'
boolean
'
,
tooltip
:
'
Toggle to enable or disable the feature
'
,
checked
:
false
,
},
{
label
:
'
Delete
'
},
{
label
:
'
Run ML
'
},
{
label
:
'
Delete
'
,
checked
:
false
},
{
label
:
'
Run ML
'
,
checked
:
false
},
],
},
{
label
:
'
Alerting
'
,
checked
:
false
,
children
:
[
{
label
:
'
View
'
,
type
:
'
boolean
'
,
checked
:
false
,
},
],
},
];
]);
const
handleCheckboxChange
=
(
index
:
number
,
childIndex
?:
number
)
=>
{
console
.
log
(
'
idx
'
,
index
,
childIndex
);
setListData
((
prevListData
)
=>
{
const
updatedListData
=
[...
prevListData
];
if
(
childIndex
!==
undefined
)
{
// Update child checkbox
updatedListData
[
index
].
children
!
[
childIndex
].
checked
=
!
updatedListData
[
index
].
children
!
[
childIndex
].
checked
;
}
else
{
// Update parent checkbox
updatedListData
[
index
].
checked
=
!
updatedListData
[
index
].
checked
;
}
return
updatedListData
;
});
};
return
(
<
div
className
=
"flex flex-col w-[50rem] h-[40rem]"
>
...
...
@@ -259,7 +282,12 @@ export const UserManagementContent: React.FC<UserManagementContentProps> = ({ se
{
item
.
children
.
map
((
child
,
childIndex
)
=>
(
<
li
key
=
{
childIndex
}
>
<
div
>
<
Input
type
=
"boolean"
label
=
{
child
.
label
}
value
=
{
isChecked
}
onChange
=
{
setIsChecked
}
/>
<
Input
type
=
"boolean"
label
=
{
child
.
label
}
value
=
{
child
.
checked
}
onChange
=
{
()
=>
handleCheckboxChange
(
index
,
childIndex
)
}
/>
</
div
>
</
li
>
))
}
...
...
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