Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
dashboard
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository 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
red-giant
dashboard
Commits
33ed85e5
Verified
Commit
33ed85e5
authored
3 years ago
by
Defendi Alberto
Browse files
Options
Downloads
Patches
Plain Diff
Chose role prototype.
parent
a258e850
No related branches found
No related tags found
2 merge requests
!56
Refined auth flow and new website pages.
,
!43
Move back cookie fetch to SignInForm. Role fetched and saved into a Context. Small refactorings.
Pipeline
#12174
passed
3 years ago
Stage: build
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/components/AuthUser/ChoseRole/ChoseRole.test.tsx
+10
-0
10 additions, 0 deletions
src/components/AuthUser/ChoseRole/ChoseRole.test.tsx
src/components/AuthUser/ChoseRole/ChoseRole.tsx
+39
-0
39 additions, 0 deletions
src/components/AuthUser/ChoseRole/ChoseRole.tsx
with
49 additions
and
0 deletions
src/components/AuthUser/ChoseRole/ChoseRole.test.tsx
0 → 100644
+
10
−
0
View file @
33ed85e5
import
React
from
'
react
'
;
import
{
render
}
from
'
@testing-library/react
'
;
import
{
ChoseRole
}
from
'
./ChoseRole
'
;
describe
(
'
<ChoseRole />
'
,
()
=>
{
it
(
'
renders without crashing
'
,
()
=>
{
const
wrapper
=
render
(<
ChoseRole
/>);
expect
(
wrapper
.
queryByTestId
(
'
ChoseRole
'
)).
toBeTruthy
();
});
});
This diff is collapsed.
Click to expand it.
src/components/AuthUser/ChoseRole/ChoseRole.tsx
0 → 100644
+
39
−
0
View file @
33ed85e5
import
React
,
{
FC
,
useContext
,
useEffect
,
useState
}
from
'
react
'
;
import
axios
from
'
axios
'
;
import
Button
from
'
@material-ui/core/Button
'
;
import
{
AuthContext
}
from
'
../AuthContext
'
;
const
choseAndForward
=
(
e
:
unknown
):
void
=>
{
// Do nothing.
};
/**
* Screen that let's users decide role between available roles.
* This is intended to use when a user has more than one role.
* @returns ChoseRole component.
*/
export
const
ChoseRole
:
FC
=
()
=>
{
const
[
userRoles
,
setUserRoles
]
=
useState
<
Array
<
string
>>
([
''
]);
useEffect
(()
=>
{
const
getUserRoles
=
async
():
Promise
<
unknown
>
=>
{
const
response
=
await
axios
(
'
/api/web/get_role
'
);
setUserRoles
(
response
.
data
.
token
);
return
null
;
};
getUserRoles
();
},
[
userRoles
]);
const
{
role
}
=
useContext
(
AuthContext
);
return
(
<
div
data-testid
=
"ChoseRole"
>
<
Button
variant
=
"outlined"
color
=
"default"
onClick
=
{
(
e
)
=>
choseAndForward
(
e
)
}
>
{
role
}
</
Button
>
</
div
>
);
};
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