From 67821442da508d21bffe2c3efa1c8c19ae41bb4a Mon Sep 17 00:00:00 2001 From: mgabdev <> Date: Wed, 18 Sep 2019 20:33:03 -0400 Subject: [PATCH] Added settings page for deleting scheduled statuses --- .../settings/scheduled_statuses_controller.rb | 33 +++++++++++++++++++ .../scheduled_statuses/index.html.haml | 30 +++++++++++++++++ config/locales/en.yml | 4 +++ config/navigation.rb | 4 +++ config/routes.rb | 3 +- 5 files changed, 73 insertions(+), 1 deletion(-) create mode 100644 app/controllers/settings/scheduled_statuses_controller.rb create mode 100644 app/views/settings/scheduled_statuses/index.html.haml diff --git a/app/controllers/settings/scheduled_statuses_controller.rb b/app/controllers/settings/scheduled_statuses_controller.rb new file mode 100644 index 00000000..9fe7f51c --- /dev/null +++ b/app/controllers/settings/scheduled_statuses_controller.rb @@ -0,0 +1,33 @@ +# frozen_string_literal: true + +class Settings::ScheduledStatusesController < Settings::BaseController + layout 'admin' + + before_action :authenticate_user! + before_action :set_account + before_action :set_scheduled_statuses, only: :index + before_action :set_scheduled_status, only: :destroy + + def index + @scheduled_statuses + end + + def destroy + @scheduled_status.destroy! + redirect_to settings_scheduled_statuses_path + end + + private + + def set_account + @account = current_user.account + end + + def set_scheduled_statuses + @scheduled_statuses = @account.scheduled_statuses + end + + def set_scheduled_status + @scheduled_status = @account.scheduled_statuses.find(params[:id]) + end +end \ No newline at end of file diff --git a/app/views/settings/scheduled_statuses/index.html.haml b/app/views/settings/scheduled_statuses/index.html.haml new file mode 100644 index 00000000..51aee71e --- /dev/null +++ b/app/views/settings/scheduled_statuses/index.html.haml @@ -0,0 +1,30 @@ +- content_for :page_title do + = t('settings.scheduled_posts') + +- unless @account.is_pro? + %span= t('scheduled_statuses.upgrade_to_pro_to_schedule_statuses') + %br + %br + = link_to "Upgrade to GabPRO", 'https://pro.gab.com', :class => "button" + %br + %br + +- if @scheduled_statuses.empty? + %span= t('scheduled_statuses.no_scheduled_statuses_to_display') +- else + .table-wrapper + %table.table + %thead + %tr + %th= t('scheduled_statuses.id') + %th= t('scheduled_statuses.scheduled_at') + %th= t('scheduled_statuses.text') + %th + %tbody + - @scheduled_statuses.each do |scheduled_status| + %tr + %td= scheduled_status.id + %td= scheduled_status.scheduled_at + %td= scheduled_status.params['text'] + %td + = table_link_to 'trash', t('scheduled_statuses.delete'), settings_scheduled_status_path(scheduled_status), method: :delete diff --git a/config/locales/en.yml b/config/locales/en.yml index 8d0a85c3..5d3ca787 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -903,7 +903,11 @@ en: profile: Profile relationships: Follows and followers two_factor_authentication: Two-factor Auth + posts: Posts + scheduled_posts: Scheduled Posts statuses: + are_you_sure: 'Are you sure?' + scheduled_title: 'Schedule' attached: description: 'Attached: %{attached}' image: diff --git a/config/navigation.rb b/config/navigation.rb index 3282b6e5..4f1bf98b 100644 --- a/config/navigation.rb +++ b/config/navigation.rb @@ -20,6 +20,10 @@ SimpleNavigation::Configuration.run do |navigation| s.item :authorized_apps, safe_join([fa_icon('list fw'), t('settings.authorized_apps')]), oauth_authorized_applications_url end + n.item :posts, safe_join([fa_icon('bars fw'), t('settings.posts')]), settings_scheduled_statuses_url do |s| + s.item :scheduled_posts, safe_join([fa_icon('calendar fw'), t('settings.scheduled_posts')]), settings_scheduled_statuses_url + end + n.item :requests, safe_join([fa_icon('id-card-o fw'), t('verifications.requests.title')]), settings_verifications_requests_url n.item :billing, safe_join([fa_icon('usd fw'), t('settings.billing')]), settings_billing_transactions_url do |s| diff --git a/config/routes.rb b/config/routes.rb index 0d31b834..b45362d2 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -90,7 +90,7 @@ Rails.application.routes.draw do end resources :promotions, only: [:index, :new, :create, :edit, :update, :destroy] - + namespace :verifications do get :moderation, to: 'moderation#index', as: :moderation get 'moderation/:id/approve', to: 'moderation#approve', as: :approve @@ -127,6 +127,7 @@ Rails.application.routes.draw do resources :sessions, only: [:destroy] resources :featured_tags, only: [:index, :create, :destroy] + resources :scheduled_statuses, only: [:index, :destroy] end resources :media, only: [:show] do