Unverified Commit 33d01b8d authored by Yassine Doghri's avatar Yassine Doghri
Browse files

fix(ux): allow for empty message upon episode publication and warn user on submit

- clarify distiction between the announcement post and the show notes
- change "note" occurences in UI by "post"
- show warning message explaining why the podcaster should fill the message area
- the podcaster
can choose to publish the episode with an empty message anyways
- redirect user to episode
dashboard with error message when episode publication pages are inaccessible instead of showing a
404 error
- add a cancel publication button in publish-edit form when episode is scheduled

closes #129
parent 8f3e9d90
Loading
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -310,6 +310,15 @@ $routes->group(
                                    'permission:podcast-manage_publications',
                            ],
                        );
                        $routes->get(
                            'publish-cancel',
                            'EpisodeController::publishCancel/$1/$2',
                            [
                                'as' => 'episode-publish-cancel',
                                'filter' =>
                                    'permission:podcast-manage_publications',
                            ],
                        );
                        $routes->get(
                            'unpublish',
                            'EpisodeController::unpublish/$1/$2',
+53 −6
Original line number Diff line number Diff line
@@ -388,7 +388,7 @@ class EpisodeController extends BaseController
        return redirect()->back();
    }

    public function publish(): string
    public function publish(): string | RedirectResponse
    {
        if ($this->episode->publication_status === 'not_published') {
            helper(['form']);
@@ -405,7 +405,10 @@ class EpisodeController extends BaseController
            return view('admin/episode/publish', $data);
        }

        throw PageNotFoundException::forPageNotFound();
        return redirect()->route('episode-view', [$this->podcast->id, $this->episode->id])->with(
            'error',
            lang('Episode.publish_error')
        );
    }

    public function attemptPublish(): RedirectResponse
@@ -478,7 +481,7 @@ class EpisodeController extends BaseController
        return redirect()->route('episode-view', [$this->podcast->id, $this->episode->id]);
    }

    public function publishEdit(): string
    public function publishEdit(): string | RedirectResponse
    {
        if ($this->episode->publication_status === 'scheduled') {
            helper(['form']);
@@ -500,7 +503,11 @@ class EpisodeController extends BaseController
            ]);
            return view('admin/episode/publish_edit', $data);
        }
        throw PageNotFoundException::forPageNotFound();

        return redirect()->route('episode-view', [$this->podcast->id, $this->episode->id])->with(
            'error',
            lang('Episode.publish_edit_error')
        );
    }

    public function attemptPublishEdit(): RedirectResponse
@@ -572,7 +579,44 @@ class EpisodeController extends BaseController
        return redirect()->route('episode-view', [$this->podcast->id, $this->episode->id]);
    }

    public function unpublish(): string
    public function publishCancel(): RedirectResponse
    {
        if ($this->episode->publication_status === 'scheduled') {
            $db = db_connect();
            $db->transStart();

            $statusModel = new StatusModel();
            $status = $statusModel
                ->where([
                    'actor_id' => $this->podcast->actor_id,
                    'episode_id' => $this->episode->id,
                ])
                ->first();
            $statusModel->removeStatus($status);

            $this->episode->published_at = null;

            $episodeModel = new EpisodeModel();
            if (! $episodeModel->update($this->episode->id, $this->episode)) {
                $db->transRollback();
                return redirect()
                    ->back()
                    ->withInput()
                    ->with('errors', $episodeModel->errors());
            }

            $db->transComplete();

            return redirect()->route('episode-view', [$this->podcast->id, $this->episode->id]);
        }

        return redirect()->route('episode-view', [$this->podcast->id, $this->episode->id])->with(
            'error',
            lang('Episode.publish_cancel_error')
        );
    }

    public function unpublish(): string | RedirectResponse
    {
        if ($this->episode->publication_status === 'published') {
            helper(['form']);
@@ -589,7 +633,10 @@ class EpisodeController extends BaseController
            return view('admin/episode/unpublish', $data);
        }

        throw PageNotFoundException::forPageNotFound();
        return redirect()->route('episode-view', [$this->podcast->id, $this->episode->id])->with(
            'error',
            lang('Episode.unpublish_error')
        );
    }

    public function attemptUnpublish(): RedirectResponse
+2 −2
Original line number Diff line number Diff line
@@ -86,11 +86,11 @@ if (! function_exists('button')) {
        }

        if ($options['iconLeft']) {
            $label = icon($options['iconLeft'], 'mr-2') . $label;
            $label = icon((string) $options['iconLeft'], 'mr-2') . $label;
        }

        if ($options['iconRight']) {
            $label .= icon($options['iconRight'], 'ml-2');
            $label .= icon((string) $options['iconRight'], 'ml-2');
        }

        if ($uri !== '') {
+13 −4
Original line number Diff line number Diff line
@@ -27,8 +27,8 @@ return [
        other {# total shares}
    }',
    'total_statuses' => '{numberOfTotalStatuses, plural,
        one {# note}
        other {# total notes}
        one {# total post}
        other {# total posts}
    }',
    'all_podcast_episodes' => 'All podcast episodes',
    'back_to_podcast' => 'Go back to podcast',
@@ -36,6 +36,10 @@ return [
    'publish' => 'Publish',
    'publish_edit' => 'Edit publication',
    'unpublish' => 'Unpublish',
    'publish_error' => 'Episode is already published.',
    'publish_edit_error' => 'Episode is already published.',
    'publish_cancel_error' => 'Episode is already published.',
    'unpublish_error' => 'Episode is not published.',
    'delete' => 'Delete',
    'go_to_page' => 'Go to page',
    'create' => 'Add an episode',
@@ -112,9 +116,10 @@ return [
        'submit_edit' => 'Save episode',
    ],
    'publish_form' => [
        'status' => 'Your note',
        'back_to_episode_dashboard' => 'Back to episode dashboard',
        'status' => 'Your announcement post',
        'status_hint' =>
            'The message you write will be broadcasted to all your followers in the fediverse.',
            "Write a message to announce the publication of your episode. The message will be broadcasted to all your followers in the fediverse and be featured in your podcast's homepage.",
        'publication_date' => 'Publication date',
        'publication_method' => [
            'now' => 'Now',
@@ -126,6 +131,10 @@ return [
            'You can schedule the episode release by setting a future publication date. This field must be formatted as YYYY-MM-DD HH:mm',
        'submit' => 'Publish',
        'submit_edit' => 'Edit publication',
        'cancel_publication' => 'Cancel publication',
        'message_warning' => 'You did not write a message for your announcement post!',
        'message_warning_hint' => 'Having a message increases social engagement, resulting in a better visibility for your episode.',
        'message_warning_submit' => 'Publish anyways',
    ],
    'unpublish_form' => [
        'disclaimer' =>
+2 −2
Original line number Diff line number Diff line
@@ -224,8 +224,8 @@ return [
        other {<span class="font-semibold">#</span> followers}
    }',
    'statuses' => '{numberOfStatuses, plural,
        one {<span class="font-semibold">#</span> note}
        other {<span class="font-semibold">#</span> notes}
        one {<span class="font-semibold">#</span> post}
        other {<span class="font-semibold">#</span> posts}
    }',
    'activity' => 'Activity',
    'episodes' => 'Episodes',
Loading