Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
V
violinist_teams
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
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
project
violinist_teams
Commits
7458b29a
Commit
7458b29a
authored
10 months ago
by
Eirik Morland
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#3442988
by eiriksm: Make it possible to edit team name
parent
f2bf481f
No related branches found
No related tags found
1 merge request
!52
Expose team name but only for admins
Pipeline
#154702
passed with warnings
10 months ago
Stage: build
Stage: validate
Stage: test
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/Controller/InviteController.php
+1
-1
1 addition, 1 deletion
src/Controller/InviteController.php
src/Form/InviteMembersForm.php
+3
-2
3 additions, 2 deletions
src/Form/InviteMembersForm.php
src/Form/TeamSettingsForm.php
+41
-2
41 additions, 2 deletions
src/Form/TeamSettingsForm.php
with
45 additions
and
5 deletions
src/Controller/InviteController.php
+
1
−
1
View file @
7458b29a
...
...
@@ -27,7 +27,7 @@ final class InviteController extends ControllerBase {
EntityTypeManagerInterface
$entityTypeManager
,
AccountProxyInterface
$currentUser
,
ModuleHandlerInterface
$moduleHandler
,
private
SessionInterface
$session
private
SessionInterface
$session
,
)
{
$this
->
entityTypeManager
=
$entityTypeManager
;
$this
->
currentUser
=
$currentUser
;
...
...
This diff is collapsed.
Click to expand it.
src/Form/InviteMembersForm.php
+
3
−
2
View file @
7458b29a
...
...
@@ -31,9 +31,10 @@ final class InviteMembersForm extends FormBase {
/**
* The constructor.
*/
public
function
__construct
(
CurrentRouteMatch
$routeMatch
,
public
function
__construct
(
CurrentRouteMatch
$routeMatch
,
private
TeamManager
$teamManager
,
private
AccountProxyInterface
$currentUser
private
AccountProxyInterface
$currentUser
,
)
{
$this
->
routeMatch
=
$routeMatch
;
$team
=
$this
->
routeMatch
->
getParameter
(
'team'
);
...
...
This diff is collapsed.
Click to expand it.
src/Form/TeamSettingsForm.php
+
41
−
2
View file @
7458b29a
...
...
@@ -7,6 +7,7 @@ namespace Drupal\violinist_teams\Form;
use
Drupal\Core\Form\FormBase
;
use
Drupal\Core\Form\FormStateInterface
;
use
Drupal\Core\Routing\CurrentRouteMatch
;
use
Drupal\Core\Session\AccountProxyInterface
;
use
Drupal\Core\Url
;
use
Drupal\violinist_teams
\TeamNode
;
use
Symfony\Component\DependencyInjection\ContainerInterface
;
...
...
@@ -16,6 +17,13 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
*/
final
class
TeamSettingsForm
extends
FormBase
{
/**
* The current user.
*
* @var \Drupal\Core\Session\AccountProxyInterface
*/
protected
AccountProxyInterface
$currentUser
;
/**
* Team node.
*
...
...
@@ -26,8 +34,9 @@ final class TeamSettingsForm extends FormBase {
/**
* The constructor.
*/
public
function
__construct
(
CurrentRouteMatch
$current_route_match
)
{
public
function
__construct
(
CurrentRouteMatch
$current_route_match
,
AccountProxyInterface
$current_user
)
{
$this
->
routeMatch
=
$current_route_match
;
$this
->
currentUser
=
$current_user
;
$team
=
$this
->
routeMatch
->
getParameter
(
'team'
);
if
(
$team
instanceof
TeamNode
)
{
$this
->
team
=
$team
;
...
...
@@ -39,7 +48,8 @@ final class TeamSettingsForm extends FormBase {
*/
public
static
function
create
(
ContainerInterface
$container
)
{
return
new
static
(
$container
->
get
(
'current_route_match'
)
$container
->
get
(
'current_route_match'
),
$container
->
get
(
'current_user'
)
);
}
...
...
@@ -58,6 +68,32 @@ final class TeamSettingsForm extends FormBase {
if
(
!
$team
instanceof
TeamNode
)
{
return
$form
;
}
$form
[
'title'
]
=
[
'#type'
=>
'textfield'
,
'#title'
=>
$this
->
t
(
'Team Name'
),
'#required'
=>
TRUE
,
'#default_value'
=>
$team
->
getTitle
(),
];
if
(
!
$team
->
isAdmin
(
$this
->
currentUser
))
{
$form
[
'title'
][
'#description'
]
=
$this
->
t
(
'Only administrators can change the team name.'
);
$form
[
'title'
][
'#disabled'
]
=
TRUE
;
$form
[
'title'
][
'#attributes'
][
'readonly'
]
=
'readonly'
;
$form
[
'title'
][
'#attributes'
][
'disabled'
]
=
'disabled'
;
}
$form
[
'slack'
]
=
[
'#type'
=>
'details'
,
'#title'
=>
$this
->
t
(
'Slack settings'
),
'#open'
=>
TRUE
,
];
$form
[
'slack'
][
'enable_slack_notifications'
]
=
[
'#type'
=>
'checkbox'
,
'#default_value'
=>
$team
->
isNotificationsEnabledForSlack
(),
'#title'
=>
$this
->
t
(
'Enable Slack notifications'
),
];
if
(
!
$team
->
getTeamSlackWebhook
())
{
$form
[
'slack'
][
'enable_slack_notifications'
][
'#disabled'
]
=
TRUE
;
$form
[
'slack'
][
'enable_slack_notifications'
][
'#description'
]
=
$this
->
getSlackDescription
();
}
$form
[
'slack'
]
=
[
'#type'
=>
'details'
,
'#title'
=>
$this
->
t
(
'Slack settings'
),
...
...
@@ -109,6 +145,9 @@ final class TeamSettingsForm extends FormBase {
if
(
!
$team
instanceof
TeamNode
)
{
return
;
}
if
(
$this
->
team
->
isAdmin
(
$this
->
currentUser
))
{
$team
->
setTitle
(
$form_state
->
getValue
(
'title'
));
}
$team
->
set
(
TeamNode
::
SLACK_NOTIFICATION_ENABLED_FIELD
,
$form_state
->
getValue
(
'enable_slack_notifications'
))
->
save
();
...
...
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