Skip to content

Commit

Permalink
fix: #116 remove services (processes) when a service has been deleted…
Browse files Browse the repository at this point in the history
… from ui
  • Loading branch information
bohdan-shulha committed Aug 11, 2024
1 parent 2073247 commit 07da9de
Show file tree
Hide file tree
Showing 8 changed files with 55 additions and 208 deletions.
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ WORKDIR /app

ENV COMPOSER_ALLOW_SUPERUSER=1
ENV SERVER_NAME=":8080"
ENV APP_NAME="Ptah.sh"

COPY package.json .
COPY package-lock.json .
Expand Down
8 changes: 8 additions & 0 deletions app/Http/Middleware/EnsureTeamSubscription.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,14 @@ public function handle(Request $request, Closure $next): Response

$doesntHaveSubscription = $subscription === null || ! $subscription->valid();
if ($doesntHaveSubscription) {
if ($request->isJson()) {
return response()->json([
'message' => 'You must have a valid subscription to access this resource.',
], 403);
}

session()->flash('error', 'You must have a valid subscription to access this resource.');

return redirect()->route('teams.billing.show', $team);
}

Expand Down
6 changes: 4 additions & 2 deletions app/Models/Service.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace App\Models;

use App\Models\DeploymentData\Process;
use App\Models\NodeTasks\DeleteService\DeleteServiceMeta;
use App\Traits\HasOwningTeam;
use Illuminate\Database\Eloquent\Factories\HasFactory;
Expand Down Expand Up @@ -40,17 +41,18 @@ protected static function booted()
'invoker_id' => auth()->id(),
]);

$deleteProcessesTasks = collect($service->latestDeployment->data->processes)->map(function ($process) use ($service) {
$deleteProcessesTasks = collect($service->latestDeployment->data->processes)->map(function (Process $process) use ($service) {
return [
'type' => NodeTaskType::DeleteService,
'meta' => new DeleteServiceMeta($service->id, $process->name, $service->name),
'payload' => [
'ServiceName' => $service->docker_name,
'ServiceName' => $process->dockerName,
],
];
})->toArray();

// TODO: apply caddy config after the services deletion
// https://github.com/ptah-sh/ptah-server/issues/117
$taskGroup->tasks()->createMany($deleteProcessesTasks);
});
}
Expand Down
14 changes: 9 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
{
"name": "laravel/laravel",
"name": "ptah-sh/ptah-server",
"type": "project",
"description": "The skeleton application for the Laravel framework.",
"description": "Ptah.sh SaaS server.",
"keywords": [
"laravel",
"framework"
"docker",
"deploy",
"ptah",
"ptah.sh",
"ptah-server",
"ptah-saas"
],
"license": "MIT",
"license": "FSL",
"require": {
"php": "^8.3",
"ext-pdo": "*",
Expand Down
176 changes: 0 additions & 176 deletions resources/js/Pages/Welcome.vue

This file was deleted.

34 changes: 19 additions & 15 deletions resources/js/app.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,31 @@
import './bootstrap';
import '../css/app.css';
import "./bootstrap";
import "../css/app.css";

import 'flowbite';
import {initFlowbite} from 'flowbite';
import "flowbite";
import { initFlowbite } from "flowbite";

import { createApp, h } from 'vue';
import { createInertiaApp } from '@inertiajs/vue3';
import { resolvePageComponent } from 'laravel-vite-plugin/inertia-helpers';
import { autoAnimatePlugin } from '@formkit/auto-animate/vue'
import { ZiggyVue } from '../../vendor/tightenco/ziggy';
import { createApp, h } from "vue";
import { createInertiaApp } from "@inertiajs/vue3";
import { resolvePageComponent } from "laravel-vite-plugin/inertia-helpers";
import { autoAnimatePlugin } from "@formkit/auto-animate/vue";
import { ZiggyVue } from "../../vendor/tightenco/ziggy";

const appName = import.meta.env.VITE_APP_NAME || 'Laravel';
const appName = import.meta.env.VITE_APP_NAME || "Ptah.sh";

import dayjs from 'dayjs';
import RelativeTime from 'dayjs/plugin/relativeTime';
import LocalizedFormat from 'dayjs/plugin/localizedFormat';
import dayjs from "dayjs";
import RelativeTime from "dayjs/plugin/relativeTime";
import LocalizedFormat from "dayjs/plugin/localizedFormat";

dayjs.extend(RelativeTime);
dayjs.extend(LocalizedFormat);

createInertiaApp({
title: (title) => `${title} - ${appName}`,
resolve: (name) => resolvePageComponent(`./Pages/${name}.vue`, import.meta.glob('./Pages/**/*.vue')),
resolve: (name) =>
resolvePageComponent(
`./Pages/${name}.vue`,
import.meta.glob("./Pages/**/*.vue"),
),
setup({ el, App, props, plugin }) {
initFlowbite();

Expand All @@ -32,6 +36,6 @@ createInertiaApp({
.mount(el);
},
progress: {
color: '#4B5563',
color: "#4B5563",
},
});
22 changes: 13 additions & 9 deletions resources/js/ssr.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
import { createSSRApp, h } from 'vue';
import { renderToString } from '@vue/server-renderer';
import { createInertiaApp } from '@inertiajs/vue3';
import createServer from '@inertiajs/vue3/server';
import { resolvePageComponent } from 'laravel-vite-plugin/inertia-helpers';
import { ZiggyVue } from '../../vendor/tightenco/ziggy';
import { createSSRApp, h } from "vue";
import { renderToString } from "@vue/server-renderer";
import { createInertiaApp } from "@inertiajs/vue3";
import createServer from "@inertiajs/vue3/server";
import { resolvePageComponent } from "laravel-vite-plugin/inertia-helpers";
import { ZiggyVue } from "../../vendor/tightenco/ziggy";

const appName = import.meta.env.VITE_APP_NAME || 'Laravel';
const appName = import.meta.env.VITE_APP_NAME || "Ptah.sh";

createServer((page) =>
createInertiaApp({
page,
render: renderToString,
title: (title) => `${title} - ${appName}`,
resolve: (name) => resolvePageComponent(`./Pages/${name}.vue`, import.meta.glob('./Pages/**/*.vue')),
resolve: (name) =>
resolvePageComponent(
`./Pages/${name}.vue`,
import.meta.glob("./Pages/**/*.vue"),
),
setup({ App, props, plugin }) {
return createSSRApp({ render: () => h(App, props) })
.use(plugin)
Expand All @@ -21,5 +25,5 @@ createServer((page) =>
location: new URL(page.props.ziggy.location),
});
},
})
}),
);
2 changes: 1 addition & 1 deletion resources/views/app.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/png" href="{{ asset('favicon.png') }}">

<title inertia>{{ config('app.name', 'Laravel') }}</title>
<title inertia>{{ config('app.name', 'Ptah.sh') }}</title>

<!-- Fonts -->
<link rel="preconnect" href="https://fonts.bunny.net">
Expand Down

0 comments on commit 07da9de

Please sign in to comment.