logo

pleroma-fe

My custom branche(s) on git.pleroma.social/pleroma/pleroma-fe git clone https://hacktivis.me/git/pleroma-fe.git

scope_selector.js (1610B)


  1. import { library } from '@fortawesome/fontawesome-svg-core'
  2. import {
  3. faEnvelope,
  4. faLock,
  5. faLockOpen,
  6. faGlobe
  7. } from '@fortawesome/free-solid-svg-icons'
  8. library.add(
  9. faEnvelope,
  10. faGlobe,
  11. faLock,
  12. faLockOpen
  13. )
  14. const ScopeSelector = {
  15. props: [
  16. 'showAll',
  17. 'userDefault',
  18. 'originalScope',
  19. 'initialScope',
  20. 'onScopeChange'
  21. ],
  22. data () {
  23. return {
  24. currentScope: this.initialScope
  25. }
  26. },
  27. computed: {
  28. showNothing () {
  29. return !this.showPublic && !this.showUnlisted && !this.showPrivate && !this.showDirect
  30. },
  31. showPublic () {
  32. return this.originalScope !== 'direct' && this.shouldShow('public')
  33. },
  34. showUnlisted () {
  35. return this.originalScope !== 'direct' && this.shouldShow('unlisted')
  36. },
  37. showPrivate () {
  38. return this.originalScope !== 'direct' && this.shouldShow('private')
  39. },
  40. showDirect () {
  41. return this.shouldShow('direct')
  42. },
  43. css () {
  44. return {
  45. public: { toggled: this.currentScope === 'public' },
  46. unlisted: { toggled: this.currentScope === 'unlisted' },
  47. private: { toggled: this.currentScope === 'private' },
  48. direct: { toggled: this.currentScope === 'direct' }
  49. }
  50. }
  51. },
  52. methods: {
  53. shouldShow (scope) {
  54. return this.showAll ||
  55. this.currentScope === scope ||
  56. this.originalScope === scope ||
  57. this.userDefault === scope ||
  58. scope === 'direct'
  59. },
  60. changeVis (scope) {
  61. this.currentScope = scope
  62. this.onScopeChange && this.onScopeChange(scope)
  63. }
  64. }
  65. }
  66. export default ScopeSelector