From 6abfc771b784b84ecd8c1ed847dbe23f91f37918 Mon Sep 17 00:00:00 2001 From: Aydin Hassan Date: Sun, 3 Mar 2024 13:29:07 +0100 Subject: [PATCH 01/15] Update some copy, reimplement slack invite --- app/config.php | 19 ++++- assets/app.js | 2 +- .../Online/WorkshopExerciseSelectionList.vue | 17 +++- assets/components/Website/JoinSlack.vue | 84 +++++++++++++++++++ assets/components/Website/MainLayout.vue | 4 +- .../Website/Pages/Home/Section/BuildList.vue | 22 +++++ .../Pages/Home/Section/BuildYourOwn.vue | 49 ++++++++--- .../Pages/Home/Section/TheWorkshops.vue | 82 +++++++++++++++--- assets/components/Website/Pages/PageHome.vue | 6 +- assets/components/Website/SiteFooter.vue | 31 +++---- assets/components/Website/SiteNav.vue | 9 +- assets/stores/workshops.js | 10 ++- public/index.php | 3 +- src/Action/Online/Workshops.php | 10 ++- src/Action/SlackInvite.php | 54 ++++++++++++ 15 files changed, 346 insertions(+), 56 deletions(-) create mode 100644 assets/components/Website/JoinSlack.vue create mode 100644 assets/components/Website/Pages/Home/Section/BuildList.vue create mode 100644 src/Action/SlackInvite.php diff --git a/app/config.php b/app/config.php index 2ca4705a..5acae9fa 100644 --- a/app/config.php +++ b/app/config.php @@ -44,6 +44,7 @@ use PhpSchool\Website\Action\Online\ComposerPackageAdd; use PhpSchool\Website\Action\Online\RunExercise; use PhpSchool\Website\Action\Online\VerifyExercise; +use PhpSchool\Website\Action\SlackInvite; use PhpSchool\Website\Action\StudentLogin; use PhpSchool\Website\Action\SubmitWorkshop; use PhpSchool\Website\Action\TrackDownloads; @@ -232,14 +233,21 @@ SubmitWorkshop::class => \DI\factory(function (ContainerInterface $c): SubmitWorkshop { return new SubmitWorkshop( $c->get(FormHandlerFactory::class)->create( - new SubmitWorkshopInputFilter(new Client, $c->get(WorkshopRepository::class)) + new SubmitWorkshopInputFilter(new Client(), $c->get(WorkshopRepository::class)) ), - new WorkshopCreator(new WorkshopComposerJsonInputFilter, $c->get(WorkshopRepository::class)), + new WorkshopCreator(new WorkshopComposerJsonInputFilter(), $c->get(WorkshopRepository::class)), $c->get(EmailNotifier::class), $c->get(LoggerInterface::class) ); }), + SlackInvite::class => function (ContainerInterface $c): SlackInvite { + return new SlackInvite( + $c->get('guzzle'), + $c->get('config')['slackInviteApiToken'] + ); + }, + Github::class => function (ContainerInterface $c): Github { return new Github([ 'clientId' => $c->get('config')['github']['clientId'], @@ -320,6 +328,10 @@ ); }, + 'guzzle' => function (ContainerInterface $c): \GuzzleHttp\Client { + return new \GuzzleHttp\Client(); + }, + 'guzzle.packagist' => function (ContainerInterface $c) { return new \GuzzleHttp\Client(['headers' => ['User-Agent' => 'PHP School: phpschool.team@gmail.com']]); }, @@ -618,7 +630,8 @@ public function parse($markdown): string 'clientSecret' => $_ENV['GITHUB_CLIENT_SECRET'], ], - 'jwtSecret' => $_ENV['JWT_SECRET'] + 'jwtSecret' => $_ENV['JWT_SECRET'], + 'slackInviteApiToken' => $_ENV['SLACK_INVITE_API_TOKEN'], ], //slim settings diff --git a/assets/app.js b/assets/app.js index 6071a9f5..1f1d65c1 100644 --- a/assets/app.js +++ b/assets/app.js @@ -60,7 +60,7 @@ const docRoutes = [].concat( const routes = [ { path: "/", component: Home, meta: { layout: MainLayout } }, - { path: "/online", component: Dashboard, meta: { layout: CompactLayout } }, + { path: "/online/:workshop?", component: Dashboard, meta: { layout: CompactLayout } }, { path: "/online/editor/:workshop/:exercise", component: ExerciseEditor, diff --git a/assets/components/Online/WorkshopExerciseSelectionList.vue b/assets/components/Online/WorkshopExerciseSelectionList.vue index 54ca3b43..fcbcd9af 100644 --- a/assets/components/Online/WorkshopExerciseSelectionList.vue +++ b/assets/components/Online/WorkshopExerciseSelectionList.vue @@ -2,26 +2,41 @@ import { CheckCircleIcon, CommandLineIcon } from "@heroicons/vue/24/solid"; import { ArrowRightCircleIcon } from "@heroicons/vue/24/outline"; import ExerciseEntry from "./ExerciseEntry.vue"; -import { ref } from "vue"; +import { ref, watch } from "vue"; import Alert from "./SiteAlert.vue"; import { useStudentStore } from "../../stores/student"; const studentStore = useStudentStore(); import { useWorkshopStore } from "../../stores/workshops"; +import { useRoute } from "vue-router"; const workshopStore = useWorkshopStore(); const selectedWorkshop = ref(null); const showNotLoggedInError = ref(false); +const route = useRoute(); + const notLoggedIn = () => { showNotLoggedInError.value = true; }; const selectWorkshop = (workshopCode) => { selectedWorkshop.value = workshopStore.workshops.find((workshop) => workshop.code === workshopCode); + + history.pushState({}, null, "/online/" + workshopCode); }; + +watch( + () => route.params, + (toParams) => { + if (toParams.workshop) { + selectedWorkshop.value = workshopStore.workshops.find((workshop) => workshop.code === toParams.workshop); + } + }, + { immediate: true }, +);