Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
converse.js
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
converse.js
Commits
23201991
Commit
23201991
authored
Jul 28, 2020
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move the modal for adding MUCs to its own file
parent
1898e786
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
102 additions
and
94 deletions
+102
-94
src/converse-muc-views.js
src/converse-muc-views.js
+2
-94
src/modals/add-muc.js
src/modals/add-muc.js
+100
-0
No files found.
src/converse-muc-views.js
View file @
23201991
...
@@ -9,8 +9,8 @@ import "converse-modal";
...
@@ -9,8 +9,8 @@ import "converse-modal";
import
MUCListModal
from
'
modals/muc-list.js
'
;
import
MUCListModal
from
'
modals/muc-list.js
'
;
import
ModeratorToolsModal
from
"
./modals/moderator-tools.js
"
;
import
ModeratorToolsModal
from
"
./modals/moderator-tools.js
"
;
import
RoomDetailsModal
from
'
modals/muc-details.js
'
;
import
RoomDetailsModal
from
'
modals/muc-details.js
'
;
import
AddMUCModal
from
'
modals/add-muc.js
'
;
import
log
from
"
@converse/headless/log
"
;
import
log
from
"
@converse/headless/log
"
;
import
tpl_add_chatroom_modal
from
"
templates/add_chatroom_modal.js
"
;
import
tpl_chatroom
from
"
templates/chatroom.js
"
;
import
tpl_chatroom
from
"
templates/chatroom.js
"
;
import
tpl_chatroom_bottom_panel
from
"
templates/chatroom_bottom_panel.html
"
;
import
tpl_chatroom_bottom_panel
from
"
templates/chatroom_bottom_panel.html
"
;
import
tpl_chatroom_destroyed
from
"
templates/chatroom_destroyed.html
"
;
import
tpl_chatroom_destroyed
from
"
templates/chatroom_destroyed.html
"
;
...
@@ -149,98 +149,6 @@ converse.plugins.add('converse-muc-views', {
...
@@ -149,98 +149,6 @@ converse.plugins.add('converse-muc-views', {
Object
.
assign
(
_converse
.
ControlBoxView
.
prototype
,
viewWithRoomsPanel
);
Object
.
assign
(
_converse
.
ControlBoxView
.
prototype
,
viewWithRoomsPanel
);
}
}
_converse
.
AddChatRoomModal
=
BootstrapModal
.
extend
({
id
:
'
add-chatroom-modal
'
,
events
:
{
'
submit form.add-chatroom
'
:
'
openChatRoom
'
,
'
keyup .roomjid-input
'
:
'
checkRoomidPolicy
'
,
'
change .roomjid-input
'
:
'
checkRoomidPolicy
'
},
initialize
()
{
BootstrapModal
.
prototype
.
initialize
.
apply
(
this
,
arguments
);
this
.
listenTo
(
this
.
model
,
'
change:muc_domain
'
,
this
.
render
);
this
.
muc_roomid_policy_error_msg
=
null
;
},
toHTML
()
{
let
placeholder
=
''
;
if
(
!
api
.
settings
.
get
(
'
locked_muc_domain
'
))
{
const
muc_domain
=
this
.
model
.
get
(
'
muc_domain
'
)
||
api
.
settings
.
get
(
'
muc_domain
'
);
placeholder
=
muc_domain
?
`name@
${
muc_domain
}
`
:
__
(
'
name@conference.example.org
'
);
}
return
tpl_add_chatroom_modal
(
Object
.
assign
(
this
.
model
.
toJSON
(),
{
'
_converse
'
:
_converse
,
'
label_room_address
'
:
api
.
settings
.
get
(
'
muc_domain
'
)
?
__
(
'
Groupchat name
'
)
:
__
(
'
Groupchat address
'
),
'
chatroom_placeholder
'
:
placeholder
,
'
muc_roomid_policy_error_msg
'
:
this
.
muc_roomid_policy_error_msg
,
'
muc_roomid_policy_hint
'
:
api
.
settings
.
get
(
'
muc_roomid_policy_hint
'
)
}));
},
afterRender
()
{
this
.
el
.
addEventListener
(
'
shown.bs.modal
'
,
()
=>
{
this
.
el
.
querySelector
(
'
input[name="chatroom"]
'
).
focus
();
},
false
);
},
parseRoomDataFromEvent
(
form
)
{
const
data
=
new
FormData
(
form
);
const
jid
=
data
.
get
(
'
chatroom
'
);
let
nick
;
if
(
api
.
settings
.
get
(
'
locked_muc_nickname
'
))
{
nick
=
_converse
.
getDefaultMUCNickname
();
if
(
!
nick
)
{
throw
new
Error
(
"
Using locked_muc_nickname but no nickname found!
"
);
}
}
else
{
nick
=
data
.
get
(
'
nickname
'
).
trim
();
}
return
{
'
jid
'
:
jid
,
'
nick
'
:
nick
}
},
openChatRoom
(
ev
)
{
ev
.
preventDefault
();
const
data
=
this
.
parseRoomDataFromEvent
(
ev
.
target
);
if
(
data
.
nick
===
""
)
{
// Make sure defaults apply if no nick is provided.
data
.
nick
=
undefined
;
}
let
jid
;
if
(
api
.
settings
.
get
(
'
locked_muc_domain
'
)
||
(
api
.
settings
.
get
(
'
muc_domain
'
)
&&
!
u
.
isValidJID
(
data
.
jid
)))
{
jid
=
`
${
Strophe
.
escapeNode
(
data
.
jid
)}
@
${
api
.
settings
.
get
(
'
muc_domain
'
)}
`
;
}
else
{
jid
=
data
.
jid
this
.
model
.
setDomain
(
jid
);
}
api
.
rooms
.
open
(
jid
,
Object
.
assign
(
data
,
{
jid
}),
true
);
this
.
modal
.
hide
();
ev
.
target
.
reset
();
},
checkRoomidPolicy
()
{
if
(
api
.
settings
.
get
(
'
muc_roomid_policy
'
)
&&
api
.
settings
.
get
(
'
muc_domain
'
))
{
let
jid
=
this
.
el
.
querySelector
(
'
.roomjid-input
'
).
value
;
if
(
converse
.
locked_muc_domain
||
!
u
.
isValidJID
(
jid
))
{
jid
=
`
${
Strophe
.
escapeNode
(
jid
)}
@
${
api
.
settings
.
get
(
'
muc_domain
'
)}
`
;
}
const
roomid
=
Strophe
.
getNodeFromJid
(
jid
);
const
roomdomain
=
Strophe
.
getDomainFromJid
(
jid
);
if
(
api
.
settings
.
get
(
'
muc_domain
'
)
!==
roomdomain
||
api
.
settings
.
get
(
'
muc_roomid_policy
'
).
test
(
roomid
))
{
this
.
muc_roomid_policy_error_msg
=
null
;
}
else
{
this
.
muc_roomid_policy_error_msg
=
__
(
'
Groupchat id is invalid.
'
);
}
this
.
render
();
}
}
});
/**
/**
* NativeView which renders a groupchat, based upon
* NativeView which renders a groupchat, based upon
...
@@ -1550,7 +1458,7 @@ converse.plugins.add('converse-muc-views', {
...
@@ -1550,7 +1458,7 @@ converse.plugins.add('converse-muc-views', {
showAddRoomModal
(
ev
)
{
showAddRoomModal
(
ev
)
{
if
(
this
.
add_room_modal
===
undefined
)
{
if
(
this
.
add_room_modal
===
undefined
)
{
this
.
add_room_modal
=
new
_converse
.
AddChatRoom
Modal
({
'
model
'
:
this
.
model
});
this
.
add_room_modal
=
new
AddMUC
Modal
({
'
model
'
:
this
.
model
});
}
}
this
.
add_room_modal
.
show
(
ev
);
this
.
add_room_modal
.
show
(
ev
);
},
},
...
...
src/modals/add-muc.js
0 → 100644
View file @
23201991
import
tpl_add_chatroom_modal
from
"
templates/add_chatroom_modal.js
"
;
import
{
BootstrapModal
}
from
"
../converse-modal.js
"
;
import
{
Strophe
}
from
'
strophe.js/src/strophe
'
;
import
{
__
}
from
'
@converse/headless/i18n
'
;
import
{
_converse
,
api
,
converse
}
from
"
@converse/headless/converse-core
"
;
const
u
=
converse
.
env
.
utils
;
export
default
BootstrapModal
.
extend
({
id
:
'
add-chatroom-modal
'
,
events
:
{
'
submit form.add-chatroom
'
:
'
openChatRoom
'
,
'
keyup .roomjid-input
'
:
'
checkRoomidPolicy
'
,
'
change .roomjid-input
'
:
'
checkRoomidPolicy
'
},
initialize
()
{
BootstrapModal
.
prototype
.
initialize
.
apply
(
this
,
arguments
);
this
.
listenTo
(
this
.
model
,
'
change:muc_domain
'
,
this
.
render
);
this
.
muc_roomid_policy_error_msg
=
null
;
},
toHTML
()
{
let
placeholder
=
''
;
if
(
!
api
.
settings
.
get
(
'
locked_muc_domain
'
))
{
const
muc_domain
=
this
.
model
.
get
(
'
muc_domain
'
)
||
api
.
settings
.
get
(
'
muc_domain
'
);
placeholder
=
muc_domain
?
`name@
${
muc_domain
}
`
:
__
(
'
name@conference.example.org
'
);
}
return
tpl_add_chatroom_modal
(
Object
.
assign
(
this
.
model
.
toJSON
(),
{
'
_converse
'
:
_converse
,
'
label_room_address
'
:
api
.
settings
.
get
(
'
muc_domain
'
)
?
__
(
'
Groupchat name
'
)
:
__
(
'
Groupchat address
'
),
'
chatroom_placeholder
'
:
placeholder
,
'
muc_roomid_policy_error_msg
'
:
this
.
muc_roomid_policy_error_msg
,
'
muc_roomid_policy_hint
'
:
api
.
settings
.
get
(
'
muc_roomid_policy_hint
'
)
}));
},
afterRender
()
{
this
.
el
.
addEventListener
(
'
shown.bs.modal
'
,
()
=>
{
this
.
el
.
querySelector
(
'
input[name="chatroom"]
'
).
focus
();
},
false
);
},
parseRoomDataFromEvent
(
form
)
{
const
data
=
new
FormData
(
form
);
const
jid
=
data
.
get
(
'
chatroom
'
);
let
nick
;
if
(
api
.
settings
.
get
(
'
locked_muc_nickname
'
))
{
nick
=
_converse
.
getDefaultMUCNickname
();
if
(
!
nick
)
{
throw
new
Error
(
"
Using locked_muc_nickname but no nickname found!
"
);
}
}
else
{
nick
=
data
.
get
(
'
nickname
'
).
trim
();
}
return
{
'
jid
'
:
jid
,
'
nick
'
:
nick
}
},
openChatRoom
(
ev
)
{
ev
.
preventDefault
();
const
data
=
this
.
parseRoomDataFromEvent
(
ev
.
target
);
if
(
data
.
nick
===
""
)
{
// Make sure defaults apply if no nick is provided.
data
.
nick
=
undefined
;
}
let
jid
;
if
(
api
.
settings
.
get
(
'
locked_muc_domain
'
)
||
(
api
.
settings
.
get
(
'
muc_domain
'
)
&&
!
u
.
isValidJID
(
data
.
jid
)))
{
jid
=
`
${
Strophe
.
escapeNode
(
data
.
jid
)}
@
${
api
.
settings
.
get
(
'
muc_domain
'
)}
`
;
}
else
{
jid
=
data
.
jid
this
.
model
.
setDomain
(
jid
);
}
api
.
rooms
.
open
(
jid
,
Object
.
assign
(
data
,
{
jid
}),
true
);
this
.
modal
.
hide
();
ev
.
target
.
reset
();
},
checkRoomidPolicy
()
{
if
(
api
.
settings
.
get
(
'
muc_roomid_policy
'
)
&&
api
.
settings
.
get
(
'
muc_domain
'
))
{
let
jid
=
this
.
el
.
querySelector
(
'
.roomjid-input
'
).
value
;
if
(
converse
.
locked_muc_domain
||
!
u
.
isValidJID
(
jid
))
{
jid
=
`
${
Strophe
.
escapeNode
(
jid
)}
@
${
api
.
settings
.
get
(
'
muc_domain
'
)}
`
;
}
const
roomid
=
Strophe
.
getNodeFromJid
(
jid
);
const
roomdomain
=
Strophe
.
getDomainFromJid
(
jid
);
if
(
api
.
settings
.
get
(
'
muc_domain
'
)
!==
roomdomain
||
api
.
settings
.
get
(
'
muc_roomid_policy
'
).
test
(
roomid
))
{
this
.
muc_roomid_policy_error_msg
=
null
;
}
else
{
this
.
muc_roomid_policy_error_msg
=
__
(
'
Groupchat id is invalid.
'
);
}
this
.
render
();
}
}
});
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment