mirror of
https://github.com/solidtime-io/solidtime.git
synced 2026-08-16 20:22:15 +01:00
Compare commits
59 Commits
4ff8a72f0b
...
feature/ex
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
dbc927b6a9 | ||
|
|
c94aa8038d | ||
|
|
c9e84260b1 | ||
|
|
9a53f903d8 | ||
|
|
d50ce52b5b | ||
|
|
aea310e639 | ||
|
|
a94627321b | ||
|
|
806d138fc9 | ||
|
|
240dd809f4 | ||
|
|
dedb50ea73 | ||
|
|
6fe856fd31 | ||
|
|
20735c2fed | ||
|
|
b14e40c64b | ||
|
|
f2277ff708 | ||
|
|
6a197f7f34 | ||
|
|
24c94af952 | ||
|
|
111ce94150 | ||
|
|
49e69b85a6 | ||
|
|
90a5c2b87c | ||
|
|
6b01034bdd | ||
|
|
a4c400ef4e | ||
|
|
5d01b20dbf | ||
|
|
24875f9424 | ||
|
|
4975cf1dab | ||
|
|
b3fb04c4be | ||
|
|
0cc8d762a5 | ||
|
|
e3e45161a1 | ||
|
|
0c825a691e | ||
|
|
24775d2c47 | ||
|
|
c5c129b239 | ||
|
|
89a9341d91 | ||
|
|
bffd0773be | ||
|
|
56ea0ed90e | ||
|
|
24c19e7e7c | ||
|
|
734aab6353 | ||
|
|
5eb1a6a006 | ||
|
|
d0334bd730 | ||
|
|
fe4e903203 | ||
|
|
43e42ace54 | ||
|
|
84728f0914 | ||
|
|
8f02f98afc | ||
|
|
c1ecd0eff5 | ||
|
|
486b5d2152 | ||
|
|
5476b4e5a9 | ||
|
|
ceec4cbf62 | ||
|
|
372c7b02a0 | ||
|
|
cb8047028c | ||
|
|
e29be581fa | ||
|
|
02da133fb3 | ||
|
|
d00fe2baff | ||
|
|
a73fe59892 | ||
|
|
5d744d70c4 | ||
|
|
12d58ee42c | ||
|
|
f9be92894e | ||
|
|
a30d192ea2 | ||
|
|
d732064f31 | ||
|
|
cb5c2547f4 | ||
|
|
13a25524f3 | ||
|
|
112f6aa6a6 |
28
.github/workflows/build-onpremise.yml
vendored
28
.github/workflows/build-onpremise.yml
vendored
@@ -35,7 +35,7 @@ jobs:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: "Check out code"
|
- name: "Check out code"
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v6
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0 # Required for WyriHaximus/github-action-get-previous-tag
|
fetch-depth: 0 # Required for WyriHaximus/github-action-get-previous-tag
|
||||||
|
|
||||||
@@ -46,9 +46,9 @@ jobs:
|
|||||||
- name: "Get Previous tag (normal push)"
|
- name: "Get Previous tag (normal push)"
|
||||||
id: previoustag
|
id: previoustag
|
||||||
if: ${{ !startsWith(github.ref, 'refs/tags/v') }}
|
if: ${{ !startsWith(github.ref, 'refs/tags/v') }}
|
||||||
uses: "WyriHaximus/github-action-get-previous-tag@v1"
|
uses: "WyriHaximus/github-action-get-previous-tag@v2"
|
||||||
with:
|
with:
|
||||||
prefix: "v"
|
pattern: "v*[0-9].*[0-9].*[0-9]"
|
||||||
|
|
||||||
- name: "Get version"
|
- name: "Get version"
|
||||||
id: release-version
|
id: release-version
|
||||||
@@ -96,7 +96,7 @@ jobs:
|
|||||||
node-version: '20.x'
|
node-version: '20.x'
|
||||||
|
|
||||||
- name: "Checkout invoicing extension"
|
- name: "Checkout invoicing extension"
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v6
|
||||||
with:
|
with:
|
||||||
repository: solidtime-io/extension-invoicing
|
repository: solidtime-io/extension-invoicing
|
||||||
path: extensions/Invoicing
|
path: extensions/Invoicing
|
||||||
@@ -124,27 +124,27 @@ jobs:
|
|||||||
|
|
||||||
- name: "Docker meta"
|
- name: "Docker meta"
|
||||||
id: "meta"
|
id: "meta"
|
||||||
uses: docker/metadata-action@v5
|
uses: docker/metadata-action@v6
|
||||||
with:
|
with:
|
||||||
images: |
|
images: |
|
||||||
${{ env.DOCKER_REPO }}
|
${{ env.DOCKER_REPO }}
|
||||||
|
|
||||||
- name: "Login to solidtime OnPremise Registry"
|
- name: "Login to solidtime OnPremise Registry"
|
||||||
uses: docker/login-action@v3
|
uses: docker/login-action@v4
|
||||||
with:
|
with:
|
||||||
registry: registry.on-premise.solidtime.io
|
registry: registry.on-premise.solidtime.io
|
||||||
username: ${{ secrets.ONPREMISE_USERNAME }}
|
username: ${{ secrets.ONPREMISE_USERNAME }}
|
||||||
password: ${{ secrets.ONPREMISE_TOKEN }}
|
password: ${{ secrets.ONPREMISE_TOKEN }}
|
||||||
|
|
||||||
- name: "Set up QEMU"
|
- name: "Set up QEMU"
|
||||||
uses: docker/setup-qemu-action@v3
|
uses: docker/setup-qemu-action@v4
|
||||||
|
|
||||||
- name: "Set up Docker Buildx"
|
- name: "Set up Docker Buildx"
|
||||||
uses: docker/setup-buildx-action@v3
|
uses: docker/setup-buildx-action@v4
|
||||||
|
|
||||||
- name: "Build and push by digest"
|
- name: "Build and push by digest"
|
||||||
id: build
|
id: build
|
||||||
uses: docker/build-push-action@v6
|
uses: docker/build-push-action@v7
|
||||||
with:
|
with:
|
||||||
context: .
|
context: .
|
||||||
file: docker/prod/Dockerfile
|
file: docker/prod/Dockerfile
|
||||||
@@ -163,7 +163,7 @@ jobs:
|
|||||||
touch "${{ runner.temp }}/digests/${digest#sha256:}"
|
touch "${{ runner.temp }}/digests/${digest#sha256:}"
|
||||||
|
|
||||||
- name: "Upload digest"
|
- name: "Upload digest"
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v7
|
||||||
with:
|
with:
|
||||||
name: digests-${{ env.PLATFORM_PAIR }}
|
name: digests-${{ env.PLATFORM_PAIR }}
|
||||||
path: ${{ runner.temp }}/digests/*
|
path: ${{ runner.temp }}/digests/*
|
||||||
@@ -177,25 +177,25 @@ jobs:
|
|||||||
- build
|
- build
|
||||||
steps:
|
steps:
|
||||||
- name: "Download digests"
|
- name: "Download digests"
|
||||||
uses: actions/download-artifact@v6
|
uses: actions/download-artifact@v8
|
||||||
with:
|
with:
|
||||||
path: ${{ runner.temp }}/digests
|
path: ${{ runner.temp }}/digests
|
||||||
pattern: digests-*
|
pattern: digests-*
|
||||||
merge-multiple: true
|
merge-multiple: true
|
||||||
|
|
||||||
- name: "Login to solidtime OnPremise Registry"
|
- name: "Login to solidtime OnPremise Registry"
|
||||||
uses: docker/login-action@v3
|
uses: docker/login-action@v4
|
||||||
with:
|
with:
|
||||||
registry: registry.on-premise.solidtime.io
|
registry: registry.on-premise.solidtime.io
|
||||||
username: ${{ secrets.ONPREMISE_USERNAME }}
|
username: ${{ secrets.ONPREMISE_USERNAME }}
|
||||||
password: ${{ secrets.ONPREMISE_TOKEN }}
|
password: ${{ secrets.ONPREMISE_TOKEN }}
|
||||||
|
|
||||||
- name: "Set up Docker Buildx"
|
- name: "Set up Docker Buildx"
|
||||||
uses: docker/setup-buildx-action@v3
|
uses: docker/setup-buildx-action@v4
|
||||||
|
|
||||||
- name: "Docker meta"
|
- name: "Docker meta"
|
||||||
id: meta
|
id: meta
|
||||||
uses: docker/metadata-action@v5
|
uses: docker/metadata-action@v6
|
||||||
with:
|
with:
|
||||||
images: |
|
images: |
|
||||||
${{ env.DOCKER_REPO }}
|
${{ env.DOCKER_REPO }}
|
||||||
|
|||||||
22
.github/workflows/build-private.yml
vendored
22
.github/workflows/build-private.yml
vendored
@@ -22,7 +22,7 @@ jobs:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: "Check out code"
|
- name: "Check out code"
|
||||||
uses: actions/checkout@v5
|
uses: actions/checkout@v6
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0 # Required for WyriHaximus/github-action-get-previous-tag
|
fetch-depth: 0 # Required for WyriHaximus/github-action-get-previous-tag
|
||||||
|
|
||||||
@@ -33,9 +33,9 @@ jobs:
|
|||||||
- name: "Get Previous tag (normal push)"
|
- name: "Get Previous tag (normal push)"
|
||||||
id: previoustag
|
id: previoustag
|
||||||
if: ${{ !startsWith(github.ref, 'refs/tags/v') }}
|
if: ${{ !startsWith(github.ref, 'refs/tags/v') }}
|
||||||
uses: "WyriHaximus/github-action-get-previous-tag@v1"
|
uses: "WyriHaximus/github-action-get-previous-tag@v2"
|
||||||
with:
|
with:
|
||||||
prefix: "v"
|
pattern: "v*[0-9].*[0-9].*[0-9]"
|
||||||
|
|
||||||
- name: "Get version"
|
- name: "Get version"
|
||||||
id: version
|
id: version
|
||||||
@@ -73,7 +73,7 @@ jobs:
|
|||||||
node-version: '20.x'
|
node-version: '20.x'
|
||||||
|
|
||||||
- name: "Checkout billing extension"
|
- name: "Checkout billing extension"
|
||||||
uses: actions/checkout@v5
|
uses: actions/checkout@v6
|
||||||
with:
|
with:
|
||||||
repository: solidtime-io/extension-billing
|
repository: solidtime-io/extension-billing
|
||||||
path: extensions/Billing
|
path: extensions/Billing
|
||||||
@@ -93,7 +93,7 @@ jobs:
|
|||||||
run: cd extensions/Billing && npm ci
|
run: cd extensions/Billing && npm ci
|
||||||
|
|
||||||
- name: "Checkout services extension"
|
- name: "Checkout services extension"
|
||||||
uses: actions/checkout@v5
|
uses: actions/checkout@v6
|
||||||
with:
|
with:
|
||||||
repository: solidtime-io/extension-services
|
repository: solidtime-io/extension-services
|
||||||
path: extensions/Services
|
path: extensions/Services
|
||||||
@@ -111,7 +111,7 @@ jobs:
|
|||||||
run: cd extensions/Services && npm ci
|
run: cd extensions/Services && npm ci
|
||||||
|
|
||||||
- name: "Checkout invoicing extension"
|
- name: "Checkout invoicing extension"
|
||||||
uses: actions/checkout@v5
|
uses: actions/checkout@v6
|
||||||
with:
|
with:
|
||||||
repository: solidtime-io/extension-invoicing
|
repository: solidtime-io/extension-invoicing
|
||||||
path: extensions/Invoicing
|
path: extensions/Invoicing
|
||||||
@@ -160,7 +160,7 @@ jobs:
|
|||||||
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
|
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
|
||||||
|
|
||||||
- name: "Login to GitHub Container Registry"
|
- name: "Login to GitHub Container Registry"
|
||||||
uses: docker/login-action@v3
|
uses: docker/login-action@v4
|
||||||
with:
|
with:
|
||||||
registry: rg.fr-par.scw.cloud/solidtime
|
registry: rg.fr-par.scw.cloud/solidtime
|
||||||
username: nologin
|
username: nologin
|
||||||
@@ -168,7 +168,7 @@ jobs:
|
|||||||
|
|
||||||
- name: "Docker meta"
|
- name: "Docker meta"
|
||||||
id: "meta"
|
id: "meta"
|
||||||
uses: docker/metadata-action@v5
|
uses: docker/metadata-action@v6
|
||||||
with:
|
with:
|
||||||
images: rg.fr-par.scw.cloud/solidtime/solidtime
|
images: rg.fr-par.scw.cloud/solidtime/solidtime
|
||||||
tags: |
|
tags: |
|
||||||
@@ -179,13 +179,13 @@ jobs:
|
|||||||
type=sha,format=long
|
type=sha,format=long
|
||||||
|
|
||||||
- name: "Set up QEMU"
|
- name: "Set up QEMU"
|
||||||
uses: docker/setup-qemu-action@v3
|
uses: docker/setup-qemu-action@v4
|
||||||
|
|
||||||
- name: "Set up Docker Buildx"
|
- name: "Set up Docker Buildx"
|
||||||
uses: docker/setup-buildx-action@v3
|
uses: docker/setup-buildx-action@v4
|
||||||
|
|
||||||
- name: "Build and push"
|
- name: "Build and push"
|
||||||
uses: docker/build-push-action@v6
|
uses: docker/build-push-action@v7
|
||||||
with:
|
with:
|
||||||
context: .
|
context: .
|
||||||
build-args: |
|
build-args: |
|
||||||
|
|||||||
30
.github/workflows/build-public.yml
vendored
30
.github/workflows/build-public.yml
vendored
@@ -36,7 +36,7 @@ jobs:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: "Check out code"
|
- name: "Check out code"
|
||||||
uses: actions/checkout@v5
|
uses: actions/checkout@v6
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0 # Required for WyriHaximus/github-action-get-previous-tag
|
fetch-depth: 0 # Required for WyriHaximus/github-action-get-previous-tag
|
||||||
|
|
||||||
@@ -47,9 +47,9 @@ jobs:
|
|||||||
- name: "Get Previous tag (normal push)"
|
- name: "Get Previous tag (normal push)"
|
||||||
id: previoustag
|
id: previoustag
|
||||||
if: ${{ !startsWith(github.ref, 'refs/tags/v') }}
|
if: ${{ !startsWith(github.ref, 'refs/tags/v') }}
|
||||||
uses: "WyriHaximus/github-action-get-previous-tag@v1"
|
uses: "WyriHaximus/github-action-get-previous-tag@v2"
|
||||||
with:
|
with:
|
||||||
prefix: "v"
|
pattern: "v*[0-9].*[0-9].*[0-9]"
|
||||||
|
|
||||||
- name: "Get version"
|
- name: "Get version"
|
||||||
id: release-version
|
id: release-version
|
||||||
@@ -109,34 +109,34 @@ jobs:
|
|||||||
|
|
||||||
- name: "Docker meta"
|
- name: "Docker meta"
|
||||||
id: "meta"
|
id: "meta"
|
||||||
uses: docker/metadata-action@v5
|
uses: docker/metadata-action@v6
|
||||||
with:
|
with:
|
||||||
images: |
|
images: |
|
||||||
${{ env.DOCKERHUB_REPO }}
|
${{ env.DOCKERHUB_REPO }}
|
||||||
${{ env.GHCR_REPO }}
|
${{ env.GHCR_REPO }}
|
||||||
|
|
||||||
- name: "Login to Docker Hub Container Registry"
|
- name: "Login to Docker Hub Container Registry"
|
||||||
uses: docker/login-action@v3
|
uses: docker/login-action@v4
|
||||||
with:
|
with:
|
||||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||||
|
|
||||||
- name: "Login to GitHub Container Registry"
|
- name: "Login to GitHub Container Registry"
|
||||||
uses: docker/login-action@v3
|
uses: docker/login-action@v4
|
||||||
with:
|
with:
|
||||||
registry: ghcr.io
|
registry: ghcr.io
|
||||||
username: ${{ github.actor }}
|
username: ${{ github.actor }}
|
||||||
password: ${{ secrets.GITHUB_TOKEN }}
|
password: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
- name: "Set up QEMU"
|
- name: "Set up QEMU"
|
||||||
uses: docker/setup-qemu-action@v3
|
uses: docker/setup-qemu-action@v4
|
||||||
|
|
||||||
- name: "Set up Docker Buildx"
|
- name: "Set up Docker Buildx"
|
||||||
uses: docker/setup-buildx-action@v3
|
uses: docker/setup-buildx-action@v4
|
||||||
|
|
||||||
- name: "Build and push by digest"
|
- name: "Build and push by digest"
|
||||||
id: build
|
id: build
|
||||||
uses: docker/build-push-action@v6
|
uses: docker/build-push-action@v7
|
||||||
with:
|
with:
|
||||||
context: .
|
context: .
|
||||||
file: docker/prod/Dockerfile
|
file: docker/prod/Dockerfile
|
||||||
@@ -155,7 +155,7 @@ jobs:
|
|||||||
touch "${{ runner.temp }}/digests/${digest#sha256:}"
|
touch "${{ runner.temp }}/digests/${digest#sha256:}"
|
||||||
|
|
||||||
- name: "Upload digest"
|
- name: "Upload digest"
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v7
|
||||||
with:
|
with:
|
||||||
name: digests-${{ env.PLATFORM_PAIR }}
|
name: digests-${{ env.PLATFORM_PAIR }}
|
||||||
path: ${{ runner.temp }}/digests/*
|
path: ${{ runner.temp }}/digests/*
|
||||||
@@ -169,31 +169,31 @@ jobs:
|
|||||||
- build
|
- build
|
||||||
steps:
|
steps:
|
||||||
- name: "Download digests"
|
- name: "Download digests"
|
||||||
uses: actions/download-artifact@v6
|
uses: actions/download-artifact@v8
|
||||||
with:
|
with:
|
||||||
path: ${{ runner.temp }}/digests
|
path: ${{ runner.temp }}/digests
|
||||||
pattern: digests-*
|
pattern: digests-*
|
||||||
merge-multiple: true
|
merge-multiple: true
|
||||||
|
|
||||||
- name: "Login to Docker Hub"
|
- name: "Login to Docker Hub"
|
||||||
uses: docker/login-action@v3
|
uses: docker/login-action@v4
|
||||||
with:
|
with:
|
||||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||||
|
|
||||||
- name: "Login to GHCR"
|
- name: "Login to GHCR"
|
||||||
uses: docker/login-action@v3
|
uses: docker/login-action@v4
|
||||||
with:
|
with:
|
||||||
registry: ghcr.io
|
registry: ghcr.io
|
||||||
username: ${{ github.actor }}
|
username: ${{ github.actor }}
|
||||||
password: ${{ secrets.GITHUB_TOKEN }}
|
password: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
- name: "Set up Docker Buildx"
|
- name: "Set up Docker Buildx"
|
||||||
uses: docker/setup-buildx-action@v3
|
uses: docker/setup-buildx-action@v4
|
||||||
|
|
||||||
- name: "Docker meta"
|
- name: "Docker meta"
|
||||||
id: meta
|
id: meta
|
||||||
uses: docker/metadata-action@v5
|
uses: docker/metadata-action@v6
|
||||||
with:
|
with:
|
||||||
images: |
|
images: |
|
||||||
${{ env.DOCKERHUB_REPO }}
|
${{ env.DOCKERHUB_REPO }}
|
||||||
|
|||||||
4
.github/workflows/generate-api-docs.yml
vendored
4
.github/workflows/generate-api-docs.yml
vendored
@@ -29,7 +29,7 @@ jobs:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: "Checkout code"
|
- name: "Checkout code"
|
||||||
uses: actions/checkout@v5
|
uses: actions/checkout@v6
|
||||||
|
|
||||||
- name: "Setup PHP"
|
- name: "Setup PHP"
|
||||||
uses: shivammathur/setup-php@v2
|
uses: shivammathur/setup-php@v2
|
||||||
@@ -52,7 +52,7 @@ jobs:
|
|||||||
run: php artisan scramble:export --path=build/api-docs.json
|
run: php artisan scramble:export --path=build/api-docs.json
|
||||||
|
|
||||||
- name: "Upload API docs to GitHub"
|
- name: "Upload API docs to GitHub"
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v7
|
||||||
with:
|
with:
|
||||||
name: api-docs.json
|
name: api-docs.json
|
||||||
path: build/api-docs.json
|
path: build/api-docs.json
|
||||||
|
|||||||
2
.github/workflows/npm-build.yml
vendored
2
.github/workflows/npm-build.yml
vendored
@@ -11,7 +11,7 @@ jobs:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: "Checkout code"
|
- name: "Checkout code"
|
||||||
uses: actions/checkout@v5
|
uses: actions/checkout@v6
|
||||||
|
|
||||||
- name: "Setup PHP (for Ziggy)"
|
- name: "Setup PHP (for Ziggy)"
|
||||||
uses: shivammathur/setup-php@v2
|
uses: shivammathur/setup-php@v2
|
||||||
|
|||||||
2
.github/workflows/npm-format-check.yml
vendored
2
.github/workflows/npm-format-check.yml
vendored
@@ -9,7 +9,7 @@ jobs:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: "Checkout code"
|
- name: "Checkout code"
|
||||||
uses: actions/checkout@v5
|
uses: actions/checkout@v6
|
||||||
|
|
||||||
- name: "Use Node.js"
|
- name: "Use Node.js"
|
||||||
uses: actions/setup-node@v6
|
uses: actions/setup-node@v6
|
||||||
|
|||||||
2
.github/workflows/npm-lint.yml
vendored
2
.github/workflows/npm-lint.yml
vendored
@@ -11,7 +11,7 @@ jobs:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: "Checkout code"
|
- name: "Checkout code"
|
||||||
uses: actions/checkout@v5
|
uses: actions/checkout@v6
|
||||||
|
|
||||||
- name: "Use Node.js"
|
- name: "Use Node.js"
|
||||||
uses: actions/setup-node@v6
|
uses: actions/setup-node@v6
|
||||||
|
|||||||
2
.github/workflows/npm-publish-api.yml
vendored
2
.github/workflows/npm-publish-api.yml
vendored
@@ -11,7 +11,7 @@ jobs:
|
|||||||
id-token: write
|
id-token: write
|
||||||
steps:
|
steps:
|
||||||
- name: "Checkout code"
|
- name: "Checkout code"
|
||||||
uses: actions/checkout@v5
|
uses: actions/checkout@v6
|
||||||
# Setup .npmrc file to publish to npm
|
# Setup .npmrc file to publish to npm
|
||||||
- name: Install root project dependencies
|
- name: Install root project dependencies
|
||||||
run: npm ci
|
run: npm ci
|
||||||
|
|||||||
2
.github/workflows/npm-publish-ui.yml
vendored
2
.github/workflows/npm-publish-ui.yml
vendored
@@ -11,7 +11,7 @@ jobs:
|
|||||||
id-token: write
|
id-token: write
|
||||||
steps:
|
steps:
|
||||||
- name: "Checkout code"
|
- name: "Checkout code"
|
||||||
uses: actions/checkout@v5
|
uses: actions/checkout@v6
|
||||||
# Setup .npmrc file to publish to npm
|
# Setup .npmrc file to publish to npm
|
||||||
- uses: actions/setup-node@v6
|
- uses: actions/setup-node@v6
|
||||||
with:
|
with:
|
||||||
|
|||||||
4
.github/workflows/npm-test-unit.yml
vendored
4
.github/workflows/npm-test-unit.yml
vendored
@@ -13,10 +13,10 @@ jobs:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: "Checkout code"
|
- name: "Checkout code"
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v6
|
||||||
|
|
||||||
- name: "Use Node.js"
|
- name: "Use Node.js"
|
||||||
uses: actions/setup-node@v4
|
uses: actions/setup-node@v6
|
||||||
with:
|
with:
|
||||||
node-version: '20.x'
|
node-version: '20.x'
|
||||||
|
|
||||||
|
|||||||
2
.github/workflows/npm-typecheck.yml
vendored
2
.github/workflows/npm-typecheck.yml
vendored
@@ -10,7 +10,7 @@ jobs:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: "Checkout code"
|
- name: "Checkout code"
|
||||||
uses: actions/checkout@v5
|
uses: actions/checkout@v6
|
||||||
|
|
||||||
- name: "Setup PHP (for Ziggy)"
|
- name: "Setup PHP (for Ziggy)"
|
||||||
uses: shivammathur/setup-php@v2
|
uses: shivammathur/setup-php@v2
|
||||||
|
|||||||
2
.github/workflows/phpstan.yml
vendored
2
.github/workflows/phpstan.yml
vendored
@@ -9,7 +9,7 @@ jobs:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: "Checkout code"
|
- name: "Checkout code"
|
||||||
uses: actions/checkout@v5
|
uses: actions/checkout@v6
|
||||||
|
|
||||||
- name: "Setup PHP"
|
- name: "Setup PHP"
|
||||||
uses: shivammathur/setup-php@v2
|
uses: shivammathur/setup-php@v2
|
||||||
|
|||||||
4
.github/workflows/phpunit.yml
vendored
4
.github/workflows/phpunit.yml
vendored
@@ -36,7 +36,7 @@ jobs:
|
|||||||
--health-retries 5
|
--health-retries 5
|
||||||
steps:
|
steps:
|
||||||
- name: "Checkout code"
|
- name: "Checkout code"
|
||||||
uses: actions/checkout@v5
|
uses: actions/checkout@v6
|
||||||
|
|
||||||
- name: "Setup PHP"
|
- name: "Setup PHP"
|
||||||
uses: shivammathur/setup-php@v2
|
uses: shivammathur/setup-php@v2
|
||||||
@@ -68,7 +68,7 @@ jobs:
|
|||||||
run: php artisan test --stop-on-failure --coverage-text --coverage-clover=coverage.xml
|
run: php artisan test --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.5.1
|
uses: codecov/codecov-action@v7.0.0
|
||||||
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
@@ -9,7 +9,7 @@ jobs:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: "Checkout code"
|
- name: "Checkout code"
|
||||||
uses: actions/checkout@v5
|
uses: actions/checkout@v6
|
||||||
|
|
||||||
- name: "Check code style"
|
- name: "Check code style"
|
||||||
uses: aglipanci/laravel-pint-action@2.6
|
uses: aglipanci/laravel-pint-action@2.6
|
||||||
|
|||||||
12
.github/workflows/playwright.yml
vendored
12
.github/workflows/playwright.yml
vendored
@@ -35,7 +35,7 @@ jobs:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: "Checkout code"
|
- name: "Checkout code"
|
||||||
uses: actions/checkout@v5
|
uses: actions/checkout@v6
|
||||||
|
|
||||||
- name: "Setup node"
|
- name: "Setup node"
|
||||||
uses: actions/setup-node@v6
|
uses: actions/setup-node@v6
|
||||||
@@ -86,7 +86,7 @@ jobs:
|
|||||||
MAILPIT_BASE_URL: 'http://localhost:8025'
|
MAILPIT_BASE_URL: 'http://localhost:8025'
|
||||||
|
|
||||||
- name: "Upload blob report"
|
- name: "Upload blob report"
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v7
|
||||||
if: always()
|
if: always()
|
||||||
with:
|
with:
|
||||||
name: blob-report-${{ matrix.shardIndex }}
|
name: blob-report-${{ matrix.shardIndex }}
|
||||||
@@ -99,10 +99,10 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: "Checkout code"
|
- name: "Checkout code"
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v6
|
||||||
|
|
||||||
- name: "Setup node"
|
- name: "Setup node"
|
||||||
uses: actions/setup-node@v4
|
uses: actions/setup-node@v6
|
||||||
with:
|
with:
|
||||||
node-version: '20.x'
|
node-version: '20.x'
|
||||||
|
|
||||||
@@ -110,7 +110,7 @@ jobs:
|
|||||||
run: npm ci
|
run: npm ci
|
||||||
|
|
||||||
- name: "Download blob reports"
|
- name: "Download blob reports"
|
||||||
uses: actions/download-artifact@v4
|
uses: actions/download-artifact@v8
|
||||||
with:
|
with:
|
||||||
path: all-blob-reports
|
path: all-blob-reports
|
||||||
pattern: blob-report-*
|
pattern: blob-report-*
|
||||||
@@ -120,7 +120,7 @@ jobs:
|
|||||||
run: npx playwright merge-reports --reporter html ./all-blob-reports
|
run: npx playwright merge-reports --reporter html ./all-blob-reports
|
||||||
|
|
||||||
- name: "Upload merged HTML report"
|
- name: "Upload merged HTML report"
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v7
|
||||||
with:
|
with:
|
||||||
name: playwright-report
|
name: playwright-report
|
||||||
path: playwright-report/
|
path: playwright-report/
|
||||||
|
|||||||
@@ -5,8 +5,12 @@ declare(strict_types=1);
|
|||||||
namespace App\Actions\Fortify;
|
namespace App\Actions\Fortify;
|
||||||
|
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
|
use App\Providers\FortifyServiceProvider;
|
||||||
|
use Illuminate\Auth\Passwords\PasswordBroker;
|
||||||
use Illuminate\Support\Facades\Hash;
|
use Illuminate\Support\Facades\Hash;
|
||||||
|
use Illuminate\Support\Facades\Password;
|
||||||
use Illuminate\Support\Facades\Validator;
|
use Illuminate\Support\Facades\Validator;
|
||||||
|
use Illuminate\Validation\ValidationException;
|
||||||
use Laravel\Fortify\Contracts\ResetsUserPasswords;
|
use Laravel\Fortify\Contracts\ResetsUserPasswords;
|
||||||
|
|
||||||
class ResetUserPassword implements ResetsUserPasswords
|
class ResetUserPassword implements ResetsUserPasswords
|
||||||
@@ -20,6 +24,16 @@ class ResetUserPassword implements ResetsUserPasswords
|
|||||||
*/
|
*/
|
||||||
public function reset(User $user, array $input): void
|
public function reset(User $user, array $input): void
|
||||||
{
|
{
|
||||||
|
if (! FortifyServiceProvider::canResetPassword($user, $input)) {
|
||||||
|
/** @var PasswordBroker $broker */
|
||||||
|
$broker = Password::broker(config('fortify.passwords'));
|
||||||
|
$broker->deleteToken($user);
|
||||||
|
|
||||||
|
throw ValidationException::withMessages([
|
||||||
|
'email' => [__('This password reset link is invalid.')],
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
Validator::make($input, [
|
Validator::make($input, [
|
||||||
'password' => $this->passwordRules(),
|
'password' => $this->passwordRules(),
|
||||||
])->validate();
|
])->validate();
|
||||||
|
|||||||
@@ -9,6 +9,9 @@ use App\Models\Organization;
|
|||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
use Illuminate\Foundation\Events\Dispatchable;
|
use Illuminate\Foundation\Events\Dispatchable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Replaces legacy TeamMemberAdded event.
|
||||||
|
*/
|
||||||
class MemberAdded
|
class MemberAdded
|
||||||
{
|
{
|
||||||
use Dispatchable;
|
use Dispatchable;
|
||||||
|
|||||||
@@ -9,6 +9,9 @@ use App\Models\Organization;
|
|||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
use Illuminate\Foundation\Events\Dispatchable;
|
use Illuminate\Foundation\Events\Dispatchable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Replaces legacy AddingTeamMember event.
|
||||||
|
*/
|
||||||
class MemberAdding
|
class MemberAdding
|
||||||
{
|
{
|
||||||
use Dispatchable;
|
use Dispatchable;
|
||||||
|
|||||||
@@ -9,6 +9,9 @@ use App\Models\Organization;
|
|||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
use Illuminate\Foundation\Events\Dispatchable;
|
use Illuminate\Foundation\Events\Dispatchable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Replaces legacy InvitingTeamMember event.
|
||||||
|
*/
|
||||||
class OrganizationInvitationAdding
|
class OrganizationInvitationAdding
|
||||||
{
|
{
|
||||||
use Dispatchable;
|
use Dispatchable;
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ namespace App\Http\Controllers\Api\V1;
|
|||||||
|
|
||||||
use App\Enums\Role;
|
use App\Enums\Role;
|
||||||
use App\Events\AfterCreateOrganization;
|
use App\Events\AfterCreateOrganization;
|
||||||
|
use App\Http\Requests\V1\Organization\OrganizationDestroyRequest;
|
||||||
use App\Http\Requests\V1\Organization\OrganizationStoreRequest;
|
use App\Http\Requests\V1\Organization\OrganizationStoreRequest;
|
||||||
use App\Http\Requests\V1\Organization\OrganizationUpdateRequest;
|
use App\Http\Requests\V1\Organization\OrganizationUpdateRequest;
|
||||||
use App\Http\Resources\V1\Organization\OrganizationResource;
|
use App\Http\Resources\V1\Organization\OrganizationResource;
|
||||||
@@ -124,7 +125,7 @@ class OrganizationController extends Controller
|
|||||||
*
|
*
|
||||||
* @throws AuthorizationException
|
* @throws AuthorizationException
|
||||||
*/
|
*/
|
||||||
public function destroy(Organization $organization, DeletionService $deletionService): JsonResponse
|
public function destroy(Organization $organization, OrganizationDestroyRequest $request, DeletionService $deletionService): JsonResponse
|
||||||
{
|
{
|
||||||
$this->checkPermission($organization, 'organizations:delete');
|
$this->checkPermission($organization, 'organizations:delete');
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ namespace App\Http\Controllers\Api\V1;
|
|||||||
|
|
||||||
use App\Exceptions\Api\CanNotDeleteUserWhoIsOwnerOfOrganizationWithMultipleMembers;
|
use App\Exceptions\Api\CanNotDeleteUserWhoIsOwnerOfOrganizationWithMultipleMembers;
|
||||||
use App\Exceptions\Api\UserResendEmailVerificationNoPendingEmailApiException;
|
use App\Exceptions\Api\UserResendEmailVerificationNoPendingEmailApiException;
|
||||||
|
use App\Http\Requests\V1\User\UserDestroyRequest;
|
||||||
use App\Http\Requests\V1\User\UserUpdateCurrentOrganizationRequest;
|
use App\Http\Requests\V1\User\UserUpdateCurrentOrganizationRequest;
|
||||||
use App\Http\Requests\V1\User\UserUpdateRequest;
|
use App\Http\Requests\V1\User\UserUpdateRequest;
|
||||||
use App\Http\Resources\V1\User\UserResource;
|
use App\Http\Resources\V1\User\UserResource;
|
||||||
@@ -193,7 +194,7 @@ class UserController extends Controller
|
|||||||
* @throws AuthorizationException Thrown when the authenticated user does not match the user to be deleted.
|
* @throws AuthorizationException Thrown when the authenticated user does not match the user to be deleted.
|
||||||
* @throws CanNotDeleteUserWhoIsOwnerOfOrganizationWithMultipleMembers Thrown when the user to be deleted is the owner of an organization with multiple members.
|
* @throws CanNotDeleteUserWhoIsOwnerOfOrganizationWithMultipleMembers Thrown when the user to be deleted is the owner of an organization with multiple members.
|
||||||
*/
|
*/
|
||||||
public function destroy(User $user, DeletionService $deletionService): JsonResponse
|
public function destroy(User $user, UserDestroyRequest $request, DeletionService $deletionService): JsonResponse
|
||||||
{
|
{
|
||||||
if ($user->getKey() !== $this->user()->getKey()) {
|
if ($user->getKey() !== $this->user()->getKey()) {
|
||||||
throw new AuthorizationException;
|
throw new AuthorizationException;
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ class EnsureEmailIsVerified
|
|||||||
*/
|
*/
|
||||||
public function handle(Request $request, Closure $next, ?string $redirectToRoute = null): Response
|
public function handle(Request $request, Closure $next, ?string $redirectToRoute = null): Response
|
||||||
{
|
{
|
||||||
if (! app()->isLocal()) {
|
if (! app()->isLocal() || config('app.local_email_verification')) {
|
||||||
if ($request->user() === null ||
|
if ($request->user() === null ||
|
||||||
(! $request->user()->hasVerifiedEmail())) {
|
(! $request->user()->hasVerifiedEmail())) {
|
||||||
return $request->expectsJson()
|
return $request->expectsJson()
|
||||||
|
|||||||
@@ -0,0 +1,48 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace App\Http\Requests\V1\Organization;
|
||||||
|
|
||||||
|
use App\Http\Requests\V1\BaseFormRequest;
|
||||||
|
use Illuminate\Support\Facades\Hash;
|
||||||
|
use Illuminate\Validation\Validator;
|
||||||
|
|
||||||
|
class OrganizationDestroyRequest extends BaseFormRequest
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Get the validation rules that apply to the request.
|
||||||
|
*
|
||||||
|
* @return array<string, array<string>>
|
||||||
|
*/
|
||||||
|
public function rules(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'password' => [
|
||||||
|
'required',
|
||||||
|
'string',
|
||||||
|
],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array<int, callable(Validator): void>
|
||||||
|
*/
|
||||||
|
public function after(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
function (Validator $validator): void {
|
||||||
|
if ($validator->errors()->has('password')) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$user = $this->user();
|
||||||
|
$password = $this->input('password');
|
||||||
|
|
||||||
|
if (! is_string($password) || $user === null || ! Hash::check($password, (string) $user->password)) {
|
||||||
|
$validator->errors()->add('password', __('The password is incorrect.'));
|
||||||
|
}
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -12,6 +12,7 @@ use App\Enums\TimeFormat;
|
|||||||
use App\Http\Requests\V1\BaseFormRequest;
|
use App\Http\Requests\V1\BaseFormRequest;
|
||||||
use App\Models\Organization;
|
use App\Models\Organization;
|
||||||
use App\Rules\CurrencyRule;
|
use App\Rules\CurrencyRule;
|
||||||
|
use Illuminate\Contracts\Validation\ValidationRule;
|
||||||
use Illuminate\Validation\Rule;
|
use Illuminate\Validation\Rule;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -22,7 +23,7 @@ class OrganizationUpdateRequest extends BaseFormRequest
|
|||||||
/**
|
/**
|
||||||
* Get the validation rules that apply to the request.
|
* Get the validation rules that apply to the request.
|
||||||
*
|
*
|
||||||
* @return array<string, array<string|\Illuminate\Contracts\Validation\Rule|\Illuminate\Contracts\Validation\ValidationRule>>
|
* @return array<string, array<string|\Illuminate\Contracts\Validation\Rule|ValidationRule>>
|
||||||
*/
|
*/
|
||||||
public function rules(): array
|
public function rules(): array
|
||||||
{
|
{
|
||||||
|
|||||||
48
app/Http/Requests/V1/User/UserDestroyRequest.php
Normal file
48
app/Http/Requests/V1/User/UserDestroyRequest.php
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace App\Http\Requests\V1\User;
|
||||||
|
|
||||||
|
use App\Http\Requests\V1\BaseFormRequest;
|
||||||
|
use Illuminate\Support\Facades\Hash;
|
||||||
|
use Illuminate\Validation\Validator;
|
||||||
|
|
||||||
|
class UserDestroyRequest extends BaseFormRequest
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Get the validation rules that apply to the request.
|
||||||
|
*
|
||||||
|
* @return array<string, array<string>>
|
||||||
|
*/
|
||||||
|
public function rules(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'password' => [
|
||||||
|
'required',
|
||||||
|
'string',
|
||||||
|
],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array<int, callable(Validator): void>
|
||||||
|
*/
|
||||||
|
public function after(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
function (Validator $validator): void {
|
||||||
|
if ($validator->errors()->has('password')) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$user = $this->user();
|
||||||
|
$password = $this->input('password');
|
||||||
|
|
||||||
|
if (! is_string($password) || $user === null || ! Hash::check($password, (string) $user->password)) {
|
||||||
|
$validator->errors()->add('password', __('The password is incorrect.'));
|
||||||
|
}
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -145,11 +145,21 @@ class User extends Authenticatable implements AuditableContract, FilamentUser, M
|
|||||||
return 'https://ui-avatars.com/api/?name='.urlencode($name).'&color=7F9CF5&background=EBF4FF';
|
return 'https://ui-avatars.com/api/?name='.urlencode($name).'&color=7F9CF5&background=EBF4FF';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function canAccessPanel(Panel $panel): bool
|
public function isSuperAdmin(): bool
|
||||||
{
|
{
|
||||||
return in_array($this->email, config('auth.super_admins', []), true) && $this->hasVerifiedEmail();
|
return in_array($this->email, config('auth.super_admins', []), true) && $this->hasVerifiedEmail();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function hasLocalPassword(): bool
|
||||||
|
{
|
||||||
|
return is_string($this->password) && $this->password !== '';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function canAccessPanel(Panel $panel): bool
|
||||||
|
{
|
||||||
|
return $this->isSuperAdmin();
|
||||||
|
}
|
||||||
|
|
||||||
public function isMemberOfOrganization(Organization $organization): bool
|
public function isMemberOfOrganization(Organization $organization): bool
|
||||||
{
|
{
|
||||||
if ($this->relationLoaded('organizations')) {
|
if ($this->relationLoaded('organizations')) {
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ use Illuminate\Session\Middleware\StartSession;
|
|||||||
use Illuminate\Support\Facades\App;
|
use Illuminate\Support\Facades\App;
|
||||||
use Illuminate\View\Middleware\ShareErrorsFromSession;
|
use Illuminate\View\Middleware\ShareErrorsFromSession;
|
||||||
use Nwidart\Modules\Facades\Module;
|
use Nwidart\Modules\Facades\Module;
|
||||||
|
use Nwidart\Modules\Laravel\Module as LaravelModule;
|
||||||
use pxlrbt\FilamentEnvironmentIndicator\EnvironmentIndicatorPlugin;
|
use pxlrbt\FilamentEnvironmentIndicator\EnvironmentIndicatorPlugin;
|
||||||
|
|
||||||
class AdminPanelProvider extends PanelProvider
|
class AdminPanelProvider extends PanelProvider
|
||||||
@@ -91,22 +92,77 @@ class AdminPanelProvider extends PanelProvider
|
|||||||
$modules = Module::allEnabled();
|
$modules = Module::allEnabled();
|
||||||
|
|
||||||
foreach ($modules as $module) {
|
foreach ($modules as $module) {
|
||||||
|
$moduleNamespace = $this->getModuleAppNamespace($module);
|
||||||
|
|
||||||
$panel->discoverResources(
|
$panel->discoverResources(
|
||||||
in: module_path($module->getName(), 'app/Filament/Resources'),
|
in: module_path($module->getName(), 'app/Filament/Resources'),
|
||||||
for: 'Extensions\\'.$module->getName().'\\App\\Filament\\Resources'
|
for: $moduleNamespace.'\\Filament\\Resources'
|
||||||
);
|
);
|
||||||
|
|
||||||
$panel->discoverPages(
|
$panel->discoverPages(
|
||||||
in: module_path($module->getName(), 'app/Filament/Pages'),
|
in: module_path($module->getName(), 'app/Filament/Pages'),
|
||||||
for: 'Extensions\\'.$module->getName().'\\App\\Filament\\Pages'
|
for: $moduleNamespace.'\\Filament\\Pages'
|
||||||
);
|
);
|
||||||
|
|
||||||
$panel->discoverWidgets(
|
$panel->discoverWidgets(
|
||||||
in: module_path($module->getName(), 'app/Filament/Widgets'),
|
in: module_path($module->getName(), 'app/Filament/Widgets'),
|
||||||
for: 'Extensions\\'.$module->getName().'\\App\\Filament\\Widgets'
|
for: $moduleNamespace.'\\Filament\\Widgets'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $panel;
|
return $panel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @var array<string, string> Cache of module name => resolved app namespace. */
|
||||||
|
private static array $moduleAppNamespaces = [];
|
||||||
|
|
||||||
|
private function getModuleAppNamespace(LaravelModule $module): string
|
||||||
|
{
|
||||||
|
return self::$moduleAppNamespaces[$module->getName()] ??= $this->resolveModuleAppNamespace($module);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Resolve the PHP namespace mapped to a module's app/ directory so the
|
||||||
|
* Filament panel can discover its Resources/Pages/Widgets under the right
|
||||||
|
* namespace.
|
||||||
|
*
|
||||||
|
* Two module layouts currently coexist in this repo:
|
||||||
|
* - laravel-modules v12 (app_folder enabled): a bare namespace maps to
|
||||||
|
* app/ — e.g. "Extensions\SSO\" => app/, so classes are
|
||||||
|
* Extensions\SSO\Filament\... (this is the current convention).
|
||||||
|
* - the older layout: an "...\App" namespace maps to app/ — e.g.
|
||||||
|
* "Extensions\Billing\App\" => app/, so classes are
|
||||||
|
* Extensions\Billing\App\Filament\...
|
||||||
|
*
|
||||||
|
* The package's own namespace derivation assumes the v12 (bare) layout and
|
||||||
|
* would mis-resolve the legacy modules, so we read each module's composer
|
||||||
|
* PSR-4 map and use whichever namespace actually points at app/. The legacy
|
||||||
|
* "...\App" shape is only a fallback for when composer is missing/unreadable.
|
||||||
|
* Once every module adopts the bare layout this collapses to
|
||||||
|
* config('modules.namespace').'\\'.$module->getName().
|
||||||
|
*/
|
||||||
|
private function resolveModuleAppNamespace(LaravelModule $module): string
|
||||||
|
{
|
||||||
|
$fallback = 'Extensions\\'.$module->getName().'\\App';
|
||||||
|
|
||||||
|
$composerPath = module_path($module->getName(), 'composer.json');
|
||||||
|
$psr4 = [];
|
||||||
|
if (is_file($composerPath)) {
|
||||||
|
$composer = json_decode((string) file_get_contents($composerPath), true);
|
||||||
|
$psr4 = is_array($composer) ? ($composer['autoload']['psr-4'] ?? []) : [];
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ((array) $psr4 as $namespace => $path) {
|
||||||
|
if (is_string($namespace) && $this->normalizeComposerPath($path) === 'app') {
|
||||||
|
return rtrim($namespace, '\\');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $fallback;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function normalizeComposerPath(mixed $path): string
|
||||||
|
{
|
||||||
|
return trim(str_replace('\\', '/', (string) $path), '/');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,6 +25,73 @@ use Laravel\Fortify\Fortify;
|
|||||||
|
|
||||||
class FortifyServiceProvider extends ServiceProvider
|
class FortifyServiceProvider extends ServiceProvider
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Dummy bcrypt hash compared against when no user matches the submitted
|
||||||
|
* email. Hash::check is run against it so login takes the same time whether
|
||||||
|
* or not the email exists — otherwise an unknown email would skip the
|
||||||
|
* (deliberately slow) hash and return faster, letting an attacker enumerate
|
||||||
|
* registered accounts by timing the response. The plaintext is irrelevant:
|
||||||
|
* it is only ever checked against attacker-supplied input and never matches.
|
||||||
|
*/
|
||||||
|
private const ABSENT_USER_PASSWORD_HASH = '$2y$12$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Authorization rules applied AFTER the password is verified. Each rule
|
||||||
|
* receives the authenticated user + request and returns whether the login
|
||||||
|
* may proceed; any rule returning false denies it. This is an extension
|
||||||
|
* point: modules (e.g. SSO enforcement) add a rule to veto a password login
|
||||||
|
* instead of replacing this credential check — which would silently drift
|
||||||
|
* from the host logic the next time it changes.
|
||||||
|
*
|
||||||
|
* @var array<int, \Closure(User, Request): bool>
|
||||||
|
*/
|
||||||
|
protected static array $loginRules = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Authorization rules applied before a password reset is completed. Rules
|
||||||
|
* receive the user being reset + submitted input and return whether the
|
||||||
|
* local reset flow may set a new password for that account.
|
||||||
|
*
|
||||||
|
* @var array<int, \Closure(User, array<string, mixed>): bool>
|
||||||
|
*/
|
||||||
|
protected static array $passwordResetRules = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register an additional rule that gates password login (see $loginRules).
|
||||||
|
*
|
||||||
|
* @param \Closure(User, Request): bool $rule
|
||||||
|
*/
|
||||||
|
public static function authenticateUsingRule(\Closure $rule): void
|
||||||
|
{
|
||||||
|
static::$loginRules[] = $rule;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register an additional rule that gates password reset completion.
|
||||||
|
*
|
||||||
|
* @param \Closure(User, array<string, mixed>): bool $rule
|
||||||
|
*/
|
||||||
|
public static function resetPasswordUsingRule(\Closure $rule): void
|
||||||
|
{
|
||||||
|
static::$passwordResetRules[] = $rule;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check whether the given user may complete the local password reset flow.
|
||||||
|
*
|
||||||
|
* @param array<string, mixed> $input
|
||||||
|
*/
|
||||||
|
public static function canResetPassword(User $user, array $input = []): bool
|
||||||
|
{
|
||||||
|
foreach (static::$passwordResetRules as $rule) {
|
||||||
|
if (! $rule($user, $input)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Register any application services.
|
* Register any application services.
|
||||||
*/
|
*/
|
||||||
@@ -92,7 +159,23 @@ class FortifyServiceProvider extends ServiceProvider
|
|||||||
->where('is_placeholder', '=', false)
|
->where('is_placeholder', '=', false)
|
||||||
->first();
|
->first();
|
||||||
|
|
||||||
if ($user !== null && Hash::check($request->password, $user->password)) {
|
// Always run the hash check — against the real hash, or a dummy when
|
||||||
|
// there is no user — so login timing is identical either way (see
|
||||||
|
// ABSENT_USER_PASSWORD_HASH). Passwordless accounts (SSO-only users
|
||||||
|
// have password = null) fail here, so they cannot password-login.
|
||||||
|
$existingPasswordHash = $user->password ?? self::ABSENT_USER_PASSWORD_HASH;
|
||||||
|
|
||||||
|
$passwordIsValid = Hash::check((string) $request->password, $existingPasswordHash);
|
||||||
|
|
||||||
|
if ($user !== null && $passwordIsValid) {
|
||||||
|
// Credentials are valid; now apply any registered authorization
|
||||||
|
// rules (e.g. SSO enforcement may still block password login).
|
||||||
|
foreach (static::$loginRules as $rule) {
|
||||||
|
if (! $rule($user, $request)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return $user;
|
return $user;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -48,6 +48,56 @@ class UserService
|
|||||||
}
|
}
|
||||||
$user->save();
|
$user->save();
|
||||||
|
|
||||||
|
$this->createDefaultOrganizationForUser(
|
||||||
|
$user,
|
||||||
|
$currency,
|
||||||
|
$numberFormat,
|
||||||
|
$currencyFormat,
|
||||||
|
$dateFormat,
|
||||||
|
$intervalFormat,
|
||||||
|
$timeFormat,
|
||||||
|
);
|
||||||
|
|
||||||
|
return $user;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a user without a password (e.g. provisioned via SSO). Such users
|
||||||
|
* can only authenticate through a linked identity provider.
|
||||||
|
*/
|
||||||
|
public function createPasswordlessUser(
|
||||||
|
string $name,
|
||||||
|
string $email,
|
||||||
|
string $timezone,
|
||||||
|
Weekday $weekStart,
|
||||||
|
?string $currency,
|
||||||
|
bool $verifyEmail = false
|
||||||
|
): User {
|
||||||
|
$user = new User;
|
||||||
|
$user->name = $name;
|
||||||
|
$user->email = strtolower($email);
|
||||||
|
$user->password = null;
|
||||||
|
$user->timezone = $timezone;
|
||||||
|
$user->week_start = $weekStart;
|
||||||
|
if ($verifyEmail) {
|
||||||
|
$user->email_verified_at = Carbon::now();
|
||||||
|
}
|
||||||
|
$user->save();
|
||||||
|
|
||||||
|
$this->createDefaultOrganizationForUser($user, $currency);
|
||||||
|
|
||||||
|
return $user;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function createDefaultOrganizationForUser(
|
||||||
|
User $user,
|
||||||
|
?string $currency,
|
||||||
|
?NumberFormat $numberFormat = null,
|
||||||
|
?CurrencyFormat $currencyFormat = null,
|
||||||
|
?DateFormat $dateFormat = null,
|
||||||
|
?IntervalFormat $intervalFormat = null,
|
||||||
|
?TimeFormat $timeFormat = null,
|
||||||
|
): void {
|
||||||
$organizations = app(InvitationService::class)->processAcceptedInvitations($user);
|
$organizations = app(InvitationService::class)->processAcceptedInvitations($user);
|
||||||
|
|
||||||
if ($organizations->isEmpty()) {
|
if ($organizations->isEmpty()) {
|
||||||
@@ -64,8 +114,6 @@ class UserService
|
|||||||
);
|
);
|
||||||
$this->switchCurrentOrganization($user, $organization);
|
$this->switchCurrentOrganization($user, $organization);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $user;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -81,6 +81,8 @@ return [
|
|||||||
|
|
||||||
'enable_registration' => (bool) env('APP_ENABLE_REGISTRATION', false),
|
'enable_registration' => (bool) env('APP_ENABLE_REGISTRATION', false),
|
||||||
|
|
||||||
|
'local_email_verification' => (bool) env('APP_LOCAL_EMAIL_VERIFICATION', false),
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
| Application Timezone
|
| Application Timezone
|
||||||
|
|||||||
@@ -107,7 +107,7 @@ services:
|
|||||||
- sail
|
- sail
|
||||||
- reverse-proxy
|
- reverse-proxy
|
||||||
playwright:
|
playwright:
|
||||||
image: mcr.microsoft.com/playwright:v1.59.1-jammy
|
image: mcr.microsoft.com/playwright:v1.60.0-jammy
|
||||||
command: ['npx', 'playwright', 'test', '--ui-port=8080', '--ui-host=0.0.0.0']
|
command: ['npx', 'playwright', 'test', '--ui-port=8080', '--ui-host=0.0.0.0']
|
||||||
working_dir: /src
|
working_dir: /src
|
||||||
extra_hosts:
|
extra_hosts:
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { expect, test } from '../playwright/fixtures';
|
import { expect, test } from '../playwright/fixtures';
|
||||||
import { PLAYWRIGHT_BASE_URL } from '../playwright/config';
|
import { PLAYWRIGHT_BASE_URL, TEST_USER_PASSWORD } from '../playwright/config';
|
||||||
|
|
||||||
async function goToOrganizationSettings(page) {
|
async function goToOrganizationSettings(page) {
|
||||||
await page.goto(PLAYWRIGHT_BASE_URL + '/dashboard');
|
await page.goto(PLAYWRIGHT_BASE_URL + '/dashboard');
|
||||||
@@ -471,6 +471,7 @@ test.describe('Organization Create, Delete & Switch', () => {
|
|||||||
|
|
||||||
// Open the confirmation modal, then confirm inside the dialog.
|
// Open the confirmation modal, then confirm inside the dialog.
|
||||||
await page.getByRole('button', { name: 'Delete Organization' }).click();
|
await page.getByRole('button', { name: 'Delete Organization' }).click();
|
||||||
|
await page.getByRole('dialog').getByPlaceholder('Password').fill(TEST_USER_PASSWORD);
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
page.waitForResponse(
|
page.waitForResponse(
|
||||||
(response) =>
|
(response) =>
|
||||||
@@ -488,6 +489,28 @@ test.describe('Organization Create, Delete & Switch', () => {
|
|||||||
).not.toContainText(orgName);
|
).not.toContainText(orgName);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('delete organization shows an error when the password is wrong', async ({ page }) => {
|
||||||
|
const orgName = 'DeleteOrgWrongPassword' + Math.floor(Math.random() * 100000);
|
||||||
|
await createOrganization(page, orgName);
|
||||||
|
await goToOrganizationSettings(page);
|
||||||
|
|
||||||
|
await page.getByRole('button', { name: 'Delete Organization' }).click();
|
||||||
|
const dialog = page.getByRole('dialog');
|
||||||
|
await dialog.getByPlaceholder('Password').fill('not-the-real-password');
|
||||||
|
await Promise.all([
|
||||||
|
page.waitForResponse(
|
||||||
|
(response) =>
|
||||||
|
response.url().includes('/api/v1/organizations') &&
|
||||||
|
response.request().method() === 'DELETE' &&
|
||||||
|
response.status() === 422
|
||||||
|
),
|
||||||
|
dialog.getByRole('button', { name: 'Delete Organization' }).click(),
|
||||||
|
]);
|
||||||
|
|
||||||
|
await expect(dialog.getByRole('alert')).toBeVisible();
|
||||||
|
await expect(dialog).toBeVisible();
|
||||||
|
});
|
||||||
|
|
||||||
test('can switch the current organization via the organization switcher', async ({ page }) => {
|
test('can switch the current organization via the organization switcher', async ({ page }) => {
|
||||||
await page.goto(PLAYWRIGHT_BASE_URL + '/dashboard');
|
await page.goto(PLAYWRIGHT_BASE_URL + '/dashboard');
|
||||||
const orgSwitcher = page.locator('[data-testid="organization_switcher"]:visible');
|
const orgSwitcher = page.locator('[data-testid="organization_switcher"]:visible');
|
||||||
|
|||||||
@@ -342,8 +342,8 @@ test('delete account shows an error when the password is wrong', async ({ page }
|
|||||||
await Promise.all([
|
await Promise.all([
|
||||||
page.waitForResponse(
|
page.waitForResponse(
|
||||||
(response) =>
|
(response) =>
|
||||||
response.url().includes('/user/confirm-password') &&
|
response.url().includes('/api/v1/users/') &&
|
||||||
response.request().method() === 'POST' &&
|
response.request().method() === 'DELETE' &&
|
||||||
response.status() === 422
|
response.status() === 422
|
||||||
),
|
),
|
||||||
dialog.getByRole('button', { name: 'Delete Account' }).click(),
|
dialog.getByRole('button', { name: 'Delete Account' }).click(),
|
||||||
|
|||||||
@@ -62,4 +62,35 @@ describe('TimesheetCell', () => {
|
|||||||
expect(wrapper.emitted('update')).toBeUndefined();
|
expect(wrapper.emitted('update')).toBeUndefined();
|
||||||
expect((input.element as HTMLInputElement).value).toBe(previousValue);
|
expect((input.element as HTMLInputElement).value).toBe(previousValue);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('shows a pending 0 (delete in flight) over the cell total', () => {
|
||||||
|
const wrapper = mount(TimesheetCell, {
|
||||||
|
props: {
|
||||||
|
cell: buildCell(2 * 3600),
|
||||||
|
dayIndex: 0,
|
||||||
|
date: '2026-04-13',
|
||||||
|
isToday: false,
|
||||||
|
hasRunningEntry: false,
|
||||||
|
pendingSeconds: 0,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
// `??` (not `||`): a pending 0 must win over the 2h cell total.
|
||||||
|
expect((wrapper.get('input').element as HTMLInputElement).value).toBe('');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('disables editing while the cell is saving', () => {
|
||||||
|
const wrapper = mount(TimesheetCell, {
|
||||||
|
props: {
|
||||||
|
cell: buildCell(2 * 3600),
|
||||||
|
dayIndex: 0,
|
||||||
|
date: '2026-04-13',
|
||||||
|
isToday: false,
|
||||||
|
hasRunningEntry: false,
|
||||||
|
saveStatus: 'saving',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
expect((wrapper.get('input').element as HTMLInputElement).disabled).toBe(true);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
import { computed } from 'vue';
|
||||||
|
import { CheckIcon } from '@heroicons/vue/16/solid';
|
||||||
import DurationSecondsInput from '@/packages/ui/src/Input/DurationSecondsInput.vue';
|
import DurationSecondsInput from '@/packages/ui/src/Input/DurationSecondsInput.vue';
|
||||||
|
import LoadingSpinner from '@/packages/ui/src/LoadingSpinner.vue';
|
||||||
import {
|
import {
|
||||||
Tooltip,
|
Tooltip,
|
||||||
TooltipContent,
|
TooltipContent,
|
||||||
@@ -7,18 +10,40 @@ import {
|
|||||||
TooltipTrigger,
|
TooltipTrigger,
|
||||||
} from '@/packages/ui/src/tooltip';
|
} from '@/packages/ui/src/tooltip';
|
||||||
import type { TimesheetCell } from '@/utils/useTimesheetGrid';
|
import type { TimesheetCell } from '@/utils/useTimesheetGrid';
|
||||||
|
import type { CellSaveStatus } from '@/utils/timesheet/useTimesheetCellMutations';
|
||||||
|
|
||||||
defineProps<{
|
const props = defineProps<{
|
||||||
cell?: TimesheetCell;
|
cell?: TimesheetCell;
|
||||||
dayIndex: number;
|
dayIndex: number;
|
||||||
date: string;
|
date: string;
|
||||||
isToday: boolean;
|
isToday: boolean;
|
||||||
hasRunningEntry: boolean;
|
hasRunningEntry: boolean;
|
||||||
|
saveStatus?: CellSaveStatus;
|
||||||
|
pendingSeconds?: number;
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
const emit = defineEmits<{
|
const emit = defineEmits<{
|
||||||
update: [newSeconds: number];
|
update: [newSeconds: number];
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
|
// Show the optimistic value while saving; `??` (not `||`) so a pending 0 (delete) wins.
|
||||||
|
const displaySeconds = computed(() => props.pendingSeconds ?? props.cell?.totalSeconds ?? 0);
|
||||||
|
const isSaving = computed(() => props.saveStatus === 'saving');
|
||||||
|
|
||||||
|
// Swap the border color (don't layer) to avoid same-specificity fights.
|
||||||
|
const inputClass = computed(() => {
|
||||||
|
const border = props.saveStatus === 'error' ? 'border-red-500/70' : 'border-input-border';
|
||||||
|
return [
|
||||||
|
'w-[80px] mx-auto text-center font-medium',
|
||||||
|
'bg-transparent text-text-primary placeholder:text-text-quaternary',
|
||||||
|
'rounded-lg border shadow-none',
|
||||||
|
border,
|
||||||
|
'hover:bg-card-background',
|
||||||
|
'focus-visible:bg-tertiary focus-visible:border-transparent',
|
||||||
|
'focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none',
|
||||||
|
'disabled:cursor-wait disabled:opacity-70',
|
||||||
|
].join(' ');
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
@@ -46,18 +71,26 @@ const emit = defineEmits<{
|
|||||||
<TooltipContent> Stop the running time entry to edit the timesheet </TooltipContent>
|
<TooltipContent> Stop the running time entry to edit the timesheet </TooltipContent>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
</TooltipProvider>
|
</TooltipProvider>
|
||||||
<DurationSecondsInput
|
<template v-else>
|
||||||
v-else
|
<span class="relative inline-flex items-center">
|
||||||
:model-value="cell?.totalSeconds ?? 0"
|
<DurationSecondsInput
|
||||||
default-unit="hours"
|
:model-value="displaySeconds"
|
||||||
placeholder="-"
|
default-unit="hours"
|
||||||
size="sm"
|
placeholder="-"
|
||||||
input-class="w-[80px] mx-auto text-center font-medium
|
size="sm"
|
||||||
bg-transparent text-text-primary placeholder:text-text-quaternary
|
:disabled="isSaving"
|
||||||
rounded-lg border border-input-border shadow-none
|
:input-class="inputClass"
|
||||||
hover:bg-card-background
|
@commit="(seconds) => emit('update', seconds ?? 0)" />
|
||||||
focus-visible:bg-tertiary focus-visible:border-transparent
|
<span
|
||||||
focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none"
|
v-if="saveStatus === 'saving' || saveStatus === 'saved'"
|
||||||
@commit="(seconds) => emit('update', seconds ?? 0)" />
|
class="pointer-events-none absolute left-full top-1/2 ml-1.5 flex -translate-y-1/2 items-center"
|
||||||
|
:aria-label="saveStatus === 'saving' ? 'Saving' : 'Saved'">
|
||||||
|
<LoadingSpinner
|
||||||
|
v-if="saveStatus === 'saving'"
|
||||||
|
class="h-3 w-3 m-0 text-text-tertiary" />
|
||||||
|
<CheckIcon v-else class="h-3 w-3 text-text-tertiary" />
|
||||||
|
</span>
|
||||||
|
</span>
|
||||||
|
</template>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import type {
|
|||||||
Task,
|
Task,
|
||||||
} from '@/packages/api/src';
|
} from '@/packages/api/src';
|
||||||
import type { TimesheetRow as TimesheetRowType, TimesheetRowKey } from '@/utils/useTimesheetGrid';
|
import type { TimesheetRow as TimesheetRowType, TimesheetRowKey } from '@/utils/useTimesheetGrid';
|
||||||
|
import type { CellSaveStatus } from '@/utils/timesheet/useTimesheetCellMutations';
|
||||||
|
|
||||||
const organization = inject<ComputedRef<Organization>>('organization');
|
const organization = inject<ComputedRef<Organization>>('organization');
|
||||||
const dayjs = getDayJsInstance();
|
const dayjs = getDayJsInstance();
|
||||||
@@ -36,6 +37,8 @@ defineProps<{
|
|||||||
createClient: (client: CreateClientBody) => Promise<Client | undefined>;
|
createClient: (client: CreateClientBody) => Promise<Client | undefined>;
|
||||||
createTag: (name: string) => Promise<Tag | undefined>;
|
createTag: (name: string) => Promise<Tag | undefined>;
|
||||||
formatDuration: (seconds: number) => string;
|
formatDuration: (seconds: number) => string;
|
||||||
|
cellStatuses: Record<string, CellSaveStatus>;
|
||||||
|
cellPendingSeconds: Record<string, number>;
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
const emit = defineEmits<{
|
const emit = defineEmits<{
|
||||||
@@ -60,7 +63,7 @@ const emit = defineEmits<{
|
|||||||
class="grid min-w-full w-max border-y border-default-background-separator"
|
class="grid min-w-full w-max border-y border-default-background-separator"
|
||||||
style="
|
style="
|
||||||
grid-template-columns:
|
grid-template-columns:
|
||||||
minmax(420px, 1fr) repeat(7, minmax(96px, 120px)) minmax(100px, auto)
|
minmax(420px, 1fr) repeat(7, minmax(116px, 120px)) minmax(100px, auto)
|
||||||
40px;
|
40px;
|
||||||
">
|
">
|
||||||
<!-- Header row -->
|
<!-- Header row -->
|
||||||
@@ -100,6 +103,8 @@ const emit = defineEmits<{
|
|||||||
:create-client="createClient"
|
:create-client="createClient"
|
||||||
:create-tag="createTag"
|
:create-tag="createTag"
|
||||||
:format-duration="formatDuration"
|
:format-duration="formatDuration"
|
||||||
|
:cell-statuses="cellStatuses"
|
||||||
|
:cell-pending-seconds="cellPendingSeconds"
|
||||||
@remove-row="$emit('remove-row', $event)"
|
@remove-row="$emit('remove-row', $event)"
|
||||||
@cell-update="
|
@cell-update="
|
||||||
(dayIndex, seconds) => $emit('cell-update', row, dayIndex, seconds)
|
(dayIndex, seconds) => $emit('cell-update', row, dayIndex, seconds)
|
||||||
|
|||||||
@@ -15,6 +15,10 @@ import type {
|
|||||||
Organization,
|
Organization,
|
||||||
} from '@/packages/api/src';
|
} from '@/packages/api/src';
|
||||||
import type { TimesheetRow, TimesheetRowKey } from '@/utils/useTimesheetGrid';
|
import type { TimesheetRow, TimesheetRowKey } from '@/utils/useTimesheetGrid';
|
||||||
|
import {
|
||||||
|
makeCellStatusKey,
|
||||||
|
type CellSaveStatus,
|
||||||
|
} from '@/utils/timesheet/useTimesheetCellMutations';
|
||||||
import { Button } from '@/packages/ui/src/Buttons';
|
import { Button } from '@/packages/ui/src/Buttons';
|
||||||
|
|
||||||
const organization = inject<ComputedRef<Organization>>('organization');
|
const organization = inject<ComputedRef<Organization>>('organization');
|
||||||
@@ -34,6 +38,8 @@ const props = defineProps<{
|
|||||||
createClient: (client: CreateClientBody) => Promise<Client | undefined>;
|
createClient: (client: CreateClientBody) => Promise<Client | undefined>;
|
||||||
createTag: (name: string) => Promise<Tag | undefined>;
|
createTag: (name: string) => Promise<Tag | undefined>;
|
||||||
formatDuration: (seconds: number) => string;
|
formatDuration: (seconds: number) => string;
|
||||||
|
cellStatuses: Record<string, CellSaveStatus>;
|
||||||
|
cellPendingSeconds: Record<string, number>;
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
const emit = defineEmits<{
|
const emit = defineEmits<{
|
||||||
@@ -109,6 +115,8 @@ function hasRunningEntry(dayIndex: number): boolean {
|
|||||||
:date="day"
|
:date="day"
|
||||||
:is-today="day === todayDate"
|
:is-today="day === todayDate"
|
||||||
:has-running-entry="hasRunningEntry(dayIndex)"
|
:has-running-entry="hasRunningEntry(dayIndex)"
|
||||||
|
:save-status="cellStatuses[makeCellStatusKey(row.key, dayIndex)]"
|
||||||
|
:pending-seconds="cellPendingSeconds[makeCellStatusKey(row.key, dayIndex)]"
|
||||||
@update="(seconds) => emit('cellUpdate', dayIndex, seconds)" />
|
@update="(seconds) => emit('cellUpdate', dayIndex, seconds)" />
|
||||||
|
|
||||||
<!-- Row total -->
|
<!-- Row total -->
|
||||||
|
|||||||
@@ -298,7 +298,7 @@ const page = usePage<{
|
|||||||
<div class="justify-self-end">
|
<div class="justify-self-end">
|
||||||
<UpdateSidebarNotification></UpdateSidebarNotification>
|
<UpdateSidebarNotification></UpdateSidebarNotification>
|
||||||
<ul
|
<ul
|
||||||
class="border-t border-default-background-separator pt-3 gap-1 pr-2 flex justify-between items-center">
|
class="border-t border-default-background-separator pt-3 gap-1 flex justify-between items-center">
|
||||||
<UserSettingsIcon></UserSettingsIcon>
|
<UserSettingsIcon></UserSettingsIcon>
|
||||||
|
|
||||||
<NavigationSidebarItem
|
<NavigationSidebarItem
|
||||||
|
|||||||
@@ -7,10 +7,16 @@ import { Field, FieldLabel, FieldError } from '@/packages/ui/src/field';
|
|||||||
import PrimaryButton from '@/packages/ui/src/Buttons/PrimaryButton.vue';
|
import PrimaryButton from '@/packages/ui/src/Buttons/PrimaryButton.vue';
|
||||||
import TextInput from '@/packages/ui/src/Input/TextInput.vue';
|
import TextInput from '@/packages/ui/src/Input/TextInput.vue';
|
||||||
|
|
||||||
defineProps({
|
withDefaults(
|
||||||
canResetPassword: Boolean,
|
defineProps<{
|
||||||
status: String,
|
canResetPassword?: boolean;
|
||||||
});
|
status?: string;
|
||||||
|
}>(),
|
||||||
|
{
|
||||||
|
canResetPassword: false,
|
||||||
|
status: '',
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
const form = useForm({
|
const form = useForm({
|
||||||
email: '',
|
email: '',
|
||||||
@@ -28,8 +34,8 @@ const submit = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const page = usePage<{
|
const page = usePage<{
|
||||||
flash: {
|
flash?: {
|
||||||
message: string;
|
message?: string;
|
||||||
};
|
};
|
||||||
}>();
|
}>();
|
||||||
</script>
|
</script>
|
||||||
@@ -61,6 +67,9 @@ const page = usePage<{
|
|||||||
{{ page.props.flash?.message }}
|
{{ page.props.flash?.message }}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- Extension seam: alternative-auth errors (e.g. SSO callback failures) -->
|
||||||
|
<slot name="error" />
|
||||||
|
|
||||||
<form @submit.prevent="submit">
|
<form @submit.prevent="submit">
|
||||||
<Field>
|
<Field>
|
||||||
<FieldLabel for="email">Email</FieldLabel>
|
<FieldLabel for="email">Email</FieldLabel>
|
||||||
@@ -103,5 +112,8 @@ const page = usePage<{
|
|||||||
</PrimaryButton>
|
</PrimaryButton>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
<!-- Extension seam: alternative auth methods (e.g. SSO providers) -->
|
||||||
|
<slot name="alternatives" />
|
||||||
</AuthenticationCard>
|
</AuthenticationCard>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -1,15 +1,14 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref } from 'vue';
|
import { ref } from 'vue';
|
||||||
import axios from 'axios';
|
|
||||||
import ActionSection from '@/Components/ActionSection.vue';
|
import ActionSection from '@/Components/ActionSection.vue';
|
||||||
import DangerButton from '@/packages/ui/src/Buttons/DangerButton.vue';
|
import DangerButton from '@/packages/ui/src/Buttons/DangerButton.vue';
|
||||||
import DialogModal from '@/packages/ui/src/DialogModal.vue';
|
import DialogModal from '@/packages/ui/src/DialogModal.vue';
|
||||||
import { Field, FieldError } from '@/packages/ui/src/field';
|
import { Field, FieldError } from '@/packages/ui/src/field';
|
||||||
import SecondaryButton from '@/packages/ui/src/Buttons/SecondaryButton.vue';
|
import SecondaryButton from '@/packages/ui/src/Buttons/SecondaryButton.vue';
|
||||||
import TextInput from '@/packages/ui/src/Input/TextInput.vue';
|
import TextInput from '@/packages/ui/src/Input/TextInput.vue';
|
||||||
import { useDeleteUserMutation, useUserQuery } from '@/utils/useUserQuery';
|
import { useDeleteUserMutation } from '@/utils/useUserQuery';
|
||||||
|
import { getCurrentUserId } from '@/utils/useUser';
|
||||||
|
|
||||||
const { user } = useUserQuery();
|
|
||||||
const deleteUserMutation = useDeleteUserMutation();
|
const deleteUserMutation = useDeleteUserMutation();
|
||||||
|
|
||||||
const confirmingUserDeletion = ref(false);
|
const confirmingUserDeletion = ref(false);
|
||||||
@@ -24,26 +23,26 @@ function confirmUserDeletion() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function deleteUser() {
|
async function deleteUser() {
|
||||||
if (!user.value || processing.value) return;
|
if (processing.value) return;
|
||||||
processing.value = true;
|
processing.value = true;
|
||||||
passwordError.value = '';
|
passwordError.value = '';
|
||||||
try {
|
try {
|
||||||
await axios.post(route('password.confirm'), { password: password.value });
|
await deleteUserMutation.mutateAsync({
|
||||||
} catch (error) {
|
userId: getCurrentUserId(),
|
||||||
processing.value = false;
|
body: { password: password.value },
|
||||||
if (axios.isAxiosError(error) && error.response?.status === 422) {
|
});
|
||||||
passwordError.value = error.response.data?.errors?.password?.[0] ?? 'Invalid password.';
|
|
||||||
} else {
|
|
||||||
passwordError.value = 'Could not confirm password. Please try again.';
|
|
||||||
}
|
|
||||||
passwordInput.value?.focus();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
await deleteUserMutation.mutateAsync(user.value.id);
|
|
||||||
window.location.href = '/';
|
window.location.href = '/';
|
||||||
} catch {
|
} catch (error) {
|
||||||
|
if (error && typeof error === 'object' && 'response' in error) {
|
||||||
|
const response = error.response as
|
||||||
|
| { status?: number; data?: { errors?: { password?: string[] } } }
|
||||||
|
| undefined;
|
||||||
|
if (response?.status === 422) {
|
||||||
|
passwordError.value = response.data?.errors?.password?.[0] ?? 'Invalid password.';
|
||||||
|
}
|
||||||
|
}
|
||||||
processing.value = false;
|
processing.value = false;
|
||||||
|
passwordInput.value?.focus();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,9 +2,11 @@
|
|||||||
import { ref } from 'vue';
|
import { ref } from 'vue';
|
||||||
import { router } from '@inertiajs/vue3';
|
import { router } from '@inertiajs/vue3';
|
||||||
import ActionSection from '@/Components/ActionSection.vue';
|
import ActionSection from '@/Components/ActionSection.vue';
|
||||||
import ConfirmationModal from '@/Components/ConfirmationModal.vue';
|
|
||||||
import DangerButton from '@/packages/ui/src/Buttons/DangerButton.vue';
|
import DangerButton from '@/packages/ui/src/Buttons/DangerButton.vue';
|
||||||
|
import DialogModal from '@/packages/ui/src/DialogModal.vue';
|
||||||
|
import { Field, FieldError } from '@/packages/ui/src/field';
|
||||||
import SecondaryButton from '@/packages/ui/src/Buttons/SecondaryButton.vue';
|
import SecondaryButton from '@/packages/ui/src/Buttons/SecondaryButton.vue';
|
||||||
|
import TextInput from '@/packages/ui/src/Input/TextInput.vue';
|
||||||
import { useOrganizationStore } from '@/utils/useOrganization';
|
import { useOrganizationStore } from '@/utils/useOrganization';
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
@@ -12,26 +14,46 @@ const props = defineProps<{
|
|||||||
}>();
|
}>();
|
||||||
|
|
||||||
const confirmingTeamDeletion = ref(false);
|
const confirmingTeamDeletion = ref(false);
|
||||||
|
const passwordInput = ref<HTMLInputElement | null>(null);
|
||||||
|
const password = ref('');
|
||||||
|
const passwordError = ref('');
|
||||||
const processing = ref(false);
|
const processing = ref(false);
|
||||||
const organizationStore = useOrganizationStore();
|
const organizationStore = useOrganizationStore();
|
||||||
|
|
||||||
const confirmTeamDeletion = () => {
|
const confirmTeamDeletion = () => {
|
||||||
confirmingTeamDeletion.value = true;
|
confirmingTeamDeletion.value = true;
|
||||||
|
setTimeout(() => passwordInput.value?.focus(), 250);
|
||||||
};
|
};
|
||||||
|
|
||||||
const deleteTeam = async () => {
|
const deleteTeam = async () => {
|
||||||
|
if (processing.value) return;
|
||||||
processing.value = true;
|
processing.value = true;
|
||||||
|
passwordError.value = '';
|
||||||
try {
|
try {
|
||||||
await organizationStore.deleteOrganization(props.team.id);
|
await organizationStore.deleteOrganization(props.team.id, { password: password.value });
|
||||||
// The backend reassigns the user's current organization after deletion,
|
// The backend reassigns the user's current organization after deletion,
|
||||||
// so flush the prefetch cache and reload into the dashboard.
|
// so flush the prefetch cache and reload into the dashboard.
|
||||||
router.flushAll();
|
router.flushAll();
|
||||||
router.visit(route('dashboard'));
|
router.visit(route('dashboard'));
|
||||||
} catch {
|
} catch (error) {
|
||||||
// Request errors are surfaced as notifications by the store.
|
if (error && typeof error === 'object' && 'response' in error) {
|
||||||
|
const response = error.response as
|
||||||
|
| { status?: number; data?: { errors?: { password?: string[] } } }
|
||||||
|
| undefined;
|
||||||
|
if (response?.status === 422) {
|
||||||
|
passwordError.value = response.data?.errors?.password?.[0] ?? 'Invalid password.';
|
||||||
|
}
|
||||||
|
}
|
||||||
processing.value = false;
|
processing.value = false;
|
||||||
|
passwordInput.value?.focus();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const closeModal = () => {
|
||||||
|
confirmingTeamDeletion.value = false;
|
||||||
|
password.value = '';
|
||||||
|
passwordError.value = '';
|
||||||
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
@@ -52,20 +74,30 @@ const deleteTeam = async () => {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Delete Organization Confirmation Modal -->
|
<!-- Delete Organization Confirmation Modal -->
|
||||||
<ConfirmationModal
|
<DialogModal :show="confirmingTeamDeletion" @close="closeModal">
|
||||||
:show="confirmingTeamDeletion"
|
|
||||||
@close="confirmingTeamDeletion = false">
|
|
||||||
<template #title> Delete Organization </template>
|
<template #title> Delete Organization </template>
|
||||||
|
|
||||||
<template #content>
|
<template #content>
|
||||||
Are you sure you want to delete this organization? Once a organization is
|
Are you sure you want to delete this organization? Once a organization is
|
||||||
deleted, all of its resources and data will be permanently deleted.
|
deleted, all of its resources and data will be permanently deleted. Please enter
|
||||||
|
your password to confirm you would like to permanently delete this organization.
|
||||||
|
|
||||||
|
<Field class="mt-4">
|
||||||
|
<TextInput
|
||||||
|
ref="passwordInput"
|
||||||
|
v-model="password"
|
||||||
|
type="password"
|
||||||
|
class="block w-3/4"
|
||||||
|
placeholder="Password"
|
||||||
|
autocomplete="current-password"
|
||||||
|
@keyup.enter="deleteTeam" />
|
||||||
|
|
||||||
|
<FieldError v-if="passwordError">{{ passwordError }}</FieldError>
|
||||||
|
</Field>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<template #footer>
|
<template #footer>
|
||||||
<SecondaryButton @click="confirmingTeamDeletion = false">
|
<SecondaryButton @click="closeModal"> Cancel </SecondaryButton>
|
||||||
Cancel
|
|
||||||
</SecondaryButton>
|
|
||||||
|
|
||||||
<DangerButton
|
<DangerButton
|
||||||
class="ms-3"
|
class="ms-3"
|
||||||
@@ -75,7 +107,7 @@ const deleteTeam = async () => {
|
|||||||
Delete Organization
|
Delete Organization
|
||||||
</DangerButton>
|
</DangerButton>
|
||||||
</template>
|
</template>
|
||||||
</ConfirmationModal>
|
</DialogModal>
|
||||||
</template>
|
</template>
|
||||||
</ActionSection>
|
</ActionSection>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -43,17 +43,17 @@ onMounted(async () => {
|
|||||||
<template v-else>
|
<template v-else>
|
||||||
<UpdateTeamNameForm :team="team" :permissions="permissions" />
|
<UpdateTeamNameForm :team="team" :permissions="permissions" />
|
||||||
|
|
||||||
<SectionBorder />
|
<SectionBorder v-if="permissions.canUpdateTeam" />
|
||||||
<OrganizationBillableRate v-if="permissions.canUpdateTeam" :team="team" />
|
<OrganizationBillableRate v-if="permissions.canUpdateTeam" :team="team" />
|
||||||
<SectionBorder />
|
|
||||||
|
|
||||||
|
<SectionBorder v-if="permissions.canUpdateTeam" />
|
||||||
<OrganizationFormatSettings v-if="permissions.canUpdateTeam" :team="team" />
|
<OrganizationFormatSettings v-if="permissions.canUpdateTeam" :team="team" />
|
||||||
<SectionBorder />
|
|
||||||
|
|
||||||
|
<SectionBorder v-if="permissions.canUpdateTeam" />
|
||||||
<OrganizationTimeEntrySettings v-if="permissions.canUpdateTeam" />
|
<OrganizationTimeEntrySettings v-if="permissions.canUpdateTeam" />
|
||||||
<SectionBorder />
|
|
||||||
|
|
||||||
<template v-if="permissions.canDeleteTeam">
|
<template v-if="permissions.canDeleteTeam">
|
||||||
|
<SectionBorder />
|
||||||
<DeleteTeamForm class="mt-10 sm:mt-0" :team="team" />
|
<DeleteTeamForm class="mt-10 sm:mt-0" :team="team" />
|
||||||
</template>
|
</template>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -90,7 +90,12 @@ const weekRangeDisplay = computed(() => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// ── Cell / row mutation handlers ──────────────────────────────────
|
// ── Cell / row mutation handlers ──────────────────────────────────
|
||||||
const { handleCellUpdate } = useTimesheetCellMutations(weekDays, timeEntries, rows, removeSlot);
|
const { handleCellUpdate, cellStatus, cellPendingSeconds } = useTimesheetCellMutations(
|
||||||
|
weekDays,
|
||||||
|
timeEntries,
|
||||||
|
rows,
|
||||||
|
removeSlot
|
||||||
|
);
|
||||||
|
|
||||||
const { handleRowIdentityChange, handleAddRow } = useTimesheetRowMutations(
|
const { handleRowIdentityChange, handleAddRow } = useTimesheetRowMutations(
|
||||||
mutations,
|
mutations,
|
||||||
@@ -167,6 +172,8 @@ async function createTag(name: string): Promise<Tag | undefined> {
|
|||||||
:create-client="createClient"
|
:create-client="createClient"
|
||||||
:create-tag="createTag"
|
:create-tag="createTag"
|
||||||
:format-duration="formatDuration"
|
:format-duration="formatDuration"
|
||||||
|
:cell-statuses="cellStatus"
|
||||||
|
:cell-pending-seconds="cellPendingSeconds"
|
||||||
@remove-row="handleRemoveRow"
|
@remove-row="handleRemoveRow"
|
||||||
@cell-update="handleCellUpdate"
|
@cell-update="handleCellUpdate"
|
||||||
@project-task-change="
|
@project-task-change="
|
||||||
|
|||||||
@@ -10,35 +10,73 @@ import { QueryClient, VueQueryPlugin } from '@tanstack/vue-query';
|
|||||||
import { type DefineComponent } from 'vue';
|
import { type DefineComponent } from 'vue';
|
||||||
import { setupPrefetching } from '@/utils/prefetch';
|
import { setupPrefetching } from '@/utils/prefetch';
|
||||||
|
|
||||||
|
interface ExtensionManifest {
|
||||||
|
name?: string;
|
||||||
|
alias?: string;
|
||||||
|
}
|
||||||
|
|
||||||
const appName = import.meta.env.VITE_APP_NAME || 'Laravel';
|
const appName = import.meta.env.VITE_APP_NAME || 'Laravel';
|
||||||
const pinia = createPinia();
|
const pinia = createPinia();
|
||||||
const queryClient = new QueryClient();
|
const queryClient = new QueryClient();
|
||||||
|
const extensionManifests = import.meta.glob('../../extensions/**/module.json', {
|
||||||
|
eager: true,
|
||||||
|
import: 'default',
|
||||||
|
}) as Record<string, ExtensionManifest>;
|
||||||
|
// BillingPortal is a Vue 2 component and must not be bundled into the Vue 3 app.
|
||||||
|
const extensionPages = import.meta.glob<DefineComponent>([
|
||||||
|
'../../extensions/**/resources/js/Pages/**/*.vue',
|
||||||
|
'!**/BillingPortal.vue',
|
||||||
|
]);
|
||||||
|
const extensionDirectories = Object.entries(extensionManifests).reduce<Record<string, string>>(
|
||||||
|
(directories, [path, manifest]) => {
|
||||||
|
const match = path.match(/^\.\.\/\.\.\/extensions\/([^/]+)\/module\.json$/);
|
||||||
|
const extensionDirectory = match?.[1];
|
||||||
|
|
||||||
|
if (extensionDirectory === undefined) {
|
||||||
|
return directories;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const key of [manifest.name, manifest.alias, extensionDirectory]) {
|
||||||
|
if (typeof key !== 'string' || key === '') {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
directories[key] = extensionDirectory;
|
||||||
|
directories[key.toLowerCase()] = extensionDirectory;
|
||||||
|
}
|
||||||
|
|
||||||
|
return directories;
|
||||||
|
},
|
||||||
|
{}
|
||||||
|
);
|
||||||
|
|
||||||
|
function resolveExtensionDirectory(moduleName: string): string {
|
||||||
|
return (
|
||||||
|
extensionDirectories[moduleName] ??
|
||||||
|
extensionDirectories[moduleName.toLowerCase()] ??
|
||||||
|
moduleName
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
createInertiaApp({
|
createInertiaApp({
|
||||||
title: (title) => `${title} - ${appName}`,
|
title: (title) => `${title} - ${appName}`,
|
||||||
resolve: (name) => {
|
resolve: (name) => {
|
||||||
if (name.includes('Invoicing::')) {
|
// "Module::Page" (both halves present) resolves to that extension's page
|
||||||
const [module, page] = name.split('::');
|
// directory; everything else is a host page under resources/js/Pages.
|
||||||
|
const [module, ...pageSegments] = name.split('::');
|
||||||
|
const page = pageSegments.join('::');
|
||||||
|
|
||||||
const pagePath = module
|
if (module && page) {
|
||||||
? `../../extensions/${module}/resources/js/Pages/${page}.vue`
|
const extensionDirectory = resolveExtensionDirectory(module);
|
||||||
: `./Pages/${page}.vue`;
|
const pagePath = `../../extensions/${extensionDirectory}/resources/js/Pages/${page}.vue`;
|
||||||
|
|
||||||
// BillingPortal is a Vue 2 Component and therefore should not be imported
|
return resolvePageComponent(pagePath, extensionPages);
|
||||||
const pages = module
|
|
||||||
? import.meta.glob<DefineComponent>([
|
|
||||||
'../../extensions/**/resources/js/Pages/*.vue',
|
|
||||||
'!**/BillingPortal.vue',
|
|
||||||
])
|
|
||||||
: import.meta.glob<DefineComponent>('./Pages/**/*.vue');
|
|
||||||
|
|
||||||
return resolvePageComponent(pagePath, pages);
|
|
||||||
} else {
|
|
||||||
return resolvePageComponent(
|
|
||||||
`./Pages/${name}.vue`,
|
|
||||||
import.meta.glob<DefineComponent>('./Pages/**/*.vue')
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return resolvePageComponent(
|
||||||
|
`./Pages/${name}.vue`,
|
||||||
|
import.meta.glob<DefineComponent>('./Pages/**/*.vue')
|
||||||
|
);
|
||||||
},
|
},
|
||||||
setup({ el, App, props, plugin }) {
|
setup({ el, App, props, plugin }) {
|
||||||
const app = createApp({ render: () => h(App, props) });
|
const app = createApp({ render: () => h(App, props) });
|
||||||
|
|||||||
@@ -114,6 +114,8 @@ export type ApiToken = ApiTokenIndexResponse['data'][0];
|
|||||||
|
|
||||||
export type DetailedInvoiceResponse = ZodiosResponseByAlias<SolidTimeApi, 'getInvoice'>;
|
export type DetailedInvoiceResponse = ZodiosResponseByAlias<SolidTimeApi, 'getInvoice'>;
|
||||||
|
|
||||||
|
export type DetailedInvoice = DetailedInvoiceResponse['data'];
|
||||||
|
|
||||||
export type InvoiceIndexEntry = ZodiosResponseByAlias<SolidTimeApi, 'getInvoices'>['data'][0];
|
export type InvoiceIndexEntry = ZodiosResponseByAlias<SolidTimeApi, 'getInvoices'>['data'][0];
|
||||||
|
|
||||||
export type UpdateInvoiceSettings = ZodiosBodyByAlias<SolidTimeApi, 'updateInvoiceSettings'>;
|
export type UpdateInvoiceSettings = ZodiosBodyByAlias<SolidTimeApi, 'updateInvoiceSettings'>;
|
||||||
@@ -124,6 +126,8 @@ export type UpdateInvoiceBody = ZodiosBodyByAlias<SolidTimeApi, 'updateInvoice'>
|
|||||||
|
|
||||||
export type User = ZodiosResponseByAlias<SolidTimeApi, 'getMe'>['data'];
|
export type User = ZodiosResponseByAlias<SolidTimeApi, 'getMe'>['data'];
|
||||||
export type UpdateUserBody = ZodiosBodyByAlias<SolidTimeApi, 'updateUser'>;
|
export type UpdateUserBody = ZodiosBodyByAlias<SolidTimeApi, 'updateUser'>;
|
||||||
|
export type DeleteUserBody = ZodiosBodyByAlias<SolidTimeApi, 'deleteUser'>;
|
||||||
|
export type DeleteOrganizationBody = ZodiosBodyByAlias<SolidTimeApi, 'deleteOrganization'>;
|
||||||
|
|
||||||
const api = createApiClient('/api', { validate: 'none' });
|
const api = createApiClient('/api', { validate: 'none' });
|
||||||
|
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ const ClientStoreRequest = z.object({ name: z.string().min(1).max(255) }).passth
|
|||||||
const ClientUpdateRequest = z
|
const ClientUpdateRequest = z
|
||||||
.object({ name: z.string().min(1).max(255), is_archived: z.boolean().optional() })
|
.object({ name: z.string().min(1).max(255), is_archived: z.boolean().optional() })
|
||||||
.passthrough();
|
.passthrough();
|
||||||
|
const DestroyWithPasswordRequest = z.object({ password: z.string() }).passthrough();
|
||||||
const ImportRequest = z.object({ type: z.string(), data: z.string() }).passthrough();
|
const ImportRequest = z.object({ type: z.string(), data: z.string() }).passthrough();
|
||||||
const InvitationResource = z
|
const InvitationResource = z
|
||||||
.object({ id: z.string(), email: z.string(), role: z.string() })
|
.object({ id: z.string(), email: z.string(), role: z.string() })
|
||||||
@@ -917,6 +918,11 @@ const endpoints = makeApi([
|
|||||||
alias: 'deleteOrganization',
|
alias: 'deleteOrganization',
|
||||||
requestFormat: 'json',
|
requestFormat: 'json',
|
||||||
parameters: [
|
parameters: [
|
||||||
|
{
|
||||||
|
name: 'body',
|
||||||
|
type: 'Body',
|
||||||
|
schema: DestroyWithPasswordRequest,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: 'organization',
|
name: 'organization',
|
||||||
type: 'Path',
|
type: 'Path',
|
||||||
@@ -1963,6 +1969,54 @@ const endpoints = makeApi([
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
method: 'post',
|
||||||
|
path: '/v1/organizations/:organization/invoices/:invoice/copy',
|
||||||
|
alias: 'copyInvoice',
|
||||||
|
requestFormat: 'json',
|
||||||
|
parameters: [
|
||||||
|
{
|
||||||
|
name: 'body',
|
||||||
|
type: 'Body',
|
||||||
|
schema: z.object({ reference: z.string() }).passthrough(),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'organization',
|
||||||
|
type: 'Path',
|
||||||
|
schema: z.string(),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'invoice',
|
||||||
|
type: 'Path',
|
||||||
|
schema: z.string(),
|
||||||
|
},
|
||||||
|
],
|
||||||
|
response: z.object({ data: DetailedInvoiceResource }).passthrough(),
|
||||||
|
errors: [
|
||||||
|
{
|
||||||
|
status: 401,
|
||||||
|
description: `Unauthenticated`,
|
||||||
|
schema: z.object({ message: z.string() }).passthrough(),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
status: 403,
|
||||||
|
description: `Authorization error`,
|
||||||
|
schema: z.object({ message: z.string() }).passthrough(),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
status: 404,
|
||||||
|
description: `Not found`,
|
||||||
|
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(),
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
{
|
{
|
||||||
method: 'get',
|
method: 'get',
|
||||||
path: '/v1/organizations/:organization/invoices/:invoice',
|
path: '/v1/organizations/:organization/invoices/:invoice',
|
||||||
@@ -4594,6 +4648,11 @@ the organization.`,
|
|||||||
description: `This endpoint is independent of the organization.`,
|
description: `This endpoint is independent of the organization.`,
|
||||||
requestFormat: 'json',
|
requestFormat: 'json',
|
||||||
parameters: [
|
parameters: [
|
||||||
|
{
|
||||||
|
name: 'body',
|
||||||
|
type: 'Body',
|
||||||
|
schema: DestroyWithPasswordRequest,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: 'user',
|
name: 'user',
|
||||||
type: 'Path',
|
type: 'Path',
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
|
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
|
||||||
import { ref } from 'vue';
|
import { ref } from 'vue';
|
||||||
import { createPinia, setActivePinia } from 'pinia';
|
import { createPinia, setActivePinia } from 'pinia';
|
||||||
import { useTimesheetCellMutations } from './useTimesheetCellMutations';
|
import { useTimesheetCellMutations, makeCellStatusKey } from './useTimesheetCellMutations';
|
||||||
import { api } from '@/packages/api/src';
|
import { api } from '@/packages/api/src';
|
||||||
import type { TimesheetRow, TimesheetCell } from '@/utils/useTimesheetGrid';
|
import type { TimesheetRow, TimesheetCell } from '@/utils/useTimesheetGrid';
|
||||||
import type { TimeEntry } from '@/packages/api/src';
|
import type { TimeEntry } from '@/packages/api/src';
|
||||||
@@ -549,3 +549,119 @@ describe('useTimesheetCellMutations.handleCellUpdate', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('useTimesheetCellMutations save status', () => {
|
||||||
|
// Timer handles keep old fade-outs from clearing newer status, and
|
||||||
|
// the same-cell saving guard prevents concurrent writes from stale rows.
|
||||||
|
|
||||||
|
it('does not let a stale fade-out timer clear a newer edit on the same cell', async () => {
|
||||||
|
const { cellMutations } = setup([]);
|
||||||
|
const row = buildEmptyRow('p-1');
|
||||||
|
const key = makeCellStatusKey(row.key, 0);
|
||||||
|
|
||||||
|
await cellMutations.handleCellUpdate(row, 0, HOUR);
|
||||||
|
expect(cellMutations.cellStatus.value[key]).toBe('saved');
|
||||||
|
|
||||||
|
// Re-edit the same cell partway through the first "saved" window.
|
||||||
|
vi.advanceTimersByTime(1000);
|
||||||
|
await cellMutations.handleCellUpdate(row, 0, 2 * HOUR);
|
||||||
|
expect(cellMutations.cellPendingSeconds.value[key]).toBe(2 * HOUR);
|
||||||
|
|
||||||
|
// Advance past the FIRST timer's deadline: it must not wipe the newer state.
|
||||||
|
vi.advanceTimersByTime(2000);
|
||||||
|
expect(cellMutations.cellStatus.value[key]).toBe('saved');
|
||||||
|
expect(cellMutations.cellPendingSeconds.value[key]).toBe(2 * HOUR);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('ignores another commit while the same cell is saving', async () => {
|
||||||
|
const { cellMutations } = setup([]);
|
||||||
|
const row = buildEmptyRow('p-1');
|
||||||
|
const key = makeCellStatusKey(row.key, 0);
|
||||||
|
|
||||||
|
let release!: () => void;
|
||||||
|
const gateA = new Promise<void>((res) => {
|
||||||
|
release = () => res();
|
||||||
|
});
|
||||||
|
apiMocks.createTimeEntry.mockImplementationOnce(async () => {
|
||||||
|
await gateA;
|
||||||
|
return { data: { id: 'a' } } as never;
|
||||||
|
});
|
||||||
|
|
||||||
|
const save = cellMutations.handleCellUpdate(row, 0, HOUR);
|
||||||
|
expect(cellMutations.cellStatus.value[key]).toBe('saving');
|
||||||
|
expect(cellMutations.cellPendingSeconds.value[key]).toBe(HOUR);
|
||||||
|
|
||||||
|
// The second commit would be planned from the same stale row, so it is ignored.
|
||||||
|
await cellMutations.handleCellUpdate(row, 0, 2 * HOUR);
|
||||||
|
expect(apiMocks.createTimeEntry).toHaveBeenCalledTimes(1);
|
||||||
|
expect(cellMutations.cellPendingSeconds.value[key]).toBe(HOUR);
|
||||||
|
|
||||||
|
release();
|
||||||
|
await save;
|
||||||
|
expect(cellMutations.cellStatus.value[key]).toBe('saved');
|
||||||
|
expect(cellMutations.cellPendingSeconds.value[key]).toBe(HOUR);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('marks error and drops the optimistic value when the save fails', async () => {
|
||||||
|
const { cellMutations } = setup([]);
|
||||||
|
const row = buildEmptyRow('p-1');
|
||||||
|
const key = makeCellStatusKey(row.key, 0);
|
||||||
|
|
||||||
|
apiMocks.createTimeEntry.mockRejectedValueOnce(new Error('boom'));
|
||||||
|
|
||||||
|
await cellMutations.handleCellUpdate(row, 0, HOUR);
|
||||||
|
|
||||||
|
expect(cellMutations.cellStatus.value[key]).toBe('error');
|
||||||
|
expect(cellMutations.cellPendingSeconds.value[key]).toBeUndefined();
|
||||||
|
expect(addNotification).toHaveBeenCalledWith(
|
||||||
|
'error',
|
||||||
|
'Failed to update timesheet',
|
||||||
|
expect.any(String)
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('marks error and drops the optimistic value when the day is full', async () => {
|
||||||
|
// Block all but the last 2h, then ask for 3h → NoFreeWindowError.
|
||||||
|
const blocker = entry('2026-04-10T00:00:00Z', '2026-04-10T22:00:00Z', { id: 'blocker' });
|
||||||
|
const { cellMutations } = setup([blocker]);
|
||||||
|
const row = buildEmptyRow('p-1');
|
||||||
|
const key = makeCellStatusKey(row.key, 0);
|
||||||
|
|
||||||
|
await cellMutations.handleCellUpdate(row, 0, 3 * HOUR);
|
||||||
|
|
||||||
|
expect(cellMutations.cellStatus.value[key]).toBe('error');
|
||||||
|
expect(cellMutations.cellPendingSeconds.value[key]).toBeUndefined();
|
||||||
|
expect(addNotification).toHaveBeenCalledWith(
|
||||||
|
'error',
|
||||||
|
"This day can't fit any more work",
|
||||||
|
expect.any(String)
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('creates no status when the committed value is unchanged', async () => {
|
||||||
|
const cellEntry = entry('2026-04-10T09:00:00Z', '2026-04-10T10:00:00Z');
|
||||||
|
const { cellMutations } = setup([cellEntry]);
|
||||||
|
const row = buildRow('p-1', [cellEntry]);
|
||||||
|
const key = makeCellStatusKey(row.key, 0);
|
||||||
|
|
||||||
|
await cellMutations.handleCellUpdate(row, 0, HOUR);
|
||||||
|
|
||||||
|
expect(cellMutations.cellStatus.value[key]).toBeUndefined();
|
||||||
|
expect(cellMutations.cellPendingSeconds.value[key]).toBeUndefined();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('tracks save status independently for each cell', async () => {
|
||||||
|
const { cellMutations } = setup([]);
|
||||||
|
const row = buildEmptyRow('p-1');
|
||||||
|
const mondayKey = makeCellStatusKey(row.key, 0);
|
||||||
|
const tuesdayKey = makeCellStatusKey(row.key, 1);
|
||||||
|
|
||||||
|
await cellMutations.handleCellUpdate(row, 0, HOUR);
|
||||||
|
await cellMutations.handleCellUpdate(row, 1, 2 * HOUR);
|
||||||
|
|
||||||
|
expect(cellMutations.cellStatus.value[mondayKey]).toBe('saved');
|
||||||
|
expect(cellMutations.cellStatus.value[tuesdayKey]).toBe('saved');
|
||||||
|
expect(cellMutations.cellPendingSeconds.value[mondayKey]).toBe(HOUR);
|
||||||
|
expect(cellMutations.cellPendingSeconds.value[tuesdayKey]).toBe(2 * HOUR);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import type { Ref } from 'vue';
|
import { ref, type Ref } from 'vue';
|
||||||
import { useQueryClient } from '@tanstack/vue-query';
|
import { useQueryClient } from '@tanstack/vue-query';
|
||||||
import { api, type CreateTimeEntryBody, type TimeEntry } from '@/packages/api/src';
|
import { api, type CreateTimeEntryBody, type TimeEntry } from '@/packages/api/src';
|
||||||
import { formatHumanReadableDuration, getDayJsInstance } from '@/packages/ui/src/utils/time';
|
import { formatHumanReadableDuration, getDayJsInstance } from '@/packages/ui/src/utils/time';
|
||||||
@@ -19,6 +19,17 @@ import {
|
|||||||
type FreeWindow,
|
type FreeWindow,
|
||||||
} from './cellMath';
|
} from './cellMath';
|
||||||
|
|
||||||
|
export type CellSaveStatus = 'saving' | 'saved' | 'error';
|
||||||
|
|
||||||
|
/** Map key for a cell's save state (row + day). */
|
||||||
|
export function makeCellStatusKey(rowKey: TimesheetRowKey, dayIndex: number): string {
|
||||||
|
return `${rowKey}:${dayIndex}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** How long the saved/error state stays visible before fading. */
|
||||||
|
const SAVED_VISIBLE_MS = 2800;
|
||||||
|
const ERROR_VISIBLE_MS = 2500;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Cell-level edit dispatcher. Picks one of four strategies based on
|
* Cell-level edit dispatcher. Picks one of four strategies based on
|
||||||
* the diff between current and requested totals:
|
* the diff between current and requested totals:
|
||||||
@@ -48,15 +59,58 @@ export function useTimesheetCellMutations(
|
|||||||
const queryClient = useQueryClient();
|
const queryClient = useQueryClient();
|
||||||
const notifications = useNotificationsStore();
|
const notifications = useNotificationsStore();
|
||||||
|
|
||||||
|
// Save status + the optimistic value shown while saving, so a saved cell
|
||||||
|
// doesn't flicker back to its old total before the refetch lands.
|
||||||
|
const cellStatus = ref<Record<string, CellSaveStatus>>({});
|
||||||
|
const cellPendingSeconds = ref<Record<string, number>>({});
|
||||||
|
const statusClearTimers: Record<string, ReturnType<typeof setTimeout>> = {};
|
||||||
|
|
||||||
|
function clearStatusTimer(key: string): void {
|
||||||
|
clearTimeout(statusClearTimers[key]);
|
||||||
|
delete statusClearTimers[key];
|
||||||
|
}
|
||||||
|
|
||||||
|
function beginSaving(key: string, seconds: number): void {
|
||||||
|
clearStatusTimer(key);
|
||||||
|
cellPendingSeconds.value[key] = seconds;
|
||||||
|
cellStatus.value[key] = 'saving';
|
||||||
|
}
|
||||||
|
|
||||||
|
function markSaved(key: string): void {
|
||||||
|
clearStatusTimer(key);
|
||||||
|
cellStatus.value[key] = 'saved';
|
||||||
|
statusClearTimers[key] = setTimeout(() => {
|
||||||
|
delete cellStatus.value[key];
|
||||||
|
delete cellPendingSeconds.value[key];
|
||||||
|
delete statusClearTimers[key];
|
||||||
|
}, SAVED_VISIBLE_MS);
|
||||||
|
}
|
||||||
|
|
||||||
|
function markError(key: string): void {
|
||||||
|
clearStatusTimer(key);
|
||||||
|
cellStatus.value[key] = 'error';
|
||||||
|
// Drop the optimistic value so the cell shows server truth after refetch.
|
||||||
|
delete cellPendingSeconds.value[key];
|
||||||
|
statusClearTimers[key] = setTimeout(() => {
|
||||||
|
delete cellStatus.value[key];
|
||||||
|
delete statusClearTimers[key];
|
||||||
|
}, ERROR_VISIBLE_MS);
|
||||||
|
}
|
||||||
|
|
||||||
async function handleCellUpdate(
|
async function handleCellUpdate(
|
||||||
row: TimesheetRow,
|
row: TimesheetRow,
|
||||||
dayIndex: number,
|
dayIndex: number,
|
||||||
newTotalSeconds: number
|
newTotalSeconds: number
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
|
const statusKey = makeCellStatusKey(row.key, dayIndex);
|
||||||
|
if (cellStatus.value[statusKey] === 'saving') return;
|
||||||
|
|
||||||
const cell = row.cells.get(dayIndex);
|
const cell = row.cells.get(dayIndex);
|
||||||
const existingSeconds = cell?.totalSeconds ?? 0;
|
const existingSeconds = cell?.totalSeconds ?? 0;
|
||||||
if (newTotalSeconds === existingSeconds) return;
|
if (newTotalSeconds === existingSeconds) return;
|
||||||
|
|
||||||
|
beginSaving(statusKey, newTotalSeconds);
|
||||||
|
|
||||||
// Capture row state before the mutation: a row that was empty
|
// Capture row state before the mutation: a row that was empty
|
||||||
// and shares identity with another slot collapses after the
|
// and shares identity with another slot collapses after the
|
||||||
// first entry lands, so the entry naturally identity-routes to
|
// first entry lands, so the entry naturally identity-routes to
|
||||||
@@ -74,7 +128,9 @@ export function useTimesheetCellMutations(
|
|||||||
'Another row with the same project, task, billable status and tags already exists.'
|
'Another row with the same project, task, billable status and tags already exists.'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
markSaved(statusKey);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
markError(statusKey);
|
||||||
if (err instanceof NoFreeWindowError) {
|
if (err instanceof NoFreeWindowError) {
|
||||||
const friendlyDuration = formatHumanReadableDuration(
|
const friendlyDuration = formatHumanReadableDuration(
|
||||||
err.requiredSeconds,
|
err.requiredSeconds,
|
||||||
@@ -93,7 +149,6 @@ export function useTimesheetCellMutations(
|
|||||||
'Failed to update timesheet',
|
'Failed to update timesheet',
|
||||||
'Please try again later.'
|
'Please try again later.'
|
||||||
);
|
);
|
||||||
throw err;
|
|
||||||
} finally {
|
} finally {
|
||||||
queryClient.invalidateQueries({ queryKey: ['timeEntries'] });
|
queryClient.invalidateQueries({ queryKey: ['timeEntries'] });
|
||||||
}
|
}
|
||||||
@@ -316,5 +371,5 @@ export function useTimesheetCellMutations(
|
|||||||
return best;
|
return best;
|
||||||
}
|
}
|
||||||
|
|
||||||
return { handleCellUpdate };
|
return { handleCellUpdate, cellStatus, cellPendingSeconds };
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,9 +2,11 @@ import { router } from '@inertiajs/vue3';
|
|||||||
import { initializeStores } from '@/utils/init';
|
import { initializeStores } from '@/utils/init';
|
||||||
import { defineStore } from 'pinia';
|
import { defineStore } from 'pinia';
|
||||||
import { computed, ref } from 'vue';
|
import { computed, ref } from 'vue';
|
||||||
|
import axios from 'axios';
|
||||||
import type {
|
import type {
|
||||||
Organization,
|
Organization,
|
||||||
OrganizationResponse,
|
OrganizationResponse,
|
||||||
|
DeleteOrganizationBody,
|
||||||
UpdateOrganizationBody,
|
UpdateOrganizationBody,
|
||||||
} from '@/packages/api/src';
|
} from '@/packages/api/src';
|
||||||
import { useNotificationsStore } from '@/utils/notification';
|
import { useNotificationsStore } from '@/utils/notification';
|
||||||
@@ -38,7 +40,7 @@ export async function switchOrganization(organizationId: string) {
|
|||||||
|
|
||||||
export const useOrganizationStore = defineStore('organization', () => {
|
export const useOrganizationStore = defineStore('organization', () => {
|
||||||
const organizationResponse = ref<OrganizationResponse | null>(null);
|
const organizationResponse = ref<OrganizationResponse | null>(null);
|
||||||
const { handleApiRequestNotifications } = useNotificationsStore();
|
const { addNotification, handleApiRequestNotifications } = useNotificationsStore();
|
||||||
|
|
||||||
async function fetchOrganization() {
|
async function fetchOrganization() {
|
||||||
const organization = getCurrentOrganizationId();
|
const organization = getCurrentOrganizationId();
|
||||||
@@ -78,17 +80,26 @@ export const useOrganizationStore = defineStore('organization', () => {
|
|||||||
return response?.data ?? null;
|
return response?.data ?? null;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function deleteOrganization(organizationId: string) {
|
async function deleteOrganization(organizationId: string, body: DeleteOrganizationBody) {
|
||||||
await handleApiRequestNotifications(
|
try {
|
||||||
() =>
|
await api.deleteOrganization(body, {
|
||||||
api.deleteOrganization(undefined, {
|
params: {
|
||||||
params: {
|
organization: organizationId,
|
||||||
organization: organizationId,
|
},
|
||||||
},
|
});
|
||||||
}),
|
addNotification('success', 'Organization deleted successfully');
|
||||||
'Organization deleted successfully',
|
} catch (error) {
|
||||||
'Failed to delete organization'
|
if (!axios.isAxiosError(error) || error.response?.status !== 422) {
|
||||||
);
|
addNotification(
|
||||||
|
'error',
|
||||||
|
'Failed to delete organization',
|
||||||
|
axios.isAxiosError(error)
|
||||||
|
? (error.response?.data?.message ?? 'Please try again later.')
|
||||||
|
: 'Please try again later.'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const organization = computed<Organization | null>(() => {
|
const organization = computed<Organization | null>(() => {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { useMutation, useQuery, useQueryClient } from '@tanstack/vue-query';
|
import { useMutation, useQuery, useQueryClient } from '@tanstack/vue-query';
|
||||||
import { computed } from 'vue';
|
import { computed } from 'vue';
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
import { api, type UpdateUserBody, type User } from '@/packages/api/src';
|
import { api, type DeleteUserBody, type UpdateUserBody, type User } from '@/packages/api/src';
|
||||||
import { useNotificationsStore } from '@/utils/notification';
|
import { useNotificationsStore } from '@/utils/notification';
|
||||||
|
|
||||||
const ME_QUERY_KEY = ['me'] as const;
|
const ME_QUERY_KEY = ['me'] as const;
|
||||||
@@ -61,9 +61,9 @@ export function useDeleteUserMutation() {
|
|||||||
const { addNotification } = useNotificationsStore();
|
const { addNotification } = useNotificationsStore();
|
||||||
|
|
||||||
return useMutation({
|
return useMutation({
|
||||||
mutationFn: async (userId: string) => {
|
mutationFn: async ({ userId, body }: { userId: string; body: DeleteUserBody }) => {
|
||||||
try {
|
try {
|
||||||
await api.deleteUser(undefined, { params: { user: userId } });
|
await api.deleteUser(body, { params: { user: userId } });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (!axios.isAxiosError(error) || error.response?.status !== 422) {
|
if (!axios.isAxiosError(error) || error.response?.status !== 422) {
|
||||||
addNotification(
|
addNotification(
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ Route::get('/shared-report', function () {
|
|||||||
|
|
||||||
Route::middleware([
|
Route::middleware([
|
||||||
'auth:web',
|
'auth:web',
|
||||||
|
'auth.session',
|
||||||
'verified',
|
'verified',
|
||||||
])->group(function (): void {
|
])->group(function (): void {
|
||||||
Route::get('/dashboard', [DashboardController::class, 'dashboard'])->name('dashboard');
|
Route::get('/dashboard', [DashboardController::class, 'dashboard'])->name('dashboard');
|
||||||
|
|||||||
@@ -441,7 +441,9 @@ class OrganizationEndpointTest extends ApiEndpointTestAbstract
|
|||||||
Passport::actingAs($data->user);
|
Passport::actingAs($data->user);
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
$response = $this->deleteJson(route('api.v1.organizations.destroy', [$data->organization->getKey()]));
|
$response = $this->deleteJson(route('api.v1.organizations.destroy', [$data->organization->getKey()]), [
|
||||||
|
'password' => 'password',
|
||||||
|
]);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
$response->assertForbidden();
|
$response->assertForbidden();
|
||||||
@@ -456,12 +458,54 @@ class OrganizationEndpointTest extends ApiEndpointTestAbstract
|
|||||||
Passport::actingAs($data->user);
|
Passport::actingAs($data->user);
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
$response = $this->deleteJson(route('api.v1.organizations.destroy', ['not-uuid']));
|
$response = $this->deleteJson(route('api.v1.organizations.destroy', ['not-uuid']), [
|
||||||
|
'password' => 'password',
|
||||||
|
]);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
$response->assertNotFound();
|
$response->assertNotFound();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function test_delete_endpoint_fails_without_password(): void
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
$data = $this->createUserWithPermission([
|
||||||
|
'organizations:delete',
|
||||||
|
]);
|
||||||
|
Passport::actingAs($data->user);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
$response = $this->deleteJson(route('api.v1.organizations.destroy', [$data->organization->getKey()]));
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
$response->assertUnprocessable();
|
||||||
|
$response->assertJsonValidationErrors(['password']);
|
||||||
|
$this->assertDatabaseHas(Organization::class, [
|
||||||
|
'id' => $data->organization->getKey(),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_delete_endpoint_fails_with_wrong_password(): void
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
$data = $this->createUserWithPermission([
|
||||||
|
'organizations:delete',
|
||||||
|
]);
|
||||||
|
Passport::actingAs($data->user);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
$response = $this->deleteJson(route('api.v1.organizations.destroy', [$data->organization->getKey()]), [
|
||||||
|
'password' => 'wrong-password',
|
||||||
|
]);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
$response->assertUnprocessable();
|
||||||
|
$response->assertJsonValidationErrors(['password']);
|
||||||
|
$this->assertDatabaseHas(Organization::class, [
|
||||||
|
'id' => $data->organization->getKey(),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
public function test_delete_endpoint_can_delete_organization(): void
|
public function test_delete_endpoint_can_delete_organization(): void
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
@@ -472,7 +516,9 @@ class OrganizationEndpointTest extends ApiEndpointTestAbstract
|
|||||||
Passport::actingAs($data->user);
|
Passport::actingAs($data->user);
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
$response = $this->deleteJson(route('api.v1.organizations.destroy', [$data->organization->getKey()]));
|
$response = $this->deleteJson(route('api.v1.organizations.destroy', [$data->organization->getKey()]), [
|
||||||
|
'password' => 'password',
|
||||||
|
]);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
$response->assertNoContent();
|
$response->assertNoContent();
|
||||||
|
|||||||
@@ -649,7 +649,9 @@ class UserEndpointTest extends ApiEndpointTestAbstract
|
|||||||
Passport::actingAs($otherData->user);
|
Passport::actingAs($otherData->user);
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
$response = $this->deleteJson(route('api.v1.users.destroy', $data->user->getKey()));
|
$response = $this->deleteJson(route('api.v1.users.destroy', $data->user->getKey()), [
|
||||||
|
'password' => 'password',
|
||||||
|
]);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
$response->assertForbidden();
|
$response->assertForbidden();
|
||||||
@@ -674,13 +676,15 @@ class UserEndpointTest extends ApiEndpointTestAbstract
|
|||||||
Passport::actingAs($data->user);
|
Passport::actingAs($data->user);
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
$response = $this->deleteJson(route('api.v1.users.destroy', 'not-valid'));
|
$response = $this->deleteJson(route('api.v1.users.destroy', 'not-valid'), [
|
||||||
|
'password' => 'password',
|
||||||
|
]);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
$response->assertNotFound();
|
$response->assertNotFound();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_delete_removes_user(): void
|
public function test_delete_fails_without_password(): void
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
$data = $this->createUserWithPermission();
|
$data = $this->createUserWithPermission();
|
||||||
@@ -689,6 +693,40 @@ class UserEndpointTest extends ApiEndpointTestAbstract
|
|||||||
// Act
|
// Act
|
||||||
$response = $this->deleteJson(route('api.v1.users.destroy', $data->user->getKey()));
|
$response = $this->deleteJson(route('api.v1.users.destroy', $data->user->getKey()));
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
$response->assertUnprocessable();
|
||||||
|
$response->assertJsonValidationErrors(['password']);
|
||||||
|
$this->assertDatabaseHas(User::class, ['id' => $data->user->getKey()]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_delete_fails_with_wrong_password(): void
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
$data = $this->createUserWithPermission();
|
||||||
|
Passport::actingAs($data->user);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
$response = $this->deleteJson(route('api.v1.users.destroy', $data->user->getKey()), [
|
||||||
|
'password' => 'wrong-password',
|
||||||
|
]);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
$response->assertUnprocessable();
|
||||||
|
$response->assertJsonValidationErrors(['password']);
|
||||||
|
$this->assertDatabaseHas(User::class, ['id' => $data->user->getKey()]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_delete_removes_user(): void
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
$data = $this->createUserWithPermission();
|
||||||
|
Passport::actingAs($data->user);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
$response = $this->deleteJson(route('api.v1.users.destroy', $data->user->getKey()), [
|
||||||
|
'password' => 'password',
|
||||||
|
]);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
$response->assertNoContent();
|
$response->assertNoContent();
|
||||||
$this->assertDatabaseMissing(User::class, ['id' => $data->user->getKey()]);
|
$this->assertDatabaseMissing(User::class, ['id' => $data->user->getKey()]);
|
||||||
|
|||||||
@@ -4,12 +4,17 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace Tests\Unit\Filament\Resources;
|
namespace Tests\Unit\Filament\Resources;
|
||||||
|
|
||||||
|
use App\Enums\Role;
|
||||||
|
use App\Events\OrganizationInvitationAdding;
|
||||||
use App\Filament\Resources\OrganizationResource;
|
use App\Filament\Resources\OrganizationResource;
|
||||||
|
use App\Mail\OrganizationInvitationMail;
|
||||||
use App\Models\Organization;
|
use App\Models\Organization;
|
||||||
use App\Models\OrganizationInvitation;
|
use App\Models\OrganizationInvitation;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
use App\Service\DeletionService;
|
use App\Service\DeletionService;
|
||||||
use Illuminate\Support\Facades\Config;
|
use Illuminate\Support\Facades\Config;
|
||||||
|
use Illuminate\Support\Facades\Event;
|
||||||
|
use Illuminate\Support\Facades\Mail;
|
||||||
use Livewire\Livewire;
|
use Livewire\Livewire;
|
||||||
use Mockery\MockInterface;
|
use Mockery\MockInterface;
|
||||||
use PHPUnit\Framework\Attributes\UsesClass;
|
use PHPUnit\Framework\Attributes\UsesClass;
|
||||||
@@ -112,4 +117,34 @@ class OrganizationResourceTest extends FilamentTestCase
|
|||||||
$response->assertSuccessful();
|
$response->assertSuccessful();
|
||||||
$response->assertCanSeeTableRecords($organizationInvitations);
|
$response->assertCanSeeTableRecords($organizationInvitations);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function test_can_create_related_invitation(): void
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
Event::fake([
|
||||||
|
OrganizationInvitationAdding::class,
|
||||||
|
]);
|
||||||
|
Mail::fake();
|
||||||
|
$organization = Organization::factory()->create();
|
||||||
|
|
||||||
|
// Act
|
||||||
|
$response = Livewire::test(OrganizationResource\RelationManagers\InvitationsRelationManager::class, [
|
||||||
|
'ownerRecord' => $organization,
|
||||||
|
'pageClass' => OrganizationResource\Pages\EditOrganization::class,
|
||||||
|
])->callTableAction('create', data: [
|
||||||
|
'email' => 'new-user@example.com',
|
||||||
|
'role' => Role::Employee->value,
|
||||||
|
]);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
$response->assertSuccessful();
|
||||||
|
$response->assertHasNoTableActionErrors();
|
||||||
|
$this->assertDatabaseHas(OrganizationInvitation::class, [
|
||||||
|
'organization_id' => $organization->getKey(),
|
||||||
|
'email' => 'new-user@example.com',
|
||||||
|
'role' => Role::Employee->value,
|
||||||
|
]);
|
||||||
|
Event::assertDispatched(OrganizationInvitationAdding::class);
|
||||||
|
Mail::assertQueued(OrganizationInvitationMail::class);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -73,13 +73,14 @@ class EnsureEmailIsVerifiedMiddlewareTest extends MiddlewareTestAbstract
|
|||||||
$response->assertOk();
|
$response->assertOk();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_users_with_unverified_email_can_access_route_in_local_environment(): void
|
public function test_users_with_unverified_email_can_access_route_in_local_environment_if_local_email_verification_is_disabled(): void
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
$user = User::factory()->unverified()->create();
|
$user = User::factory()->unverified()->create();
|
||||||
$route = $this->createTestRoute();
|
$route = $this->createTestRoute();
|
||||||
$this->actingAs($user);
|
$this->actingAs($user);
|
||||||
$this->app->detectEnvironment(fn () => 'local');
|
$this->app->detectEnvironment(fn () => 'local');
|
||||||
|
config(['app.local_email_verification' => false]);
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
$response = $this->get($route);
|
$response = $this->get($route);
|
||||||
@@ -87,4 +88,36 @@ class EnsureEmailIsVerifiedMiddlewareTest extends MiddlewareTestAbstract
|
|||||||
// Assert
|
// Assert
|
||||||
$response->assertOk();
|
$response->assertOk();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function tests_users_with_unverified_email_are_redirected_in_non_local_environment_even_if_local_email_verification_is_disabled(): void
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
$user = User::factory()->unverified()->create();
|
||||||
|
$route = $this->createTestRoute();
|
||||||
|
$this->actingAs($user);
|
||||||
|
$this->assertSame('testing', config('app.env'));
|
||||||
|
config(['app.local_email_verification' => false]);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
$response = $this->get($route);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
$response->assertRedirect(route('verification.notice'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_users_with_unverified_email_are_redirected_in_local_environment_if_local_email_verification_is_enabled(): void
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
$user = User::factory()->unverified()->create();
|
||||||
|
$route = $this->createTestRoute();
|
||||||
|
$this->actingAs($user);
|
||||||
|
$this->app->detectEnvironment(fn () => 'local');
|
||||||
|
config(['app.local_email_verification' => true]);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
$response = $this->get($route);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
$response->assertRedirect(route('verification.notice'));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,8 +5,10 @@ declare(strict_types=1);
|
|||||||
namespace Tests\Unit\Service;
|
namespace Tests\Unit\Service;
|
||||||
|
|
||||||
use App\Enums\Role;
|
use App\Enums\Role;
|
||||||
|
use App\Enums\Weekday;
|
||||||
use App\Models\Member;
|
use App\Models\Member;
|
||||||
use App\Models\Organization;
|
use App\Models\Organization;
|
||||||
|
use App\Models\OrganizationInvitation;
|
||||||
use App\Models\Project;
|
use App\Models\Project;
|
||||||
use App\Models\ProjectMember;
|
use App\Models\ProjectMember;
|
||||||
use App\Models\TimeEntry;
|
use App\Models\TimeEntry;
|
||||||
@@ -135,4 +137,60 @@ class UserServiceTest extends TestCase
|
|||||||
$this->assertSame(Role::Owner->value, $newMember->role);
|
$this->assertSame(Role::Owner->value, $newMember->role);
|
||||||
$this->assertSame($newOrganization->getKey(), $user->currentOrganization->getKey());
|
$this->assertSame($newOrganization->getKey(), $user->currentOrganization->getKey());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function test_create_passwordless_user_joins_accepted_invitation_organization_instead_of_creating_personal_one(): void
|
||||||
|
{
|
||||||
|
// Arrange — an accepted invitation exists for the email (e.g. the user
|
||||||
|
// followed the invite link, then signs up via SSO). Casing differs to
|
||||||
|
// prove the email is normalised before the invitation is matched.
|
||||||
|
$organization = Organization::factory()->create();
|
||||||
|
OrganizationInvitation::factory()
|
||||||
|
->forOrganization($organization)
|
||||||
|
->role(Role::Employee)
|
||||||
|
->accepted()
|
||||||
|
->create([
|
||||||
|
'email' => 'invitee@example.com',
|
||||||
|
]);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
$user = $this->userService->createPasswordlessUser(
|
||||||
|
'Invitee',
|
||||||
|
'Invitee@Example.com',
|
||||||
|
'UTC',
|
||||||
|
Weekday::Monday,
|
||||||
|
null,
|
||||||
|
);
|
||||||
|
|
||||||
|
// Assert — invitation is materialised, no personal organization is created
|
||||||
|
$this->assertNull($user->password);
|
||||||
|
$this->assertDatabaseMissing(OrganizationInvitation::class, [
|
||||||
|
'email' => 'invitee@example.com',
|
||||||
|
]);
|
||||||
|
$user->refresh();
|
||||||
|
$this->assertSame(1, $user->organizations()->count());
|
||||||
|
$this->assertSame($organization->getKey(), $user->organizations()->first()->getKey());
|
||||||
|
$member = Member::whereBelongsTo($user)->whereBelongsTo($organization)->firstOrFail();
|
||||||
|
$this->assertSame(Role::Employee->value, $member->role);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_create_passwordless_user_creates_personal_organization_when_no_invitation_exists(): void
|
||||||
|
{
|
||||||
|
// Act
|
||||||
|
$user = $this->userService->createPasswordlessUser(
|
||||||
|
'Solo User',
|
||||||
|
'solo@example.com',
|
||||||
|
'UTC',
|
||||||
|
Weekday::Monday,
|
||||||
|
null,
|
||||||
|
);
|
||||||
|
|
||||||
|
// Assert — a personal organization is created, owned by the user and set current
|
||||||
|
$user->refresh();
|
||||||
|
$this->assertNull($user->password);
|
||||||
|
$this->assertSame(1, $user->organizations()->count());
|
||||||
|
$organization = $user->organizations()->first();
|
||||||
|
$this->assertTrue($organization->personal_team);
|
||||||
|
$this->assertSame($user->getKey(), $organization->user_id);
|
||||||
|
$this->assertSame($organization->getKey(), $user->currentOrganization->getKey());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ async function getConfig() {
|
|||||||
const additionalPlugins = await collectModulePlugins('extensions');
|
const additionalPlugins = await collectModulePlugins('extensions');
|
||||||
|
|
||||||
return defineConfig({
|
return defineConfig({
|
||||||
|
base: './',
|
||||||
build: {
|
build: {
|
||||||
sourcemap: true, // Source map generation must be turned on
|
sourcemap: true, // Source map generation must be turned on
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user