Ensures some sensible text is always in webhook text data.
Also aligned some notification reporting to use centralised activity
system instead of custom success events.
For #4216
12 files changed:
$token->save();
session()->flash('api-token-secret:' . $token->id, $secret);
$token->save();
session()->flash('api-token-secret:' . $token->id, $secret);
- $this->showSuccessNotification(trans('settings.user_api_token_create_success'));
$this->logActivity(ActivityType::API_TOKEN_CREATE, $token);
return redirect($user->getEditUrl('/api-tokens/' . $token->id));
$this->logActivity(ActivityType::API_TOKEN_CREATE, $token);
return redirect($user->getEditUrl('/api-tokens/' . $token->id));
'expires_at' => $request->get('expires_at') ?: ApiToken::defaultExpiry(),
])->save();
'expires_at' => $request->get('expires_at') ?: ApiToken::defaultExpiry(),
])->save();
- $this->showSuccessNotification(trans('settings.user_api_token_update_success'));
$this->logActivity(ActivityType::API_TOKEN_UPDATE, $token);
return redirect($user->getEditUrl('/api-tokens/' . $token->id));
$this->logActivity(ActivityType::API_TOKEN_UPDATE, $token);
return redirect($user->getEditUrl('/api-tokens/' . $token->id));
[$user, $token] = $this->checkPermissionAndFetchUserToken($userId, $tokenId);
$token->delete();
[$user, $token] = $this->checkPermissionAndFetchUserToken($userId, $tokenId);
$token->delete();
- $this->showSuccessNotification(trans('settings.user_api_token_delete_success'));
$this->logActivity(ActivityType::API_TOKEN_DELETE, $token);
return redirect($user->getEditUrl('#api_tokens'));
$this->logActivity(ActivityType::API_TOKEN_DELETE, $token);
return redirect($user->getEditUrl('#api_tokens'));
return redirect()->back();
}
return redirect()->back();
}
- $this->showSuccessNotification(trans('entities.chapter_move_success', ['bookName' => $newBook->name]));
-
return redirect($chapter->getUrl());
}
return redirect($chapter->getUrl());
}
- $parent = $this->pageRepo->move($page, $entitySelection);
+ $this->pageRepo->move($page, $entitySelection);
} catch (PermissionsException $exception) {
$this->showPermissionError();
} catch (Exception $exception) {
} catch (PermissionsException $exception) {
$this->showPermissionError();
} catch (Exception $exception) {
return redirect()->back();
}
return redirect()->back();
}
- $this->showSuccessNotification(trans('entities.pages_move_success', ['parentName' => $parent->name]));
-
return redirect($page->getUrl());
}
return redirect($page->getUrl());
}
class PageRevisionController extends Controller
{
class PageRevisionController extends Controller
{
- protected PageRepo $pageRepo;
-
- public function __construct(PageRepo $pageRepo)
- {
- $this->pageRepo = $pageRepo;
+ public function __construct(
+ protected PageRepo $pageRepo
+ ) {
$revision->delete();
Activity::add(ActivityType::REVISION_DELETE, $revision);
$revision->delete();
Activity::add(ActivityType::REVISION_DELETE, $revision);
- $this->showSuccessNotification(trans('entities.revision_delete_success'));
return redirect($page->getUrl('/revisions'));
}
return redirect($page->getUrl('/revisions'));
}
class RecycleBinController extends Controller
{
class RecycleBinController extends Controller
{
- protected $recycleBinBaseUrl = '/settings/recycle-bin';
+ protected string $recycleBinBaseUrl = '/settings/recycle-bin';
/**
* On each request to a method of this controller check permissions
/**
* On each request to a method of this controller check permissions
]);
$store->storeFromUpdateRequest($request, $category);
]);
$store->storeFromUpdateRequest($request, $category);
$this->logActivity(ActivityType::SETTINGS_UPDATE, $category);
$this->logActivity(ActivityType::SETTINGS_UPDATE, $category);
- $this->showSuccessNotification(trans('settings.settings_save_success'));
return redirect("/settings/{$category}");
}
return redirect("/settings/{$category}");
}
class UserController extends Controller
{
class UserController extends Controller
{
- protected UserRepo $userRepo;
- protected ImageRepo $imageRepo;
-
- public function __construct(UserRepo $userRepo, ImageRepo $imageRepo)
- {
- $this->userRepo = $userRepo;
- $this->imageRepo = $imageRepo;
+ public function __construct(
+ protected UserRepo $userRepo,
+ protected ImageRepo $imageRepo
+ ) {
'page_restore' => 'restored page',
'page_restore_notification' => 'Page successfully restored',
'page_move' => 'moved page',
'page_restore' => 'restored page',
'page_restore_notification' => 'Page successfully restored',
'page_move' => 'moved page',
+ 'page_move_notification' => 'Page successfully moved',
// Chapters
'chapter_create' => 'created chapter',
// Chapters
'chapter_create' => 'created chapter',
'chapter_delete' => 'deleted chapter',
'chapter_delete_notification' => 'Chapter successfully deleted',
'chapter_move' => 'moved chapter',
'chapter_delete' => 'deleted chapter',
'chapter_delete_notification' => 'Chapter successfully deleted',
'chapter_move' => 'moved chapter',
+ 'chapter_move_notification' => 'Chapter successfully moved',
// Books
'book_create' => 'created book',
// Books
'book_create' => 'created book',
'bookshelf_delete' => 'deleted shelf',
'bookshelf_delete_notification' => 'Shelf successfully deleted',
'bookshelf_delete' => 'deleted shelf',
'bookshelf_delete_notification' => 'Shelf successfully deleted',
+ // Revisions
+ 'revision_restore' => 'restored revision',
+ 'revision_delete' => 'deleted revision',
+ 'revision_delete_notification' => 'Revision successfully deleted',
+
// Favourites
'favourite_add_notification' => '":name" has been added to your favourites',
'favourite_remove_notification' => '":name" has been removed from your favourites',
// Favourites
'favourite_add_notification' => '":name" has been added to your favourites',
'favourite_remove_notification' => '":name" has been removed from your favourites',
+ // Auth
+ 'auth_login' => 'logged in',
+ 'auth_register' => 'registered as new user',
+ 'auth_password_reset_request' => 'requested user password reset',
+ 'auth_password_reset_update' => 'reset user password',
+ 'mfa_setup_method' => 'configured MFA method',
'mfa_setup_method_notification' => 'Multi-factor method successfully configured',
'mfa_setup_method_notification' => 'Multi-factor method successfully configured',
+ 'mfa_remove_method' => 'removed MFA method',
'mfa_remove_method_notification' => 'Multi-factor method successfully removed',
'mfa_remove_method_notification' => 'Multi-factor method successfully removed',
+ // Settings
+ 'settings_update' => 'updated settings',
+ 'settings_update_notification' => 'Settings successfully updated',
+ 'maintenance_action_run' => 'ran maintenance action',
+
// Webhooks
'webhook_create' => 'created webhook',
'webhook_create_notification' => 'Webhook successfully created',
// Webhooks
'webhook_create' => 'created webhook',
'webhook_create_notification' => 'Webhook successfully created',
'webhook_delete_notification' => 'Webhook successfully deleted',
// Users
'webhook_delete_notification' => 'Webhook successfully deleted',
// Users
+ 'user_create' => 'created user',
+ 'user_create_notification' => 'User successfully created',
+ 'user_update' => 'updated user',
'user_update_notification' => 'User successfully updated',
'user_update_notification' => 'User successfully updated',
+ 'user_delete' => 'deleted user',
'user_delete_notification' => 'User successfully removed',
'user_delete_notification' => 'User successfully removed',
+ // API Tokens
+ 'api_token_create' => 'created api token',
+ 'api_token_create_notification' => 'API token successfully created',
+ 'api_token_update' => 'updated api token',
+ 'api_token_update_notification' => 'API token successfully updated',
+ 'api_token_delete' => 'deleted api token',
+ 'api_token_delete_notification' => 'API token successfully deleted',
+
+ 'role_create' => 'created role',
'role_create_notification' => 'Role successfully created',
'role_create_notification' => 'Role successfully created',
+ 'role_update' => 'updated role',
'role_update_notification' => 'Role successfully updated',
'role_update_notification' => 'Role successfully updated',
+ 'role_delete' => 'deleted role',
'role_delete_notification' => 'Role successfully deleted',
'role_delete_notification' => 'Role successfully deleted',
+ // Recycle Bin
+ 'recycle_bin_empty' => 'emptied recycle bin',
+ 'recycle_bin_restore' => 'restored from recycle bin',
+ 'recycle_bin_destroy' => 'removed from recycle bin',
+
// Other
'commented_on' => 'commented on',
'permissions_update' => 'updated permissions',
// Other
'commented_on' => 'commented on',
'permissions_update' => 'updated permissions',
'chapters_save' => 'Save Chapter',
'chapters_move' => 'Move Chapter',
'chapters_move_named' => 'Move Chapter :chapterName',
'chapters_save' => 'Save Chapter',
'chapters_move' => 'Move Chapter',
'chapters_move_named' => 'Move Chapter :chapterName',
- 'chapter_move_success' => 'Chapter moved to :bookName',
'chapters_copy' => 'Copy Chapter',
'chapters_copy_success' => 'Chapter successfully copied',
'chapters_permissions' => 'Chapter Permissions',
'chapters_copy' => 'Copy Chapter',
'chapters_copy_success' => 'Chapter successfully copied',
'chapters_permissions' => 'Chapter Permissions',
'pages_md_sync_scroll' => 'Sync preview scroll',
'pages_not_in_chapter' => 'Page is not in a chapter',
'pages_move' => 'Move Page',
'pages_md_sync_scroll' => 'Sync preview scroll',
'pages_not_in_chapter' => 'Page is not in a chapter',
'pages_move' => 'Move Page',
- 'pages_move_success' => 'Page moved to ":parentName"',
'pages_copy' => 'Copy Page',
'pages_copy_desination' => 'Copy Destination',
'pages_copy_success' => 'Page successfully copied',
'pages_copy' => 'Copy Page',
'pages_copy_desination' => 'Copy Destination',
'pages_copy_success' => 'Page successfully copied',
// Revision
'revision_delete_confirm' => 'Are you sure you want to delete this revision?',
'revision_restore_confirm' => 'Are you sure you want to restore this revision? The current page contents will be replaced.',
// Revision
'revision_delete_confirm' => 'Are you sure you want to delete this revision?',
'revision_restore_confirm' => 'Are you sure you want to restore this revision? The current page contents will be replaced.',
- 'revision_delete_success' => 'Revision deleted',
'revision_cannot_delete_latest' => 'Cannot delete the latest revision.',
// Copy view
'revision_cannot_delete_latest' => 'Cannot delete the latest revision.',
// Copy view
// Common Messages
'settings' => 'Settings',
'settings_save' => 'Save Settings',
// Common Messages
'settings' => 'Settings',
'settings_save' => 'Save Settings',
- 'settings_save_success' => 'Settings saved',
'system_version' => 'System Version',
'categories' => 'Categories',
'system_version' => 'System Version',
'categories' => 'Categories',
'user_api_token_expiry' => 'Expiry Date',
'user_api_token_expiry_desc' => 'Set a date at which this token expires. After this date, requests made using this token will no longer work. Leaving this field blank will set an expiry 100 years into the future.',
'user_api_token_create_secret_message' => 'Immediately after creating this token a "Token ID" & "Token Secret" will be generated and displayed. The secret will only be shown a single time so be sure to copy the value to somewhere safe and secure before proceeding.',
'user_api_token_expiry' => 'Expiry Date',
'user_api_token_expiry_desc' => 'Set a date at which this token expires. After this date, requests made using this token will no longer work. Leaving this field blank will set an expiry 100 years into the future.',
'user_api_token_create_secret_message' => 'Immediately after creating this token a "Token ID" & "Token Secret" will be generated and displayed. The secret will only be shown a single time so be sure to copy the value to somewhere safe and secure before proceeding.',
- 'user_api_token_create_success' => 'API token successfully created',
- 'user_api_token_update_success' => 'API token successfully updated',
'user_api_token' => 'API Token',
'user_api_token_id' => 'Token ID',
'user_api_token_id_desc' => 'This is a non-editable system generated identifier for this token which will need to be provided in API requests.',
'user_api_token' => 'API Token',
'user_api_token_id' => 'Token ID',
'user_api_token_id_desc' => 'This is a non-editable system generated identifier for this token which will need to be provided in API requests.',
'user_api_token_delete' => 'Delete Token',
'user_api_token_delete_warning' => 'This will fully delete this API token with the name \':tokenName\' from the system.',
'user_api_token_delete_confirm' => 'Are you sure you want to delete this API token?',
'user_api_token_delete' => 'Delete Token',
'user_api_token_delete_warning' => 'This will fully delete this API token with the name \':tokenName\' from the system.',
'user_api_token_delete_confirm' => 'Are you sure you want to delete this API token?',
- 'user_api_token_delete_success' => 'API token successfully deleted',
// Webhooks
'webhooks' => 'Webhooks',
// Webhooks
'webhooks' => 'Webhooks',
+use BookStack\Activity\ActivityType;
+
class LanguageTest extends TestCase
{
protected array $langs;
class LanguageTest extends TestCase
{
protected array $langs;
$loginReq->assertOk();
$loginReq->assertSee('Log In');
}
$loginReq->assertOk();
$loginReq->assertSee('Log In');
}
+
+ public function test_all_activity_types_have_activity_text()
+ {
+ foreach (ActivityType::all() as $activityType) {
+ $langKey = 'activities.' . $activityType;
+ $this->assertNotEquals($langKey, trans($langKey, [], 'en'));
+ }
+ }
$resp = $this->post('/settings/features', []);
$resp->assertRedirect('/settings/features');
$resp = $this->get('/settings/features');
$resp = $this->post('/settings/features', []);
$resp->assertRedirect('/settings/features');
$resp = $this->get('/settings/features');
- $resp->assertSee('Settings saved');
+ $resp->assertSee('Settings successfully updated');
}
public function test_restrictions_manage_all_permission()
}
public function test_restrictions_manage_all_permission()