Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
G
Greenlight
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Arbeitsgruppe Hardwarenahe IT-Systeme
Greenlight
Commits
0fbf47cb
Unverified
Commit
0fbf47cb
authored
2 years ago
by
Ahmad Farhat
Committed by
GitHub
2 years ago
Browse files
Options
Downloads
Patches
Plain Diff
More localesssss (#4776)
* More localesssss * eslint
parent
84a5db03
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
app/javascript/components/users/user/forms/UpdateUserForm.jsx
+25
-9
25 additions, 9 deletions
...javascript/components/users/user/forms/UpdateUserForm.jsx
app/serializers/user_serializer.rb
+4
-0
4 additions, 0 deletions
app/serializers/user_serializer.rb
with
29 additions
and
9 deletions
app/javascript/components/users/user/forms/UpdateUserForm.jsx
+
25
−
9
View file @
0fbf47cb
import
React
from
'
react
'
;
import
React
,
{
useEffect
}
from
'
react
'
;
import
{
Button
,
Stack
}
from
'
react-bootstrap
'
;
import
PropTypes
from
'
prop-types
'
;
import
{
useTranslation
}
from
'
react-i18next
'
;
...
...
@@ -15,22 +15,38 @@ import useUpdateUserForm from '../../../../hooks/forms/users/user/useUpdateUserF
import
PermissionChecker
from
'
../../../../helpers/PermissionChecker
'
;
export
default
function
UpdateUserForm
({
user
})
{
const
{
t
}
=
useTranslation
();
const
currentUser
=
useAuth
();
const
localesAPI
=
useLocales
();
const
canUpdateRole
=
PermissionChecker
.
hasManageUsers
(
currentUser
);
const
{
data
:
roles
}
=
useRoles
({
enabled
:
canUpdateRole
});
const
{
data
:
locales
}
=
useLocales
();
const
updateUserAPI
=
useUpdateUser
(
user
?.
id
);
const
{
t
}
=
useTranslation
();
function
currentLanguage
()
{
const
language
=
user
?.
language
;
const
noDialect
=
language
.
substring
(
0
,
language
.
indexOf
(
'
-
'
));
if
(
locales
?.[
language
]
!==
undefined
)
{
return
language
;
}
if
(
noDialect
!==
''
&&
locales
?.[
noDialect
]
!==
undefined
)
{
return
noDialect
;
}
return
'
en
'
;
}
const
{
methods
,
fields
,
reset
}
=
useUpdateUserForm
({
defaultValues
:
{
name
:
user
?.
name
,
email
:
user
?.
email
,
language
:
user
?.
l
anguage
,
language
:
currentL
anguage
()
,
role_id
:
user
?.
role
?.
id
,
},
});
const
canUpdateRole
=
PermissionChecker
.
hasManageUsers
(
currentUser
);
const
rolesAPI
=
useRoles
({
enabled
:
canUpdateRole
});
useEffect
(()
=>
{
methods
.
setValue
(
'
language
'
,
currentLanguage
());
},
[
currentLanguage
()]);
return
(
<
Form
methods
=
{
methods
}
onSubmit
=
{
updateUserAPI
.
mutate
}
>
...
...
@@ -38,13 +54,13 @@ export default function UpdateUserForm({ user }) {
<
FormControl
field
=
{
fields
.
email
}
type
=
"email"
readOnly
/>
<
FormSelect
field
=
{
fields
.
language
}
variant
=
"dropdown"
>
{
Object
.
keys
(
locales
API
.
data
||
{}).
map
((
code
)
=>
<
Option
key
=
{
code
}
value
=
{
code
}
>
{
locales
API
.
data
[
code
]
}
</
Option
>)
Object
.
keys
(
locales
||
{}).
map
((
code
)
=>
<
Option
key
=
{
code
}
value
=
{
code
}
>
{
locales
[
code
]
}
</
Option
>)
}
</
FormSelect
>
{
(
canUpdateRole
&&
roles
API
.
data
)
&&
(
{
(
canUpdateRole
&&
roles
)
&&
(
<
FormSelect
field
=
{
fields
.
role_id
}
variant
=
"dropdown"
>
{
roles
API
.
data
.
map
((
role
)
=>
<
Option
key
=
{
role
.
id
}
value
=
{
role
.
id
}
>
{
role
.
name
}
</
Option
>)
roles
.
map
((
role
)
=>
<
Option
key
=
{
role
.
id
}
value
=
{
role
.
id
}
>
{
role
.
name
}
</
Option
>)
}
</
FormSelect
>
)
}
...
...
This diff is collapsed.
Click to expand it.
app/serializers/user_serializer.rb
+
4
−
0
View file @
0fbf47cb
...
...
@@ -7,6 +7,10 @@ class UserSerializer < ApplicationSerializer
belongs_to
:role
def
language
object
.
language
.
tr
(
'_'
,
'-'
)
end
def
avatar
user_avatar
(
object
)
end
...
...
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