mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-30 10:58:31 -05:00
Add confirmation modal to admin group deletion
This commit is contained in:
parent
58e7c3e1f3
commit
9616767bff
23 changed files with 196 additions and 28 deletions
|
@ -33,12 +33,16 @@ Discourse.AdminGroupsController = Ember.Controller.extend({
|
|||
},
|
||||
|
||||
destroy: function(group){
|
||||
var list = this.get("model");
|
||||
if(group.get("id")){
|
||||
group.destroy().then(function(){
|
||||
list.removeObject(group);
|
||||
});
|
||||
}
|
||||
var _this = this;
|
||||
return bootbox.confirm(I18n.t("admin.groups.delete_confirm"), I18n.t("no_value"), I18n.t("yes_value"), function(result) {
|
||||
if (result) {
|
||||
group.destroy().then(function(deleted) {
|
||||
if (deleted) {
|
||||
_this.get("model").removeObject(group);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -36,12 +36,18 @@ Discourse.Group = Discourse.Model.extend({
|
|||
}.property('users'),
|
||||
|
||||
destroy: function(){
|
||||
if(!this.id) return;
|
||||
|
||||
var group = this;
|
||||
group.set('disableSave', true);
|
||||
|
||||
return Discourse.ajax("/admin/groups/" + this.get("id"), {type: "DELETE"})
|
||||
return Discourse.ajax("/admin/groups/" + group.id, {type: "DELETE"})
|
||||
.then(function(){
|
||||
return true;
|
||||
}, function(jqXHR, status, error) {
|
||||
group.set('disableSave', false);
|
||||
bootbox.alert(I18n.t("admin.groups.delete_failed"));
|
||||
return false;
|
||||
});
|
||||
},
|
||||
|
||||
|
|
|
@ -64,7 +64,7 @@ $.fn.autocomplete = function(options) {
|
|||
|
||||
d.find('a').click(function() {
|
||||
closeAutocomplete();
|
||||
inputSelectedItems.splice($.inArray(item), 1);
|
||||
inputSelectedItems.splice($.inArray(item, inputSelectedItems), 1);
|
||||
$(this).parent().parent().remove();
|
||||
if (options.single) {
|
||||
me.show();
|
||||
|
|
|
@ -43,7 +43,7 @@ class Admin::GroupsController < Admin::AdminController
|
|||
can_not_modify_automatic
|
||||
else
|
||||
group.destroy
|
||||
render json: "ok"
|
||||
render json: success_json
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -1152,6 +1152,9 @@ cs:
|
|||
name_placeholder: "Název skupiny, bez mezer, stejná pravidla jako pro uživatelská jména"
|
||||
about: "Zde můžete upravit názvy skupin a členství"
|
||||
can_not_edit_automatic: "Členství v automatických skupinách se přiděluje samo, administrátoři mohou přidělit další role a důveryhodnost uživatelům"
|
||||
delete: "Smazat"
|
||||
delete_confirm: "Smazat toto skupiny?"
|
||||
delete_failed: "Unable to delete group. If this is an automatic group, it cannot be destroyed."
|
||||
|
||||
api:
|
||||
title: "API"
|
||||
|
|
|
@ -728,8 +728,29 @@ da:
|
|||
flagged_by: "Flagged by"
|
||||
error: "Something went wrong"
|
||||
|
||||
groups:
|
||||
title: "Groups"
|
||||
edit: "Edit Groups"
|
||||
selector_placeholder: "add users"
|
||||
name_placeholder: "Group name, no spaces, same as username rule"
|
||||
about: "Edit your group membership and names here"
|
||||
can_not_edit_automatic: "Automatic group membership is determined automatically, administer users to assign roles and trust levels"
|
||||
delete: "Delete"
|
||||
delete_confirm: "Delete this group?"
|
||||
delete_failed: "Unable to delete group. If this is an automatic group, it cannot be destroyed."
|
||||
|
||||
api:
|
||||
title: "API"
|
||||
long_title: "API Information"
|
||||
key: "Key"
|
||||
generate: "Generate API Key"
|
||||
regenerate: "Regenerate API Key"
|
||||
info_html: "Your API key will allow you to create and update topics using JSON calls."
|
||||
note_html: "Keep this key <strong>secret</strong>, all users that have it may create arbitrary posts on the forum as any user."
|
||||
|
||||
customize:
|
||||
title: "Customize"
|
||||
long_title: "Site Customizations"
|
||||
header: "Header"
|
||||
css: "Stylesheet"
|
||||
override_default: "Do not include standard style sheet"
|
||||
|
@ -741,6 +762,7 @@ da:
|
|||
new_style: "New Style"
|
||||
delete: "Delete"
|
||||
delete_confirm: "Delete this customization?"
|
||||
about: "Site Customization allow you to modify stylesheets and headers on the site. Choose or add one to start editing."
|
||||
|
||||
email:
|
||||
title: "Email"
|
||||
|
|
|
@ -1092,6 +1092,9 @@ de:
|
|||
name_placeholder: "Gruppenname, keine Leerzeichen, gleiche Regel wie beim Benutzernamen"
|
||||
about: "Hier kannst du Gruppenzugehörigkeiten und Gruppennamen bearbeiten."
|
||||
can_not_edit_automatic: "Automatische Gruppenzugehörigkeiten können nicht bearbeitet werden. Bearbeite Benutzer, um Rollen und Vertrauensstufen einzustellen."
|
||||
delete: "Löschen"
|
||||
delete_confirm: "Diese gruppe löschen?"
|
||||
delete_failed: "Unable to delete group. If this is an automatic group, it cannot be destroyed."
|
||||
|
||||
api:
|
||||
title: "API"
|
||||
|
|
|
@ -1092,6 +1092,9 @@ en:
|
|||
name_placeholder: "Group name, no spaces, same as username rule"
|
||||
about: "Edit your group membership and names here"
|
||||
can_not_edit_automatic: "Automatic group membership is determined automatically, administer users to assign roles and trust levels"
|
||||
delete: "Delete"
|
||||
delete_confirm: "Delete this group?"
|
||||
delete_failed: "Unable to delete group. If this is an automatic group, it cannot be destroyed."
|
||||
|
||||
api:
|
||||
title: "API"
|
||||
|
|
|
@ -815,6 +815,26 @@ es:
|
|||
delete_title: "delete post (if its the first post delete topic)"
|
||||
flagged_by: "Flagged by"
|
||||
|
||||
groups:
|
||||
title: "Groups"
|
||||
edit: "Edit Groups"
|
||||
selector_placeholder: "add users"
|
||||
name_placeholder: "Group name, no spaces, same as username rule"
|
||||
about: "Edit your group membership and names here"
|
||||
can_not_edit_automatic: "Automatic group membership is determined automatically, administer users to assign roles and trust levels"
|
||||
delete: "Delete"
|
||||
delete_confirm: "Delete this group?"
|
||||
delete_failed: "Unable to delete group. If this is an automatic group, it cannot be destroyed."
|
||||
|
||||
api:
|
||||
title: "API"
|
||||
long_title: "API Information"
|
||||
key: "Key"
|
||||
generate: "Generate API Key"
|
||||
regenerate: "Regenerate API Key"
|
||||
info_html: "Your API key will allow you to create and update topics using JSON calls."
|
||||
note_html: "Keep this key <strong>secret</strong>, all users that have it may create arbitrary posts on the forum as any user."
|
||||
|
||||
customize:
|
||||
title: "Customize"
|
||||
header: "Header"
|
||||
|
|
|
@ -207,6 +207,7 @@ fr:
|
|||
taken: "Désolé, ce pseudo est déjà pris"
|
||||
error: "Il y a eu une erreur en changeant votre pseudo."
|
||||
invalid: "Ce pseudo est invalide. Il ne doit être composé que de lettres et de chiffres."
|
||||
|
||||
change_email:
|
||||
action: 'changer'
|
||||
title: "Changer d'email"
|
||||
|
@ -227,6 +228,7 @@ fr:
|
|||
instructions: "Votre nom complet (pas nécessairement unique)."
|
||||
too_short: "Votre nom est trop court."
|
||||
ok: "Votre nom à l'air sympa !."
|
||||
|
||||
username:
|
||||
title: "Pseudo"
|
||||
instructions: "Doit être unique et ne pas contenir d'espace. Les gens pourrons vous mentionner avec @pseudo."
|
||||
|
@ -1037,6 +1039,9 @@ fr:
|
|||
name_placeholder: "Nom du groupe, sans espace, mêmes règles que pour les noms d'utilisateurs"
|
||||
about: "Modifier votre adhésion et les noms ici"
|
||||
can_not_edit_automatic: "L'adhésion au groupe est défini automatiquement, les administrateurs assignent des rôles et niveaux de confiance"
|
||||
delete: "Supprimer"
|
||||
delete_confirm: "Supprimer ce groupe?"
|
||||
delete_failed: "Unable to delete group. If this is an automatic group, it cannot be destroyed."
|
||||
|
||||
api:
|
||||
title: "API"
|
||||
|
|
|
@ -667,6 +667,26 @@ id:
|
|||
delete_title: "delete post (if its the first post delete topic)"
|
||||
flagged_by: "Flagged by"
|
||||
|
||||
groups:
|
||||
title: "Groups"
|
||||
edit: "Edit Groups"
|
||||
selector_placeholder: "add users"
|
||||
name_placeholder: "Group name, no spaces, same as username rule"
|
||||
about: "Edit your group membership and names here"
|
||||
can_not_edit_automatic: "Automatic group membership is determined automatically, administer users to assign roles and trust levels"
|
||||
delete: "Delete"
|
||||
delete_confirm: "Delete this group?"
|
||||
delete_failed: "Unable to delete group. If this is an automatic group, it cannot be destroyed."
|
||||
|
||||
api:
|
||||
title: "API"
|
||||
long_title: "API Information"
|
||||
key: "Key"
|
||||
generate: "Generate API Key"
|
||||
regenerate: "Regenerate API Key"
|
||||
info_html: "Your API key will allow you to create and update topics using JSON calls."
|
||||
note_html: "Keep this key <strong>secret</strong>, all users that have it may create arbitrary posts on the forum as any user."
|
||||
|
||||
customize:
|
||||
title: "Customize"
|
||||
header: "Header"
|
||||
|
|
|
@ -958,6 +958,11 @@ it:
|
|||
edit: "Modifica Gruppi"
|
||||
selector_placeholder: "aggiungi utenti"
|
||||
name_placeholder: "Nome gruppo, no spazi, come lo username"
|
||||
about: "Edit your group membership and names here"
|
||||
can_not_edit_automatic: "Automatic group membership is determined automatically, administer users to assign roles and trust levels"
|
||||
delete: "Elimina"
|
||||
delete_confirm: "Delete this group?"
|
||||
delete_failed: "Unable to delete group. If this is an automatic group, it cannot be destroyed."
|
||||
|
||||
api:
|
||||
title: "API"
|
||||
|
|
|
@ -900,9 +900,22 @@ ko:
|
|||
title: "그룹"
|
||||
edit: "Edit 그룹"
|
||||
selector_placeholder: "메뉴 추가"
|
||||
name_placeholder: "Group name, no spaces, same as username rule"
|
||||
about: "Edit your group membership and names here"
|
||||
can_not_edit_automatic: "Automatic group membership is determined automatically, administer users to assign roles and trust levels"
|
||||
delete: "삭제"
|
||||
delete_confirm: "이 그룹을 삭제 하시겠습니까?"
|
||||
delete_failed: "Unable to delete group. If this is an automatic group, it cannot be destroyed."
|
||||
|
||||
api:
|
||||
title: "API"
|
||||
long_title: "API Information"
|
||||
key: "Key"
|
||||
generate: "Generate API Key"
|
||||
regenerate: "Regenerate API Key"
|
||||
info_html: "Your API key will allow you to create and update topics using JSON calls."
|
||||
note_html: "Keep this key <strong>secret</strong>, all users that have it may create arbitrary posts on the forum as any user."
|
||||
|
||||
customize:
|
||||
title: "사용자 지정"
|
||||
long_title: "사이트 사용자 지정"
|
||||
|
|
|
@ -979,6 +979,11 @@ nb_NO:
|
|||
edit: "Rediger Grupper"
|
||||
selector_placeholder: "legg til brukere"
|
||||
name_placeholder: "Gruppenavn, ingen mellomrom, samme som reglene for brukernavn"
|
||||
about: "Edit your group membership and names here"
|
||||
can_not_edit_automatic: "Automatic group membership is determined automatically, administer users to assign roles and trust levels"
|
||||
delete: "Slett"
|
||||
delete_confirm: "Slette denne grupper?"
|
||||
delete_failed: "Unable to delete group. If this is an automatic group, it cannot be destroyed."
|
||||
|
||||
api:
|
||||
title: "API"
|
||||
|
|
|
@ -1091,6 +1091,9 @@ nl:
|
|||
name_placeholder: "Groepsnaam, geen spaties, zelfde regels als bij een gebruikersnaam"
|
||||
about: "Wijzig hier je deelname aan groepen en je namen"
|
||||
can_not_edit_automatic: "Automatisch lidmaatschap van groepen wordt automatisch bepaald. Beheer rollen en trust levels van gebruikers"
|
||||
delete: Verwijder
|
||||
delete_confirm: Verwijder deze groepen?
|
||||
delete_failed: "Unable to delete group. If this is an automatic group, it cannot be destroyed."
|
||||
|
||||
api:
|
||||
title: API
|
||||
|
|
|
@ -1060,6 +1060,9 @@ pseudo:
|
|||
about: '[[ Éďíť ýóůř ǧřóůƿ ɱéɱƀéřšĥíƿ áɳď ɳáɱéš ĥéřé ]]'
|
||||
can_not_edit_automatic: '[[ Áůťóɱáťíč ǧřóůƿ ɱéɱƀéřšĥíƿ íš ďéťéřɱíɳéď áůťóɱáťíčáłłý,
|
||||
áďɱíɳíšťéř ůšéřš ťó áššíǧɳ řółéš áɳď ťřůšť łéνéłš ]]'
|
||||
delete: '[[ Ďéłéťé ]]'
|
||||
delete_confirm: '[[ Ďéłéťé ťĥíš ǧřóůƿ? ]]'
|
||||
delete_failed: '[[ Unable to delete group. If this is an automatic group, it cannot be destroyed. ]]'
|
||||
api:
|
||||
title: '[[ ÁРÍ ]]'
|
||||
long_title: '[[ ÁРÍ Íɳƒóřɱáťíóɳ ]]'
|
||||
|
|
|
@ -623,6 +623,26 @@ pt:
|
|||
delete_title: "apagar post (se for o primeiro post, apagar tópico)"
|
||||
flagged_by: "Flagged por"
|
||||
|
||||
groups:
|
||||
title: "Groups"
|
||||
edit: "Edit Groups"
|
||||
selector_placeholder: "add users"
|
||||
name_placeholder: "Group name, no spaces, same as username rule"
|
||||
about: "Edit your group membership and names here"
|
||||
can_not_edit_automatic: "Automatic group membership is determined automatically, administer users to assign roles and trust levels"
|
||||
delete: "Delete"
|
||||
delete_confirm: "Delete this group?"
|
||||
delete_failed: "Unable to delete group. If this is an automatic group, it cannot be destroyed."
|
||||
|
||||
api:
|
||||
title: "API"
|
||||
long_title: "API Information"
|
||||
key: "Key"
|
||||
generate: "Generate API Key"
|
||||
regenerate: "Regenerate API Key"
|
||||
info_html: "Your API key will allow you to create and update topics using JSON calls."
|
||||
note_html: "Keep this key <strong>secret</strong>, all users that have it may create arbitrary posts on the forum as any user."
|
||||
|
||||
customize:
|
||||
title: "Personalizar"
|
||||
header: "Cabeçalho"
|
||||
|
|
|
@ -968,6 +968,9 @@ pt_BR:
|
|||
name_placeholder: "Nome do grupo, sem espaços, regras iguais ao nome de usuário"
|
||||
about: "Editar participação no grupo e nomes aqui"
|
||||
can_not_edit_automatic: "Participação nos grupos automáticos é determinada automaticamente, gerencie os usuários para determinar papéis e níveis de confiança"
|
||||
delete: "Apagar"
|
||||
delete_confirm: "Apagar este grupos?"
|
||||
delete_failed: "Unable to delete group. If this is an automatic group, it cannot be destroyed."
|
||||
api:
|
||||
title: "API"
|
||||
long_title: "Informações da API"
|
||||
|
|
|
@ -1096,6 +1096,9 @@ ru:
|
|||
name_placeholder: Название группы, без пробелов, по тем же правилам, что и имя пользователя.
|
||||
about: Здесь можно редактировать группы и имена групп
|
||||
can_not_edit_automatic: Принадлежность пользователя к системным группам определяется автоматически, однако вы можете самостоятельно переназначить группу пользователя и уровень доверия
|
||||
delete: Удалить
|
||||
delete_confirm: удалить эту Группы?
|
||||
delete_failed: "Unable to delete group. If this is an automatic group, it cannot be destroyed."
|
||||
api:
|
||||
title: API
|
||||
long_title: Информация об API
|
||||
|
|
|
@ -839,8 +839,26 @@ sv:
|
|||
flagged_by: "Flaggad av"
|
||||
error: "Någonting gick snett"
|
||||
|
||||
groups:
|
||||
title: "Groups"
|
||||
edit: "Edit Groups"
|
||||
selector_placeholder: "add users"
|
||||
name_placeholder: "Group name, no spaces, same as username rule"
|
||||
about: "Edit your group membership and names here"
|
||||
can_not_edit_automatic: "Automatic group membership is determined automatically, administer users to assign roles and trust levels"
|
||||
delete: "Radera"
|
||||
delete_confirm: "Delete this group?"
|
||||
delete_failed: "Unable to delete group. If this is an automatic group, it cannot be destroyed."
|
||||
|
||||
api:
|
||||
title: "API"
|
||||
long_title: "API Information"
|
||||
key: "Key"
|
||||
generate: "Generate API Key"
|
||||
regenerate: "Regenerate API Key"
|
||||
info_html: "Your API key will allow you to create and update topics using JSON calls."
|
||||
note_html: "Keep this key <strong>secret</strong>, all users that have it may create arbitrary posts on the forum as any user."
|
||||
|
||||
customize:
|
||||
title: "Anpassa"
|
||||
header: "Sidhuvud"
|
||||
|
|
|
@ -568,10 +568,10 @@ zh_CN:
|
|||
not_found:
|
||||
title: "未找到主题"
|
||||
description: "抱歉,无法找到此主题。有可能它被论坛版主删掉了?"
|
||||
unread_posts:
|
||||
unread_posts:
|
||||
one: "此主题中你有一个帖子未阅"
|
||||
other: "此主题中你有 {{unread}} 个帖子未阅"
|
||||
new_posts:
|
||||
new_posts:
|
||||
other: "从你最近一次阅读此主题后,又有一个新帖子发表"
|
||||
other: "从你最近一次阅读此主题后,又有 {{new_posts}} 个新帖子发表"
|
||||
|
||||
|
@ -1109,6 +1109,9 @@ zh_CN:
|
|||
name_placeholder: "组名,不能含有空格,与用户名规则一致"
|
||||
about: "在这里编辑群组的名字和成员"
|
||||
can_not_edit_automatic: "这是一个自动划分的群组,管理员用来分配角色和管理用户等级"
|
||||
delete: "删除"
|
||||
delete_confirm: "删除这个小组吗?"
|
||||
delete_failed: "Unable to delete group. If this is an automatic group, it cannot be destroyed."
|
||||
|
||||
api:
|
||||
title: "应用开发接口(API)"
|
||||
|
|
|
@ -958,6 +958,9 @@ zh_TW:
|
|||
edit: "編輯群組"
|
||||
selector_placeholder: "添加用戶"
|
||||
name_placeholder: "組名,不能含有空格,與用戶名規則一致"
|
||||
delete: "刪除"
|
||||
delete_confirm: "删除这个小组吗?"
|
||||
delete_failed: "Unable to delete group. If this is an automatic group, it cannot be destroyed."
|
||||
|
||||
api:
|
||||
title: "應用開發接口(API)"
|
||||
|
|
|
@ -2,14 +2,17 @@ require 'spec_helper'
|
|||
|
||||
describe Admin::GroupsController do
|
||||
|
||||
before do
|
||||
@admin = log_in(:admin)
|
||||
end
|
||||
|
||||
it "is a subclass of AdminController" do
|
||||
(Admin::GroupsController < Admin::AdminController).should be_true
|
||||
end
|
||||
|
||||
it "produces valid json for groups" do
|
||||
admin = log_in(:admin)
|
||||
group = Fabricate.build(:group, name: "test")
|
||||
group.add(admin)
|
||||
group.add(@admin)
|
||||
group.save
|
||||
|
||||
xhr :get, :index
|
||||
|
@ -23,28 +26,31 @@ describe Admin::GroupsController do
|
|||
end
|
||||
|
||||
it "is able to refresh automatic groups" do
|
||||
admin = log_in(:admin)
|
||||
Group.expects(:refresh_automatic_groups!).returns(true)
|
||||
|
||||
xhr :post, :refresh_automatic_groups
|
||||
response.status.should == 200
|
||||
end
|
||||
|
||||
it "is able to destroy a group" do
|
||||
log_in(:admin)
|
||||
group = Fabricate(:group)
|
||||
context '.destroy' do
|
||||
it "returns a 422 if the group is automatic" do
|
||||
group = Fabricate(:group, automatic: true)
|
||||
xhr :delete, :destroy, id: group.id
|
||||
response.status.should == 422
|
||||
Group.where(id: group.id).count.should == 1
|
||||
end
|
||||
|
||||
xhr :delete, :destroy, id: group.id
|
||||
response.status.should == 200
|
||||
|
||||
Group.where(id: group.id).count.should == 0
|
||||
it "is able to destroy a non-automatic group" do
|
||||
group = Fabricate(:group)
|
||||
xhr :delete, :destroy, id: group.id
|
||||
response.status.should == 200
|
||||
Group.where(id: group.id).count.should == 0
|
||||
end
|
||||
end
|
||||
|
||||
it "is able to create a group" do
|
||||
a = log_in(:admin)
|
||||
|
||||
xhr :post, :create, group: {
|
||||
usernames: a.username,
|
||||
usernames: @admin.username,
|
||||
name: "bob"
|
||||
}
|
||||
|
||||
|
@ -53,16 +59,14 @@ describe Admin::GroupsController do
|
|||
groups = Group.where(name: "bob").to_a
|
||||
|
||||
groups.count.should == 1
|
||||
groups[0].usernames.should == a.username
|
||||
groups[0].usernames.should == @admin.username
|
||||
groups[0].name.should == "bob"
|
||||
|
||||
end
|
||||
|
||||
it "is able to update group members" do
|
||||
user1 = Fabricate(:user)
|
||||
user2 = Fabricate(:user)
|
||||
group = Fabricate(:group)
|
||||
log_in(:admin)
|
||||
|
||||
xhr :put, :update, id: group.id, name: 'fred', group: {
|
||||
name: 'fred',
|
||||
|
@ -72,6 +76,5 @@ describe Admin::GroupsController do
|
|||
group.reload
|
||||
group.users.count.should == 2
|
||||
group.name.should == 'fred'
|
||||
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue