From 0757fd741e1a705a5e60e654aa6ed15bc247fd1b Mon Sep 17 00:00:00 2001 From: Steve Worley Date: Fri, 23 Feb 2024 09:21:11 +1000 Subject: [PATCH 1/9] Fix: Change + icon to hamburger. --- resources/views/components/navbar.blade.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/resources/views/components/navbar.blade.php b/resources/views/components/navbar.blade.php index 0713ca503..598ccb2fd 100644 --- a/resources/views/components/navbar.blade.php +++ b/resources/views/components/navbar.blade.php @@ -44,9 +44,8 @@
From 62ae845f4b0d0607bf2b30b936d59f3cd2029f5b Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Fri, 23 Feb 2024 10:09:42 +0100 Subject: [PATCH 2/9] fix: complex service status service: firefly III --- app/Models/Service.php | 79 ++++++++++++------- public/svgs/firefly.svg | 21 +++++ .../components/services/navbar.blade.php | 21 +++-- .../components/status/degraded.blade.php | 9 ++- .../components/status/restarting.blade.php | 2 +- .../livewire/project/new/select.blade.php | 2 +- templates/compose/appsmith.yaml | 4 +- templates/compose/firefly.yaml | 56 +++++++++++++ templates/service-templates.json | 15 +++- 9 files changed, 164 insertions(+), 45 deletions(-) create mode 100644 public/svgs/firefly.svg create mode 100644 templates/compose/firefly.yaml diff --git a/app/Models/Service.php b/app/Models/Service.php index 246e812c2..9fa175bae 100644 --- a/app/Models/Service.php +++ b/app/Models/Service.php @@ -6,7 +6,6 @@ use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Relations\HasMany; use Illuminate\Database\Eloquent\SoftDeletes; use Illuminate\Support\Collection; -use Illuminate\Support\Str; class Service extends BaseModel { @@ -28,47 +27,73 @@ class Service extends BaseModel { return $this->morphToMany(Tag::class, 'taggable'); } - public function status() { - $foundRunning = false; - $isDegraded = false; - $foundRestaring = false; + public function status() + { $applications = $this->applications; $databases = $this->databases; + + $complexStatus = null; + $complexHealth = null; + foreach ($applications as $application) { if ($application->exclude_from_status) { continue; } - if (Str::of($application->status)->startsWith('running')) { - $foundRunning = true; - } else if (Str::of($application->status)->startsWith('restarting')) { - $foundRestaring = true; + $status = str($application->status)->before('(')->trim(); + $health = str($application->status)->between('(', ')')->trim(); + if ($complexStatus === 'degraded') { + continue; + } + if ($status->startsWith('running')) { + if ($complexStatus === 'exited') { + $complexStatus = 'degraded'; + } else { + $complexStatus = 'running'; + } + } else if ($status->startsWith('restarting')) { + $complexStatus = 'degraded'; + } else if ($status->startsWith('exited')) { + $complexStatus = 'exited'; + } + if ($health->value() === 'healthy') { + if ($complexHealth === 'unhealthy') { + continue; + } + $complexHealth = 'healthy'; } else { - $isDegraded = true; + $complexHealth = 'unhealthy'; } } foreach ($databases as $database) { if ($database->exclude_from_status) { continue; } - if (Str::of($database->status)->startsWith('running')) { - $foundRunning = true; - } else if (Str::of($database->status)->startsWith('restarting')) { - $foundRestaring = true; + $status = str($database->status)->before('(')->trim(); + $health = str($database->status)->between('(', ')')->trim(); + if ($complexStatus === 'degraded') { + continue; + } + if ($status->startsWith('running')) { + if ($complexStatus === 'exited') { + $complexStatus = 'degraded'; + } else { + $complexStatus = 'running'; + } + } else if ($status->startsWith('restarting')) { + $complexStatus = 'degraded'; + } else if ($status->startsWith('exited')) { + $complexStatus = 'exited'; + } + if ($health->value() === 'healthy') { + if ($complexHealth === 'unhealthy') { + continue; + } + $complexHealth = 'healthy'; } else { - $isDegraded = true; + $complexHealth = 'unhealthy'; } } - if ($foundRestaring) { - return 'degraded'; - } - if ($foundRunning && !$isDegraded) { - return 'running'; - } else if ($foundRunning && $isDegraded) { - return 'degraded'; - } else if (!$foundRunning && !$isDegraded) { - return 'exited'; - } - return 'exited'; + return "{$complexStatus}:{$complexHealth}"; } public function extraFields() { @@ -414,7 +439,7 @@ class Service extends BaseModel public function documentation() { $services = getServiceTemplates(); - $service = data_get($services, Str::of($this->name)->beforeLast('-')->value, []); + $service = data_get($services, str($this->name)->beforeLast('-')->value, []); return data_get($service, 'documentation', config('constants.docs.base_url')); } public function applications() diff --git a/public/svgs/firefly.svg b/public/svgs/firefly.svg new file mode 100644 index 000000000..cd371be1b --- /dev/null +++ b/public/svgs/firefly.svg @@ -0,0 +1,21 @@ + + + \ No newline at end of file diff --git a/resources/views/components/services/navbar.blade.php b/resources/views/components/services/navbar.blade.php index e5327935f..e593b79a8 100644 --- a/resources/views/components/services/navbar.blade.php +++ b/resources/views/components/services/navbar.blade.php @@ -1,11 +1,11 @@ @script - + @endscript diff --git a/resources/views/components/status/degraded.blade.php b/resources/views/components/status/degraded.blade.php index 81beedfa7..490ecc239 100644 --- a/resources/views/components/status/degraded.blade.php +++ b/resources/views/components/status/degraded.blade.php @@ -2,7 +2,12 @@ 'status' => 'Degraded', ]) -
+
-
{{ Str::headline($status) }}
+
+ {{ str($status)->before(':')->headline() }} +
+ @if (!str($status)->startsWith('Proxy') && !str($status)->contains('(')) +
({{ str($status)->after(':') }})
+ @endif
diff --git a/resources/views/components/status/restarting.blade.php b/resources/views/components/status/restarting.blade.php index 50142de1a..d9c353d02 100644 --- a/resources/views/components/status/restarting.blade.php +++ b/resources/views/components/status/restarting.blade.php @@ -2,7 +2,7 @@ 'status' => 'Restarting', ]) -
+
{{ str($status)->before(':')->headline() }} diff --git a/resources/views/livewire/project/new/select.blade.php b/resources/views/livewire/project/new/select.blade.php index 4ae372871..0f63e2605 100644 --- a/resources/views/livewire/project/new/select.blade.php +++ b/resources/views/livewire/project/new/select.blade.php @@ -168,7 +168,7 @@ Reload List + wire:model.live.debounce.200ms="search" autofocus placeholder="Search...">
@if ($loadingServices) diff --git a/templates/compose/appsmith.yaml b/templates/compose/appsmith.yaml index 65861db9f..a70c5ba90 100644 --- a/templates/compose/appsmith.yaml +++ b/templates/compose/appsmith.yaml @@ -7,11 +7,11 @@ services: appsmith: image: index.docker.io/appsmith/appsmith-ce:latest environment: - - SERVICE_FQDN + - SERVICE_FQDN_APPSMITH - APPSMITH_MAIL_ENABLED=false - APPSMITH_DISABLE_TELEMETRY=true - APPSMITH_DISABLE_INTERCOM=true - - APPSMITH_SENTRY_DSN= + - APPSMITH_SENTRY_DSN= - APPSMITH_SMART_LOOK_ID= volumes: - stacks-data:/appsmith-stacks diff --git a/templates/compose/firefly.yaml b/templates/compose/firefly.yaml new file mode 100644 index 000000000..49dc0d9cf --- /dev/null +++ b/templates/compose/firefly.yaml @@ -0,0 +1,56 @@ +# documentation: https://firefly-iii.org +# slogan: A personal finances manager that can help you save money. +# tags: finance, money, personal, manager +# logo: svgs/firefly.svg + +services: + firefly: + image: fireflyiii/core:latest + environment: + - SERVICE_FQDN_FIREFLY + - APP_KEY=$SERVICE_BASE64_APPKEY + - DB_HOST=mysql + - DB_PORT=3306 + - DB_CONNECTION=mysql + - DB_DATABASE=${MYSQL_DATABASE:-firefly} + - DB_USERNAME=$SERVICE_USER_MYSQL + - DB_PASSWORD=$SERVICE_PASSWORD_MYSQL + - STATIC_CRON_TOKEN=$SERVICE_BASE64_CRONTOKEN + volumes: + - firefly-upload:/var/www/html/storage/upload + healthcheck: + test: ["CMD", "curl", "-f", "http://localhost:8080"] + interval: 5s + timeout: 20s + retries: 10 + depends_on: + mysql: + condition: service_healthy + mysql: + image: mariadb:lts + environment: + - MYSQL_USER=${SERVICE_USER_MYSQL} + - MYSQL_PASSWORD=${SERVICE_PASSWORD_MYSQL} + - MYSQL_DATABASE=${MYSQL_DATABASE:-firefly} + - MYSQL_ROOT_PASSWORD=${SERVICE_PASSWORD_MYSQLROOT} + healthcheck: + test: + [ + "CMD", + "mysqladmin", + "ping", + "-h", + "localhost", + "-uroot", + "-p${SERVICE_PASSWORD_MYSQLROOT}", + ] + interval: 5s + timeout: 20s + retries: 10 + volumes: + - firefly-mysql-data:/var/lib/mysql + # cron: + # image: alpine + # command: sh -c "echo \"0 3 * * * wget -qO- http://app:8080/api/v1/cron/$STATIC_CRON_TOKEN\" | crontab - && crond -f -L /dev/stdout" + # environment: + # - STATIC_CRON_TOKEN=$SERVICE_PASSWORD_32_CRONTOKEN diff --git a/templates/service-templates.json b/templates/service-templates.json index db7654401..50b53a7f1 100644 --- a/templates/service-templates.json +++ b/templates/service-templates.json @@ -2,7 +2,7 @@ "appsmith": { "documentation": "https:\/\/appsmith.com", "slogan": "Appsmith is low-code application platform for building internal tools.", - "compose": "c2VydmljZXM6CiAgYXBwc21pdGg6CiAgICBpbWFnZTogJ2luZGV4LmRvY2tlci5pby9hcHBzbWl0aC9hcHBzbWl0aC1jZTpsYXRlc3QnCiAgICBlbnZpcm9ubWVudDoKICAgICAgLSBTRVJWSUNFX0ZRRE4KICAgICAgLSBBUFBTTUlUSF9NQUlMX0VOQUJMRUQ9ZmFsc2UKICAgICAgLSBBUFBTTUlUSF9ESVNBQkxFX1RFTEVNRVRSWT10cnVlCiAgICAgIC0gQVBQU01JVEhfRElTQUJMRV9JTlRFUkNPTT10cnVlCiAgICAgIC0gQVBQU01JVEhfU0VOVFJZX0RTTj0KICAgICAgLSBBUFBTTUlUSF9TTUFSVF9MT09LX0lEPQogICAgdm9sdW1lczoKICAgICAgLSAnc3RhY2tzLWRhdGE6L2FwcHNtaXRoLXN0YWNrcycKICAgIGhlYWx0aGNoZWNrOgogICAgICB0ZXN0OgogICAgICAgIC0gTk9ORQo=", + "compose": "c2VydmljZXM6CiAgYXBwc21pdGg6CiAgICBpbWFnZTogJ2luZGV4LmRvY2tlci5pby9hcHBzbWl0aC9hcHBzbWl0aC1jZTpsYXRlc3QnCiAgICBlbnZpcm9ubWVudDoKICAgICAgLSBTRVJWSUNFX0ZRRE5fQVBQU01JVEgKICAgICAgLSBBUFBTTUlUSF9NQUlMX0VOQUJMRUQ9ZmFsc2UKICAgICAgLSBBUFBTTUlUSF9ESVNBQkxFX1RFTEVNRVRSWT10cnVlCiAgICAgIC0gQVBQU01JVEhfRElTQUJMRV9JTlRFUkNPTT10cnVlCiAgICAgIC0gQVBQU01JVEhfU0VOVFJZX0RTTj0KICAgICAgLSBBUFBTTUlUSF9TTUFSVF9MT09LX0lEPQogICAgdm9sdW1lczoKICAgICAgLSAnc3RhY2tzLWRhdGE6L2FwcHNtaXRoLXN0YWNrcycKICAgIGhlYWx0aGNoZWNrOgogICAgICB0ZXN0OgogICAgICAgIC0gTk9ORQo=", "tags": [ "lowcode", "nocode", @@ -192,6 +192,19 @@ "logo": "svgs\/filebrowser.svg", "minversion": "0.0.0" }, + "firefly": { + "documentation": "https:\/\/firefly-iii.org", + "slogan": "A personal finances manager that can help you save money.", + "compose": "c2VydmljZXM6CiAgZmlyZWZseToKICAgIGltYWdlOiAnZmlyZWZseWlpaS9jb3JlOmxhdGVzdCcKICAgIGVudmlyb25tZW50OgogICAgICAtIFNFUlZJQ0VfRlFETl9GSVJFRkxZCiAgICAgIC0gQVBQX0tFWT0kU0VSVklDRV9CQVNFNjRfQVBQS0VZCiAgICAgIC0gREJfSE9TVD1teXNxbAogICAgICAtIERCX1BPUlQ9MzMwNgogICAgICAtIERCX0NPTk5FQ1RJT049bXlzcWwKICAgICAgLSAnREJfREFUQUJBU0U9JHtNWVNRTF9EQVRBQkFTRTotZmlyZWZseX0nCiAgICAgIC0gREJfVVNFUk5BTUU9JFNFUlZJQ0VfVVNFUl9NWVNRTAogICAgICAtIERCX1BBU1NXT1JEPSRTRVJWSUNFX1BBU1NXT1JEX01ZU1FMCiAgICAgIC0gU1RBVElDX0NST05fVE9LRU49JFNFUlZJQ0VfQkFTRTY0X0NST05UT0tFTgogICAgdm9sdW1lczoKICAgICAgLSAnZmlyZWZseS11cGxvYWQ6L3Zhci93d3cvaHRtbC9zdG9yYWdlL3VwbG9hZCcKICAgIGhlYWx0aGNoZWNrOgogICAgICB0ZXN0OgogICAgICAgIC0gQ01ECiAgICAgICAgLSBjdXJsCiAgICAgICAgLSAnLWYnCiAgICAgICAgLSAnaHR0cDovL2xvY2FsaG9zdDo4MDgwJwogICAgICBpbnRlcnZhbDogNXMKICAgICAgdGltZW91dDogMjBzCiAgICAgIHJldHJpZXM6IDEwCiAgICBkZXBlbmRzX29uOgogICAgICBteXNxbDoKICAgICAgICBjb25kaXRpb246IHNlcnZpY2VfaGVhbHRoeQogIG15c3FsOgogICAgaW1hZ2U6ICdtYXJpYWRiOmx0cycKICAgIGVudmlyb25tZW50OgogICAgICAtICdNWVNRTF9VU0VSPSR7U0VSVklDRV9VU0VSX01ZU1FMfScKICAgICAgLSAnTVlTUUxfUEFTU1dPUkQ9JHtTRVJWSUNFX1BBU1NXT1JEX01ZU1FMfScKICAgICAgLSAnTVlTUUxfREFUQUJBU0U9JHtNWVNRTF9EQVRBQkFTRTotZmlyZWZseX0nCiAgICAgIC0gJ01ZU1FMX1JPT1RfUEFTU1dPUkQ9JHtTRVJWSUNFX1BBU1NXT1JEX01ZU1FMUk9PVH0nCiAgICBoZWFsdGhjaGVjazoKICAgICAgdGVzdDoKICAgICAgICAtIENNRAogICAgICAgIC0gbXlzcWxhZG1pbgogICAgICAgIC0gcGluZwogICAgICAgIC0gJy1oJwogICAgICAgIC0gbG9jYWxob3N0CiAgICAgICAgLSAnLXVyb290JwogICAgICAgIC0gJy1wJHtTRVJWSUNFX1BBU1NXT1JEX01ZU1FMUk9PVH0nCiAgICAgIGludGVydmFsOiA1cwogICAgICB0aW1lb3V0OiAyMHMKICAgICAgcmV0cmllczogMTAKICAgIHZvbHVtZXM6CiAgICAgIC0gJ2ZpcmVmbHktbXlzcWwtZGF0YTovdmFyL2xpYi9teXNxbCcK", + "tags": [ + "finance", + "money", + "personal", + "manager" + ], + "logo": "svgs\/firefly.svg", + "minversion": "0.0.0" + }, "formbricks": { "documentation": "https:\/\/formbricks.com", "slogan": "Open Source Experience Management", From 1150633fefcc4e3293f46c28922c209e160c8bc5 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Fri, 23 Feb 2024 10:14:13 +0100 Subject: [PATCH 3/9] fix: unknown image of service until it is uploaded --- .../livewire/project/new/select.blade.php | 49 ++++++++++--------- 1 file changed, 27 insertions(+), 22 deletions(-) diff --git a/resources/views/livewire/project/new/select.blade.php b/resources/views/livewire/project/new/select.blade.php index 0f63e2605..97bcd179f 100644 --- a/resources/views/livewire/project/new/select.blade.php +++ b/resources/views/livewire/project/new/select.blade.php @@ -176,28 +176,29 @@ @else @forelse ($services as $serviceName => $service) @if (data_get($service, 'minversion') && version_compare(config('version'), data_get($service, 'minversion'), '<')) - - {{ Str::headline($serviceName) }} - - @if (data_get($service, 'slogan')) - {{ data_get($service, 'slogan') }} - @endif + + {{ Str::headline($serviceName) }} + + @if (data_get($service, 'slogan')) + {{ data_get($service, 'slogan') }} + @endif - - - @if (data_get($service, 'logo')) - - @endif - - - {{ data_get($service, 'documentation') }} - - - You need to upgrade Coolify to {{ data_get($service, 'minversion') }} to use this service. - - + src="{{ asset(data_get($service, 'logo')) }}"> + @endif + + + {{ data_get($service, 'documentation') }} + + + You need to upgrade Coolify to {{ data_get($service, 'minversion') }} to use this + service. + + {{--
- @endif - + @endif --}}
diff --git a/resources/views/livewire/subscription/show.blade.php b/resources/views/livewire/subscription/show.blade.php new file mode 100644 index 000000000..b4ba502bd --- /dev/null +++ b/resources/views/livewire/subscription/show.blade.php @@ -0,0 +1,16 @@ +
+
+

Subscription

+
Here you can see and manage your subscription.
+
+
+ @if (data_get(currentTeam(), 'subscription')) + + @else +
You are not subscribed to any plan. Please subscribe to a plan to continue.
+ Subscribe Now + + @endif +
+
diff --git a/resources/views/livewire/team/index.blade.php b/resources/views/livewire/team/index.blade.php index 64421f657..99637f17f 100644 --- a/resources/views/livewire/team/index.blade.php +++ b/resources/views/livewire/team/index.blade.php @@ -14,19 +14,6 @@
- @if (isCloud()) -
-

Subscription

- @if (data_get(currentTeam(), 'subscription')) - - @else - Subscribe Now - - @endif - -
- @endif

Danger Zone

Woah. I hope you know what are you doing.
@@ -36,7 +23,7 @@ @elseif(auth()->user()->teams()->get()->count() === 1)
You can't delete your last team.
@elseif(currentTeam()->subscription && currentTeam()->subscription?->lemon_status !== 'cancelled') -
Please cancel your subscription before delete this team (Manage My Subscription).
+
Please cancel your subscription here before delete this team.
@else @if (currentTeam()->isEmpty())
This will delete your team. Beware! There is no coming back!
diff --git a/routes/web.php b/routes/web.php index a4998aaff..ae0321a67 100644 --- a/routes/web.php +++ b/routes/web.php @@ -72,6 +72,7 @@ use App\Livewire\Server\Proxy\Show as ProxyShow; use App\Livewire\Server\Proxy\Logs as ProxyLogs; use App\Livewire\Source\Github\Change as GitHubChange; use App\Livewire\Subscription\Index as SubscriptionIndex; +use App\Livewire\Subscription\Show as SubscriptionShow; use App\Livewire\Tags\Index as TagsIndex; use App\Livewire\Tags\Show as TagsShow; @@ -110,7 +111,8 @@ Route::middleware(['auth', 'verified'])->group(function () { Route::get('/', Dashboard::class)->name('dashboard'); Route::get('/boarding', BoardingIndex::class)->name('boarding'); - Route::get('/subscription', SubscriptionIndex::class)->name('subscription.index'); + Route::get('/subscription/new', SubscriptionIndex::class)->name('subscription.index'); + Route::get('/subscription', SubscriptionShow::class)->name('subscription.show'); Route::get('/settings', SettingsIndex::class)->name('settings.index'); Route::get('/settings/license', SettingsLicense::class)->name('settings.license'); diff --git a/routes/webhooks.php b/routes/webhooks.php index 594e54d4a..e4e9c043b 100644 --- a/routes/webhooks.php +++ b/routes/webhooks.php @@ -816,9 +816,7 @@ Route::post('/payments/stripe/events', function () { Sleep::for(5)->seconds(); $subscription = Subscription::where('stripe_customer_id', $customerId)->firstOrFail(); } - $subscription->update([ - 'stripe_plan_id' => $planId, 'stripe_invoice_paid' => true, ]); break; From ea0a9763bfe8769e9d9a08c58f441f13af51202f Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Fri, 23 Feb 2024 11:23:14 +0100 Subject: [PATCH 6/9] Update navbar icons --- resources/views/components/navbar.blade.php | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/resources/views/components/navbar.blade.php b/resources/views/components/navbar.blade.php index 93adb9126..3bd1730be 100644 --- a/resources/views/components/navbar.blade.php +++ b/resources/views/components/navbar.blade.php @@ -44,8 +44,10 @@
@@ -137,8 +139,12 @@
  • - - + + Subscription From f931ebece8257be208f76ebba0ab4398ed612e26 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Fri, 23 Feb 2024 12:34:36 +0100 Subject: [PATCH 7/9] feat: make user owner fix: ownership check --- app/Livewire/Team/Member.php | 7 +- app/Models/User.php | 10 ++- .../views/livewire/team/invitations.blade.php | 84 +++++++++++-------- .../views/livewire/team/invite-link.blade.php | 1 + .../views/livewire/team/member.blade.php | 56 +++++++++---- .../livewire/team/member/index.blade.php | 46 ++++++---- 6 files changed, 131 insertions(+), 73 deletions(-) diff --git a/app/Livewire/Team/Member.php b/app/Livewire/Team/Member.php index 7d02dbf66..0f0774898 100644 --- a/app/Livewire/Team/Member.php +++ b/app/Livewire/Team/Member.php @@ -16,6 +16,11 @@ class Member extends Component $this->dispatch('reloadWindow'); } + public function makeOwner() + { + $this->member->teams()->updateExistingPivot(currentTeam()->id, ['role' => 'owner']); + $this->dispatch('reloadWindow'); + } public function makeReadonly() { $this->member->teams()->updateExistingPivot(currentTeam()->id, ['role' => 'member']); @@ -26,7 +31,7 @@ class Member extends Component { $this->member->teams()->detach(currentTeam()); Cache::forget("team:{$this->member->id}"); - Cache::remember('team:' . $this->member->id, 3600, function() { + Cache::remember('team:' . $this->member->id, 3600, function () { return $this->member->teams()->first(); }); $this->dispatch('reloadWindow'); diff --git a/app/Models/User.php b/app/Models/User.php index c099eb2b6..ad5120a3d 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -67,7 +67,7 @@ class User extends Authenticatable implements SendsEmail 'team_id' => session('currentTeam')->id ]); - return new NewAccessToken($token, $token->getKey().'|'.$plainTextToken); + return new NewAccessToken($token, $token->getKey() . '|' . $plainTextToken); } public function teams() { @@ -103,9 +103,13 @@ class User extends Authenticatable implements SendsEmail public function isAdmin() { - return data_get($this->pivot, 'role') === 'admin' || data_get($this->pivot, 'role') === 'owner'; + return $this->role() === 'admin' || $this->role() === 'owner'; } + public function isOwner() + { + return $this->role() === 'owner'; + } public function isAdminFromSession() { if (auth()->user()->id === 0) { @@ -155,6 +159,6 @@ class User extends Authenticatable implements SendsEmail public function role() { - return session('currentTeam')->pivot->role; + return auth()->user()->teams->where('id', currentTeam()->id)->first()->pivot->role; } } diff --git a/resources/views/livewire/team/invitations.blade.php b/resources/views/livewire/team/invitations.blade.php index 8fc8f9cf3..84cd3287c 100644 --- a/resources/views/livewire/team/invitations.blade.php +++ b/resources/views/livewire/team/invitations.blade.php @@ -1,39 +1,55 @@
    @if ($invitations->count() > 0) -

    Pending Invitations

    -
    - - - - - - - - - - - - @foreach ($invitations as $invite) - - - - - - - - @endforeach - -
    EmailViaRoleInvitation LinkActions
    {{ $invite->email }}{{ $invite->via }}{{ $invite->role }} - - - - Revoke - Invitation - -
    +

    Pending Invitations

    +
    +
    +
    +
    +
    + + + + + + + + + + + + @foreach ($invitations as $invite) + + + + + + + + @endforeach + +
    Email + + ViaRoleInvitation Link + Actions +
    {{ $invite->email }}{{ $invite->via }}{{ $invite->role }} + + + + Revoke + Invitation + +
    +
    +
    +
    +
    @endif
    diff --git a/resources/views/livewire/team/invite-link.blade.php b/resources/views/livewire/team/invite-link.blade.php index f35af72ff..cb67f6b41 100644 --- a/resources/views/livewire/team/invite-link.blade.php +++ b/resources/views/livewire/team/invite-link.blade.php @@ -2,6 +2,7 @@
    + diff --git a/resources/views/livewire/team/member.blade.php b/resources/views/livewire/team/member.blade.php index e86b2202f..dab5df404 100644 --- a/resources/views/livewire/team/member.blade.php +++ b/resources/views/livewire/team/member.blade.php @@ -1,25 +1,47 @@ - - - {{ $member->name }} - {{ $member->email }} - - {{ data_get($member, 'pivot.role') }} - - {{-- TODO: This is not good --}} + $member->id == auth()->user()->id, +])> + + {{ $member->name }} + + + {{ $member->email }} + + + {{ data_get($member, 'pivot.role') }} + + @if (auth()->user()->isAdminFromSession()) @if ($member->id !== auth()->user()->id) - @if (data_get($member, 'pivot.role') !== 'owner') - @if (data_get($member, 'pivot.role') !== 'admin') - Convert to Admin - @else - Convert to Member + @if (auth()->user()->isOwner()) + @if (data_get($member, 'pivot.role') === 'owner') + To Admin + To Member + Remove + @endif + @if (data_get($member, 'pivot.role') === 'admin') + To Owner + To Member + Remove + @endif + @if (data_get($member, 'pivot.role') === 'member') + To Owner + To Admin + Remove + @endif + @elseif (auth()->user()->isAdmin()) + @if (data_get($member, 'pivot.role') === 'admin') + To Member + Remove + @endif + @if (data_get($member, 'pivot.role') === 'member') + To Admin + Remove @endif - Remove - @else - Remove @endif @else - Remove +
    (This is you)
    @endif @endif diff --git a/resources/views/livewire/team/member/index.blade.php b/resources/views/livewire/team/member/index.blade.php index 72d7864c6..6345cab02 100644 --- a/resources/views/livewire/team/member/index.blade.php +++ b/resources/views/livewire/team/member/index.blade.php @@ -1,29 +1,39 @@

    Members

    -
    - - - - - - - - - - - @foreach (currentTeam()->members->sortBy('name') as $member) - - @endforeach - -
    NameEmailRoleActions
    + +
    +
    +
    +
    +
    + + + + + + + + + + + @foreach (currentTeam()->members as $member) + + @endforeach + +
    Name + EmailRoleActions
    +
    +
    +
    +
    @if (auth()->user()->isAdminFromSession())
    @if (is_transactional_emails_active()) -

    Invite a new member

    +

    Invite New Member

    @else -

    Invite a new member

    +

    Invite New Member

    @if (isInstanceAdmin())
    You need to configure (as root team) Transactional From f78fd212bbc14a9a1501f40b6a7055322356b104 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Fri, 23 Feb 2024 12:59:14 +0100 Subject: [PATCH 8/9] fix: subscription / plan switch, etc --- app/Livewire/Subscription/Index.php | 9 +- app/Livewire/Subscription/Show.php | 3 + app/Models/Subscription.php | 6 +- app/Models/User.php | 3 + config/subscription.php | 6 ++ docker-compose.prod.yml | 6 ++ resources/views/livewire/dashboard.blade.php | 86 +++++++++---------- .../livewire/subscription/actions.blade.php | 1 - .../livewire/subscription/show.blade.php | 13 +-- routes/web.php | 2 +- 10 files changed, 74 insertions(+), 61 deletions(-) diff --git a/app/Livewire/Subscription/Index.php b/app/Livewire/Subscription/Index.php index afc3729c6..4f36750c7 100644 --- a/app/Livewire/Subscription/Index.php +++ b/app/Livewire/Subscription/Index.php @@ -10,14 +10,19 @@ class Index extends Component { public InstanceSettings $settings; public bool $alreadySubscribed = false; - public function mount() { + public function mount() + { if (!isCloud()) { return redirect(RouteServiceProvider::HOME); } + if (data_get(currentTeam(), 'subscription')) { + return redirect()->route('subscription.show'); + } $this->settings = InstanceSettings::get(); $this->alreadySubscribed = currentTeam()->subscription()->exists(); } - public function stripeCustomerPortal() { + public function stripeCustomerPortal() + { $session = getStripeCustomerPortalSession(currentTeam()); if (is_null($session)) { return; diff --git a/app/Livewire/Subscription/Show.php b/app/Livewire/Subscription/Show.php index 8069b98a6..ad677ce53 100644 --- a/app/Livewire/Subscription/Show.php +++ b/app/Livewire/Subscription/Show.php @@ -11,6 +11,9 @@ class Show extends Component if (!isCloud()) { return redirect()->route('dashboard'); } + if (!data_get(currentTeam(), 'subscription')) { + return redirect()->route('subscription.index'); + } } public function render() { diff --git a/app/Models/Subscription.php b/app/Models/Subscription.php index cd35dc477..668394bc4 100644 --- a/app/Models/Subscription.php +++ b/app/Models/Subscription.php @@ -30,8 +30,7 @@ class Subscription extends Model if (in_array($subscription, $ultimate)) { return 'ultimate'; } - } - if (isStripe()) { + } else if (isStripe()) { if (!$this->stripe_plan_id) { return 'zero'; } @@ -55,7 +54,8 @@ class Subscription extends Model }; })->first(); if ($stripePlanId) { - return Str::of($stripePlanId)->after('stripe_price_id_')->before('_')->lower(); + raY($stripePlanId); + return str($stripePlanId)->after('stripe_price_id_')->before('_')->lower(); } } return 'zero'; diff --git a/app/Models/User.php b/app/Models/User.php index ad5120a3d..f8507a6b9 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -159,6 +159,9 @@ class User extends Authenticatable implements SendsEmail public function role() { + if (data_get($this, 'pivot')) { + return $this->pivot->role; + } return auth()->user()->teams->where('id', currentTeam()->id)->first()->pivot->role; } } diff --git a/config/subscription.php b/config/subscription.php index 677689ff1..96a9a8e1c 100644 --- a/config/subscription.php +++ b/config/subscription.php @@ -13,6 +13,12 @@ return [ 'stripe_price_id_ultimate_yearly' => env('STRIPE_PRICE_ID_ULTIMATE_YEARLY', null), 'stripe_excluded_plans' => env('STRIPE_EXCLUDED_PLANS', null), + 'stripe_price_id_basic_monthly_old' => env('STRIPE_PRICE_ID_BASIC_MONTHLY_OLD', null), + 'stripe_price_id_basic_yearly_old' => env('STRIPE_PRICE_ID_BASIC_YEARLY_OLD', null), + 'stripe_price_id_pro_monthly_old' => env('STRIPE_PRICE_ID_PRO_MONTHLY_OLD', null), + 'stripe_price_id_pro_yearly_old' => env('STRIPE_PRICE_ID_PRO_YEARLY_OLD', null), + 'stripe_price_id_ultimate_monthly_old' => env('STRIPE_PRICE_ID_ULTIMATE_MONTHLY_OLD', null), + 'stripe_price_id_ultimate_yearly_old' => env('STRIPE_PRICE_ID_ULTIMATE_YEARLY_OLD', null), // Paddle 'paddle_vendor_id' => env('PADDLE_VENDOR_ID', null), diff --git a/docker-compose.prod.yml b/docker-compose.prod.yml index 407be245b..6a80dab47 100644 --- a/docker-compose.prod.yml +++ b/docker-compose.prod.yml @@ -57,6 +57,12 @@ services: - STRIPE_PRICE_ID_PRO_YEARLY - STRIPE_PRICE_ID_ULTIMATE_MONTHLY - STRIPE_PRICE_ID_ULTIMATE_YEARLY + - STRIPE_PRICE_ID_BASIC_MONTHLY_OLD + - STRIPE_PRICE_ID_BASIC_YEARLY_OLD + - STRIPE_PRICE_ID_PRO_MONTHLY_OLD + - STRIPE_PRICE_ID_PRO_YEARLY_OLD + - STRIPE_PRICE_ID_ULTIMATE_MONTHLY_OLD + - STRIPE_PRICE_ID_ULTIMATE_YEARLY_OLD - STRIPE_EXCLUDED_PLANS - PADDLE_VENDOR_ID - PADDLE_WEBHOOK_SECRET diff --git a/resources/views/livewire/dashboard.blade.php b/resources/views/livewire/dashboard.blade.php index 7b5ea1417..e8ba873ea 100644 --- a/resources/views/livewire/dashboard.blade.php +++ b/resources/views/livewire/dashboard.blade.php @@ -5,7 +5,7 @@

    Dashboard

    Your self-hosted environment
    @if (request()->query->get('success')) -
    +
    @endif @if ($projects->count() === 0 && $servers->count() === 0) - No resources found. Add your first server / private key here. + No resources found. Add your first server & private key here or go to the boarding page. @endif @if ($projects->count() > 0)

    Projects

    - @endif - @if ($projects->count() === 1) -
    - @else -
    - @endif - @foreach ($projects as $project) -
    - @if (data_get($project, 'environments')->count() === 1) - -
    {{ $project->name }}
    -
    - {{ $project->description }}
    -
    + @if ($projects->count() === 1) +
    @else - -
    {{ $project->name }}
    -
    - {{ $project->description }}
    -
    - @endif -
    - - + Add Resource - - - - - - - - +
    + @endif + @foreach ($projects as $project) + -
    - @endforeach + @endforeach
    @if ($projects->count() > 0)

    Servers

    @@ -139,6 +138,7 @@
    No deployments running.
    @endforelse
    +@endif