GroupSettings.vue 37 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103
  1. <template>
  2. <div class="group-settings-component">
  3. <div v-if="!initalLoad">
  4. <p class="text-center mt-5 pt-5 font-weight-bold">Loading...</p>
  5. </div>
  6. <div v-else>
  7. <div class="bg-white mb-3 border-bottom">
  8. <div class="container">
  9. <div class="col-12 group-settings-component-header">
  10. <div>
  11. <h1 class="font-weight-bold mb-4">Group Settings</h1>
  12. <p class="text-muted mb-0">
  13. <span v-once>
  14. <i class="fas fa-globe mr-1"></i>
  15. {{ group.membership == 'all' ? 'Public Group' : 'Private Group'}}
  16. </span>
  17. <span class="mx-2">
  18. ·
  19. </span>
  20. <span>{{ group.member_count == 1 ? group.member_count + ' Member' : group.member_count + ' Members' }}</span>
  21. <span class="mx-2">
  22. ·
  23. </span>
  24. <span class="text-lighter">ID:{{ group.id }}</span>
  25. </p>
  26. </div>
  27. <div>
  28. <a
  29. v-if="isAdmin"
  30. class="mr-2 btn btn-outline-secondary rounded-pill cta-btn font-weight-bold"
  31. :href="group.url">
  32. <i class="fas fa-chevron-left mr-1"></i> Back to Group
  33. </a>
  34. <button class="btn btn-primary font-weight-bold rounded-pill px-4" :disabled="savingChanges" @click="submit">
  35. Save Changes
  36. </button>
  37. </div>
  38. </div>
  39. <div class="col-12">
  40. <ul class="nav nav-tabs border-bottom-0 font-weight-bold small">
  41. <li class="nav-item">
  42. <a
  43. :class="{ active: tab == 'home'}"
  44. class="nav-link"
  45. href="#"
  46. @click.prevent="toggleTab('home')">
  47. General
  48. </a>
  49. </li>
  50. <li class="nav-item">
  51. <a
  52. :class="{ active: tab == 'customize'}"
  53. class="nav-link"
  54. href="#"
  55. @click.prevent="toggleTab('customize')">
  56. Customize
  57. </a>
  58. </li>
  59. <!-- <li class="nav-item">
  60. <a
  61. :class="{ active: tab == 'mod'}"
  62. class="nav-link"
  63. href="#"
  64. @click.prevent="toggleTab('mod')">
  65. Moderation
  66. </a>
  67. </li> -->
  68. <li class="nav-item">
  69. <a
  70. :class="{ active: tab == 'blocked'}"
  71. class="nav-link"
  72. href="#"
  73. @click.prevent="toggleTab('blocked')">
  74. Domain/User Blocks
  75. </a>
  76. </li>
  77. <li class="nav-item">
  78. <a
  79. :class="{ active: tab == 'interactions'}"
  80. class="nav-link"
  81. href="#"
  82. @click.prevent="toggleTab('interactions')">
  83. Interactions
  84. </a>
  85. </li>
  86. <!-- <li class="nav-item">
  87. <a class="nav-link" href="#">Interaction Log</a>
  88. </li>
  89. <li class="nav-item">
  90. <a class="nav-link" href="#">Blocked Instances &amp; Users</a>
  91. </li> -->
  92. <li class="nav-item">
  93. <a
  94. :class="{ active: tab == 'limits'}"
  95. class="nav-link"
  96. href="#"
  97. @click.prevent="toggleTab('limits')">
  98. Limits
  99. </a>
  100. </li>
  101. <!-- <li class="nav-item">
  102. <a class="nav-link" href="#">Limits</a>
  103. </li>
  104. <li class="nav-item">
  105. <a class="nav-link" href="#">Roles</a>
  106. </li>
  107. <li class="nav-item">
  108. <a class="nav-link" href="#">Import &amp; Export</a>
  109. </li> -->
  110. <li class="nav-item">
  111. <a
  112. :class="{ active: tab == 'advanced'}"
  113. class="nav-link"
  114. href="#"
  115. @click.prevent="toggleTab('advanced')">
  116. Advanced
  117. </a>
  118. </li>
  119. </ul>
  120. </div>
  121. </div>
  122. </div>
  123. <div class="container-xl pt-3">
  124. <div v-if="tab == 'home'" class="row">
  125. <div class="col-12 col-md-6 offset-md-3">
  126. <div class="">
  127. <div class="form-group">
  128. <label class="font-weight-bold">Name</label>
  129. <input class="form-control" :value="group.name" disabled>
  130. <p class="form-text small text-muted">You cannot change a groups name at this time.</p>
  131. </div>
  132. <hr>
  133. <div class="form-group">
  134. <label class="font-weight-bold">Category</label>
  135. <select class="custom-select" v-model="category">
  136. <option value="" selected="" disabled="">Select a category</option>
  137. <option v-for="c in categories" :value="c">{{ c }}</option>
  138. </select>
  139. <p class="form-text small text-muted">Choose the most relevant category to improve discovery and visibility</p>
  140. </div>
  141. <hr>
  142. <div class="form-group">
  143. <label class="font-weight-bold">Description</label>
  144. <textarea class="form-control" rows="4" v-model="group.description" style="resize: none;">
  145. </textarea>
  146. <span class="form-text small text-muted font-weight-bold text-right">
  147. {{group.description ? group.description.length : 0}}/500
  148. </span>
  149. <p class="form-text small text-muted">A plain text description of your group. Be as descriptive as possible to give potential members a better idea of what to expect.</p>
  150. </div>
  151. <!-- <hr>
  152. <div class="form-group">
  153. <label class="font-weight-bold">Avatar Photo</label>
  154. <div v-if="group.metadata && group.metadata.hasOwnProperty('avatar')" class="d-flex justify-content-between align-items-center">
  155. <img :src="group.metadata.avatar.url" width="100" height="100" class="rounded-circle border" style="object-fit: cover;">
  156. <p class="mb-0 mt-2 text-lighter">
  157. <a href="" class="text-muted font-weight-bold">
  158. Preview
  159. </a>
  160. <span class="mx-1">·</span>
  161. <a href="" class="text-muted font-weight-bold">
  162. Update
  163. </a>
  164. <span class="mx-1">·</span>
  165. <a href="" class="text-danger font-weight-bold">
  166. Delete
  167. </a>
  168. </p>
  169. </div>
  170. <div v-else>
  171. <div class="custom-file">
  172. <input type="file" class="custom-file-input" ref="avatarInput">
  173. <label class="custom-file-label" for="avatarInput">Choose file</label>
  174. </div>
  175. <p class="form-text small text-muted">Must be jpeg or png format, up to 2MB</p>
  176. </div>
  177. </div>
  178. <hr>
  179. <div class="form-group">
  180. <label class="font-weight-bold">Header Photo</label>
  181. <div v-if="group.metadata && group.metadata.hasOwnProperty('header')" class="d-flex justify-content-between align-items-center">
  182. <img :src="group.metadata.header.url" width="200" height="100" class="rounded border" style="object-fit: cover;">
  183. <p class="mb-0 mt-2 text-lighter">
  184. <a href="" class="text-muted font-weight-bold">
  185. Preview
  186. </a>
  187. <span class="mx-1">·</span>
  188. <a href="" class="text-muted font-weight-bold">
  189. Update
  190. </a>
  191. <span class="mx-1">·</span>
  192. <a href="" class="text-danger font-weight-bold">
  193. Delete
  194. </a>
  195. </p>
  196. </div>
  197. <div v-else>
  198. <div class="custom-file">
  199. <input type="file" class="custom-file-input" ref="headerInput">
  200. <label class="custom-file-label" for="headerInput">Choose file</label>
  201. </div>
  202. <p class="form-text small text-muted">Must be jpeg or png format, up to 10MB</p>
  203. </div>
  204. </div> -->
  205. </div>
  206. </div>
  207. </div>
  208. <div v-if="tab == 'customize'" class="row">
  209. <div class="col-12 col-md-6 offset-md-3">
  210. <div class="">
  211. <div class="form-group">
  212. <label class="font-weight-bold">Avatar Photo</label>
  213. <div v-if="group.metadata && group.metadata.hasOwnProperty('avatar')" class="d-flex justify-content-between align-items-center">
  214. <img :src="group.metadata.avatar.url" width="100" height="100" class="rounded-circle border" style="object-fit: cover;">
  215. <p class="mb-0 mt-2 text-lighter">
  216. <a href="" class="text-muted font-weight-bold">
  217. Preview
  218. </a>
  219. <span class="mx-1">·</span>
  220. <a href="" class="text-muted font-weight-bold">
  221. Update
  222. </a>
  223. <span class="mx-1">·</span>
  224. <a href="#" class="text-danger font-weight-bold" @click.prevent="handleDeleteAvatar()">
  225. Delete
  226. </a>
  227. </p>
  228. </div>
  229. <div v-else>
  230. <div class="custom-file">
  231. <input type="file" class="custom-file-input" ref="avatarInput">
  232. <label class="custom-file-label" for="avatarInput">Choose file</label>
  233. </div>
  234. <p class="form-text small text-muted">Must be jpeg or png format, up to 2MB</p>
  235. </div>
  236. </div>
  237. <hr>
  238. <div class="form-group">
  239. <label class="font-weight-bold">Header Photo</label>
  240. <div v-if="group.metadata && group.metadata.hasOwnProperty('header')" class="d-flex justify-content-between align-items-center">
  241. <img :src="group.metadata.header.url" width="200" height="100" class="rounded border" style="object-fit: cover;">
  242. <p class="mb-0 mt-2 text-lighter">
  243. <a href="" class="text-muted font-weight-bold">
  244. Preview
  245. </a>
  246. <span class="mx-1">·</span>
  247. <a href="" class="text-muted font-weight-bold">
  248. Update
  249. </a>
  250. <span class="mx-1">·</span>
  251. <a href="#" class="text-danger font-weight-bold" @click.prevent="handleDeleteHeader()">
  252. Delete
  253. </a>
  254. </p>
  255. </div>
  256. <div v-else>
  257. <div class="custom-file">
  258. <input type="file" class="custom-file-input" ref="headerInput">
  259. <label class="custom-file-label" for="headerInput">Choose file</label>
  260. </div>
  261. <p class="form-text small text-muted">Must be jpeg or png format, up to 10MB</p>
  262. </div>
  263. </div>
  264. </div>
  265. </div>
  266. </div>
  267. <div v-if="tab == 'interactions'" class="row">
  268. <div class="col-12 col-md-3">
  269. <p class="lead">The <strong>Interaction Log</strong> displays all member activities relating to this group.</p>
  270. <p class="lead">You may see logs from blocked, deleted and remote accounts.</p>
  271. </div>
  272. <div class="col-12 col-md-6">
  273. <div class="list-group">
  274. <div v-for="(log, index) in interactionLog" class="list-group-item">
  275. <div class="media align-items-center">
  276. <img :src="log.profile.avatar" width="32" height="32" class="rounded-circle border mr-3" onerror="this.onerror=null;this.src='/storage/avatars/default.png?v=2'">
  277. <div class="media-body">
  278. <span class="font-weight-bold">{{log.profile.username}}</span>
  279. <span v-if="log.type == 'group:comment:created'">
  280. commented on a <a :href="sidToUrl(log.metadata.status_id)" class="font-weight-bold">post</a>
  281. </span>
  282. <span v-else-if="log.type == 'group:joined'">
  283. joined the group
  284. </span>
  285. <span v-else-if="log.type == 'group:like'">
  286. liked a <a :href="sidToUrl(log.metadata.status_id)" class="font-weight-bold">post</a>
  287. </span>
  288. <span v-else-if="log.type == 'group:settings:updated'">
  289. updated the <a href="" class="font-weight-bold">group settings</a>
  290. </span>
  291. <span v-else-if="log.type == 'group:status:created'">
  292. created a <a :href="sidToUrl(log.metadata.status_id)" class="font-weight-bold">post</a>
  293. </span>
  294. <span v-else-if="log.type == 'group:status:deleted'">
  295. deleted a <a :href="sidToUrl(log.metadata.status_id)" class="font-weight-bold">post</a>
  296. </span>
  297. <span v-else-if="log.type == 'group:unlike'">
  298. unliked a <a :href="sidToUrl(log.metadata.status_id)" class="font-weight-bold">post</a>
  299. </span>
  300. <span v-else-if="log.type == 'group:admin:block:instance'">
  301. blocked <span class="font-weight-bold text-primary">{{ log.metadata.domain }}</span>
  302. </span>
  303. <span v-else-if="log.type == 'group:admin:block:user'">
  304. blocked <a class="font-weight-bold text-primary" :href="'/' + log.metadata.username">{{ log.metadata.username }}</a>
  305. </span>
  306. <span v-else-if="log.type == 'group:report:create'">
  307. created a <a :href="reportUrl(log.metadata.report_id)" class="font-weight-bold">report</a> about <a :href="'/' + log.metadata.username" class="font-weight-bold">{{ log.metadata.username}}</a>'s <a :href="log.metadata.url" class="font-weight-bold">post</a>
  308. </span>
  309. <span v-else-if="log.type == 'group:moderation:action'">
  310. handled a <a :href="reportUrl(log.metadata.report_id)" class="font-weight-bold">mod report</a> regarding <a :href="log.metadata.status_url" class="font-weight-bold">this post</a>
  311. </span>
  312. <span v-else-if="log.type =='group:member-limits:updated'">
  313. updated <a :href="memberInteractionUrl(log.metadata.profile_id)" class="font-weight-bold">interaction limits</a> for <a :href="'/' + log.metadata.username" class="font-weight-bold">{{ log.metadata.username }}</a>
  314. </span>
  315. <span v-else>{{log.type}}</span>
  316. <div class="float-right text-muted small font-weight-bold">{{timeago(log.created_at)}}</div>
  317. </div>
  318. </div>
  319. </div>
  320. <div v-if="interactionLogShowMore" class="list-group-item">
  321. <button class="btn btn-light font-weight-bold btn-block" @click="loadMoreInteractions">Load more</button>
  322. </div>
  323. </div>
  324. </div>
  325. <div class="col-12 col-md-3">
  326. <p class="font-weight-bold small">SEARCH</p>
  327. <div class="form-group">
  328. <input class="form-control rounded-pill" placeholder="Search username, type or url"/>
  329. </div>
  330. <hr>
  331. <p class="font-weight-bold small">ACTIVITIES</p>
  332. <div class="form-check">
  333. <input class="form-check-input" type="checkbox" checked id="filter1">
  334. <label class="form-check-label font-weight-bold" for="filter1">
  335. Joined Group
  336. </label>
  337. </div>
  338. <div class="form-check">
  339. <input class="form-check-input" type="checkbox" checked id="filter1">
  340. <label class="form-check-label font-weight-bold" for="filter1">
  341. Left Group
  342. </label>
  343. </div>
  344. <div class="form-check">
  345. <input class="form-check-input" type="checkbox" checked id="filter1">
  346. <label class="form-check-label font-weight-bold" for="filter1">
  347. Posts
  348. </label>
  349. </div>
  350. <div class="form-check">
  351. <input class="form-check-input" type="checkbox" checked id="filter1">
  352. <label class="form-check-label font-weight-bold" for="filter1">
  353. Comments
  354. </label>
  355. </div>
  356. <div class="form-check">
  357. <input class="form-check-input" type="checkbox" checked id="filter1">
  358. <label class="form-check-label font-weight-bold" for="filter1">
  359. Likes
  360. </label>
  361. </div>
  362. <hr>
  363. <p class="font-weight-bold small">FILTERS</p>
  364. <div class="form-check">
  365. <input class="form-check-input" type="checkbox" value="" id="filter1">
  366. <label class="form-check-label font-weight-bold" for="filter1">
  367. Local members only
  368. </label>
  369. </div>
  370. <div class="form-check">
  371. <input class="form-check-input" type="checkbox" value="" id="filter1">
  372. <label class="form-check-label font-weight-bold" for="filter1">
  373. Remote members only
  374. </label>
  375. </div>
  376. <div class="form-check">
  377. <input class="form-check-input" type="checkbox" value="" id="filter1">
  378. <label class="form-check-label font-weight-bold" for="filter1">
  379. Blocked members only
  380. </label>
  381. </div>
  382. </div>
  383. </div>
  384. <div v-if="tab == 'blocked'" class="row">
  385. <div class="col-12 col-md-3">
  386. <p class="h5">Blocked Instances &amp; Users</p>
  387. <p>Fine-grained control over who can join and interact with your group</p>
  388. <p>Blocking an instance will revoke membership from users on that instance and prevent other users on that instance from joining</p>
  389. <p>Blocking a user will revoke membership and remove all interactions from that user</p>
  390. <p>Moderating an instance will require all new membership requests from that instance to be approved by a group admin before the specific user can join</p>
  391. </div>
  392. <div class="col-12 col-md-6">
  393. <div class="card mb-3">
  394. <div class="card-header text-muted font-weight-bold small">Blocked Instances</div>
  395. <div class="list-group list-group-flush">
  396. <div v-for="instance in blockedInstances" class="list-group-item d-flex justify-content-between align-items-center">
  397. <div>
  398. {{instance}}
  399. </div>
  400. <button class="btn btn-light" @click.prevent="undoBlock('instance', instance)">
  401. <i class="far fa-trash-alt text-lighter"></i>
  402. </button>
  403. </div>
  404. <div v-if="blockedInstances.length == 3" class="list-group-item">
  405. <p class="mb-0 small font-weight-bold text-lighter text-center">View All</p>
  406. </div>
  407. </div>
  408. </div>
  409. <div class="card mb-3">
  410. <div class="card-header text-muted font-weight-bold small">Blocked Users</div>
  411. <div class="list-group list-group-flush">
  412. <div v-for="instance in blockedUsers" class="list-group-item d-flex justify-content-between align-items-center">
  413. <div>
  414. <img src="/storage/avatars/default.jpg" width="32" height="32" class="rounded-circle border mr-3">{{instance}}
  415. </div>
  416. <button class="btn btn-light" @click.prevent="undoBlock('user', instance)">
  417. <i class="far fa-trash-alt text-lighter"></i>
  418. </button>
  419. </div>
  420. <div v-if="blockedUsers.length == 3" class="list-group-item">
  421. <p class="mb-0 small font-weight-bold text-lighter text-center">View All</p>
  422. </div>
  423. </div>
  424. </div>
  425. <div class="card mb-3">
  426. <div class="card-header text-muted font-weight-bold small">Moderated Join Requests</div>
  427. <div class="list-group list-group-flush">
  428. <div v-for="instance in moderatedInstances" class="list-group-item d-flex justify-content-between align-items-center">
  429. <div>
  430. {{instance}}
  431. </div>
  432. <button class="btn btn-light" @click.prevent="undoBlock('moderate', instance)">
  433. <i class="far fa-trash-alt text-lighter"></i>
  434. </button>
  435. </div>
  436. </div>
  437. </div>
  438. </div>
  439. <div class="col-12 col-md-3">
  440. <button class="btn btn-light border btn-block font-weight-bold" @click.prevent="blockAction('instance')">Block Instance</button>
  441. <button class="btn btn-light border btn-block font-weight-bold" @click.prevent="blockAction('user')">Block User</button>
  442. <button class="btn btn-light border btn-block font-weight-bold" @click.prevent="blockAction('moderate')">Moderate Join Requests</button>
  443. <hr>
  444. <button class="btn btn-light border btn-block font-weight-bold">Import</button>
  445. <button class="btn btn-light border btn-block font-weight-bold" @click.prevent="exportBlocks()">Export</button>
  446. </div>
  447. </div>
  448. <div v-if="tab == 'advanced'" class="row">
  449. <div class="col-12 col-md-6 offset-md-3">
  450. <div class="mt-3">
  451. <div class="form-group">
  452. <label class="font-weight-bold">Membership</label>
  453. <select class="form-control rounded-pill" v-model="group.membership">
  454. <option value="all">Public</option>
  455. <option value="private">Private</option>
  456. <option value="local">Local</option>
  457. </select>
  458. <p class="help-text mt-1">
  459. {{ membershipDescription[group.membership] }}
  460. </p>
  461. </div>
  462. <!-- <hr>
  463. <div class="form-group">
  464. <label class="font-weight-bold">Post Types</label>
  465. <div class="custom-control custom-checkbox mb-2">
  466. <input type="checkbox" class="custom-control-input" id="textType" checked disabled>
  467. <label class="custom-control-label" for="textType">Text</label>
  468. </div>
  469. <div class="custom-control custom-checkbox mb-2">
  470. <input type="checkbox" class="custom-control-input" id="photoType" checked>
  471. <label class="custom-control-label" for="photoType">Photos</label>
  472. </div>
  473. <div class="custom-control custom-checkbox mb-2">
  474. <input type="checkbox" class="custom-control-input" id="videoType" checked>
  475. <label class="custom-control-label" for="videoType">Videos</label>
  476. </div>
  477. <div class="custom-control custom-checkbox mb-2">
  478. <input type="checkbox" class="custom-control-input" id="pollType" checked>
  479. <label class="custom-control-label" for="pollType">Polls</label>
  480. </div>
  481. <div class="custom-control custom-checkbox">
  482. <input type="checkbox" class="custom-control-input" id="eventType" disabled>
  483. <label class="custom-control-label" for="eventType">Events</label>
  484. </div>
  485. </div> -->
  486. </div>
  487. <hr>
  488. <div v-if="group.membership !== 'local'" class="form-group row">
  489. <div class="col-sm-12">
  490. <div class="mb-1">
  491. <div class="form-check">
  492. <input class="form-check-input" type="checkbox" v-model="advanced.activitypub">
  493. <label class="form-check-label font-weight-bold text-dark text-capitalize ml-1">Enable ActivityPub</label>
  494. </div>
  495. </div>
  496. <transition name="fade">
  497. <div v-if="!advanced.activitypub" class="alert alert-info mt-2">
  498. <div class="media align-items-center">
  499. <i class="far fa-exclamation-circle fa-2x mr-3"></i>
  500. <div class="media-body">
  501. <p class="font-weight-bold mb-0">Federation Warning</p>
  502. <p class="small mb-0" style="font-weight:600;">Groups that choose to disable federation later will lose remote content and members and cannot re-enable federation for 24 hours. You can change this later</p>
  503. </div>
  504. </div>
  505. </div>
  506. </transition>
  507. </div>
  508. </div>
  509. <hr v-if="group.membership !== 'local'">
  510. <div class="form-group row">
  511. <div class="col-sm-12">
  512. <div class="mb-1">
  513. <div class="form-check">
  514. <input class="form-check-input" type="checkbox" v-model="advanced.is_nsfw">
  515. <label class="form-check-label font-weight-bold text-dark text-capitalize ml-1">Allow adult content (18+)</label>
  516. </div>
  517. </div>
  518. <transition name="fade">
  519. <div v-if="!advanced.is_nsfw" class="alert alert-info mt-2">
  520. <div class="media align-items-center">
  521. <i class="far fa-exclamation-circle fa-2x mr-3"></i>
  522. <div class="media-body">
  523. <p class="font-weight-bold mb-0">Adult Content Warning</p>
  524. <p class="small mb-0" style="font-weight:600;">Groups that allow adult content should enable this or risk suspension or deletion by instance admins. Illegal content is prohibited. You can change this later</p>
  525. </div>
  526. </div>
  527. </div>
  528. </transition>
  529. </div>
  530. </div>
  531. <hr>
  532. <div class="form-group row">
  533. <div class="col-sm-12">
  534. <div class="mb-1">
  535. <div class="form-check">
  536. <input class="form-check-input" type="checkbox" v-model="advanced.discoverable">
  537. <label class="form-check-label font-weight-bold text-dark text-capitalize ml-1">Make group discoverable</label>
  538. </div>
  539. <p class="help-text small text-muted">
  540. <span>
  541. Being discoverable means that your group appears in search results, on the discover page and can be used in group recommendations
  542. </span>
  543. </p>
  544. </div>
  545. </div>
  546. <hr>
  547. </div>
  548. <div v-if="group.member_count >= 25" class="form-group row">
  549. <div class="col-sm-12">
  550. <div class="mb-1">
  551. <div class="form-check">
  552. <input class="form-check-input" type="checkbox">
  553. <label class="form-check-label font-weight-bold text-dark text-capitalize ml-1">Enable spam detection</label>
  554. </div>
  555. <p class="help-text small text-muted">
  556. <span>
  557. Detect and temporarily remove content classified as spam from new members until it can be reviewed by a group admin. <strong>We do not recommend enabling this unless you have or expect periodic spam as it may produce false-positives and reduce member experience &amp; retention.</strong>
  558. </span>
  559. </p>
  560. </div>
  561. </div>
  562. <hr>
  563. </div>
  564. <div v-if="group.member_count >= 25" class="form-group row">
  565. <div class="col-sm-12">
  566. <div class="mb-1">
  567. <div class="form-check">
  568. <input class="form-check-input" type="checkbox">
  569. <label class="form-check-label font-weight-bold text-dark text-capitalize ml-1">Enable admin direct messages</label>
  570. </div>
  571. <p class="help-text small text-muted">
  572. <span>
  573. Allow {{ group.membership == 'local' ? 'local users' : group.membership == 'private' ? 'members' : 'anyone'}} to <a href="#">direct message</a> group admins. The direct message inbox is separate from your own account.
  574. </span>
  575. </p>
  576. </div>
  577. </div>
  578. <hr>
  579. </div>
  580. <h4 class="font-weight-bold pt-3">Danger Zone</h4>
  581. <div class="mb-4 border rounded border-danger">
  582. <ul class="list-group mb-0 pb-0">
  583. <li class="list-group-item border-left-0 border-right-0 py-3 d-flex justify-content-between disabled">
  584. <div>
  585. <p class="font-weight-bold mb-1">Temporarily Disable Group</p>
  586. <p class="mb-0 small">Not available</p>
  587. </div>
  588. <div>
  589. <a class="btn btn-outline-danger font-weight-bold py-1" href="#">Disable</a>
  590. </div>
  591. </li>
  592. <li class="list-group-item border-left-0 border-right-0 py-3 d-flex justify-content-between">
  593. <div>
  594. <p class="font-weight-bold mb-1">Delete Group</p>
  595. <p class="mb-0 small">Once you delete your group, there is no going back.</p>
  596. </div>
  597. <div>
  598. <button class="btn btn-outline-danger font-weight-bold py-1" @click="deleteGroup">Delete Group</button>
  599. </div>
  600. </li>
  601. </ul>
  602. </div>
  603. </div>
  604. </div>
  605. <div v-if="tab == 'limits'" class="row">
  606. <div class="col-12 col-md-6 offset-md-3">
  607. <div class="mt-3">
  608. </div>
  609. </div>
  610. </div>
  611. </div>
  612. </div>
  613. </div>
  614. </template>
  615. <script type="text/javascript">
  616. export default {
  617. props: {
  618. groupId: {
  619. type: String
  620. }
  621. },
  622. data() {
  623. return {
  624. initalLoad: false,
  625. profile: undefined,
  626. group: {},
  627. isMember: false,
  628. isAdmin: false,
  629. changed: false,
  630. savingChanges: false,
  631. categories: [],
  632. category: 'General',
  633. tab: 'home',
  634. tabs: [
  635. 'home',
  636. 'customize',
  637. 'interactions',
  638. 'blocked',
  639. 'advanced',
  640. 'limits',
  641. 'blocked:import'
  642. ],
  643. interactionLog: [],
  644. interactionLogPage: 1,
  645. interactionLogInitialLoad: false,
  646. interactionLogShowMore: true,
  647. blockedInitialLoad: false,
  648. blockedInstances: [
  649. 'facebook.com',
  650. 'instagram.com'
  651. ],
  652. blockedUsers: [
  653. 'mark@facebook.com',
  654. 'user@example.org',
  655. 'troll'
  656. ],
  657. moderatedInstances: [
  658. 'pawoo.net',
  659. 'pixelfed.com'
  660. ],
  661. importBlocksData: {},
  662. importBlocksUploaded: false,
  663. membershipDescription: {
  664. all: 'Anyone can join your group',
  665. local: 'Only local users can join your group',
  666. private: 'Only users you approve can join your group'
  667. },
  668. advanced: {}
  669. };
  670. },
  671. beforeMount() {
  672. axios.get('/api/v0/groups/categories/list')
  673. .then(res => {
  674. this.categories = res.data;
  675. })
  676. },
  677. mounted() {
  678. let u = new URLSearchParams(window.location.search);
  679. if(u.has('tab') && this.tabs.includes(u.get('tab'))) {
  680. this.tab = u.get('tab');
  681. this.toggleTab(this.tab);
  682. }
  683. axios.get('/api/pixelfed/v1/accounts/verify_credentials')
  684. .then(res => {
  685. this.profile = res.data;
  686. axios.get('/api/v0/groups/' + this.groupId)
  687. .then(res => {
  688. this.group = res.data;
  689. this.initalLoad = true;
  690. this.isMember = res.data.self.is_member;
  691. this.isAdmin = ['founder', 'admin'].includes(res.data.self.role);
  692. this.advanced = res.data.config;
  693. this.category = res.data.category.name;
  694. })
  695. });
  696. },
  697. methods: {
  698. timestampFormat(date, showTime = false) {
  699. let ts = new Date(date);
  700. return showTime ? ts.toDateString() + ' · ' + ts.toLocaleTimeString() : ts.toDateString();
  701. },
  702. timeago(ts) {
  703. return window.App.util.format.timeAgo(ts);
  704. },
  705. sidToUrl(sid) {
  706. return `/groups/${this.groupId}/p/${sid}`;
  707. },
  708. submit() {
  709. this.savingChanges = true;
  710. let formData = new FormData();
  711. formData.append('category', this.category);
  712. formData.append('membership', this.group.membership);
  713. formData.append('discoverable', this.advanced.discoverable);
  714. formData.append('activitypub', this.advanced.activitypub);
  715. formData.append('is_nsfw', this.advanced.is_nsfw);
  716. if(this.group.description) {
  717. formData.append('description', this.group.description);
  718. }
  719. if(this.$refs.avatarInput) {
  720. formData.append('avatar', this.$refs.avatarInput.files[0]);
  721. }
  722. if(this.$refs.headerInput) {
  723. formData.append('header', this.$refs.headerInput.files[0]);
  724. }
  725. axios.post('/api/v0/groups/' + this.group.id + '/settings', formData)
  726. .then(res => {
  727. this.savingChanges = false;
  728. this.group = res.data;
  729. swal('Updated!', 'Successfully updated group settings.', 'success');
  730. }).catch(err => {
  731. this.savingChanges = false;
  732. console.log(err.response);
  733. swal('Oops!', 'An error occured while attempting to save changes. Please try again later.', 'error');
  734. });
  735. },
  736. toggleTab(tab) {
  737. if(event) {
  738. event.currentTarget.blur();
  739. }
  740. switch(tab) {
  741. case 'home':
  742. this.tab = 'home';
  743. history.pushState(null, null, `/groups/${this.groupId}/settings`);
  744. break;
  745. case 'customize':
  746. this.tab = 'customize';
  747. history.pushState(null, null, `/groups/${this.groupId}/settings?tab=customize`);
  748. break;
  749. case 'limits':
  750. this.tab = 'limits';
  751. history.pushState(null, null, `/groups/${this.groupId}/settings?tab=limits`);
  752. break;
  753. case 'interactions':
  754. if(!this.interactionLogInitialLoad) {
  755. this.loadInteractions();
  756. }
  757. this.tab = 'interactions';
  758. history.pushState(null, null, `/groups/${this.groupId}/settings?tab=interactions`);
  759. break;
  760. case 'blocked':
  761. if(!this.blockedInitialLoad) {
  762. this.loadBlocks();
  763. }
  764. this.tab = 'blocked';
  765. history.pushState(null, null, `/groups/${this.groupId}/settings?tab=blocked`);
  766. break;
  767. case 'advanced':
  768. this.tab = 'advanced';
  769. history.pushState(null, null, `/groups/${this.groupId}/settings?tab=advanced`);
  770. break;
  771. default:
  772. this.tab = 'home';
  773. history.pushState(null, null, `/groups/${this.groupId}/settings`);
  774. break;
  775. }
  776. },
  777. loadInteractions() {
  778. axios.get('/api/v0/groups/' + this.groupId + '/admin/interactions')
  779. .then(res => {
  780. this.interactionLog = res.data;
  781. this.interactionLogPage++;
  782. this.interactionLogInitialLoad = true;
  783. });
  784. },
  785. loadMoreInteractions() {
  786. axios.get('/api/v0/groups/' + this.groupId + '/admin/interactions', {
  787. params: {
  788. page: this.interactionLogPage
  789. }
  790. }).then(res => {
  791. if(res.data.length == 0) {
  792. this.interactionLogShowMore = false;
  793. return;
  794. }
  795. this.interactionLog.push(...res.data);
  796. this.interactionLogPage++;
  797. })
  798. },
  799. loadBlocks() {
  800. axios.get(`/api/v0/groups/${this.groupId}/admin/blocks`)
  801. .then(res => {
  802. this.blockedInstances = res.data.instances;
  803. this.blockedUsers = res.data.users;
  804. this.moderatedInstances = res.data.moderated;
  805. this.blockedInitialLoad = true;
  806. })
  807. },
  808. blockAction(action) {
  809. let type = action == 'user' ? 'user' : 'instance domain';
  810. swal({
  811. text: `Which ${type}?`,
  812. content: {
  813. element: 'input',
  814. attributes: {
  815. placeholder: type == 'user' ? 'pixelfed' : 'pixelfed.org'
  816. }
  817. },
  818. button: {
  819. text: "Next",
  820. closeModal: false,
  821. },
  822. })
  823. .then(name => {
  824. if (!name) throw null;
  825. if(action !== 'user' && name.startsWith('http')) {
  826. swal('Oops!', 'Please enter the instance domain (eg: pixelfed.social)', 'error');
  827. return null;
  828. }
  829. return name;
  830. }).then(name => {
  831. return axios.post('/api/v0/groups/' + this.groupId + '/admin/mbs', {
  832. type: action == 'user' ? 'user' : 'instance',
  833. item: name
  834. }).then(res => {
  835. if(res.data) {
  836. return name;
  837. } else {
  838. swal.stopLoading();
  839. swal.close();
  840. return null;
  841. }
  842. }).catch(err => {
  843. swal.stopLoading();
  844. swal.close();
  845. return null;
  846. });
  847. }).then(name => {
  848. if(!name) {
  849. this.$bvToast.toast(`Invalid ${action}, please try again`, {
  850. title: 'Error',
  851. variant: 'danger',
  852. autoHideDelay: 5000
  853. });
  854. return;
  855. }
  856. swal({
  857. title: "Are you sure?",
  858. text: action === 'moderate' ? `Manually approve all membership requests from ${name}` : `Limiting ${name} will purge and reject all interactions with this group`,
  859. icon: "warning",
  860. buttons: true,
  861. dangerMode: true,
  862. })
  863. .then((confirm) => {
  864. if (confirm) {
  865. axios.post('/api/v0/groups/' + this.groupId + '/admin/blocks/add', {
  866. item: name,
  867. type: action
  868. }).then(res => {
  869. switch(action) {
  870. case 'instance':
  871. this.blockedInstances.push(name);
  872. break;
  873. case 'user':
  874. this.blockedUsers.push(name);
  875. break;
  876. case 'moderate':
  877. this.moderatedInstances.push(name);
  878. break;
  879. }
  880. // swal("Poof! Your imaginary file has been deleted!", {
  881. // icon: "success",
  882. // });
  883. })
  884. }
  885. });
  886. });
  887. },
  888. reportUrl(report) {
  889. return `/groups/${this.groupId}/moderation?tab=view&id=${report}`;
  890. },
  891. memberInteractionUrl(pid) {
  892. return `/groups/${this.groupId}/members?a=il&pid=${pid}`;
  893. },
  894. handleDeleteAvatar() {
  895. if(!window.confirm('Are you sure you want to delete your group avatar image?')) {
  896. return;
  897. }
  898. this.savingChanges = true;
  899. axios.post('/api/v0/groups/' + this.group.id + '/settings/delete-avatar')
  900. .then(res => {
  901. this.savingChanges = false;
  902. this.group = res.data;
  903. });
  904. },
  905. handleDeleteHeader() {
  906. if(!window.confirm('Are you sure you want to delete your group header image?')) {
  907. return;
  908. }
  909. this.savingChanges = true;
  910. axios.post('/api/v0/groups/' + this.group.id + '/settings/delete-header')
  911. .then(res => {
  912. this.savingChanges = false;
  913. this.group = res.data;
  914. });
  915. },
  916. undoBlock(type, val) {
  917. let action = type == 'moderate' ? `unblock ${val}?` : `allow anyone to join without approval from ${val}?`;
  918. swal({
  919. 'title': 'Confirm',
  920. 'text': `Are you sure you want to ${action}`,
  921. 'buttons': {
  922. cancel: {
  923. text: "Cancel",
  924. value: null,
  925. visible: true,
  926. className: "",
  927. closeModal: true,
  928. },
  929. confirm: {
  930. text: "Proceed",
  931. value: true,
  932. visible: true,
  933. className: "",
  934. closeModal: true
  935. }
  936. }
  937. }).then(res => {
  938. if(res) {
  939. axios.post(`/api/v0/groups/${this.groupId}/admin/blocks/undo`, {
  940. item: val,
  941. type: type
  942. }).then(res => {
  943. switch(type) {
  944. case 'instance':
  945. this.blockedInstances = this.blockedInstances.filter(i => {
  946. return i != val;
  947. })
  948. break;
  949. case 'user':
  950. this.blockedUsers = this.blockedUsers.filter(i => {
  951. return i != val;
  952. })
  953. break;
  954. case 'moderate':
  955. this.moderatedInstances = this.moderatedInstances.filter(i => {
  956. return i != val;
  957. })
  958. break;
  959. }
  960. })
  961. }
  962. });
  963. },
  964. exportBlocks() {
  965. event.currentTarget.blur();
  966. axios({
  967. url: '/api/v0/groups/'+this.groupId+'/admin/blocks/export',
  968. method: 'POST',
  969. responseType: 'blob',
  970. }).then((response) => {
  971. const url = window.URL.createObjectURL(new Blob([response.data]));
  972. const link = document.createElement('a');
  973. link.href = url;
  974. link.setAttribute('download', `pixelfed-group-blocks-${Date.now()}.json`);
  975. document.body.appendChild(link);
  976. link.click();
  977. });
  978. },
  979. deleteGroup() {
  980. axios.post('/api/v0/groups/delete', {
  981. gid: this.groupId
  982. })
  983. .then(res => {
  984. location.href = `/groups/${this.groupId}`;
  985. })
  986. }
  987. }
  988. }
  989. </script>
  990. <style lang="scss">
  991. .group-settings-component {
  992. &-header {
  993. display: flex;
  994. justify-content: space-between;
  995. align-items: flex-end;
  996. padding: 2rem 1rem 1rem 1rem;
  997. background-color: #fff;
  998. .cta-btn {
  999. min-width: 140px;
  1000. }
  1001. }
  1002. }
  1003. </style>