-
Notifications
You must be signed in to change notification settings - Fork 71
Organization Announcements (Tier 1) #10830
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
167 commits
Select commit
Hold shift + click to select a range
089b031
Add announcements page
polypixeldev 97ca23d
Fix file name
polypixeldev 0900261
Add create announcement modal
polypixeldev b83da5f
Add announcement model
polypixeldev 2b6cd75
Update title
polypixeldev 264593b
Add follow model
Luke-Oldenburg 38e33d7
Rework announcements routing and fix modal submission with Trix
polypixeldev 950ebe0
Remove trix and actiontext
polypixeldev ffdf86c
Add back frozen string literal
polypixeldev 1f31f8a
Merge branch 'main' into organization-updates
polypixeldev 4bd0b10
Add tiptap editor
polypixeldev 8288afd
Add drafting option
polypixeldev d12e67d
Rework event policy
Luke-Oldenburg 7ec7917
Fix event migration
polypixeldev bba3e37
Improve at placement
Luke-Oldenburg 54e1b06
Render posts on show page
polypixeldev b177a5b
Add post editing
polypixeldev 99a8969
Add following
Luke-Oldenburg 6e0d592
Init feed
Luke-Oldenburg 202d3be
Add manage button
Luke-Oldenburg 25be375
Fix event nav
Luke-Oldenburg b69262e
Add autosaving
polypixeldev bf4cdc4
Change announcements tooltip
polypixeldev f5ac0c3
Fix in other nav
polypixeldev aa66b95
Remove logging
Luke-Oldenburg 55e25c6
Add link to modal
Luke-Oldenburg a3ce457
Delete old event follow
Luke-Oldenburg 5f30be1
Add check for autosave
polypixeldev 6aab15f
Redirect to announcements
Luke-Oldenburg 3140286
Merge branch 'main' into organization-updates
Luke-Oldenburg 75b8031
Fix rounding
polypixeldev a9756cb
Change announcements icon
polypixeldev db7ff31
Fix autosave
polypixeldev b0bdd69
Add index posts
polypixeldev c485f0f
Change save to back
polypixeldev 70ac180
Fix back btn
polypixeldev 5ea854a
Add draft post order and style
polypixeldev c621999
Add tooltips
polypixeldev b504a8b
Add follow list
Luke-Oldenburg 1ae7018
link title in announcement post
polypixeldev 02e42df
Add date and user to announcement post on index
polypixeldev 770a47f
Add user and date text to post show
polypixeldev 7945939
Add publish buttons and action
polypixeldev eb9c7f6
Readd deleted line
polypixeldev 2b6506b
Always create as draft
polypixeldev c821b3b
Move follow button to partial
Luke-Oldenburg 90afee5
Check published at presence
Luke-Oldenburg 53b3404
Hide actions for unauthorized users
polypixeldev 2c9fa34
Fix unauthorized_callout partial reference
polypixeldev dacf88f
Add divider to post cards
polypixeldev 84a6a2e
Fix light mode
polypixeldev bc9dab4
Extract announcement card into partial
polypixeldev de807be
List posts in feed
polypixeldev 9adbfaf
Remove event
Luke-Oldenburg df63c78
Require title
Luke-Oldenburg d1de694
Add render_html method
polypixeldev 19df625
Hide event name on event announcements page
polypixeldev 9c3c288
Add announcement mailer
Luke-Oldenburg bc7b53b
Add proper sorting and pagination
polypixeldev 92dbdfa
Check presence
Luke-Oldenburg 2e2f957
Add mailer preview
Luke-Oldenburg 8351bce
Prevent editing published announcements
polypixeldev f75ab09
Add unsubscribe text
Luke-Oldenburg 467dc1c
Render post content on backend
polypixeldev 7d924dd
Clarify org name more
Luke-Oldenburg 9fde9a1
Fix typo
Luke-Oldenburg 9383c04
Debounce autosave
polypixeldev 0813ead
Fix email list
Luke-Oldenburg 24e8d4f
Add announcement title to body
Luke-Oldenburg e7bf8bd
Install more tiptap extensions
polypixeldev 11ff53b
Add functionality for more editor buttons
polypixeldev f1a4742
Don't send flash for autosave
polypixeldev 05bd598
Remove bubble menu
polypixeldev 2773932
Add blockquote
polypixeldev bc0ef2f
Add flipper logic
Luke-Oldenburg d0f048b
Add text when feed or announcements is empty
polypixeldev 7cd0bb1
Hide manage button when no follows
polypixeldev ed12130
Add feature toggle
Luke-Oldenburg 97dda73
Add markdown notice
polypixeldev a7b2ab6
Add back dropdown button
polypixeldev 9e77f60
Fix ordering
polypixeldev 53967d2
Use flipped in event policy
Luke-Oldenburg 7d00f72
Add new line
Luke-Oldenburg 2ca8c74
Fix publishing from form and adjust copy
polypixeldev 57edb01
Add new line
Luke-Oldenburg 399ec45
Add new lines
Luke-Oldenburg 33f479f
Add redirect if not signed in
Luke-Oldenburg 2931c81
add custom mission statement node
polypixeldev bc0beaf
Don't use global variables
polypixeldev 5ebcfeb
Store HTML instead of JSON for announcement content
polypixeldev 9f467a0
render_html -> content
Luke-Oldenburg 3c1b4ba
Add donation goal node
polypixeldev 27a014a
Revert "Add donation goal node"
polypixeldev 1d921a4
Revert "render_html -> content"
polypixeldev 3e4ff55
Revert "Store HTML instead of JSON for announcement content"
polypixeldev 77bd65b
Revert "Don't use global variables"
polypixeldev d8e12c1
Revert "add custom mission statement node"
polypixeldev 505afbb
Merge branch 'main' into organization-updates
garyhtou 564b97d
Fix JS formatting
polypixeldev 365f16d
Fix Rubocop lints
polypixeldev 41c1e88
Ignore html_safe lints
polypixeldev 2ed0563
Re-enable cop
polypixeldev aa132c8
comma
polypixeldev e83f6a5
fix capitalization
polypixeldev db90dd5
Fix saving editing posts
polypixeldev 0b49dcf
Update app/views/announcements/_announcement_form.html.erb
Luke-Oldenburg 49d0a79
Merge branch 'main' into organization-updates
Luke-Oldenburg 80d5112
Update app/controllers/announcements_controller.rb
Luke-Oldenburg 17de130
Merge branch 'main' into organization-updates
YodaLightsabr 8987866
Add follow button to announcements
Luke-Oldenburg d2fc14a
Fix hover color in light mode for editor
polypixeldev 1bfbc24
Fix light mode announcement form
polypixeldev b6ab2fc
Add selected
Luke-Oldenburg 400370f
Lock down nav
Luke-Oldenburg b074113
Fix dropdown button styling
polypixeldev ad18833
Fix paragraph margin in editor
polypixeldev 4a009c1
Fix margin/padding on post
YodaLightsabr c27a919
Fix paragraph margins
polypixeldev 4fd5ad4
Improve pagination
Luke-Oldenburg 7508cf0
Edit title size
Luke-Oldenburg b1c98b8
Update app/controllers/event/follows_controller.rb
Luke-Oldenburg f7802bb
Update app/controllers/event/follows_controller.rb
Luke-Oldenburg a6f2758
Use current user relation
Luke-Oldenburg 9388e7e
Update app/controllers/event/follows_controller.rb
Luke-Oldenburg 77009d7
Drop announcements helper
Luke-Oldenburg d6fc747
Improve pagination
Luke-Oldenburg 938a61a
Update app/jobs/announcement_published_job.rb
Luke-Oldenburg c68a92f
Fix edit policy
Luke-Oldenburg 542f573
Update app/jobs/announcement_published_job.rb
Luke-Oldenburg 2935bbf
Show management buttons properly
Luke-Oldenburg 79cde0b
Fix migrations with null checks
polypixeldev 6a85482
Use author and not draft
polypixeldev 2ecfdfa
Improve authorize
Luke-Oldenburg 0c0d037
Add following text
Luke-Oldenburg 958542f
Use announcement.persisted?
polypixeldev 84ae048
Use publish!
polypixeldev 2713e31
Delay job
Luke-Oldenburg 3be9ce0
Remove draft
Luke-Oldenburg 385404c
Use draft scope
Luke-Oldenburg 4e3e2aa
Fix scope
Luke-Oldenburg d68b471
Check if still published to run job
Luke-Oldenburg a3bc66a
Improve margins/padding
YodaLightsabr 2f26887
Fix draft?
Luke-Oldenburg 6803388
DB changes, part 1 (checkout this commit, then rollback by 15)
YodaLightsabr a9964e1
DB changes, part 2 (checkout this commit, then migrate)
YodaLightsabr 162a7a2
Update schema file
YodaLightsabr f4a2181
Merge pull request #10867 from hackclub/fix-migrations
YodaLightsabr 33052ba
Merge pull request #10868 from hackclub/schema-fixes-for-organization…
YodaLightsabr 90f4935
Fix job bug
Luke-Oldenburg 6b7a0aa
nil safety
Luke-Oldenburg 8e5deb5
Rename feed
Luke-Oldenburg dfba7b7
Add broken confetti
Luke-Oldenburg e046c85
Styling fix + partial fix
Luke-Oldenburg 075f1a1
Fix follow button rendering improperly
Luke-Oldenburg 3d1579e
Remove index
Luke-Oldenburg b0fe29b
Remove unnecessary validation
Luke-Oldenburg 7f86a33
Add content validation
Luke-Oldenburg 1f8485c
Editor styling fixes
Luke-Oldenburg 6ff8ff7
Split set_announcement and set_dinner
Luke-Oldenburg bece34b
Add delete button to show
Luke-Oldenburg f857c1f
Move buttons in show
Luke-Oldenburg 952100b
Allow editing published announcements
Luke-Oldenburg 62821c5
Merge branch 'main' into organization-updates
Luke-Oldenburg 6b23ece
Remove parentheses
Luke-Oldenburg 0dc1d4d
Update app/models/announcement.rb
Luke-Oldenburg b2a0651
Use hashid
Luke-Oldenburg 5f1f78d
Revert "Add broken confetti"
Luke-Oldenburg File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -228,3 +228,5 @@ gem "rack-timeout", require: "rack/timeout/base" | |
| gem "irb" | ||
|
|
||
| gem "pstore" | ||
|
|
||
| gem "prosemirror_to_html" | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| .tiptap p.is-editor-empty:first-child::before { | ||
| color: #adb5bd; | ||
| content: attr(data-placeholder); | ||
| float: left; | ||
| height: 0; | ||
| pointer-events: none; | ||
| } | ||
Luke-Oldenburg marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| .tiptap p:first-child { | ||
| margin-top: 0px; | ||
| } | ||
|
|
||
| .tiptap p:last-child { | ||
| margin-bottom: 0px; | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,107 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| class AnnouncementsController < ApplicationController | ||
| before_action :set_event | ||
| before_action :set_announcement, except: [:index, :new] | ||
| before_action :set_event_follow | ||
|
|
||
| def index | ||
| @announcement = Announcement.new | ||
| @announcement.event = @event | ||
|
|
||
| authorize @announcement | ||
|
|
||
| @all_announcements = Announcement.where(event: @event).order(published_at: :desc, created_at: :desc) | ||
| @announcements = @all_announcements.page(params[:page]).per(10) | ||
|
|
||
| raise ActionController::RoutingError.new("Not Found") if [email protected]_public && @all_announcements.empty? && !organizer_signed_in? | ||
YodaLightsabr marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| end | ||
|
|
||
| def new | ||
| @announcement = Announcement.new | ||
| @announcement.event = @event | ||
|
|
||
| authorize @announcement | ||
| end | ||
|
|
||
| def create | ||
| @announcement = @event.announcements.build(params.require(:announcement).permit(:title, :content).merge(author: current_user)) | ||
|
|
||
| authorize @announcement | ||
|
|
||
| @announcement.save! | ||
Luke-Oldenburg marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| unless params[:announcement][:draft] == "true" | ||
| @announcement.publish! | ||
| end | ||
|
|
||
| flash[:success] = "Announcement successfully #{params[:announcement][:draft] == "true" ? "drafted" : "published"}!" | ||
|
|
||
| rescue => e | ||
| puts e.message | ||
| flash[:error] = "Something went wrong. #{e.message}" | ||
| Rails.error.report(e) | ||
| ensure | ||
| redirect_to event_announcement_path(@event, @announcement) | ||
| end | ||
|
|
||
| def show | ||
| authorize @announcement | ||
| end | ||
|
|
||
| def edit | ||
| authorize @announcement | ||
|
|
||
| render "announcements/show", locals: { editing: true } | ||
| end | ||
|
|
||
| def update | ||
| authorize @announcement | ||
|
|
||
| @announcement.update!(params.require(:announcement).permit(:title, :content)) | ||
|
|
||
| if params[:announcement][:autosave] != "true" | ||
| flash[:success] = "Updated announcement" | ||
| redirect_to event_announcement_path(@event, @announcement) | ||
| end | ||
| end | ||
|
|
||
| def destroy | ||
| authorize @announcement | ||
|
|
||
| @announcement.destroy! | ||
|
|
||
| flash[:success] = "Deleted announcement" | ||
|
|
||
| redirect_to event_announcements_path(@event) | ||
| end | ||
|
|
||
| def publish | ||
| authorize @announcement | ||
|
|
||
| @announcement.publish! | ||
|
|
||
| flash[:success] = "Published announcement" | ||
|
|
||
| redirect_to event_announcement_path(@event, @announcement) | ||
| end | ||
|
|
||
| private | ||
|
|
||
| def set_announcement | ||
Luke-Oldenburg marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| if params[:id].present? | ||
| @announcement = @event.announcements.find(params[:id]) | ||
| end | ||
| end | ||
|
|
||
| def set_event | ||
| if params[:event_id].present? | ||
| @event = Event.find_by!(slug: params[:event_id]) | ||
| end | ||
| end | ||
|
|
||
| def set_event_follow | ||
| @event_follow = Event::Follow.where({ user_id: current_user.id, event_id: @event.id }).first if current_user | ||
| end | ||
|
|
||
| end | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| class Event | ||
| class FollowsController < ApplicationController | ||
| include SetEvent | ||
| skip_before_action :signed_in_user, only: :create | ||
| before_action :set_event, only: :create | ||
|
|
||
| def create | ||
| unless signed_in? | ||
| skip_authorization | ||
| return redirect_to auth_users_path(return_to: event_url(@event), require_reload: true) | ||
| end | ||
|
|
||
| attrs = { | ||
| user_id: current_user.id, | ||
| event: @event | ||
| } | ||
| follow = Event::Follow.new(attrs) | ||
| authorize follow | ||
| follow.save! | ||
| redirect_to event_announcements_path(@event) | ||
| end | ||
|
|
||
| def destroy | ||
| @event_follow = Event::Follow.find(params[:id]) | ||
| authorize @event_follow | ||
| slug = @event_follow.event.slug | ||
| @event_follow.destroy! | ||
| redirect_to event_path(slug) | ||
| end | ||
|
|
||
| end | ||
|
|
||
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,136 @@ | ||
| import { Controller } from '@hotwired/stimulus' | ||
| import { debounce } from 'lodash/function' | ||
| import { Editor } from '@tiptap/core' | ||
| import StarterKit from '@tiptap/starter-kit' | ||
| import Underline from '@tiptap/extension-underline' | ||
| import Placeholder from '@tiptap/extension-placeholder' | ||
| import Link from '@tiptap/extension-link' | ||
| import Image from '@tiptap/extension-image' | ||
|
|
||
| export default class extends Controller { | ||
| static targets = ['editor', 'form', 'contentInput', 'autosaveInput'] | ||
| static values = { content: String } | ||
|
|
||
| editor = null | ||
|
|
||
| connect() { | ||
| const debouncedSubmit = debounce(this.submit.bind(this), 1000, { | ||
| leading: true, | ||
| }) | ||
|
|
||
| this.editor = new Editor({ | ||
| element: this.editorTarget, | ||
| extensions: [ | ||
| StarterKit.configure({ | ||
| heading: { | ||
| levels: [1, 2, 3], | ||
| }, | ||
| }), | ||
| Underline, | ||
| Placeholder.configure({ | ||
| placeholder: 'Write a message to your followers...', | ||
| }), | ||
| Link, | ||
| Image, | ||
| ], | ||
| editorProps: { | ||
| attributes: { | ||
| class: 'outline-none', | ||
| }, | ||
| }, | ||
| content: this.hasContentValue ? JSON.parse(this.contentValue) : null, | ||
| onUpdate: () => { | ||
| if (this.hasContentValue) { | ||
| debouncedSubmit(true) | ||
| } | ||
| }, | ||
| }) | ||
| } | ||
|
|
||
| disconnect() { | ||
| this.editor.destroy() | ||
| } | ||
|
|
||
| submit(autosave) { | ||
| this.autosaveInputTarget.value = autosave === true ? 'true' : 'false' | ||
| this.contentInputTarget.value = JSON.stringify(this.editor.getJSON()) | ||
| this.formTarget.requestSubmit() | ||
| } | ||
|
|
||
| bold() { | ||
| this.editor.chain().focus().toggleBold().run() | ||
| } | ||
|
|
||
| italic() { | ||
| this.editor.chain().focus().toggleItalic().run() | ||
| } | ||
|
|
||
| underline() { | ||
| this.editor.chain().focus().toggleUnderline().run() | ||
| } | ||
|
|
||
| h1() { | ||
| this.editor.chain().focus().toggleHeading({ level: 1 }).run() | ||
| } | ||
|
|
||
| h2() { | ||
| this.editor.chain().focus().toggleHeading({ level: 2 }).run() | ||
| } | ||
|
|
||
| h3() { | ||
| this.editor.chain().focus().toggleHeading({ level: 3 }).run() | ||
| } | ||
|
|
||
| strike() { | ||
| this.editor.chain().focus().toggleStrike().run() | ||
| } | ||
|
|
||
| link() { | ||
| const url = window.prompt('Link URL') | ||
|
|
||
| if (url === null) { | ||
| return | ||
| } | ||
|
|
||
| if (url === '') { | ||
| this.editor.chain().focus().extendMarkRange('link').unsetLink().run() | ||
| } else { | ||
| this.editor | ||
| .chain() | ||
| .focus() | ||
| .extendMarkRange('link') | ||
| .setLink({ href: url }) | ||
| .run() | ||
| } | ||
| } | ||
|
|
||
| code() { | ||
| this.editor.chain().focus().toggleCode().run() | ||
| } | ||
|
|
||
| codeBlock() { | ||
| this.editor.chain().focus().toggleCodeBlock().run() | ||
| } | ||
|
|
||
| bulletList() { | ||
| this.editor.chain().focus().toggleBulletList().run() | ||
| } | ||
|
|
||
| orderedList() { | ||
| this.editor.chain().focus().toggleOrderedList().run() | ||
| } | ||
|
|
||
| blockQuote() { | ||
| this.editor.chain().focus().toggleBlockquote().run() | ||
| } | ||
|
|
||
| image() { | ||
| const url = window.prompt('Image URL') | ||
|
|
||
| if (url === null || url === '') { | ||
| return | ||
| } | ||
|
|
||
| this.editor.chain().focus().setImage({ src: url }).run() | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.