mirror of
https://github.com/solidtime-io/solidtime.git
synced 2026-08-18 21:22:15 +01:00
Compare commits
2 Commits
feature/de
...
7ae4f2171d
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7ae4f2171d | ||
|
|
96acd4b962 |
3
.github/workflows/build-private.yml
vendored
3
.github/workflows/build-private.yml
vendored
@@ -10,8 +10,6 @@ on:
|
|||||||
- '.github/workflows/build-private.yml'
|
- '.github/workflows/build-private.yml'
|
||||||
- 'docker/prod/**'
|
- 'docker/prod/**'
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
permissions:
|
|
||||||
contents: read
|
|
||||||
|
|
||||||
name: Build - Private
|
name: Build - Private
|
||||||
jobs:
|
jobs:
|
||||||
@@ -19,7 +17,6 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
timeout-minutes: 20
|
timeout-minutes: 20
|
||||||
|
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: "Check out code"
|
- name: "Check out code"
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|||||||
16
.github/workflows/build-public.yml
vendored
16
.github/workflows/build-public.yml
vendored
@@ -11,12 +11,6 @@ on:
|
|||||||
- 'docker/prod/**'
|
- 'docker/prod/**'
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|
||||||
permissions:
|
|
||||||
packages: write
|
|
||||||
contents: read
|
|
||||||
attestations: write
|
|
||||||
id-token: write
|
|
||||||
|
|
||||||
env:
|
env:
|
||||||
DOCKERHUB_REPO: solidtime/solidtime
|
DOCKERHUB_REPO: solidtime/solidtime
|
||||||
GHCR_REPO: ghcr.io/solidtime-io/solidtime
|
GHCR_REPO: ghcr.io/solidtime-io/solidtime
|
||||||
@@ -32,6 +26,11 @@ jobs:
|
|||||||
- runs-on: "ubuntu-24.04"
|
- runs-on: "ubuntu-24.04"
|
||||||
platform: "linux/amd64"
|
platform: "linux/amd64"
|
||||||
runs-on: ${{ matrix.runs-on }}
|
runs-on: ${{ matrix.runs-on }}
|
||||||
|
permissions:
|
||||||
|
packages: write
|
||||||
|
contents: read
|
||||||
|
attestations: write
|
||||||
|
id-token: write
|
||||||
timeout-minutes: 90
|
timeout-minutes: 90
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
@@ -164,6 +163,11 @@ jobs:
|
|||||||
|
|
||||||
merge:
|
merge:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
permissions:
|
||||||
|
packages: write
|
||||||
|
contents: read
|
||||||
|
attestations: write
|
||||||
|
id-token: write
|
||||||
timeout-minutes: 90
|
timeout-minutes: 90
|
||||||
needs:
|
needs:
|
||||||
- build
|
- build
|
||||||
|
|||||||
3
.github/workflows/generate-api-docs.yml
vendored
3
.github/workflows/generate-api-docs.yml
vendored
@@ -3,9 +3,6 @@ on:
|
|||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- main
|
- main
|
||||||
permissions:
|
|
||||||
contents: read
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
api_docs:
|
api_docs:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|||||||
2
.github/workflows/npm-build.yml
vendored
2
.github/workflows/npm-build.yml
vendored
@@ -1,8 +1,6 @@
|
|||||||
name: NPM Build
|
name: NPM Build
|
||||||
|
|
||||||
on: [push]
|
on: [push]
|
||||||
permissions:
|
|
||||||
contents: read
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
|
|||||||
2
.github/workflows/npm-lint.yml
vendored
2
.github/workflows/npm-lint.yml
vendored
@@ -1,8 +1,6 @@
|
|||||||
name: NPM Lint
|
name: NPM Lint
|
||||||
|
|
||||||
on: [push]
|
on: [push]
|
||||||
permissions:
|
|
||||||
contents: read
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
|
|||||||
2
.github/workflows/npm-publish-api.yml
vendored
2
.github/workflows/npm-publish-api.yml
vendored
@@ -1,8 +1,6 @@
|
|||||||
name: Publish API package to NPM
|
name: Publish API package to NPM
|
||||||
on:
|
on:
|
||||||
workflow_dispatch
|
workflow_dispatch
|
||||||
permissions:
|
|
||||||
contents: read
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|||||||
2
.github/workflows/npm-publish-ui.yml
vendored
2
.github/workflows/npm-publish-ui.yml
vendored
@@ -1,8 +1,6 @@
|
|||||||
name: Publish UI package to NPM
|
name: Publish UI package to NPM
|
||||||
on:
|
on:
|
||||||
workflow_dispatch
|
workflow_dispatch
|
||||||
permissions:
|
|
||||||
contents: read
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|||||||
3
.github/workflows/npm-typecheck.yml
vendored
3
.github/workflows/npm-typecheck.yml
vendored
@@ -1,8 +1,7 @@
|
|||||||
name: NPM Typecheck
|
name: NPM Typecheck
|
||||||
|
|
||||||
on: [push]
|
on: [push]
|
||||||
permissions:
|
|
||||||
contents: read
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|||||||
2
.github/workflows/phpstan.yml
vendored
2
.github/workflows/phpstan.yml
vendored
@@ -1,7 +1,5 @@
|
|||||||
name: Static code analysis (PHPStan)
|
name: Static code analysis (PHPStan)
|
||||||
on: push
|
on: push
|
||||||
permissions:
|
|
||||||
contents: read
|
|
||||||
jobs:
|
jobs:
|
||||||
phpstan:
|
phpstan:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|||||||
11
.github/workflows/phpunit.yml
vendored
11
.github/workflows/phpunit.yml
vendored
@@ -1,18 +1,13 @@
|
|||||||
name: PHPUnit Tests
|
name: PHPUnit Tests
|
||||||
on: push
|
on: push
|
||||||
permissions:
|
|
||||||
contents: read
|
|
||||||
jobs:
|
jobs:
|
||||||
phpunit:
|
phpunit:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
timeout-minutes: 10
|
timeout-minutes: 10
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
postgres_version: [ 15, 16, 17 ]
|
|
||||||
|
|
||||||
services:
|
services:
|
||||||
pgsql_test:
|
pgsql_test:
|
||||||
image: postgres:${{ matrix.postgres_version }}
|
image: postgres:15
|
||||||
env:
|
env:
|
||||||
PGPASSWORD: 'root'
|
PGPASSWORD: 'root'
|
||||||
POSTGRES_DB: 'laravel'
|
POSTGRES_DB: 'laravel'
|
||||||
@@ -65,10 +60,10 @@ jobs:
|
|||||||
php artisan passport:keys
|
php artisan passport:keys
|
||||||
|
|
||||||
- name: "Run PHPUnit"
|
- name: "Run PHPUnit"
|
||||||
run: php artisan test --stop-on-failure --coverage-text --coverage-clover=coverage.xml
|
run: php artisan test --parallel --stop-on-failure --coverage-text --coverage-clover=coverage.xml
|
||||||
|
|
||||||
- name: "Upload coverage reports to Codecov"
|
- name: "Upload coverage reports to Codecov"
|
||||||
uses: codecov/codecov-action@v5.4.3
|
uses: codecov/codecov-action@v5.4.2
|
||||||
with:
|
with:
|
||||||
token: ${{ secrets.CODECOV_TOKEN }}
|
token: ${{ secrets.CODECOV_TOKEN }}
|
||||||
slug: solidtime-io/solidtime
|
slug: solidtime-io/solidtime
|
||||||
|
|||||||
2
.github/workflows/pint.yml
vendored
2
.github/workflows/pint.yml
vendored
@@ -1,7 +1,5 @@
|
|||||||
name: PHP Linting
|
name: PHP Linting
|
||||||
on: push
|
on: push
|
||||||
permissions:
|
|
||||||
contents: read
|
|
||||||
jobs:
|
jobs:
|
||||||
pint:
|
pint:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|||||||
2
.github/workflows/playwright.yml
vendored
2
.github/workflows/playwright.yml
vendored
@@ -1,7 +1,5 @@
|
|||||||
name: Playwright Tests
|
name: Playwright Tests
|
||||||
on: [push]
|
on: [push]
|
||||||
permissions:
|
|
||||||
contents: read
|
|
||||||
jobs:
|
jobs:
|
||||||
test:
|
test:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|||||||
@@ -23,7 +23,6 @@ use Filament\Tables;
|
|||||||
use Filament\Tables\Filters\TernaryFilter;
|
use Filament\Tables\Filters\TernaryFilter;
|
||||||
use Filament\Tables\Table;
|
use Filament\Tables\Table;
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
use Illuminate\Support\Collection;
|
|
||||||
use Illuminate\Support\Facades\Auth;
|
use Illuminate\Support\Facades\Auth;
|
||||||
use Illuminate\Support\Facades\Hash;
|
use Illuminate\Support\Facades\Hash;
|
||||||
use Korridor\LaravelModelValidationRules\Rules\UniqueEloquent;
|
use Korridor\LaravelModelValidationRules\Rules\UniqueEloquent;
|
||||||
@@ -208,14 +207,6 @@ class UserResource extends Resource
|
|||||||
}),
|
}),
|
||||||
])
|
])
|
||||||
->bulkActions([
|
->bulkActions([
|
||||||
Tables\Actions\BulkAction::make('Resend verification email')
|
|
||||||
->icon('heroicon-o-paper-airplane')
|
|
||||||
->action(function (Collection $records): void {
|
|
||||||
foreach ($records as $user) {
|
|
||||||
/** @var User $user */
|
|
||||||
$user->sendEmailVerificationNotification();
|
|
||||||
}
|
|
||||||
}),
|
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,6 @@ use App\Exceptions\Api\OrganizationNeedsAtLeastOneOwner;
|
|||||||
use App\Exceptions\Api\ThisPlaceholderCanNotBeInvitedUseTheMergeToolInsteadException;
|
use App\Exceptions\Api\ThisPlaceholderCanNotBeInvitedUseTheMergeToolInsteadException;
|
||||||
use App\Exceptions\Api\UserIsAlreadyMemberOfOrganizationApiException;
|
use App\Exceptions\Api\UserIsAlreadyMemberOfOrganizationApiException;
|
||||||
use App\Exceptions\Api\UserNotPlaceholderApiException;
|
use App\Exceptions\Api\UserNotPlaceholderApiException;
|
||||||
use App\Http\Requests\V1\Member\MemberDestroyRequest;
|
|
||||||
use App\Http\Requests\V1\Member\MemberIndexRequest;
|
use App\Http\Requests\V1\Member\MemberIndexRequest;
|
||||||
use App\Http\Requests\V1\Member\MemberMergeIntoRequest;
|
use App\Http\Requests\V1\Member\MemberMergeIntoRequest;
|
||||||
use App\Http\Requests\V1\Member\MemberUpdateRequest;
|
use App\Http\Requests\V1\Member\MemberUpdateRequest;
|
||||||
@@ -101,13 +100,11 @@ class MemberController extends Controller
|
|||||||
*
|
*
|
||||||
* @operationId removeMember
|
* @operationId removeMember
|
||||||
*/
|
*/
|
||||||
public function destroy(MemberDestroyRequest $request, Organization $organization, Member $member, MemberService $memberService): JsonResponse
|
public function destroy(Organization $organization, Member $member, MemberService $memberService): JsonResponse
|
||||||
{
|
{
|
||||||
$this->checkPermission($organization, 'members:delete', $member);
|
$this->checkPermission($organization, 'members:delete', $member);
|
||||||
|
|
||||||
$deleteRelated = $request->getDeleteRelated();
|
$memberService->removeMember($member, $organization);
|
||||||
|
|
||||||
$memberService->removeMember($member, $organization, $deleteRelated);
|
|
||||||
|
|
||||||
return response()
|
return response()
|
||||||
->json(null, 204);
|
->json(null, 204);
|
||||||
|
|||||||
@@ -1,35 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace App\Http\Requests\V1\Member;
|
|
||||||
|
|
||||||
use App\Http\Requests\V1\BaseFormRequest;
|
|
||||||
use App\Models\Organization;
|
|
||||||
use Illuminate\Contracts\Validation\ValidationRule;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @property Organization $organization
|
|
||||||
*/
|
|
||||||
class MemberDestroyRequest extends BaseFormRequest
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Get the validation rules that apply to the request.
|
|
||||||
*
|
|
||||||
* @return array<string, array<string|ValidationRule>>
|
|
||||||
*/
|
|
||||||
public function rules(): array
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
'delete_related' => [
|
|
||||||
'string',
|
|
||||||
'in:true,false',
|
|
||||||
],
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getDeleteRelated(): bool
|
|
||||||
{
|
|
||||||
return $this->input('delete_related', 'false') === 'true';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -187,7 +187,6 @@ class JetstreamServiceProvider extends ServiceProvider
|
|||||||
'members:invite-placeholder',
|
'members:invite-placeholder',
|
||||||
'members:make-placeholder',
|
'members:make-placeholder',
|
||||||
'members:merge-into',
|
'members:merge-into',
|
||||||
'members:delete',
|
|
||||||
'members:update',
|
'members:update',
|
||||||
'reports:view',
|
'reports:view',
|
||||||
'reports:create',
|
'reports:create',
|
||||||
|
|||||||
@@ -45,9 +45,6 @@ class MemberService
|
|||||||
$member->organization()->associate($organization);
|
$member->organization()->associate($organization);
|
||||||
$member->role = $role->value;
|
$member->role = $role->value;
|
||||||
$member->save();
|
$member->save();
|
||||||
|
|
||||||
$user->currentOrganization()->associate($organization);
|
|
||||||
$user->save();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
if (! $asSuperAdmin) {
|
if (! $asSuperAdmin) {
|
||||||
@@ -61,24 +58,18 @@ class MemberService
|
|||||||
* @throws CanNotRemoveOwnerFromOrganization
|
* @throws CanNotRemoveOwnerFromOrganization
|
||||||
* @throws EntityStillInUseApiException
|
* @throws EntityStillInUseApiException
|
||||||
*/
|
*/
|
||||||
public function removeMember(Member $member, Organization $organization, bool $withRelations = false): void
|
public function removeMember(Member $member, Organization $organization): void
|
||||||
{
|
{
|
||||||
|
if (TimeEntry::query()->where('user_id', $member->user_id)->whereBelongsTo($organization, 'organization')->exists()) {
|
||||||
|
throw new EntityStillInUseApiException('member', 'time_entry');
|
||||||
|
}
|
||||||
|
if (ProjectMember::query()->whereBelongsToOrganization($organization)->where('user_id', $member->user_id)->exists()) {
|
||||||
|
throw new EntityStillInUseApiException('member', 'project_member');
|
||||||
|
}
|
||||||
if ($member->role === Role::Owner->value) {
|
if ($member->role === Role::Owner->value) {
|
||||||
throw new CanNotRemoveOwnerFromOrganization;
|
throw new CanNotRemoveOwnerFromOrganization;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($withRelations) {
|
|
||||||
TimeEntry::query()->where('user_id', $member->user_id)->whereBelongsTo($organization, 'organization')->delete();
|
|
||||||
ProjectMember::query()->whereBelongsToOrganization($organization)->where('user_id', $member->user_id)->delete();
|
|
||||||
} else {
|
|
||||||
if (TimeEntry::query()->where('user_id', $member->user_id)->whereBelongsTo($organization, 'organization')->exists()) {
|
|
||||||
throw new EntityStillInUseApiException('member', 'time_entry');
|
|
||||||
}
|
|
||||||
if (ProjectMember::query()->whereBelongsToOrganization($organization)->where('user_id', $member->user_id)->exists()) {
|
|
||||||
throw new EntityStillInUseApiException('member', 'project_member');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$member->delete();
|
$member->delete();
|
||||||
MemberRemoved::dispatch($member, $organization);
|
MemberRemoved::dispatch($member, $organization);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -102,7 +102,7 @@ test('test that updating billable rate works with existing time entries', async
|
|||||||
|
|
||||||
await page.getByRole('row').first().getByRole('button').click();
|
await page.getByRole('row').first().getByRole('button').click();
|
||||||
await page.getByRole('menuitem').getByText('Edit').first().click();
|
await page.getByRole('menuitem').getByText('Edit').first().click();
|
||||||
await page.getByText('Non-Billable').click();
|
await page.getByText('Non-Billable').click();
|
||||||
await page.getByText('Custom Rate').click();
|
await page.getByText('Custom Rate').click();
|
||||||
await page
|
await page
|
||||||
.getByPlaceholder('Billable Rate')
|
.getByPlaceholder('Billable Rate')
|
||||||
@@ -111,8 +111,8 @@ test('test that updating billable rate works with existing time entries', async
|
|||||||
|
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
page
|
page
|
||||||
.locator('button').filter({ hasText: 'Yes, update existing time' })
|
.getByRole('button', { name: 'Yes, update existing time entries' })
|
||||||
.click(),
|
.click(),
|
||||||
page.waitForRequest(
|
page.waitForRequest(
|
||||||
async (request) =>
|
async (request) =>
|
||||||
request.url().includes('/projects/') &&
|
request.url().includes('/projects/') &&
|
||||||
|
|||||||
@@ -1,151 +0,0 @@
|
|||||||
<script setup lang="ts">
|
|
||||||
import type { Member } from '@/packages/api/src';
|
|
||||||
import { api } from '@/packages/api/src';
|
|
||||||
import { useForm } from '@tanstack/vue-form';
|
|
||||||
import { useMutation } from '@tanstack/vue-query';
|
|
||||||
import Modal from '@/packages/ui/src/Modal.vue';
|
|
||||||
import DangerButton from '@/packages/ui/src/Buttons/DangerButton.vue';
|
|
||||||
import SecondaryButton from '@/packages/ui/src/Buttons/SecondaryButton.vue';
|
|
||||||
import Checkbox from '@/packages/ui/src/Input/Checkbox.vue';
|
|
||||||
import { useNotificationsStore } from '@/utils/notification';
|
|
||||||
import { getCurrentOrganizationId } from '@/utils/useUser';
|
|
||||||
import InputLabel from '@/packages/ui/src/Input/InputLabel.vue';
|
|
||||||
import InputError from '@/packages/ui/src/Input/InputError.vue';
|
|
||||||
import { useMembersStore } from '@/utils/useMembers';
|
|
||||||
|
|
||||||
const props = defineProps<{
|
|
||||||
show: boolean;
|
|
||||||
member: Member;
|
|
||||||
}>();
|
|
||||||
|
|
||||||
const emit = defineEmits<{
|
|
||||||
'update:show': [value: boolean];
|
|
||||||
}>();
|
|
||||||
|
|
||||||
const { handleApiRequestNotifications } = useNotificationsStore();
|
|
||||||
|
|
||||||
const deleteMutation = useMutation({
|
|
||||||
mutationFn: async () => {
|
|
||||||
const organizationId = getCurrentOrganizationId();
|
|
||||||
if (!organizationId) {
|
|
||||||
throw new Error('No organization ID found');
|
|
||||||
}
|
|
||||||
|
|
||||||
return api.removeMember(undefined, {
|
|
||||||
params: {
|
|
||||||
member: props.member.id,
|
|
||||||
organization: organizationId,
|
|
||||||
},
|
|
||||||
queries: {
|
|
||||||
delete_related: 'true',
|
|
||||||
},
|
|
||||||
});
|
|
||||||
},
|
|
||||||
onSuccess: () => {
|
|
||||||
close();
|
|
||||||
useMembersStore().fetchMembers();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
const form = useForm({
|
|
||||||
canSubmitWhenInvalid: true,
|
|
||||||
defaultValues: {
|
|
||||||
confirmDelete: false,
|
|
||||||
},
|
|
||||||
onSubmit: async () => {
|
|
||||||
await handleApiRequestNotifications(
|
|
||||||
() => deleteMutation.mutateAsync(),
|
|
||||||
'Member deleted successfully',
|
|
||||||
'Error deleting member'
|
|
||||||
);
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const close = () => {
|
|
||||||
emit('update:show', false);
|
|
||||||
form.reset();
|
|
||||||
};
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<template>
|
|
||||||
<Modal :show="show" max-width="md" @close="close">
|
|
||||||
<div class="p-6">
|
|
||||||
<h2 class="text-lg font-medium text-text-primary">
|
|
||||||
Delete Member
|
|
||||||
</h2>
|
|
||||||
|
|
||||||
<div class="mt-4 text-sm text-text-secondary">
|
|
||||||
<p class="mb-4">
|
|
||||||
Are you sure you want to delete {{ member.name }}? This action cannot be undone.
|
|
||||||
</p>
|
|
||||||
<p class="mb-4">
|
|
||||||
This will permanently delete:
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<ul class="list-disc ml-6 mt-2">
|
|
||||||
<li>All time entries created by this member</li>
|
|
||||||
<li>Their project assignments</li>
|
|
||||||
<li>Their organization membership</li>
|
|
||||||
</ul>
|
|
||||||
<p class="pt-4">
|
|
||||||
<strong>Note:</strong> Deleting time entries will affect all reports and statistics.
|
|
||||||
If you want to keep the time entries but remove the member from your organization, you can convert them to a placeholder user instead. Placeholder users are not charged and their time entries remain intact for reporting purposes.
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<form
|
|
||||||
class="mt-6" @submit="
|
|
||||||
(e) => {
|
|
||||||
e.preventDefault();
|
|
||||||
e.stopPropagation();
|
|
||||||
form.handleSubmit();
|
|
||||||
}
|
|
||||||
">
|
|
||||||
<div class="flex items-start">
|
|
||||||
<form.Field
|
|
||||||
name="confirmDelete"
|
|
||||||
:validators="{
|
|
||||||
onSubmit: ({value}) => {
|
|
||||||
if (!value) {
|
|
||||||
return 'You must confirm that you understand the consequences of this action';
|
|
||||||
}
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
}"
|
|
||||||
>
|
|
||||||
<template #default="{ field }">
|
|
||||||
<div class="flex flex-col">
|
|
||||||
<div class="flex items-center space-x-3 text-sm">
|
|
||||||
<Checkbox
|
|
||||||
:id="field.name"
|
|
||||||
:name="field.name"
|
|
||||||
:checked="field.state.value"
|
|
||||||
@update:checked="field.handleChange"
|
|
||||||
@blur="field.handleBlur"
|
|
||||||
/>
|
|
||||||
<InputLabel :for="field.name" class="font-medium text-text-primary">
|
|
||||||
I understand that this will permanently delete all data related to this member
|
|
||||||
</InputLabel>
|
|
||||||
</div>
|
|
||||||
<InputError class="pl-7 pt-2" :message="field.state.meta.errors[0]" />
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
</form.Field>
|
|
||||||
</div>
|
|
||||||
<div class="mt-6 flex justify-end space-x-3">
|
|
||||||
<SecondaryButton @click="close">Cancel</SecondaryButton>
|
|
||||||
<form.Subscribe>
|
|
||||||
<template #default="{ canSubmit, isSubmitting }">
|
|
||||||
<DangerButton
|
|
||||||
type="submit"
|
|
||||||
:disabled="!canSubmit"
|
|
||||||
>
|
|
||||||
{{ isSubmitting ? 'Deleting...' : 'Delete Member' }}
|
|
||||||
</DangerButton>
|
|
||||||
</template>
|
|
||||||
</form.Subscribe>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
</Modal>
|
|
||||||
</template>
|
|
||||||
@@ -49,6 +49,15 @@ const props = defineProps<{
|
|||||||
<PencilSquareIcon class="w-5 text-icon-active" />
|
<PencilSquareIcon class="w-5 text-icon-active" />
|
||||||
<span>Edit</span>
|
<span>Edit</span>
|
||||||
</DropdownMenuItem>
|
</DropdownMenuItem>
|
||||||
|
<DropdownMenuItem
|
||||||
|
v-if="canDeleteMembers()"
|
||||||
|
:aria-label="'Delete Member ' + props.member.name"
|
||||||
|
data-testid="member_delete"
|
||||||
|
class="flex items-center space-x-3 cursor-pointer text-destructive focus:text-destructive"
|
||||||
|
@click="emit('delete')">
|
||||||
|
<TrashIcon class="w-5" />
|
||||||
|
<span>Delete</span>
|
||||||
|
</DropdownMenuItem>
|
||||||
<DropdownMenuItem
|
<DropdownMenuItem
|
||||||
v-if="props.member.role === 'placeholder' && canMergeMembers()"
|
v-if="props.member.role === 'placeholder' && canMergeMembers()"
|
||||||
:aria-label="'Merge Member ' + props.member.name"
|
:aria-label="'Merge Member ' + props.member.name"
|
||||||
@@ -66,15 +75,6 @@ const props = defineProps<{
|
|||||||
<UserCircleIcon class="w-5 text-icon-active" />
|
<UserCircleIcon class="w-5 text-icon-active" />
|
||||||
<span>Deactivate</span>
|
<span>Deactivate</span>
|
||||||
</DropdownMenuItem>
|
</DropdownMenuItem>
|
||||||
<DropdownMenuItem
|
|
||||||
v-if="canDeleteMembers()"
|
|
||||||
:aria-label="'Delete Member ' + props.member.name"
|
|
||||||
data-testid="member_delete"
|
|
||||||
class="flex items-center space-x-3 cursor-pointer text-destructive focus:text-destructive"
|
|
||||||
@click="emit('delete')">
|
|
||||||
<TrashIcon class="w-5" />
|
|
||||||
<span>Delete</span>
|
|
||||||
</DropdownMenuItem>
|
|
||||||
</DropdownMenuContent>
|
</DropdownMenuContent>
|
||||||
</DropdownMenu>
|
</DropdownMenu>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -8,30 +8,26 @@ import SecondaryButton from '@/packages/ui/src/Buttons/SecondaryButton.vue';
|
|||||||
import { getCurrentOrganizationId } from '@/utils/useUser';
|
import { getCurrentOrganizationId } from '@/utils/useUser';
|
||||||
import { useNotificationsStore } from '@/utils/notification';
|
import { useNotificationsStore } from '@/utils/notification';
|
||||||
import { canInvitePlaceholderMembers } from '@/utils/permissions';
|
import { canInvitePlaceholderMembers } from '@/utils/permissions';
|
||||||
|
import { useMembersStore } from '@/utils/useMembers';
|
||||||
import { computed, type ComputedRef, inject, ref } from 'vue';
|
import { computed, type ComputedRef, inject, ref } from 'vue';
|
||||||
import MemberEditModal from '@/Components/Common/Member/MemberEditModal.vue';
|
import MemberEditModal from '@/Components/Common/Member/MemberEditModal.vue';
|
||||||
import MemberMergeModal from '@/Components/Common/Member/MemberMergeModal.vue';
|
import MemberMergeModal from '@/Components/Common/Member/MemberMergeModal.vue';
|
||||||
import MemberMakePlaceholderModal from '@/Components/Common/Member/MemberMakePlaceholderModal.vue';
|
import MemberMakePlaceholderModal from '@/Components/Common/Member/MemberMakePlaceholderModal.vue';
|
||||||
import MemberDeleteModal from '@/Components/Common/Member/MemberDeleteModal.vue';
|
|
||||||
import { capitalizeFirstLetter } from '../../../utils/format';
|
import { capitalizeFirstLetter } from '../../../utils/format';
|
||||||
import { formatCents } from '../../../packages/ui/src/utils/money';
|
import { formatCents } from '../../../packages/ui/src/utils/money';
|
||||||
import { useMembersStore } from '@/utils/useMembers';
|
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
member: Member;
|
member: Member;
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
const organization = inject<ComputedRef<Organization>>('organization');
|
const organization = inject<ComputedRef<Organization>>('organization');
|
||||||
const memberStore = useMembersStore();
|
|
||||||
|
|
||||||
const showEditMemberModal = ref(false);
|
const showEditMemberModal = ref(false);
|
||||||
const showMergeMemberModal = ref(false);
|
const showMergeMemberModal = ref(false);
|
||||||
const showMakeMemberPlaceholderModal = ref(false);
|
const showMakeMemberPlaceholderModal = ref(false);
|
||||||
const showDeleteMemberModal = ref(false);
|
|
||||||
|
|
||||||
function removeMember() {
|
function removeMember() {
|
||||||
showDeleteMemberModal.value = true;
|
useMembersStore().removeMember(props.member.id);
|
||||||
memberStore.fetchMembers();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function invitePlaceholder(id: string) {
|
async function invitePlaceholder(id: string) {
|
||||||
@@ -125,9 +121,6 @@ const userHasValidMailAddress = computed(() => {
|
|||||||
<MemberMakePlaceholderModal
|
<MemberMakePlaceholderModal
|
||||||
v-model:show="showMakeMemberPlaceholderModal"
|
v-model:show="showMakeMemberPlaceholderModal"
|
||||||
:member="member"></MemberMakePlaceholderModal>
|
:member="member"></MemberMakePlaceholderModal>
|
||||||
<MemberDeleteModal
|
|
||||||
v-model:show="showDeleteMemberModal"
|
|
||||||
:member="member"></MemberDeleteModal>
|
|
||||||
</TableRow>
|
</TableRow>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|||||||
@@ -30,21 +30,22 @@ const forwarded = useForwardPropsEmits(delegatedProps, emits)
|
|||||||
<div
|
<div
|
||||||
class="absolute inset-0 bg-default-background opacity-30" />
|
class="absolute inset-0 bg-default-background opacity-30" />
|
||||||
</DialogOverlay>
|
</DialogOverlay>
|
||||||
<div
|
<DialogContent
|
||||||
|
v-bind="forwarded"
|
||||||
:class="
|
:class="
|
||||||
cn(
|
cn(
|
||||||
'fixed top-0 left-0 z-50 pointer-events-none w-screen h-screen flex items-start pt-6 md:pt-20 xl:pt-32 justify-center overflow-auto',
|
'fixed top-0 left-0 z-50 w-screen h-screen flex items-start pt-6 md:pt-20 xl:pt-32 justify-center overflow-auto data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95',
|
||||||
|
|
||||||
)"
|
)"
|
||||||
>
|
>
|
||||||
<DialogContent
|
<div
|
||||||
v-bind="forwarded"
|
|
||||||
:class="cn(
|
:class="cn(
|
||||||
'bg-default-background grid w-full max-w-lg border border-border-tertiary shadow-lg duration-200 sm:rounded-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95',
|
'bg-default-background grid w-full max-w-lg border shadow-lg duration-200 sm:rounded-lg',
|
||||||
props.class,
|
props.class,
|
||||||
)"
|
)"
|
||||||
>
|
>
|
||||||
<slot />
|
<slot />
|
||||||
</DialogContent>
|
|
||||||
</div>
|
</div>
|
||||||
|
</DialogContent>
|
||||||
</DialogPortal>
|
</DialogPortal>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -2407,11 +2407,6 @@ const endpoints = makeApi([
|
|||||||
type: 'Path',
|
type: 'Path',
|
||||||
schema: z.string(),
|
schema: z.string(),
|
||||||
},
|
},
|
||||||
{
|
|
||||||
name: 'delete_related',
|
|
||||||
type: 'Query',
|
|
||||||
schema: z.enum(['true', 'false']).optional(),
|
|
||||||
},
|
|
||||||
],
|
],
|
||||||
response: z.void(),
|
response: z.void(),
|
||||||
errors: [
|
errors: [
|
||||||
@@ -2441,16 +2436,6 @@ const endpoints = makeApi([
|
|||||||
description: `Not found`,
|
description: `Not found`,
|
||||||
schema: z.object({ message: z.string() }).passthrough(),
|
schema: z.object({ message: z.string() }).passthrough(),
|
||||||
},
|
},
|
||||||
{
|
|
||||||
status: 422,
|
|
||||||
description: `Validation error`,
|
|
||||||
schema: z
|
|
||||||
.object({
|
|
||||||
message: z.string(),
|
|
||||||
errors: z.record(z.array(z.string())),
|
|
||||||
})
|
|
||||||
.passthrough(),
|
|
||||||
},
|
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -5,7 +5,10 @@ import {
|
|||||||
PopoverTrigger,
|
PopoverTrigger,
|
||||||
} from '@/Components/ui/popover';
|
} from '@/Components/ui/popover';
|
||||||
import { RangeCalendar } from '@/Components/ui/range-calendar';
|
import { RangeCalendar } from '@/Components/ui/range-calendar';
|
||||||
import { CalendarDate } from '@internationalized/date';
|
import {
|
||||||
|
CalendarDate,
|
||||||
|
getLocalTimeZone,
|
||||||
|
} from '@internationalized/date';
|
||||||
import { CalendarIcon } from 'lucide-vue-next';
|
import { CalendarIcon } from 'lucide-vue-next';
|
||||||
import { computed, ref, inject, type ComputedRef, watch } from 'vue';
|
import { computed, ref, inject, type ComputedRef, watch } from 'vue';
|
||||||
import { twMerge } from 'tailwind-merge';
|
import { twMerge } from 'tailwind-merge';
|
||||||
@@ -13,9 +16,8 @@ import {
|
|||||||
getDayJsInstance,
|
getDayJsInstance,
|
||||||
getLocalizedDayJs,
|
getLocalizedDayJs,
|
||||||
} from '@/packages/ui/src/utils/time';
|
} from '@/packages/ui/src/utils/time';
|
||||||
|
import { formatDateLocalized } from '@/packages/ui/src/utils/time';
|
||||||
import { type Organization } from '@/packages/api/src';
|
import { type Organization } from '@/packages/api/src';
|
||||||
import { getUserTimezone } from '@/packages/ui/src/utils/settings';
|
|
||||||
import { formatDate } from '@/packages/ui/src/utils/time';
|
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
start: string;
|
start: string;
|
||||||
@@ -57,13 +59,12 @@ const modelValue = computed<CalendarDateRange>({
|
|||||||
}),
|
}),
|
||||||
set: (newValue) => {
|
set: (newValue) => {
|
||||||
if (newValue.start) {
|
if (newValue.start) {
|
||||||
console.log(newValue.start);
|
const date = newValue.start.toDate(getLocalTimeZone());
|
||||||
const date = newValue.start.toDate(getUserTimezone());
|
emit('update:start', getDayJsInstance()(date).format('YYYY-MM-DD'));
|
||||||
emit('update:start', getLocalizedDayJs(date.toString()).format());
|
|
||||||
}
|
}
|
||||||
if (newValue.end) {
|
if (newValue.end) {
|
||||||
const date = newValue.end.toDate(getUserTimezone());
|
const date = newValue.end.toDate(getLocalTimeZone());
|
||||||
emit('update:end', getLocalizedDayJs(date.toString()).format());
|
emit('update:end', getDayJsInstance()(date).format('YYYY-MM-DD'));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
@@ -73,18 +74,18 @@ const open = ref(false);
|
|||||||
function setToday() {
|
function setToday() {
|
||||||
emit(
|
emit(
|
||||||
'update:start',
|
'update:start',
|
||||||
getLocalizedDayJs().startOf('day').format()
|
getLocalizedDayJs().startOf('day').format('YYYY-MM-DD')
|
||||||
);
|
);
|
||||||
emit('update:end', getLocalizedDayJs().endOf('day').format());
|
emit('update:end', getLocalizedDayJs().endOf('day').format('YYYY-MM-DD'));
|
||||||
open.value = false;
|
open.value = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function setThisWeek() {
|
function setThisWeek() {
|
||||||
emit(
|
emit(
|
||||||
'update:start',
|
'update:start',
|
||||||
getLocalizedDayJs().startOf('week').format()
|
getLocalizedDayJs().startOf('week').format('YYYY-MM-DD')
|
||||||
);
|
);
|
||||||
emit('update:end', getLocalizedDayJs().endOf('week').format());
|
emit('update:end', getLocalizedDayJs().endOf('week').format('YYYY-MM-DD'));
|
||||||
open.value = false;
|
open.value = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -94,14 +95,14 @@ function setLastWeek() {
|
|||||||
getLocalizedDayJs()
|
getLocalizedDayJs()
|
||||||
.subtract(1, 'week')
|
.subtract(1, 'week')
|
||||||
.startOf('week')
|
.startOf('week')
|
||||||
.format()
|
.format('YYYY-MM-DD')
|
||||||
);
|
);
|
||||||
emit(
|
emit(
|
||||||
'update:end',
|
'update:end',
|
||||||
getLocalizedDayJs()
|
getLocalizedDayJs()
|
||||||
.subtract(1, 'week')
|
.subtract(1, 'week')
|
||||||
.endOf('week')
|
.endOf('week')
|
||||||
.format()
|
.format('YYYY-MM-DD')
|
||||||
);
|
);
|
||||||
open.value = false;
|
open.value = false;
|
||||||
}
|
}
|
||||||
@@ -109,18 +110,18 @@ function setLastWeek() {
|
|||||||
function setLast14Days() {
|
function setLast14Days() {
|
||||||
emit(
|
emit(
|
||||||
'update:start',
|
'update:start',
|
||||||
getLocalizedDayJs().subtract(14, 'days').format()
|
getLocalizedDayJs().subtract(14, 'days').format('YYYY-MM-DD')
|
||||||
);
|
);
|
||||||
emit('update:end', getLocalizedDayJs().format());
|
emit('update:end', getLocalizedDayJs().format('YYYY-MM-DD'));
|
||||||
open.value = false;
|
open.value = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function setThisMonth() {
|
function setThisMonth() {
|
||||||
emit(
|
emit(
|
||||||
'update:start',
|
'update:start',
|
||||||
getLocalizedDayJs().startOf('month').format()
|
getLocalizedDayJs().startOf('month').format('YYYY-MM-DD')
|
||||||
);
|
);
|
||||||
emit('update:end', getLocalizedDayJs().endOf('month').format());
|
emit('update:end', getLocalizedDayJs().endOf('month').format('YYYY-MM-DD'));
|
||||||
open.value = false;
|
open.value = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -130,14 +131,14 @@ function setLastMonth() {
|
|||||||
getLocalizedDayJs()
|
getLocalizedDayJs()
|
||||||
.subtract(1, 'month')
|
.subtract(1, 'month')
|
||||||
.startOf('month')
|
.startOf('month')
|
||||||
.format()
|
.format('YYYY-MM-DD')
|
||||||
);
|
);
|
||||||
emit(
|
emit(
|
||||||
'update:end',
|
'update:end',
|
||||||
getLocalizedDayJs()
|
getLocalizedDayJs()
|
||||||
.subtract(1, 'month')
|
.subtract(1, 'month')
|
||||||
.endOf('month')
|
.endOf('month')
|
||||||
.format()
|
.format('YYYY-MM-DD')
|
||||||
);
|
);
|
||||||
open.value = false;
|
open.value = false;
|
||||||
}
|
}
|
||||||
@@ -145,36 +146,36 @@ function setLastMonth() {
|
|||||||
function setLast30Days() {
|
function setLast30Days() {
|
||||||
emit(
|
emit(
|
||||||
'update:start',
|
'update:start',
|
||||||
getLocalizedDayJs().subtract(30, 'days').format()
|
getLocalizedDayJs().subtract(30, 'days').format('YYYY-MM-DD')
|
||||||
);
|
);
|
||||||
emit('update:end', getLocalizedDayJs().format());
|
emit('update:end', getLocalizedDayJs().format('YYYY-MM-DD'));
|
||||||
open.value = false;
|
open.value = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function setLast90Days() {
|
function setLast90Days() {
|
||||||
emit(
|
emit(
|
||||||
'update:start',
|
'update:start',
|
||||||
getDayJsInstance()().subtract(90, 'days').format()
|
getDayJsInstance()().subtract(90, 'days').format('YYYY-MM-DD')
|
||||||
);
|
);
|
||||||
emit('update:end', getDayJsInstance()().format());
|
emit('update:end', getDayJsInstance()().format('YYYY-MM-DD'));
|
||||||
open.value = false;
|
open.value = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function setLast12Months() {
|
function setLast12Months() {
|
||||||
emit(
|
emit(
|
||||||
'update:start',
|
'update:start',
|
||||||
getLocalizedDayJs().subtract(12, 'months').format()
|
getLocalizedDayJs().subtract(12, 'months').format('YYYY-MM-DD')
|
||||||
);
|
);
|
||||||
emit('update:end', getLocalizedDayJs().format());
|
emit('update:end', getLocalizedDayJs().format('YYYY-MM-DD'));
|
||||||
open.value = false;
|
open.value = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function setThisYear() {
|
function setThisYear() {
|
||||||
emit(
|
emit(
|
||||||
'update:start',
|
'update:start',
|
||||||
getLocalizedDayJs().startOf('year').format()
|
getLocalizedDayJs().startOf('year').format('YYYY-MM-DD')
|
||||||
);
|
);
|
||||||
emit('update:end', getLocalizedDayJs().endOf('year').format());
|
emit('update:end', getLocalizedDayJs().endOf('year').format('YYYY-MM-DD'));
|
||||||
open.value = false;
|
open.value = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -184,14 +185,14 @@ function setLastYear() {
|
|||||||
getLocalizedDayJs()
|
getLocalizedDayJs()
|
||||||
.subtract(1, 'year')
|
.subtract(1, 'year')
|
||||||
.startOf('year')
|
.startOf('year')
|
||||||
.format()
|
.format('YYYY-MM-DD')
|
||||||
);
|
);
|
||||||
emit(
|
emit(
|
||||||
'update:end',
|
'update:end',
|
||||||
getLocalizedDayJs()
|
getLocalizedDayJs()
|
||||||
.subtract(1, 'year')
|
.subtract(1, 'year')
|
||||||
.endOf('year')
|
.endOf('year')
|
||||||
.format()
|
.format('YYYY-MM-DD')
|
||||||
);
|
);
|
||||||
open.value = false;
|
open.value = false;
|
||||||
}
|
}
|
||||||
@@ -218,27 +219,12 @@ watch(open, (value) => {
|
|||||||
<CalendarIcon class="mr-2 h-4 w-4" />
|
<CalendarIcon class="mr-2 h-4 w-4" />
|
||||||
<template v-if="modelValue.start">
|
<template v-if="modelValue.start">
|
||||||
<template v-if="modelValue.end">
|
<template v-if="modelValue.end">
|
||||||
{{
|
{{ formatDateLocalized(modelValue.start.toString(), organization?.date_format) }}
|
||||||
formatDate(
|
|
||||||
modelValue.start.toString(),
|
|
||||||
organization?.date_format
|
|
||||||
)
|
|
||||||
}}
|
|
||||||
-
|
-
|
||||||
{{
|
{{ formatDateLocalized(modelValue.end.toString(), organization?.date_format) }}
|
||||||
formatDate(
|
|
||||||
modelValue.end.toString(),
|
|
||||||
organization?.date_format
|
|
||||||
)
|
|
||||||
}}
|
|
||||||
</template>
|
</template>
|
||||||
<template v-else>
|
<template v-else>
|
||||||
{{
|
{{ formatDateLocalized(modelValue.start.toString(), organization?.date_format) }}
|
||||||
formatDate(
|
|
||||||
modelValue.start.toString(),
|
|
||||||
organization?.date_format
|
|
||||||
)
|
|
||||||
}}
|
|
||||||
</template>
|
</template>
|
||||||
</template>
|
</template>
|
||||||
<template v-else> Pick a date </template>
|
<template v-else> Pick a date </template>
|
||||||
|
|||||||
@@ -12,12 +12,12 @@ use Illuminate\Support\Facades\Artisan;
|
|||||||
use Illuminate\Support\Facades\Http;
|
use Illuminate\Support\Facades\Http;
|
||||||
use PHPUnit\Framework\Attributes\CoversClass;
|
use PHPUnit\Framework\Attributes\CoversClass;
|
||||||
use PHPUnit\Framework\Attributes\UsesClass;
|
use PHPUnit\Framework\Attributes\UsesClass;
|
||||||
use Tests\TestCase;
|
use Tests\TestCaseWithDatabase;
|
||||||
|
|
||||||
#[CoversClass(SelfHostTelemetryCommand::class)]
|
#[CoversClass(SelfHostTelemetryCommand::class)]
|
||||||
#[CoversClass(ApiService::class)]
|
#[CoversClass(ApiService::class)]
|
||||||
#[UsesClass(SelfHostTelemetryCommand::class)]
|
#[UsesClass(SelfHostTelemetryCommand::class)]
|
||||||
class SelfHostTelemetryCommandTest extends TestCase
|
class SelfHostTelemetryCommandTest extends TestCaseWithDatabase
|
||||||
{
|
{
|
||||||
public function test_telemetry_sends_data_to_telemetry_endpoint_of_solidtime_cloud(): void
|
public function test_telemetry_sends_data_to_telemetry_endpoint_of_solidtime_cloud(): void
|
||||||
{
|
{
|
||||||
@@ -30,9 +30,12 @@ class SelfHostTelemetryCommandTest extends TestCase
|
|||||||
$exitCode = $this->withoutMockingConsoleOutput()->artisan('self-host:telemetry');
|
$exitCode = $this->withoutMockingConsoleOutput()->artisan('self-host:telemetry');
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
$this->assertSame(Command::SUCCESS, $exitCode);
|
|
||||||
$output = Artisan::output();
|
$output = Artisan::output();
|
||||||
$this->assertSame('', $output);
|
$this->assertSame('', $output);
|
||||||
|
if ($exitCode !== Command::SUCCESS) {
|
||||||
|
dump($output);
|
||||||
|
}
|
||||||
|
$this->assertSame(Command::SUCCESS, $exitCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_telemetry_sends_fails_gracefully_if_response_has_error_status_code(): void
|
public function test_telemetry_sends_fails_gracefully_if_response_has_error_status_code(): void
|
||||||
|
|||||||
@@ -653,85 +653,6 @@ class MemberEndpointTest extends ApiEndpointTestAbstract
|
|||||||
Event::assertNotDispatched(MemberRemoved::class);
|
Event::assertNotDispatched(MemberRemoved::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_destroy_endpoint_succeeds_if_member_is_still_in_use_by_a_project_member_and_delete_related_is_active(): void
|
|
||||||
{
|
|
||||||
// Arrange
|
|
||||||
$data = $this->createUserWithPermission([
|
|
||||||
'members:delete',
|
|
||||||
]);
|
|
||||||
$otherMember = Member::factory()->forOrganization($data->organization)->role(Role::Employee)->create();
|
|
||||||
$project = Project::factory()->forOrganization($data->organization)->create();
|
|
||||||
$projectMember = ProjectMember::factory()->forProject($project)->forMember($data->member)->create();
|
|
||||||
$otherProjectMember = ProjectMember::factory()->forProject($project)->forMember($otherMember)->create();
|
|
||||||
Passport::actingAs($data->user);
|
|
||||||
Event::fake([
|
|
||||||
MemberRemoved::class,
|
|
||||||
]);
|
|
||||||
|
|
||||||
// Act
|
|
||||||
$response = $this->deleteJson(route('api.v1.members.destroy', [
|
|
||||||
'organization' => $data->organization->getKey(),
|
|
||||||
'member' => $data->member->getKey(),
|
|
||||||
'delete_related' => 'true',
|
|
||||||
]));
|
|
||||||
|
|
||||||
// Assert
|
|
||||||
$response->assertStatus(204);
|
|
||||||
$this->assertDatabaseMissing(Member::class, [
|
|
||||||
'id' => $data->member->getKey(),
|
|
||||||
]);
|
|
||||||
$this->assertDatabaseHas(ProjectMember::class, [
|
|
||||||
'id' => $otherProjectMember->getKey(),
|
|
||||||
'member_id' => $otherMember->getKey(),
|
|
||||||
'user_id' => $otherMember->user_id,
|
|
||||||
]);
|
|
||||||
$this->assertDatabaseMissing(ProjectMember::class, [
|
|
||||||
'id' => $projectMember->getKey(),
|
|
||||||
]);
|
|
||||||
Event::assertDispatched(function (MemberRemoved $event) use ($data): bool {
|
|
||||||
return $event->organization->is($data->organization) &&
|
|
||||||
$event->member->is($data->member);
|
|
||||||
}, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function test_destroy_endpoint_succeeds_if_member_is_still_in_use_by_a_time_entry_and_delete_related_is_active(): void
|
|
||||||
{
|
|
||||||
// Arrange
|
|
||||||
$data = $this->createUserWithPermission([
|
|
||||||
'members:delete',
|
|
||||||
]);
|
|
||||||
$otherMember = Member::factory()->forOrganization($data->organization)->role(Role::Employee)->create();
|
|
||||||
$timeEntry = TimeEntry::factory()->forMember($data->member)->forOrganization($data->organization)->create();
|
|
||||||
$otherTimeEntry = TimeEntry::factory()->forMember($otherMember)->forOrganization($data->organization)->create();
|
|
||||||
Passport::actingAs($data->user);
|
|
||||||
Event::fake([
|
|
||||||
MemberRemoved::class,
|
|
||||||
]);
|
|
||||||
|
|
||||||
// Act
|
|
||||||
$response = $this->deleteJson(route('api.v1.members.destroy', [
|
|
||||||
'organization' => $data->organization->getKey(),
|
|
||||||
'member' => $data->member->getKey(),
|
|
||||||
'delete_related' => 'true',
|
|
||||||
]));
|
|
||||||
|
|
||||||
// Assert
|
|
||||||
$response->assertStatus(204);
|
|
||||||
$this->assertDatabaseMissing(Member::class, [
|
|
||||||
'id' => $data->member->getKey(),
|
|
||||||
]);
|
|
||||||
$this->assertDatabaseHas(TimeEntry::class, [
|
|
||||||
'id' => $otherTimeEntry->getKey(),
|
|
||||||
]);
|
|
||||||
$this->assertDatabaseMissing(TimeEntry::class, [
|
|
||||||
'id' => $timeEntry->getKey(),
|
|
||||||
]);
|
|
||||||
Event::assertDispatched(function (MemberRemoved $event) use ($data): bool {
|
|
||||||
return $event->organization->is($data->organization) &&
|
|
||||||
$event->member->is($data->member);
|
|
||||||
}, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function test_destroy_member_succeeds_if_data_is_valid(): void
|
public function test_destroy_member_succeeds_if_data_is_valid(): void
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
|
|||||||
Reference in New Issue
Block a user