Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Salamander - APP
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
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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Eirik Martin Danielsen
Salamander - APP
Merge requests
!69
Resolve "Refactor app"
Code
Review changes
Check out branch
Open in Workspace
Download
Patches
Plain diff
Expand sidebar
Merged
Resolve "Refactor app"
66-refactor-app
into
master
Overview
0
Commits
5
Pipelines
0
Changes
1
Merged
Andrea Magnussen
requested to merge
66-refactor-app
into
master
4 years ago
Overview
0
Commits
5
Pipelines
0
Changes
1
Closes
#66 (closed)
Edited
4 years ago
by
Andrea Magnussen
0
0
Merge request reports
Viewing commit
dde0e40f
Prev
Next
Show latest version
1 file
+
28
−
34
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
dde0e40f
Added radiobutton component to customdialog
· dde0e40f
Andrea Magnussen
authored
4 years ago
components/CustomDialog.js
+
28
−
34
View file @ dde0e40f
Edit in single-file editor
Open in Web IDE
Show full file
import
React
,
{
useState
}
from
"
react
"
;
import
{
StyleSheet
,
View
,
Alert
}
from
"
react-native
"
;
import
{
Button
,
Paragraph
,
Dialog
,
Portal
,
RadioButton
,
Text
,
Divider
}
from
"
react-native-paper
"
;
import
{
Button
,
Paragraph
,
Dialog
,
Portal
,
Text
,
Divider
}
from
"
react-native-paper
"
;
import
APIKit
from
"
../APIkit
"
;
import
CustomActivityIndicator
from
"
./CustomActivityIndicator
"
;
import
{
toast500
,
toastError
}
from
"
../constants/toasts
"
;
import
CustomRadioButtonGroup
from
"
./CustomRadioButtonGroup
"
;
const
CustomDialog
=
(
props
)
=>
{
const
[
value
,
setValue
]
=
React
.
useState
(
1
);
const
[
value
,
setValue
]
=
React
.
useState
(
null
);
const
[
showIndicator
,
setShowIndicator
]
=
useState
(
false
);
const
[
resetCode
,
setResetCode
]
=
useState
(
null
);
const
values
=
{
firstValue
:
"
denyAccess
"
,
secondValue
:
"
makeAdmin
"
,
thirdValue
:
"
removeAdmin
"
,
firstText
:
"
Deny Access
"
,
secondText
:
"
Make Admin
"
,
thirdText
:
"
Remove Admin
"
};
const
getValue
=
(
value
)
=>
{
setValue
(
value
);
};
const
updateUser
=
()
=>
{
let
bodyFormData
=
new
FormData
();
bodyFormData
.
append
(
"
email
"
,
props
.
email
);
bodyFormData
.
append
(
"
id
"
,
props
.
id
);
switch
(
value
)
{
case
1
:
bodyFormData
.
append
(
"
denyAccess
"
,
true
);
break
;
case
2
:
bodyFormData
.
append
(
"
makeAdmin
"
,
true
);
break
;
case
3
:
bodyFormData
.
append
(
"
removeAdmin
"
,
true
);
break
;
}
bodyFormData
.
append
(
value
,
true
);
setShowIndicator
(
true
);
@@ -94,27 +91,17 @@ const CustomDialog = (props) => {
<
Dialog
.
Content
>
<
Paragraph
>
{
props
.
email
}
<
/Paragraph
>
<
Paragraph
>
Admin
:{
props
.
admin
.
toString
()},
Accepted
:
{
props
.
accepted
.
toString
()}
Admin
:
{
props
.
admin
.
toString
()}
<
/Paragraph
>
<
Paragraph
>
Accepted
:
{
props
.
accepted
.
toString
()}
<
/Paragraph
>
<
View
>
<
RadioButton
.
Group
onValueChange
=
{(
newValue
)
=>
setValue
(
newValue
)}
value
=
{
value
}
>
<
View
style
=
{
styles
.
radioButton
}
>
<
RadioButton
value
=
{
1
}
/
>
<
Text
>
Deny
Access
<
/Text
>
<
/View
>
<
View
style
=
{
styles
.
radioButton
}
>
<
RadioButton
value
=
{
2
}
/
>
<
Text
>
Make
Admin
<
/Text
>
<
/View
>
<
View
style
=
{
styles
.
radioButton
}
>
<
RadioButton
value
=
{
3
}
/
>
<
Text
>
Remove
Admin
<
/Text
>
<
/View
>
<
/RadioButton.Group
>
<
CustomRadioButtonGroup
default
=
{
value
}
values
=
{
values
}
sendDataToParent
=
{
getValue
}
/
>
<
/View
>
<
Divider
/>
<
View
style
=
{{
marginTop
:
10
}}
>
@@ -127,7 +114,14 @@ const CustomDialog = (props) => {
<
/Dialog.Content
>
<
Dialog
.
Actions
>
<
Button
onPress
=
{
props
.
onCancel
}
>
Cancel
<
/Button
>
<
Button
onPress
=
{
updateUser
}
>
Done
<
/Button
>
<
Button
onPress
=
{
updateUser
}
disabled
=
{
!
(
value
!=
null
)
}
>
Done
<
/Button
>
<
/Dialog.Actions
>
<
/Dialog
>
<
/Portal
>
Loading