mirror of
https://github.com/solidtime-io/solidtime.git
synced 2026-08-18 05:02:14 +01:00
Compare commits
23 Commits
feature/fr
...
f32ec59bb5
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f32ec59bb5 | ||
|
|
d2b6be137f | ||
|
|
dc082b2b19 | ||
|
|
82ad8ee316 | ||
|
|
117c3c4b6c | ||
|
|
4c2586936d | ||
|
|
ca843168f6 | ||
|
|
67dcf77635 | ||
|
|
dcd21345b2 | ||
|
|
1f832a24a0 | ||
|
|
07cf3f7405 | ||
|
|
a880ccb32c | ||
|
|
5a41c356d4 | ||
|
|
72bddfba8b | ||
|
|
34a1a89c30 | ||
|
|
77e4d768d4 | ||
|
|
d42e3ffff0 | ||
|
|
4e26c8ad6d | ||
|
|
57794940f1 | ||
|
|
09827d3d83 | ||
|
|
64c5da5223 | ||
|
|
983e6c3815 | ||
|
|
f34b60874e |
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@v6
|
uses: actions/checkout@v4
|
||||||
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@v2"
|
uses: "WyriHaximus/github-action-get-previous-tag@v1"
|
||||||
with:
|
with:
|
||||||
pattern: "v*[0-9].*[0-9].*[0-9]"
|
prefix: "v"
|
||||||
|
|
||||||
- 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@v6
|
uses: actions/checkout@v4
|
||||||
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@v6
|
uses: docker/metadata-action@v5
|
||||||
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@v4
|
uses: docker/login-action@v3
|
||||||
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@v4
|
uses: docker/setup-qemu-action@v3
|
||||||
|
|
||||||
- name: "Set up Docker Buildx"
|
- name: "Set up Docker Buildx"
|
||||||
uses: docker/setup-buildx-action@v4
|
uses: docker/setup-buildx-action@v3
|
||||||
|
|
||||||
- name: "Build and push by digest"
|
- name: "Build and push by digest"
|
||||||
id: build
|
id: build
|
||||||
uses: docker/build-push-action@v7
|
uses: docker/build-push-action@v6
|
||||||
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@v7
|
uses: actions/upload-artifact@v4
|
||||||
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@v8
|
uses: actions/download-artifact@v6
|
||||||
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@v4
|
uses: docker/login-action@v3
|
||||||
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@v4
|
uses: docker/setup-buildx-action@v3
|
||||||
|
|
||||||
- name: "Docker meta"
|
- name: "Docker meta"
|
||||||
id: meta
|
id: meta
|
||||||
uses: docker/metadata-action@v6
|
uses: docker/metadata-action@v5
|
||||||
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@v6
|
uses: actions/checkout@v5
|
||||||
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@v2"
|
uses: "WyriHaximus/github-action-get-previous-tag@v1"
|
||||||
with:
|
with:
|
||||||
pattern: "v*[0-9].*[0-9].*[0-9]"
|
prefix: "v"
|
||||||
|
|
||||||
- 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@v6
|
uses: actions/checkout@v5
|
||||||
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@v6
|
uses: actions/checkout@v5
|
||||||
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@v6
|
uses: actions/checkout@v5
|
||||||
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@v4
|
uses: docker/login-action@v3
|
||||||
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@v6
|
uses: docker/metadata-action@v5
|
||||||
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@v4
|
uses: docker/setup-qemu-action@v3
|
||||||
|
|
||||||
- name: "Set up Docker Buildx"
|
- name: "Set up Docker Buildx"
|
||||||
uses: docker/setup-buildx-action@v4
|
uses: docker/setup-buildx-action@v3
|
||||||
|
|
||||||
- name: "Build and push"
|
- name: "Build and push"
|
||||||
uses: docker/build-push-action@v7
|
uses: docker/build-push-action@v6
|
||||||
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@v6
|
uses: actions/checkout@v5
|
||||||
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@v2"
|
uses: "WyriHaximus/github-action-get-previous-tag@v1"
|
||||||
with:
|
with:
|
||||||
pattern: "v*[0-9].*[0-9].*[0-9]"
|
prefix: "v"
|
||||||
|
|
||||||
- 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@v6
|
uses: docker/metadata-action@v5
|
||||||
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@v4
|
uses: docker/login-action@v3
|
||||||
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@v4
|
uses: docker/login-action@v3
|
||||||
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@v4
|
uses: docker/setup-qemu-action@v3
|
||||||
|
|
||||||
- name: "Set up Docker Buildx"
|
- name: "Set up Docker Buildx"
|
||||||
uses: docker/setup-buildx-action@v4
|
uses: docker/setup-buildx-action@v3
|
||||||
|
|
||||||
- name: "Build and push by digest"
|
- name: "Build and push by digest"
|
||||||
id: build
|
id: build
|
||||||
uses: docker/build-push-action@v7
|
uses: docker/build-push-action@v6
|
||||||
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@v7
|
uses: actions/upload-artifact@v4
|
||||||
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@v8
|
uses: actions/download-artifact@v6
|
||||||
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@v4
|
uses: docker/login-action@v3
|
||||||
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@v4
|
uses: docker/login-action@v3
|
||||||
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@v4
|
uses: docker/setup-buildx-action@v3
|
||||||
|
|
||||||
- name: "Docker meta"
|
- name: "Docker meta"
|
||||||
id: meta
|
id: meta
|
||||||
uses: docker/metadata-action@v6
|
uses: docker/metadata-action@v5
|
||||||
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@v6
|
uses: actions/checkout@v5
|
||||||
|
|
||||||
- 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@v7
|
uses: actions/upload-artifact@v4
|
||||||
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@v6
|
uses: actions/checkout@v5
|
||||||
|
|
||||||
- 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@v6
|
uses: actions/checkout@v5
|
||||||
|
|
||||||
- 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@v6
|
uses: actions/checkout@v5
|
||||||
|
|
||||||
- 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@v6
|
uses: actions/checkout@v5
|
||||||
# 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@v6
|
uses: actions/checkout@v5
|
||||||
# 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@v6
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: "Use Node.js"
|
- name: "Use Node.js"
|
||||||
uses: actions/setup-node@v6
|
uses: actions/setup-node@v4
|
||||||
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@v6
|
uses: actions/checkout@v5
|
||||||
|
|
||||||
- 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@v6
|
uses: actions/checkout@v5
|
||||||
|
|
||||||
- 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@v6
|
uses: actions/checkout@v5
|
||||||
|
|
||||||
- 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@v7.0.0
|
uses: codecov/codecov-action@v5.5.1
|
||||||
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@v6
|
uses: actions/checkout@v5
|
||||||
|
|
||||||
- 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@v6
|
uses: actions/checkout@v5
|
||||||
|
|
||||||
- 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@v7
|
uses: actions/upload-artifact@v4
|
||||||
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@v6
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: "Setup node"
|
- name: "Setup node"
|
||||||
uses: actions/setup-node@v6
|
uses: actions/setup-node@v4
|
||||||
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@v8
|
uses: actions/download-artifact@v4
|
||||||
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@v7
|
uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: playwright-report
|
name: playwright-report
|
||||||
path: playwright-report/
|
path: playwright-report/
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ use Illuminate\Support\Facades\Validator;
|
|||||||
use Illuminate\Validation\ValidationException;
|
use Illuminate\Validation\ValidationException;
|
||||||
use Korridor\LaravelModelValidationRules\Rules\UniqueEloquent;
|
use Korridor\LaravelModelValidationRules\Rules\UniqueEloquent;
|
||||||
use Laravel\Fortify\Contracts\CreatesNewUsers;
|
use Laravel\Fortify\Contracts\CreatesNewUsers;
|
||||||
|
use Laravel\Jetstream\Jetstream;
|
||||||
use Log;
|
use Log;
|
||||||
|
|
||||||
class CreateNewUser implements CreatesNewUsers
|
class CreateNewUser implements CreatesNewUsers
|
||||||
@@ -54,7 +55,7 @@ class CreateNewUser implements CreatesNewUsers
|
|||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
'password' => $this->passwordRules(),
|
'password' => $this->passwordRules(),
|
||||||
'terms' => ['accepted', 'required'],
|
'terms' => Jetstream::hasTermsAndPrivacyPolicyFeature() ? ['accepted', 'required'] : '',
|
||||||
'newsletter_consent' => [
|
'newsletter_consent' => [
|
||||||
'boolean',
|
'boolean',
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -4,9 +4,16 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace App\Actions\Fortify;
|
namespace App\Actions\Fortify;
|
||||||
|
|
||||||
use App\Exceptions\MovedToApiException;
|
use App\Enums\Weekday;
|
||||||
|
use App\Mail\VerifyUpdatedEmailMail;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
|
use Illuminate\Support\Facades\Mail;
|
||||||
|
use Illuminate\Support\Facades\Validator;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
use Illuminate\Validation\Rule;
|
||||||
use Illuminate\Validation\ValidationException;
|
use Illuminate\Validation\ValidationException;
|
||||||
|
use Korridor\LaravelModelValidationRules\Rules\UniqueEloquent;
|
||||||
use Laravel\Fortify\Contracts\UpdatesUserProfileInformation;
|
use Laravel\Fortify\Contracts\UpdatesUserProfileInformation;
|
||||||
|
|
||||||
class UpdateUserProfileInformation implements UpdatesUserProfileInformation
|
class UpdateUserProfileInformation implements UpdatesUserProfileInformation
|
||||||
@@ -20,6 +27,61 @@ class UpdateUserProfileInformation implements UpdatesUserProfileInformation
|
|||||||
*/
|
*/
|
||||||
public function update(User $user, array $input): void
|
public function update(User $user, array $input): void
|
||||||
{
|
{
|
||||||
throw new MovedToApiException;
|
if (isset($input['email']) && is_string($input['email'])) {
|
||||||
|
$input['email'] = Str::lower($input['email']);
|
||||||
|
}
|
||||||
|
|
||||||
|
Validator::make($input, [
|
||||||
|
'name' => [
|
||||||
|
'required',
|
||||||
|
'string',
|
||||||
|
'max:255',
|
||||||
|
],
|
||||||
|
'email' => [
|
||||||
|
'required',
|
||||||
|
'email',
|
||||||
|
'max:255',
|
||||||
|
UniqueEloquent::make(User::class, 'email')->ignore($user->id)->query(function (Builder $query) {
|
||||||
|
/** @var Builder<User> $query */
|
||||||
|
return $query->where('is_placeholder', '=', false);
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
'photo' => [
|
||||||
|
'nullable',
|
||||||
|
'mimes:jpg,jpeg,png',
|
||||||
|
'max:1024',
|
||||||
|
],
|
||||||
|
'timezone' => [
|
||||||
|
'required',
|
||||||
|
'timezone:all',
|
||||||
|
],
|
||||||
|
'week_start' => [
|
||||||
|
'required',
|
||||||
|
Rule::enum(Weekday::class),
|
||||||
|
],
|
||||||
|
])->validateWithBag('updateProfileInformation');
|
||||||
|
|
||||||
|
if (isset($input['photo'])) {
|
||||||
|
$user->updateProfilePhoto($input['photo']);
|
||||||
|
}
|
||||||
|
|
||||||
|
$email = Str::lower((string) $input['email']);
|
||||||
|
|
||||||
|
if ($email !== Str::lower($user->email)) {
|
||||||
|
$user->forceFill([
|
||||||
|
'name' => $input['name'],
|
||||||
|
'pending_email' => $email,
|
||||||
|
'timezone' => $input['timezone'],
|
||||||
|
'week_start' => $input['week_start'],
|
||||||
|
])->save();
|
||||||
|
|
||||||
|
Mail::to($email)->send(new VerifyUpdatedEmailMail($user, $email));
|
||||||
|
} else {
|
||||||
|
$user->forceFill([
|
||||||
|
'name' => $input['name'],
|
||||||
|
'timezone' => $input['timezone'],
|
||||||
|
'week_start' => $input['week_start'],
|
||||||
|
])->save();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
21
app/Actions/Jetstream/AddOrganizationMember.php
Normal file
21
app/Actions/Jetstream/AddOrganizationMember.php
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace App\Actions\Jetstream;
|
||||||
|
|
||||||
|
use App\Exceptions\MovedToApiException;
|
||||||
|
use App\Models\Organization;
|
||||||
|
use App\Models\User;
|
||||||
|
use Laravel\Jetstream\Contracts\AddsTeamMembers;
|
||||||
|
|
||||||
|
class AddOrganizationMember implements AddsTeamMembers
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Add a new team member to the given team.
|
||||||
|
*/
|
||||||
|
public function add(User $owner, Organization $organization, string $email, ?string $role = null): void
|
||||||
|
{
|
||||||
|
throw new MovedToApiException;
|
||||||
|
}
|
||||||
|
}
|
||||||
60
app/Actions/Jetstream/CreateOrganization.php
Normal file
60
app/Actions/Jetstream/CreateOrganization.php
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace App\Actions\Jetstream;
|
||||||
|
|
||||||
|
use App\Events\AfterCreateOrganization;
|
||||||
|
use App\Models\Organization;
|
||||||
|
use App\Models\User;
|
||||||
|
use App\Service\IpLookup\IpLookupServiceContract;
|
||||||
|
use App\Service\OrganizationService;
|
||||||
|
use App\Service\UserService;
|
||||||
|
use Illuminate\Auth\Access\AuthorizationException;
|
||||||
|
use Illuminate\Support\Facades\Gate;
|
||||||
|
use Illuminate\Support\Facades\Validator;
|
||||||
|
use Illuminate\Validation\ValidationException;
|
||||||
|
use Laravel\Jetstream\Contracts\CreatesTeams;
|
||||||
|
use Laravel\Jetstream\Jetstream;
|
||||||
|
|
||||||
|
class CreateOrganization implements CreatesTeams
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Validate and create a new team for the given user.
|
||||||
|
*
|
||||||
|
* @param array<string, string> $input
|
||||||
|
*
|
||||||
|
* @throws AuthorizationException
|
||||||
|
* @throws ValidationException
|
||||||
|
*
|
||||||
|
* @deprecated Use REST endpoint instead
|
||||||
|
*/
|
||||||
|
public function create(User $user, array $input): Organization
|
||||||
|
{
|
||||||
|
Gate::forUser($user)->authorize('create', Jetstream::newTeamModel());
|
||||||
|
|
||||||
|
Validator::make($input, [
|
||||||
|
'name' => ['required', 'string', 'max:255'],
|
||||||
|
])->validateWithBag('createTeam');
|
||||||
|
|
||||||
|
$ipLookupResponse = app(IpLookupServiceContract::class)->lookup(request()->ip());
|
||||||
|
|
||||||
|
$currency = null;
|
||||||
|
if ($ipLookupResponse !== null) {
|
||||||
|
$currency = $ipLookupResponse->currency;
|
||||||
|
}
|
||||||
|
|
||||||
|
$organization = app(OrganizationService::class)->createOrganization(
|
||||||
|
$input['name'],
|
||||||
|
$user,
|
||||||
|
false,
|
||||||
|
$currency
|
||||||
|
);
|
||||||
|
|
||||||
|
app(UserService::class)->switchCurrentOrganization($user, $organization);
|
||||||
|
|
||||||
|
AfterCreateOrganization::dispatch($organization);
|
||||||
|
|
||||||
|
return $organization;
|
||||||
|
}
|
||||||
|
}
|
||||||
23
app/Actions/Jetstream/DeleteOrganization.php
Normal file
23
app/Actions/Jetstream/DeleteOrganization.php
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace App\Actions\Jetstream;
|
||||||
|
|
||||||
|
use App\Models\Organization;
|
||||||
|
use App\Service\DeletionService;
|
||||||
|
use Laravel\Jetstream\Contracts\DeletesTeams;
|
||||||
|
|
||||||
|
class DeleteOrganization implements DeletesTeams
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Delete the given team.
|
||||||
|
*
|
||||||
|
* @deprecated Use REST endpoint instead
|
||||||
|
*/
|
||||||
|
public function delete(Organization $organization): void
|
||||||
|
{
|
||||||
|
/** @see ValidateOrganizationDeletion */
|
||||||
|
app(DeletionService::class)->deleteOrganization($organization);
|
||||||
|
}
|
||||||
|
}
|
||||||
32
app/Actions/Jetstream/DeleteUser.php
Normal file
32
app/Actions/Jetstream/DeleteUser.php
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace App\Actions\Jetstream;
|
||||||
|
|
||||||
|
use App\Exceptions\Api\ApiException;
|
||||||
|
use App\Models\User;
|
||||||
|
use App\Service\DeletionService;
|
||||||
|
use Illuminate\Validation\ValidationException;
|
||||||
|
use Laravel\Jetstream\Contracts\DeletesUsers;
|
||||||
|
|
||||||
|
class DeleteUser implements DeletesUsers
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Delete the given user.
|
||||||
|
*
|
||||||
|
* @throws ValidationException
|
||||||
|
*
|
||||||
|
* @deprecated Use REST endpoint instead
|
||||||
|
*/
|
||||||
|
public function delete(User $user): void
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
app(DeletionService::class)->deleteUser($user);
|
||||||
|
} catch (ApiException $exception) {
|
||||||
|
throw ValidationException::withMessages([
|
||||||
|
'password' => $exception->getTranslatedMessage(),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
24
app/Actions/Jetstream/InviteOrganizationMember.php
Normal file
24
app/Actions/Jetstream/InviteOrganizationMember.php
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace App\Actions\Jetstream;
|
||||||
|
|
||||||
|
use App\Exceptions\MovedToApiException;
|
||||||
|
use App\Models\Organization;
|
||||||
|
use App\Models\User;
|
||||||
|
use Exception;
|
||||||
|
use Laravel\Jetstream\Contracts\InvitesTeamMembers;
|
||||||
|
|
||||||
|
class InviteOrganizationMember implements InvitesTeamMembers
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Invite a new team member to the given team.
|
||||||
|
*
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public function invite(User $user, Organization $organization, string $email, ?string $role = null): void
|
||||||
|
{
|
||||||
|
throw new MovedToApiException;
|
||||||
|
}
|
||||||
|
}
|
||||||
24
app/Actions/Jetstream/RemoveOrganizationMember.php
Normal file
24
app/Actions/Jetstream/RemoveOrganizationMember.php
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace App\Actions\Jetstream;
|
||||||
|
|
||||||
|
use App\Exceptions\MovedToApiException;
|
||||||
|
use App\Models\Organization;
|
||||||
|
use App\Models\User;
|
||||||
|
use Exception;
|
||||||
|
use Laravel\Jetstream\Contracts\RemovesTeamMembers;
|
||||||
|
|
||||||
|
class RemoveOrganizationMember implements RemovesTeamMembers
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Remove the team member from the given team.
|
||||||
|
*
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public function remove(User $user, Organization $organization, User $teamMember): void
|
||||||
|
{
|
||||||
|
throw new MovedToApiException;
|
||||||
|
}
|
||||||
|
}
|
||||||
25
app/Actions/Jetstream/UpdateMemberRole.php
Normal file
25
app/Actions/Jetstream/UpdateMemberRole.php
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace App\Actions\Jetstream;
|
||||||
|
|
||||||
|
use App\Enums\Role;
|
||||||
|
use App\Exceptions\MovedToApiException;
|
||||||
|
use App\Models\Member;
|
||||||
|
use App\Models\Organization;
|
||||||
|
use App\Models\User;
|
||||||
|
use Exception;
|
||||||
|
|
||||||
|
class UpdateMemberRole
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Update the role for the given team member.
|
||||||
|
*
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public function update(User $actingUser, Organization $organization, string $userId, string $role): void
|
||||||
|
{
|
||||||
|
throw new MovedToApiException;
|
||||||
|
}
|
||||||
|
}
|
||||||
48
app/Actions/Jetstream/UpdateOrganization.php
Normal file
48
app/Actions/Jetstream/UpdateOrganization.php
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace App\Actions\Jetstream;
|
||||||
|
|
||||||
|
use App\Models\Organization;
|
||||||
|
use App\Models\User;
|
||||||
|
use App\Rules\CurrencyRule;
|
||||||
|
use Illuminate\Auth\Access\AuthorizationException;
|
||||||
|
use Illuminate\Support\Facades\Gate;
|
||||||
|
use Illuminate\Support\Facades\Validator;
|
||||||
|
use Illuminate\Validation\ValidationException;
|
||||||
|
use Laravel\Jetstream\Contracts\UpdatesTeamNames;
|
||||||
|
|
||||||
|
class UpdateOrganization implements UpdatesTeamNames
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Validate and update the given team's name.
|
||||||
|
*
|
||||||
|
* @param array<string, string> $input
|
||||||
|
*
|
||||||
|
* @throws AuthorizationException
|
||||||
|
* @throws ValidationException
|
||||||
|
*/
|
||||||
|
public function update(User $user, Organization $organization, array $input): void
|
||||||
|
{
|
||||||
|
Gate::forUser($user)->authorize('update', $organization);
|
||||||
|
|
||||||
|
Validator::make($input, [
|
||||||
|
'name' => [
|
||||||
|
'required',
|
||||||
|
'string',
|
||||||
|
'max:255',
|
||||||
|
],
|
||||||
|
'currency' => [
|
||||||
|
'required',
|
||||||
|
'string',
|
||||||
|
new CurrencyRule,
|
||||||
|
],
|
||||||
|
])->validateWithBag('updateTeamName');
|
||||||
|
|
||||||
|
$organization->forceFill([
|
||||||
|
'name' => $input['name'],
|
||||||
|
'currency' => $input['currency'],
|
||||||
|
])->save();
|
||||||
|
}
|
||||||
|
}
|
||||||
30
app/Actions/Jetstream/ValidateOrganizationDeletion.php
Normal file
30
app/Actions/Jetstream/ValidateOrganizationDeletion.php
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace App\Actions\Jetstream;
|
||||||
|
|
||||||
|
use App\Models\Organization;
|
||||||
|
use App\Models\User;
|
||||||
|
use App\Service\PermissionStore;
|
||||||
|
use Illuminate\Auth\Access\AuthorizationException;
|
||||||
|
|
||||||
|
class ValidateOrganizationDeletion
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Validate that the team can be deleted by the given user.
|
||||||
|
*
|
||||||
|
* @param User $user Authenticated user
|
||||||
|
* @param Organization $organization Organization to be deleted
|
||||||
|
*
|
||||||
|
* @throws AuthorizationException
|
||||||
|
*
|
||||||
|
* @deprecated Use REST endpoint instead
|
||||||
|
*/
|
||||||
|
public function validate(User $user, Organization $organization): void
|
||||||
|
{
|
||||||
|
if (! app(PermissionStore::class)->userHas($organization, $user, 'organizations:delete')) {
|
||||||
|
throw new AuthorizationException;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -4,12 +4,8 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace App\Enums;
|
namespace App\Enums;
|
||||||
|
|
||||||
use Datomatic\LaravelEnumHelper\LaravelEnumHelper;
|
|
||||||
|
|
||||||
enum Role: string
|
enum Role: string
|
||||||
{
|
{
|
||||||
use LaravelEnumHelper;
|
|
||||||
|
|
||||||
case Owner = 'owner';
|
case Owner = 'owner';
|
||||||
case Admin = 'admin';
|
case Admin = 'admin';
|
||||||
case Manager = 'manager';
|
case Manager = 'manager';
|
||||||
|
|||||||
@@ -9,9 +9,6 @@ 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,9 +9,6 @@ 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;
|
||||||
|
|||||||
@@ -1,38 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace App\Events;
|
|
||||||
|
|
||||||
use App\Enums\Role;
|
|
||||||
use App\Models\Organization;
|
|
||||||
use App\Models\User;
|
|
||||||
use Illuminate\Foundation\Events\Dispatchable;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Replaces legacy InvitingTeamMember event.
|
|
||||||
*/
|
|
||||||
class OrganizationInvitationAdding
|
|
||||||
{
|
|
||||||
use Dispatchable;
|
|
||||||
|
|
||||||
public Organization $organization;
|
|
||||||
|
|
||||||
public string $email;
|
|
||||||
|
|
||||||
public Role $role;
|
|
||||||
|
|
||||||
public User $inviter;
|
|
||||||
|
|
||||||
public function __construct(
|
|
||||||
Organization $organization,
|
|
||||||
string $email,
|
|
||||||
Role $role,
|
|
||||||
User $inviter
|
|
||||||
) {
|
|
||||||
$this->role = $role;
|
|
||||||
$this->email = $email;
|
|
||||||
$this->organization = $organization;
|
|
||||||
$this->inviter = $inviter;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -64,7 +64,7 @@ class InvitationsRelationManager extends RelationManager
|
|||||||
$ownerRecord = $this->getOwnerRecord();
|
$ownerRecord = $this->getOwnerRecord();
|
||||||
|
|
||||||
return app(InvitationService::class)
|
return app(InvitationService::class)
|
||||||
->inviteUser($ownerRecord, $data['email'], Role::from($data['role']), auth()->user());
|
->inviteUser($ownerRecord, $data['email'], Role::from($data['role']));
|
||||||
}),
|
}),
|
||||||
])
|
])
|
||||||
->actions([
|
->actions([
|
||||||
|
|||||||
@@ -43,8 +43,7 @@ class ClientController extends Controller
|
|||||||
|
|
||||||
$clientsQuery = Client::query()
|
$clientsQuery = Client::query()
|
||||||
->whereBelongsTo($organization, 'organization')
|
->whereBelongsTo($organization, 'organization')
|
||||||
->orderBy('created_at', 'desc')
|
->orderBy('created_at', 'desc');
|
||||||
->orderBy('id');
|
|
||||||
|
|
||||||
if (! $canViewAllClients) {
|
if (! $canViewAllClients) {
|
||||||
$clientsQuery->visibleByEmployee($user);
|
$clientsQuery->visibleByEmployee($user);
|
||||||
|
|||||||
@@ -42,7 +42,6 @@ class InvitationController extends Controller
|
|||||||
|
|
||||||
$invitations = $organization->organizationInvitations()
|
$invitations = $organization->organizationInvitations()
|
||||||
->orderBy('created_at', 'desc')
|
->orderBy('created_at', 'desc')
|
||||||
->orderBy('id')
|
|
||||||
->paginate(config('app.pagination_per_page_default'));
|
->paginate(config('app.pagination_per_page_default'));
|
||||||
|
|
||||||
return InvitationCollection::make($invitations);
|
return InvitationCollection::make($invitations);
|
||||||
@@ -64,7 +63,7 @@ class InvitationController extends Controller
|
|||||||
$email = $request->getEmail();
|
$email = $request->getEmail();
|
||||||
$role = $request->getRole();
|
$role = $request->getRole();
|
||||||
|
|
||||||
$invitationService->inviteUser($organization, $email, $role, $this->user());
|
$invitationService->inviteUser($organization, $email, $role);
|
||||||
|
|
||||||
return response()->json(null, 204);
|
return response()->json(null, 204);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -61,7 +61,6 @@ class MemberController extends Controller
|
|||||||
->whereBelongsTo($organization, 'organization')
|
->whereBelongsTo($organization, 'organization')
|
||||||
->with(['user'])
|
->with(['user'])
|
||||||
->orderBy('created_at', 'desc')
|
->orderBy('created_at', 'desc')
|
||||||
->orderBy('id')
|
|
||||||
->paginate(config('app.pagination_per_page_default'));
|
->paginate(config('app.pagination_per_page_default'));
|
||||||
|
|
||||||
return MemberCollection::make($members);
|
return MemberCollection::make($members);
|
||||||
@@ -193,7 +192,7 @@ class MemberController extends Controller
|
|||||||
throw new ThisPlaceholderCanNotBeInvitedUseTheMergeToolInsteadException;
|
throw new ThisPlaceholderCanNotBeInvitedUseTheMergeToolInsteadException;
|
||||||
}
|
}
|
||||||
|
|
||||||
$invitationService->inviteUser($organization, $user->email, Role::Employee, $this->user());
|
$invitationService->inviteUser($organization, $user->email, Role::Employee);
|
||||||
|
|
||||||
return response()->json(null, 204);
|
return response()->json(null, 204);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ 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;
|
||||||
@@ -51,9 +50,6 @@ class OrganizationController extends Controller
|
|||||||
if ($request->getName() !== null) {
|
if ($request->getName() !== null) {
|
||||||
$organization->name = $request->getName();
|
$organization->name = $request->getName();
|
||||||
}
|
}
|
||||||
if ($request->getCurrency() !== null) {
|
|
||||||
$organization->currency = $request->getCurrency();
|
|
||||||
}
|
|
||||||
if ($request->getEmployeesCanSeeBillableRates() !== null) {
|
if ($request->getEmployeesCanSeeBillableRates() !== null) {
|
||||||
$organization->employees_can_see_billable_rates = $request->getEmployeesCanSeeBillableRates();
|
$organization->employees_can_see_billable_rates = $request->getEmployeesCanSeeBillableRates();
|
||||||
}
|
}
|
||||||
@@ -125,7 +121,7 @@ class OrganizationController extends Controller
|
|||||||
*
|
*
|
||||||
* @throws AuthorizationException
|
* @throws AuthorizationException
|
||||||
*/
|
*/
|
||||||
public function destroy(Organization $organization, OrganizationDestroyRequest $request, DeletionService $deletionService): JsonResponse
|
public function destroy(Organization $organization, DeletionService $deletionService): JsonResponse
|
||||||
{
|
{
|
||||||
$this->checkPermission($organization, 'organizations:delete');
|
$this->checkPermission($organization, 'organizations:delete');
|
||||||
|
|
||||||
|
|||||||
@@ -62,7 +62,6 @@ class ProjectController extends Controller
|
|||||||
|
|
||||||
$projects = $projectsQuery
|
$projects = $projectsQuery
|
||||||
->orderBy('created_at', 'desc')
|
->orderBy('created_at', 'desc')
|
||||||
->orderBy('id')
|
|
||||||
->paginate(config('app.pagination_per_page_default'));
|
->paginate(config('app.pagination_per_page_default'));
|
||||||
|
|
||||||
$showBillableRate = $this->member($organization)->role !== Role::Employee->value || $organization->employees_can_see_billable_rates;
|
$showBillableRate = $this->member($organization)->role !== Role::Employee->value || $organization->employees_can_see_billable_rates;
|
||||||
|
|||||||
@@ -49,7 +49,6 @@ class ProjectMemberController extends Controller
|
|||||||
$projectMembers = ProjectMember::query()
|
$projectMembers = ProjectMember::query()
|
||||||
->whereBelongsTo($project, 'project')
|
->whereBelongsTo($project, 'project')
|
||||||
->orderBy('created_at', 'desc')
|
->orderBy('created_at', 'desc')
|
||||||
->orderBy('id')
|
|
||||||
->paginate(config('app.pagination_per_page_default'));
|
->paginate(config('app.pagination_per_page_default'));
|
||||||
|
|
||||||
return new ProjectMemberCollection($projectMembers);
|
return new ProjectMemberCollection($projectMembers);
|
||||||
|
|||||||
@@ -47,7 +47,6 @@ class ReportController extends Controller
|
|||||||
|
|
||||||
$reports = Report::query()
|
$reports = Report::query()
|
||||||
->orderBy('created_at', 'desc')
|
->orderBy('created_at', 'desc')
|
||||||
->orderBy('id')
|
|
||||||
->whereBelongsTo($organization, 'organization')
|
->whereBelongsTo($organization, 'organization')
|
||||||
->paginate(config('app.pagination_per_page_default'));
|
->paginate(config('app.pagination_per_page_default'));
|
||||||
|
|
||||||
|
|||||||
@@ -42,7 +42,6 @@ class TagController extends Controller
|
|||||||
$tags = Tag::query()
|
$tags = Tag::query()
|
||||||
->whereBelongsTo($organization, 'organization')
|
->whereBelongsTo($organization, 'organization')
|
||||||
->orderBy('created_at', 'desc')
|
->orderBy('created_at', 'desc')
|
||||||
->orderBy('id')
|
|
||||||
->paginate(config('app.pagination_per_page_default'));
|
->paginate(config('app.pagination_per_page_default'));
|
||||||
|
|
||||||
return new TagCollection($tags);
|
return new TagCollection($tags);
|
||||||
|
|||||||
@@ -84,7 +84,6 @@ class TaskController extends Controller
|
|||||||
|
|
||||||
$tasks = $query
|
$tasks = $query
|
||||||
->orderBy('created_at', 'desc')
|
->orderBy('created_at', 'desc')
|
||||||
->orderBy('id')
|
|
||||||
->paginate(config('app.pagination_per_page_default'));
|
->paginate(config('app.pagination_per_page_default'));
|
||||||
|
|
||||||
return new TaskCollection($tasks);
|
return new TaskCollection($tasks);
|
||||||
|
|||||||
@@ -194,8 +194,7 @@ class TimeEntryController extends Controller
|
|||||||
$timeEntriesQuery = TimeEntry::query()
|
$timeEntriesQuery = TimeEntry::query()
|
||||||
->whereBelongsTo($organization, 'organization')
|
->whereBelongsTo($organization, 'organization')
|
||||||
->select($select)
|
->select($select)
|
||||||
->orderBy('time_entries.start', 'desc')
|
->orderBy('start', 'desc');
|
||||||
->orderBy('time_entries.id');
|
|
||||||
|
|
||||||
$filter = new TimeEntryFilter($timeEntriesQuery);
|
$filter = new TimeEntryFilter($timeEntriesQuery);
|
||||||
$filter->addStartFilter($request->input('start'));
|
$filter->addStartFilter($request->input('start'));
|
||||||
|
|||||||
@@ -1,33 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace App\Http\Controllers\Api\V1;
|
|
||||||
|
|
||||||
use App\Service\TimezoneService;
|
|
||||||
use Illuminate\Http\JsonResponse;
|
|
||||||
|
|
||||||
class TimeZoneController extends Controller
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Get all timezones
|
|
||||||
*
|
|
||||||
* @response object{key: string}[]
|
|
||||||
*
|
|
||||||
* @operationId getTimezones
|
|
||||||
*/
|
|
||||||
public function index(): JsonResponse
|
|
||||||
{
|
|
||||||
$timezones = app(TimezoneService::class)->getTimezones();
|
|
||||||
|
|
||||||
$response = [];
|
|
||||||
|
|
||||||
foreach ($timezones as $timezone) {
|
|
||||||
$response[] = (object) [
|
|
||||||
'key' => $timezone,
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
return response()->json($response);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -6,15 +6,11 @@ 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\UserUpdateRequest;
|
use App\Http\Requests\V1\User\UserUpdateRequest;
|
||||||
use App\Http\Resources\V1\User\UserResource;
|
use App\Http\Resources\V1\User\UserResource;
|
||||||
use App\Mail\VerifyUpdatedEmailMail;
|
use App\Mail\VerifyUpdatedEmailMail;
|
||||||
use App\Models\Organization;
|
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
use App\Service\DeletionService;
|
use App\Service\DeletionService;
|
||||||
use App\Service\UserService;
|
|
||||||
use App\Support\Base64File;
|
use App\Support\Base64File;
|
||||||
use Illuminate\Auth\Access\AuthorizationException;
|
use Illuminate\Auth\Access\AuthorizationException;
|
||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
@@ -40,35 +36,6 @@ class UserController extends Controller
|
|||||||
return new UserResource($user);
|
return new UserResource($user);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Update the current organization of the current user
|
|
||||||
*
|
|
||||||
* Switches the organization that the user is currently working in. The user
|
|
||||||
* must be a member of the given organization. This endpoint is independent of
|
|
||||||
* the organization.
|
|
||||||
*
|
|
||||||
* @operationId updateMyCurrentOrganization
|
|
||||||
*
|
|
||||||
* @throws AuthorizationException
|
|
||||||
*/
|
|
||||||
public function updateMyCurrentOrganization(UserUpdateCurrentOrganizationRequest $request, UserService $userService): UserResource
|
|
||||||
{
|
|
||||||
$user = $this->user();
|
|
||||||
|
|
||||||
/** @var Organization|null $organization */
|
|
||||||
$organization = $user->organizations()
|
|
||||||
->whereKey($request->getOrganizationId())
|
|
||||||
->first();
|
|
||||||
|
|
||||||
if ($organization === null) {
|
|
||||||
throw new AuthorizationException;
|
|
||||||
}
|
|
||||||
|
|
||||||
$userService->switchCurrentOrganization($user, $organization);
|
|
||||||
|
|
||||||
return new UserResource($user->refresh());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update the current user
|
* Update the current user
|
||||||
*
|
*
|
||||||
@@ -83,7 +50,7 @@ class UserController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($request->hasPhotoKey()) {
|
if ($request->hasPhotoKey()) {
|
||||||
$photoDisk = (string) config('filesystems.public');
|
$photoDisk = (string) config('jetstream.profile_photo_disk', 'public');
|
||||||
$previousPhotoPath = $user->profile_photo_path;
|
$previousPhotoPath = $user->profile_photo_path;
|
||||||
$newPhoto = $request->getPhoto();
|
$newPhoto = $request->getPhoto();
|
||||||
|
|
||||||
@@ -194,7 +161,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, UserDestroyRequest $request, DeletionService $deletionService): JsonResponse
|
public function destroy(User $user, DeletionService $deletionService): JsonResponse
|
||||||
{
|
{
|
||||||
if ($user->getKey() !== $this->user()->getKey()) {
|
if ($user->getKey() !== $this->user()->getKey()) {
|
||||||
throw new AuthorizationException;
|
throw new AuthorizationException;
|
||||||
|
|||||||
@@ -4,21 +4,4 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace App\Http\Controllers\Web;
|
namespace App\Http\Controllers\Web;
|
||||||
|
|
||||||
use App\Models\Organization;
|
abstract class Controller extends \App\Http\Controllers\Controller {}
|
||||||
use App\Service\PermissionStore;
|
|
||||||
use Illuminate\Auth\Access\AuthorizationException;
|
|
||||||
|
|
||||||
abstract class Controller extends \App\Http\Controllers\Controller
|
|
||||||
{
|
|
||||||
public function __construct(
|
|
||||||
protected PermissionStore $permissionStore,
|
|
||||||
) {}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @throws AuthorizationException
|
|
||||||
*/
|
|
||||||
protected function hasPermission(Organization $organization, string $permission): bool
|
|
||||||
{
|
|
||||||
return $this->permissionStore->has($organization, $permission);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,63 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace App\Http\Controllers\Web;
|
|
||||||
|
|
||||||
use App\Models\Organization;
|
|
||||||
use Brick\Money\Currency;
|
|
||||||
use Brick\Money\ISOCurrencyProvider;
|
|
||||||
use Illuminate\Http\RedirectResponse;
|
|
||||||
use Illuminate\Http\Request;
|
|
||||||
use Illuminate\Support\Str;
|
|
||||||
use Inertia\Inertia;
|
|
||||||
use Inertia\Response;
|
|
||||||
|
|
||||||
class OrganizationController extends Controller
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Show the team creation screen.
|
|
||||||
*/
|
|
||||||
public function create(Request $request): Response
|
|
||||||
{
|
|
||||||
return Inertia::render('Teams/Create');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Show the organizatio details screen.
|
|
||||||
*
|
|
||||||
* @param string $organizationId The organization ID
|
|
||||||
*/
|
|
||||||
public function show(string $organizationId): Response|RedirectResponse
|
|
||||||
{
|
|
||||||
$organization = Str::isUuid($organizationId) ? Organization::find($organizationId) : null;
|
|
||||||
if ($organization === null) {
|
|
||||||
return redirect()->route('dashboard');
|
|
||||||
}
|
|
||||||
if (! $this->hasPermission($organization, 'organizations:view')) {
|
|
||||||
return redirect()->route('dashboard');
|
|
||||||
}
|
|
||||||
|
|
||||||
$owner = $organization->owner;
|
|
||||||
|
|
||||||
return Inertia::render('Teams/Show', [
|
|
||||||
'team' => [
|
|
||||||
'id' => $organization->getKey(),
|
|
||||||
'name' => $organization->name,
|
|
||||||
'currency' => $organization->currency,
|
|
||||||
'owner' => [
|
|
||||||
'id' => $owner->getKey(),
|
|
||||||
'name' => $owner->name,
|
|
||||||
'profile_photo_url' => $owner->profile_photo_url,
|
|
||||||
],
|
|
||||||
],
|
|
||||||
'currencies' => array_map(function (Currency $currency): string {
|
|
||||||
return $currency->getName();
|
|
||||||
}, ISOCurrencyProvider::getInstance()->getAvailableCurrencies()),
|
|
||||||
'permissions' => [
|
|
||||||
'canDeleteTeam' => $this->hasPermission($organization, 'organizations:delete'),
|
|
||||||
'canUpdateTeam' => $this->hasPermission($organization, 'organizations:update'),
|
|
||||||
],
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,54 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace App\Http\Controllers\Web;
|
|
||||||
|
|
||||||
use Illuminate\Contracts\Auth\StatefulGuard;
|
|
||||||
use Illuminate\Http\RedirectResponse;
|
|
||||||
use Illuminate\Http\Request;
|
|
||||||
use Illuminate\Routing\Controller;
|
|
||||||
use Illuminate\Support\Facades\DB;
|
|
||||||
use Illuminate\Validation\ValidationException;
|
|
||||||
use Laravel\Fortify\Actions\ConfirmPassword;
|
|
||||||
|
|
||||||
class OtherBrowserSessionsController extends Controller
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Log the user out of their other browser sessions across all devices.
|
|
||||||
*/
|
|
||||||
public function destroy(Request $request, StatefulGuard $guard): RedirectResponse
|
|
||||||
{
|
|
||||||
$password = (string) $request->string('password');
|
|
||||||
|
|
||||||
$confirmed = app(ConfirmPassword::class)($guard, $request->user(), $password);
|
|
||||||
|
|
||||||
if (! $confirmed) {
|
|
||||||
throw ValidationException::withMessages([
|
|
||||||
'password' => __('The password is incorrect.'),
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
$guard->logoutOtherDevices($password);
|
|
||||||
|
|
||||||
$this->deleteOtherSessionRecords($request);
|
|
||||||
|
|
||||||
return back(303);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Delete the other browser session records from storage.
|
|
||||||
*/
|
|
||||||
protected function deleteOtherSessionRecords(Request $request): void
|
|
||||||
{
|
|
||||||
if (config('session.driver') !== 'database') {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
DB::connection(config('session.connection'))
|
|
||||||
->table(config('session.table', 'sessions'))
|
|
||||||
->where('user_id', $request->user()->getAuthIdentifier())
|
|
||||||
->where('id', '!=', $request->session()->getId())
|
|
||||||
->delete();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,142 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace App\Http\Controllers\Web;
|
|
||||||
|
|
||||||
use App\Enums\Weekday;
|
|
||||||
use App\Service\Dto\UserAgentDto;
|
|
||||||
use App\Service\TimezoneService;
|
|
||||||
use Illuminate\Http\Request;
|
|
||||||
use Illuminate\Routing\Controller;
|
|
||||||
use Illuminate\Support\Carbon;
|
|
||||||
use Illuminate\Support\Facades\Auth;
|
|
||||||
use Illuminate\Support\Facades\DB;
|
|
||||||
use Inertia\Inertia;
|
|
||||||
use Inertia\Response;
|
|
||||||
use Laravel\Fortify\Actions\DisableTwoFactorAuthentication;
|
|
||||||
use Laravel\Fortify\Features;
|
|
||||||
|
|
||||||
class UserProfileController extends Controller
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Validate the two-factor authentication state for the request.
|
|
||||||
*/
|
|
||||||
protected function validateTwoFactorAuthenticationState(Request $request): void
|
|
||||||
{
|
|
||||||
if (! Features::optionEnabled(Features::twoFactorAuthentication(), 'confirm')) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$currentTime = time();
|
|
||||||
|
|
||||||
// Notate totally disabled state in session...
|
|
||||||
if ($this->twoFactorAuthenticationDisabled($request)) {
|
|
||||||
$request->session()->put('two_factor_empty_at', $currentTime);
|
|
||||||
}
|
|
||||||
|
|
||||||
// If was previously totally disabled this session but is now confirming, notate time...
|
|
||||||
if ($this->hasJustBegunConfirmingTwoFactorAuthentication($request)) {
|
|
||||||
$request->session()->put('two_factor_confirming_at', $currentTime);
|
|
||||||
}
|
|
||||||
|
|
||||||
// If the profile is reloaded and is not confirmed but was previously in confirming state, disable...
|
|
||||||
if ($this->neverFinishedConfirmingTwoFactorAuthentication($request, $currentTime)) {
|
|
||||||
app(DisableTwoFactorAuthentication::class)(Auth::user());
|
|
||||||
|
|
||||||
$request->session()->put('two_factor_empty_at', $currentTime);
|
|
||||||
$request->session()->remove('two_factor_confirming_at');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Determine if two-factor authentication is totally disabled.
|
|
||||||
*
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
protected function twoFactorAuthenticationDisabled(Request $request)
|
|
||||||
{
|
|
||||||
return is_null($request->user()->two_factor_secret) &&
|
|
||||||
is_null($request->user()->two_factor_confirmed_at);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Determine if two-factor authentication is just now being confirmed within the last request cycle.
|
|
||||||
*
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
protected function hasJustBegunConfirmingTwoFactorAuthentication(Request $request)
|
|
||||||
{
|
|
||||||
return ! is_null($request->user()->two_factor_secret) &&
|
|
||||||
is_null($request->user()->two_factor_confirmed_at) &&
|
|
||||||
$request->session()->has('two_factor_empty_at') &&
|
|
||||||
is_null($request->session()->get('two_factor_confirming_at'));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Determine if two-factor authentication was never totally confirmed once confirmation started.
|
|
||||||
*
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
protected function neverFinishedConfirmingTwoFactorAuthentication(Request $request, int $currentTime)
|
|
||||||
{
|
|
||||||
return ! array_key_exists('code', $request->session()->getOldInput()) &&
|
|
||||||
is_null($request->user()->two_factor_confirmed_at) &&
|
|
||||||
$request->session()->get('two_factor_confirming_at', 0) !== $currentTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Show the general profile settings screen.
|
|
||||||
*/
|
|
||||||
public function show(Request $request): Response
|
|
||||||
{
|
|
||||||
$this->validateTwoFactorAuthenticationState($request);
|
|
||||||
|
|
||||||
return Inertia::render('Profile/Show', [
|
|
||||||
'timezones' => app(TimezoneService::class)->getSelectOptions(),
|
|
||||||
'weekdays' => Weekday::toSelectArray(),
|
|
||||||
'confirmsTwoFactorAuthentication' => Features::optionEnabled(Features::twoFactorAuthentication(), 'confirm'),
|
|
||||||
'sessions' => $this->sessions($request),
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the current sessions.
|
|
||||||
*
|
|
||||||
* @return array<int, object{agent: array{is_desktop: bool, platform: string|null, browser: string|null}, ip_address: string, is_current_device: bool, last_active: string}&\stdClass>
|
|
||||||
*/
|
|
||||||
public function sessions(Request $request): array
|
|
||||||
{
|
|
||||||
if (config('session.driver') !== 'database') {
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
|
|
||||||
return collect(
|
|
||||||
DB::connection(config('session.connection'))->table(config('session.table', 'sessions'))
|
|
||||||
->where('user_id', $request->user()->getAuthIdentifier())
|
|
||||||
->orderBy('last_activity', 'desc')
|
|
||||||
->get()
|
|
||||||
)->map(function (object $session) use ($request): object {
|
|
||||||
$agent = $this->createAgent(is_string($session->user_agent) ? $session->user_agent : '');
|
|
||||||
|
|
||||||
return (object) [
|
|
||||||
'agent' => [
|
|
||||||
'is_desktop' => $agent->isDesktop(),
|
|
||||||
'platform' => $agent->platform(),
|
|
||||||
'browser' => $agent->browser(),
|
|
||||||
],
|
|
||||||
'ip_address' => is_string($session->ip_address) ? $session->ip_address : '',
|
|
||||||
'is_current_device' => $session->id === $request->session()->getId(),
|
|
||||||
'last_active' => Carbon::createFromTimestamp($session->last_activity)->diffForHumans(),
|
|
||||||
];
|
|
||||||
})->all();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a new agent instance from the given session.
|
|
||||||
*/
|
|
||||||
protected function createAgent(string $userAgent): UserAgentDto
|
|
||||||
{
|
|
||||||
return tap(new UserAgentDto, fn ($agent) => $agent->setUserAgent($userAgent));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -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() || config('app.local_email_verification')) {
|
if (! app()->isLocal()) {
|
||||||
if ($request->user() === null ||
|
if ($request->user() === null ||
|
||||||
(! $request->user()->hasVerifiedEmail())) {
|
(! $request->user()->hasVerifiedEmail())) {
|
||||||
return $request->expectsJson()
|
return $request->expectsJson()
|
||||||
|
|||||||
@@ -9,10 +9,12 @@ use App\Models\User;
|
|||||||
use App\Service\PermissionStore;
|
use App\Service\PermissionStore;
|
||||||
use Closure;
|
use Closure;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Gate;
|
||||||
use Illuminate\Support\Facades\Session;
|
use Illuminate\Support\Facades\Session;
|
||||||
use Illuminate\Support\MessageBag;
|
use Illuminate\Support\MessageBag;
|
||||||
use Inertia\Inertia;
|
use Inertia\Inertia;
|
||||||
use Laravel\Fortify\Features;
|
use Laravel\Fortify\Features;
|
||||||
|
use Laravel\Jetstream\Jetstream;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
|
||||||
class ShareInertiaData
|
class ShareInertiaData
|
||||||
@@ -25,8 +27,27 @@ class ShareInertiaData
|
|||||||
/** @var PermissionStore $permissions */
|
/** @var PermissionStore $permissions */
|
||||||
$permissions = app(PermissionStore::class);
|
$permissions = app(PermissionStore::class);
|
||||||
Inertia::share([
|
Inertia::share([
|
||||||
|
'jetstream' => function () use ($request) {
|
||||||
|
/** @var User|null $user */
|
||||||
|
$user = $request->user();
|
||||||
|
|
||||||
|
return [
|
||||||
|
'canCreateTeams' => $user !== null &&
|
||||||
|
Jetstream::userHasTeamFeatures($user) &&
|
||||||
|
Gate::forUser($user)->check('create', Jetstream::newTeamModel()),
|
||||||
|
'canManageTwoFactorAuthentication' => Features::canManageTwoFactorAuthentication(),
|
||||||
|
'canUpdatePassword' => Features::enabled(Features::updatePasswords()),
|
||||||
|
'canUpdateProfileInformation' => Features::canUpdateProfileInformation(),
|
||||||
|
'hasEmailVerification' => Features::enabled(Features::emailVerification()),
|
||||||
|
'hasAccountDeletionFeatures' => Jetstream::hasAccountDeletionFeatures(),
|
||||||
|
'hasApiFeatures' => Jetstream::hasApiFeatures(),
|
||||||
|
'hasTeamFeatures' => Jetstream::hasTeamFeatures(),
|
||||||
|
'hasTermsAndPrivacyPolicyFeature' => Jetstream::hasTermsAndPrivacyPolicyFeature(),
|
||||||
|
'managesProfilePhotos' => Jetstream::managesProfilePhotos(),
|
||||||
|
];
|
||||||
|
},
|
||||||
'auth' => [
|
'auth' => [
|
||||||
'permissions' => $request->user() !== null && $request->user()->currentOrganization !== null ? $permissions->getPermissions($request->user()->currentOrganization) : [],
|
'permissions' => $request->user() !== null && $request->user()->currentTeam !== null ? $permissions->getPermissions($request->user()->currentTeam) : [],
|
||||||
'user' => function () use ($request): array {
|
'user' => function () use ($request): array {
|
||||||
/** @var User|null $user */
|
/** @var User|null $user */
|
||||||
$user = $request->user();
|
$user = $request->user();
|
||||||
@@ -35,8 +56,6 @@ class ShareInertiaData
|
|||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
$currentOrganization = $user->currentOrganization;
|
|
||||||
|
|
||||||
return array_merge([
|
return array_merge([
|
||||||
'id' => $user->id,
|
'id' => $user->id,
|
||||||
'name' => $user->name,
|
'name' => $user->name,
|
||||||
@@ -49,12 +68,12 @@ class ShareInertiaData
|
|||||||
'profile_photo_url' => $user->profile_photo_url,
|
'profile_photo_url' => $user->profile_photo_url,
|
||||||
'two_factor_enabled' => Features::enabled(Features::twoFactorAuthentication())
|
'two_factor_enabled' => Features::enabled(Features::twoFactorAuthentication())
|
||||||
&& ! is_null($user->two_factor_secret),
|
&& ! is_null($user->two_factor_secret),
|
||||||
'current_team' => $currentOrganization !== null ? [
|
'current_team' => $user->currentTeam !== null ? [
|
||||||
'id' => $currentOrganization->id,
|
'id' => $user->currentTeam->id,
|
||||||
'user_id' => $currentOrganization->user_id,
|
'user_id' => $user->currentTeam->user_id,
|
||||||
'name' => $currentOrganization->name,
|
'name' => $user->currentTeam->name,
|
||||||
'personal_team' => $currentOrganization->personal_team,
|
'personal_team' => $user->currentTeam->personal_team,
|
||||||
'currency' => $currentOrganization->currency,
|
'currency' => $user->currentTeam->currency,
|
||||||
] : null,
|
] : null,
|
||||||
], array_filter([
|
], array_filter([
|
||||||
'all_teams' => $user->organizations->map(function (Organization $organization): array {
|
'all_teams' => $user->organizations->map(function (Organization $organization): array {
|
||||||
|
|||||||
@@ -1,48 +0,0 @@
|
|||||||
<?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.'));
|
|
||||||
}
|
|
||||||
},
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -11,8 +11,6 @@ use App\Enums\NumberFormat;
|
|||||||
use App\Enums\TimeFormat;
|
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 Illuminate\Contracts\Validation\ValidationRule;
|
|
||||||
use Illuminate\Validation\Rule;
|
use Illuminate\Validation\Rule;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -23,7 +21,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|ValidationRule>>
|
* @return array<string, array<string|\Illuminate\Contracts\Validation\Rule>>
|
||||||
*/
|
*/
|
||||||
public function rules(): array
|
public function rules(): array
|
||||||
{
|
{
|
||||||
@@ -32,10 +30,6 @@ class OrganizationUpdateRequest extends BaseFormRequest
|
|||||||
'string',
|
'string',
|
||||||
'max:255',
|
'max:255',
|
||||||
],
|
],
|
||||||
'currency' => [
|
|
||||||
'string',
|
|
||||||
new CurrencyRule,
|
|
||||||
],
|
|
||||||
'billable_rate' => array_merge(
|
'billable_rate' => array_merge(
|
||||||
[
|
[
|
||||||
'nullable',
|
'nullable',
|
||||||
@@ -74,11 +68,6 @@ class OrganizationUpdateRequest extends BaseFormRequest
|
|||||||
return $this->has('name') ? (string) $this->input('name') : null;
|
return $this->has('name') ? (string) $this->input('name') : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getCurrency(): ?string
|
|
||||||
{
|
|
||||||
return $this->has('currency') ? (string) $this->input('currency') : null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getNumberFormat(): ?NumberFormat
|
public function getNumberFormat(): ?NumberFormat
|
||||||
{
|
{
|
||||||
return $this->has('number_format') ? NumberFormat::from($this->input('number_format')) : null;
|
return $this->has('number_format') ? NumberFormat::from($this->input('number_format')) : null;
|
||||||
|
|||||||
@@ -1,48 +0,0 @@
|
|||||||
<?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.'));
|
|
||||||
}
|
|
||||||
},
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace App\Http\Requests\V1\User;
|
|
||||||
|
|
||||||
use App\Http\Requests\V1\BaseFormRequest;
|
|
||||||
use Illuminate\Contracts\Validation\ValidationRule;
|
|
||||||
|
|
||||||
class UserUpdateCurrentOrganizationRequest extends BaseFormRequest
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Get the validation rules that apply to the request.
|
|
||||||
*
|
|
||||||
* @return array<string, array<string|ValidationRule>>
|
|
||||||
*/
|
|
||||||
public function rules(): array
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
'organization_id' => [
|
|
||||||
'required',
|
|
||||||
'string',
|
|
||||||
'uuid',
|
|
||||||
],
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getOrganizationId(): string
|
|
||||||
{
|
|
||||||
return (string) $this->input('organization_id');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -9,11 +9,10 @@ use App\Models\Concerns\HasUuids;
|
|||||||
use Database\Factories\MemberFactory;
|
use Database\Factories\MemberFactory;
|
||||||
use Illuminate\Database\Eloquent\Collection;
|
use Illuminate\Database\Eloquent\Collection;
|
||||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
|
||||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||||
use Illuminate\Database\Eloquent\Relations\Pivot;
|
|
||||||
use Illuminate\Support\Carbon;
|
use Illuminate\Support\Carbon;
|
||||||
|
use Laravel\Jetstream\Membership as JetstreamMembership;
|
||||||
use OwenIt\Auditing\Contracts\Auditable as AuditableContract;
|
use OwenIt\Auditing\Contracts\Auditable as AuditableContract;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -31,7 +30,7 @@ use OwenIt\Auditing\Contracts\Auditable as AuditableContract;
|
|||||||
*
|
*
|
||||||
* @method static MemberFactory factory()
|
* @method static MemberFactory factory()
|
||||||
*/
|
*/
|
||||||
class Member extends Pivot implements AuditableContract
|
class Member extends JetstreamMembership implements AuditableContract
|
||||||
{
|
{
|
||||||
use CustomAuditable;
|
use CustomAuditable;
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ use App\Models\Concerns\HasUuids;
|
|||||||
use Database\Factories\OrganizationFactory;
|
use Database\Factories\OrganizationFactory;
|
||||||
use Illuminate\Database\Eloquent\Collection;
|
use Illuminate\Database\Eloquent\Collection;
|
||||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
|
||||||
use Illuminate\Database\Eloquent\ModelNotFoundException;
|
use Illuminate\Database\Eloquent\ModelNotFoundException;
|
||||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||||
@@ -22,6 +21,11 @@ use Illuminate\Database\Eloquent\Relations\HasMany;
|
|||||||
use Illuminate\Database\Eloquent\Relations\Pivot;
|
use Illuminate\Database\Eloquent\Relations\Pivot;
|
||||||
use Illuminate\Support\Carbon;
|
use Illuminate\Support\Carbon;
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
|
use Laravel\Jetstream\Events\TeamCreated;
|
||||||
|
use Laravel\Jetstream\Events\TeamDeleted;
|
||||||
|
use Laravel\Jetstream\Events\TeamUpdated;
|
||||||
|
use Laravel\Jetstream\Team;
|
||||||
|
use Laravel\Jetstream\Team as JetstreamTeam;
|
||||||
use OwenIt\Auditing\Contracts\Auditable as AuditableContract;
|
use OwenIt\Auditing\Contracts\Auditable as AuditableContract;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -49,7 +53,7 @@ use OwenIt\Auditing\Contracts\Auditable as AuditableContract;
|
|||||||
*
|
*
|
||||||
* @method static OrganizationFactory factory()
|
* @method static OrganizationFactory factory()
|
||||||
*/
|
*/
|
||||||
class Organization extends Model implements AuditableContract
|
class Organization extends JetstreamTeam implements AuditableContract
|
||||||
{
|
{
|
||||||
use CustomAuditable;
|
use CustomAuditable;
|
||||||
|
|
||||||
@@ -87,6 +91,17 @@ class Organization extends Model implements AuditableContract
|
|||||||
'personal_team',
|
'personal_team',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The event map for the model.
|
||||||
|
*
|
||||||
|
* @var array<string, class-string>
|
||||||
|
*/
|
||||||
|
protected $dispatchesEvents = [
|
||||||
|
'created' => TeamCreated::class,
|
||||||
|
'updated' => TeamUpdated::class,
|
||||||
|
'deleted' => TeamDeleted::class,
|
||||||
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The model's default values for attributes.
|
* The model's default values for attributes.
|
||||||
*
|
*
|
||||||
@@ -148,13 +163,12 @@ class Organization extends Model implements AuditableContract
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Find a model by its primary key or throw an exception.
|
* This method prevents an unhandled exception when the ID is not a UUID.
|
||||||
|
* Normally this can be fixed with a route pattern, but Jetstream does not use route model binding.
|
||||||
*
|
*
|
||||||
* @param array<int, string> $columns
|
* @param array<string> $columns
|
||||||
*
|
|
||||||
* @throws ModelNotFoundException<Model>
|
|
||||||
*/
|
*/
|
||||||
public static function findOrFail(string $id, array $columns = ['*']): Model
|
public function findOrFail(string $id, array $columns = ['*']): Team
|
||||||
{
|
{
|
||||||
if (! Str::isUuid($id)) {
|
if (! Str::isUuid($id)) {
|
||||||
throw (new ModelNotFoundException)->setModel(
|
throw (new ModelNotFoundException)->setModel(
|
||||||
|
|||||||
@@ -8,9 +8,9 @@ use App\Models\Concerns\CustomAuditable;
|
|||||||
use App\Models\Concerns\HasUuids;
|
use App\Models\Concerns\HasUuids;
|
||||||
use Database\Factories\OrganizationInvitationFactory;
|
use Database\Factories\OrganizationInvitationFactory;
|
||||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
|
||||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||||
use Illuminate\Support\Carbon;
|
use Illuminate\Support\Carbon;
|
||||||
|
use Laravel\Jetstream\TeamInvitation as JetstreamTeamInvitation;
|
||||||
use OwenIt\Auditing\Contracts\Auditable as AuditableContract;
|
use OwenIt\Auditing\Contracts\Auditable as AuditableContract;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -25,7 +25,7 @@ use OwenIt\Auditing\Contracts\Auditable as AuditableContract;
|
|||||||
*
|
*
|
||||||
* @method static OrganizationInvitationFactory factory()
|
* @method static OrganizationInvitationFactory factory()
|
||||||
*/
|
*/
|
||||||
class OrganizationInvitation extends Model implements AuditableContract
|
class OrganizationInvitation extends JetstreamTeamInvitation implements AuditableContract
|
||||||
{
|
{
|
||||||
use CustomAuditable;
|
use CustomAuditable;
|
||||||
|
|
||||||
|
|||||||
@@ -26,6 +26,8 @@ use Illuminate\Notifications\Notifiable;
|
|||||||
use Illuminate\Support\Carbon;
|
use Illuminate\Support\Carbon;
|
||||||
use Illuminate\Support\Facades\Storage;
|
use Illuminate\Support\Facades\Storage;
|
||||||
use Laravel\Fortify\TwoFactorAuthenticatable;
|
use Laravel\Fortify\TwoFactorAuthenticatable;
|
||||||
|
use Laravel\Jetstream\HasProfilePhoto;
|
||||||
|
use Laravel\Jetstream\HasTeams;
|
||||||
use Laravel\Passport\AuthCode;
|
use Laravel\Passport\AuthCode;
|
||||||
use Laravel\Passport\Contracts\OAuthenticatable;
|
use Laravel\Passport\Contracts\OAuthenticatable;
|
||||||
use Laravel\Passport\HasApiTokens;
|
use Laravel\Passport\HasApiTokens;
|
||||||
@@ -44,6 +46,7 @@ use OwenIt\Auditing\Contracts\Auditable as AuditableContract;
|
|||||||
* @property Weekday $week_start
|
* @property Weekday $week_start
|
||||||
* @property string|null $profile_photo_path
|
* @property string|null $profile_photo_path
|
||||||
* @property-read Organization|null $currentOrganization
|
* @property-read Organization|null $currentOrganization
|
||||||
|
* @property-read Organization|null $currentTeam
|
||||||
* @property-read string $profile_photo_url
|
* @property-read string $profile_photo_url
|
||||||
* @property-read Collection<int, Token> $tokens
|
* @property-read Collection<int, Token> $tokens
|
||||||
* @property Carbon|null $created_at
|
* @property Carbon|null $created_at
|
||||||
@@ -68,6 +71,8 @@ class User extends Authenticatable implements AuditableContract, FilamentUser, M
|
|||||||
/** @use HasFactory<UserFactory> */
|
/** @use HasFactory<UserFactory> */
|
||||||
use HasFactory;
|
use HasFactory;
|
||||||
|
|
||||||
|
use HasProfilePhoto;
|
||||||
|
use HasTeams;
|
||||||
use HasUuids;
|
use HasUuids;
|
||||||
use Notifiable;
|
use Notifiable;
|
||||||
use TwoFactorAuthenticatable;
|
use TwoFactorAuthenticatable;
|
||||||
|
|||||||
102
app/Policies/OrganizationPolicy.php
Normal file
102
app/Policies/OrganizationPolicy.php
Normal file
@@ -0,0 +1,102 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace App\Policies;
|
||||||
|
|
||||||
|
use App\Models\Organization;
|
||||||
|
use App\Models\User;
|
||||||
|
use App\Service\PermissionStore;
|
||||||
|
use Filament\Facades\Filament;
|
||||||
|
use Illuminate\Auth\Access\HandlesAuthorization;
|
||||||
|
|
||||||
|
class OrganizationPolicy
|
||||||
|
{
|
||||||
|
use HandlesAuthorization;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine whether the user can view any models.
|
||||||
|
*/
|
||||||
|
public function viewAny(User $user): bool
|
||||||
|
{
|
||||||
|
if (Filament::isServing()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine whether the user can view the model.
|
||||||
|
*/
|
||||||
|
public function view(User $user, Organization $organization): bool
|
||||||
|
{
|
||||||
|
if (Filament::isServing()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $user->isMemberOfOrganization($organization);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine whether the user can create models.
|
||||||
|
*/
|
||||||
|
public function create(User $user): bool
|
||||||
|
{
|
||||||
|
if (Filament::isServing()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine whether the user can update the model.
|
||||||
|
*/
|
||||||
|
public function update(User $user, Organization $organization): bool
|
||||||
|
{
|
||||||
|
if (Filament::isServing()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return app(PermissionStore::class)->userHas($organization, $user, 'organizations:update');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine whether the user can update team member permissions.
|
||||||
|
*/
|
||||||
|
public function updateTeamMember(User $user, Organization $organization): bool
|
||||||
|
{
|
||||||
|
if (Filament::isServing()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Note: since this policy is only used for jetstream endpoints, we can return false here
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine whether the user can remove team members.
|
||||||
|
*/
|
||||||
|
public function removeTeamMember(User $user, Organization $organization): bool
|
||||||
|
{
|
||||||
|
if (Filament::isServing()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Note: since this policy is only used for jetstream endpoints that are no longer in use, we can return false here
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine whether the user can delete the model.
|
||||||
|
*/
|
||||||
|
public function delete(User $user, Organization $organization): bool
|
||||||
|
{
|
||||||
|
if (Filament::isServing()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return app(PermissionStore::class)->userHas($organization, $user, 'organizations:delete');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -4,11 +4,14 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace App\Providers;
|
namespace App\Providers;
|
||||||
|
|
||||||
|
use App\Models\Organization;
|
||||||
use App\Models\Passport\AuthCode;
|
use App\Models\Passport\AuthCode;
|
||||||
use App\Models\Passport\Client;
|
use App\Models\Passport\Client;
|
||||||
use App\Models\Passport\RefreshToken;
|
use App\Models\Passport\RefreshToken;
|
||||||
use App\Models\Passport\Token;
|
use App\Models\Passport\Token;
|
||||||
|
use App\Policies\OrganizationPolicy;
|
||||||
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
|
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
|
||||||
|
use Laravel\Jetstream\Jetstream;
|
||||||
use Laravel\Passport\Passport;
|
use Laravel\Passport\Passport;
|
||||||
|
|
||||||
class AuthServiceProvider extends ServiceProvider
|
class AuthServiceProvider extends ServiceProvider
|
||||||
@@ -19,6 +22,7 @@ class AuthServiceProvider extends ServiceProvider
|
|||||||
* @var array<class-string, class-string>
|
* @var array<class-string, class-string>
|
||||||
*/
|
*/
|
||||||
protected $policies = [
|
protected $policies = [
|
||||||
|
Organization::class => OrganizationPolicy::class,
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -52,5 +56,11 @@ class AuthServiceProvider extends ServiceProvider
|
|||||||
// Passport::tokensExpireIn(now()->addDays(15));
|
// Passport::tokensExpireIn(now()->addDays(15));
|
||||||
// Passport::refreshTokensExpireIn(now()->addDays(30));
|
// Passport::refreshTokensExpireIn(now()->addDays(30));
|
||||||
Passport::personalAccessTokensExpireIn(now()->addMonths(12));
|
Passport::personalAccessTokensExpireIn(now()->addMonths(12));
|
||||||
|
|
||||||
|
// same as passport default above
|
||||||
|
Jetstream::defaultApiTokenPermissions(['read']);
|
||||||
|
|
||||||
|
// use passport scopes for jetstream token permissions
|
||||||
|
Jetstream::permissions(Passport::scopeIds());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,13 +15,12 @@ use Illuminate\Cache\RateLimiting\Limit;
|
|||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Support\Facades\Hash;
|
use Illuminate\Support\Facades\Hash;
|
||||||
use Illuminate\Support\Facades\RateLimiter;
|
use Illuminate\Support\Facades\RateLimiter;
|
||||||
use Illuminate\Support\Facades\Route;
|
|
||||||
use Illuminate\Support\ServiceProvider;
|
use Illuminate\Support\ServiceProvider;
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
use Inertia\Inertia;
|
use Inertia\Inertia;
|
||||||
use Laravel\Fortify\Contracts\LoginResponse as LoginResponseContract;
|
|
||||||
use Laravel\Fortify\Contracts\TwoFactorLoginResponse;
|
use Laravel\Fortify\Contracts\TwoFactorLoginResponse;
|
||||||
use Laravel\Fortify\Fortify;
|
use Laravel\Fortify\Fortify;
|
||||||
|
use Laravel\Fortify\Http\Responses\LoginResponse;
|
||||||
|
|
||||||
class FortifyServiceProvider extends ServiceProvider
|
class FortifyServiceProvider extends ServiceProvider
|
||||||
{
|
{
|
||||||
@@ -51,40 +50,6 @@ class FortifyServiceProvider extends ServiceProvider
|
|||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
Fortify::loginView(function () {
|
|
||||||
return Inertia::render('Auth/Login', [
|
|
||||||
'canResetPassword' => Route::has('password.request'),
|
|
||||||
'status' => session('status'),
|
|
||||||
]);
|
|
||||||
});
|
|
||||||
|
|
||||||
Fortify::requestPasswordResetLinkView(function () {
|
|
||||||
return Inertia::render('Auth/ForgotPassword', [
|
|
||||||
'status' => session('status'),
|
|
||||||
]);
|
|
||||||
});
|
|
||||||
|
|
||||||
Fortify::resetPasswordView(function (Request $request) {
|
|
||||||
return Inertia::render('Auth/ResetPassword', [
|
|
||||||
'email' => $request->input('email'),
|
|
||||||
'token' => $request->route('token'),
|
|
||||||
]);
|
|
||||||
});
|
|
||||||
|
|
||||||
Fortify::verifyEmailView(function () {
|
|
||||||
return Inertia::render('Auth/VerifyEmail', [
|
|
||||||
'status' => session('status'),
|
|
||||||
]);
|
|
||||||
});
|
|
||||||
|
|
||||||
Fortify::twoFactorChallengeView(function () {
|
|
||||||
return Inertia::render('Auth/TwoFactorChallenge');
|
|
||||||
});
|
|
||||||
|
|
||||||
Fortify::confirmPasswordView(function () {
|
|
||||||
return Inertia::render('Auth/ConfirmPassword');
|
|
||||||
});
|
|
||||||
|
|
||||||
Fortify::authenticateUsing(function (Request $request): ?User {
|
Fortify::authenticateUsing(function (Request $request): ?User {
|
||||||
/** @var User|null $user */
|
/** @var User|null $user */
|
||||||
$user = User::query()
|
$user = User::query()
|
||||||
@@ -109,7 +74,7 @@ class FortifyServiceProvider extends ServiceProvider
|
|||||||
return Limit::perMinute(5)->by($request->session()->get('login.id'));
|
return Limit::perMinute(5)->by($request->session()->get('login.id'));
|
||||||
});
|
});
|
||||||
|
|
||||||
$this->app->instance(LoginResponseContract::class, new CustomLoginResponse);
|
$this->app->instance(LoginResponse::class, new CustomLoginResponse);
|
||||||
$this->app->instance(TwoFactorLoginResponse::class, new CustomTwoFactorLoginResponse);
|
$this->app->instance(TwoFactorLoginResponse::class, new CustomTwoFactorLoginResponse);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
113
app/Providers/JetstreamServiceProvider.php
Normal file
113
app/Providers/JetstreamServiceProvider.php
Normal file
@@ -0,0 +1,113 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace App\Providers;
|
||||||
|
|
||||||
|
use App\Actions\Jetstream\AddOrganizationMember;
|
||||||
|
use App\Actions\Jetstream\CreateOrganization;
|
||||||
|
use App\Actions\Jetstream\DeleteOrganization;
|
||||||
|
use App\Actions\Jetstream\DeleteUser;
|
||||||
|
use App\Actions\Jetstream\InviteOrganizationMember;
|
||||||
|
use App\Actions\Jetstream\RemoveOrganizationMember;
|
||||||
|
use App\Actions\Jetstream\UpdateMemberRole;
|
||||||
|
use App\Actions\Jetstream\UpdateOrganization;
|
||||||
|
use App\Actions\Jetstream\ValidateOrganizationDeletion;
|
||||||
|
use App\Enums\Weekday;
|
||||||
|
use App\Models\Member;
|
||||||
|
use App\Models\Organization;
|
||||||
|
use App\Models\OrganizationInvitation;
|
||||||
|
use App\Models\User;
|
||||||
|
use App\Service\PermissionStore;
|
||||||
|
use App\Service\TimezoneService;
|
||||||
|
use Brick\Money\Currency;
|
||||||
|
use Brick\Money\ISOCurrencyProvider;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Gate;
|
||||||
|
use Illuminate\Support\ServiceProvider;
|
||||||
|
use Laravel\Jetstream\Actions\UpdateTeamMemberRole;
|
||||||
|
use Laravel\Jetstream\Actions\ValidateTeamDeletion;
|
||||||
|
use Laravel\Jetstream\Jetstream;
|
||||||
|
|
||||||
|
class JetstreamServiceProvider extends ServiceProvider
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Register any application services.
|
||||||
|
*/
|
||||||
|
public function register(): void
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Bootstrap any application services.
|
||||||
|
*/
|
||||||
|
public function boot(): void
|
||||||
|
{
|
||||||
|
$this->configurePermissions();
|
||||||
|
|
||||||
|
Jetstream::createTeamsUsing(CreateOrganization::class);
|
||||||
|
Jetstream::updateTeamNamesUsing(UpdateOrganization::class);
|
||||||
|
Jetstream::addTeamMembersUsing(AddOrganizationMember::class);
|
||||||
|
Jetstream::inviteTeamMembersUsing(InviteOrganizationMember::class);
|
||||||
|
Jetstream::removeTeamMembersUsing(RemoveOrganizationMember::class);
|
||||||
|
Jetstream::deleteTeamsUsing(DeleteOrganization::class);
|
||||||
|
Jetstream::deleteUsersUsing(DeleteUser::class);
|
||||||
|
Jetstream::useTeamModel(Organization::class);
|
||||||
|
Jetstream::useMembershipModel(Member::class);
|
||||||
|
Jetstream::useTeamInvitationModel(OrganizationInvitation::class);
|
||||||
|
app()->singleton(UpdateTeamMemberRole::class, UpdateMemberRole::class);
|
||||||
|
app()->singleton(ValidateTeamDeletion::class, ValidateOrganizationDeletion::class);
|
||||||
|
Gate::define('removeTeamMember', function (User $user, Organization $team) {
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Configure the roles and permissions that are available within the application.
|
||||||
|
*/
|
||||||
|
protected function configurePermissions(): void
|
||||||
|
{
|
||||||
|
Jetstream::defaultApiTokenPermissions([]);
|
||||||
|
|
||||||
|
foreach (PermissionStore::roleDefinitions() as $role => $definition) {
|
||||||
|
Jetstream::role($role, $definition['name'], $definition['permissions'])
|
||||||
|
->description($definition['description']);
|
||||||
|
}
|
||||||
|
|
||||||
|
Jetstream::inertia()
|
||||||
|
->whenRendering(
|
||||||
|
'Profile/Show',
|
||||||
|
function (Request $request, array $data): array {
|
||||||
|
return array_merge($data, [
|
||||||
|
'timezones' => $this->app->get(TimezoneService::class)->getSelectOptions(),
|
||||||
|
'weekdays' => Weekday::toSelectArray(),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
)
|
||||||
|
->whenRendering(
|
||||||
|
'Teams/Show',
|
||||||
|
function (Request $request, array $data): array {
|
||||||
|
/** @var Organization $teamModel */
|
||||||
|
$teamModel = $data['team'];
|
||||||
|
$owner = $teamModel->owner;
|
||||||
|
|
||||||
|
return array_merge($data, [
|
||||||
|
'team' => [
|
||||||
|
'id' => $teamModel->getKey(),
|
||||||
|
'name' => $teamModel->name,
|
||||||
|
'currency' => $teamModel->currency,
|
||||||
|
'owner' => [
|
||||||
|
'id' => $owner->getKey(),
|
||||||
|
'name' => $owner->name,
|
||||||
|
'profile_photo_url' => $owner->profile_photo_url,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'currencies' => array_map(function (Currency $currency): string {
|
||||||
|
return $currency->getName();
|
||||||
|
}, ISOCurrencyProvider::getInstance()->getAvailableCurrencies()),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,179 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace App\Service\Dto;
|
|
||||||
|
|
||||||
use Closure;
|
|
||||||
use Detection\MobileDetect;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @copyright Originally created by Jens Segers: https://github.com/jenssegers/agent
|
|
||||||
*/
|
|
||||||
class UserAgentDto extends MobileDetect
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* List of additional operating systems.
|
|
||||||
*
|
|
||||||
* @var array<string, string>
|
|
||||||
*/
|
|
||||||
protected static array $additionalOperatingSystems = [
|
|
||||||
'Windows' => 'Windows',
|
|
||||||
'Windows NT' => 'Windows NT',
|
|
||||||
'OS X' => 'Mac OS X',
|
|
||||||
'Debian' => 'Debian',
|
|
||||||
'Ubuntu' => 'Ubuntu',
|
|
||||||
'Macintosh' => 'PPC',
|
|
||||||
'OpenBSD' => 'OpenBSD',
|
|
||||||
'Linux' => 'Linux',
|
|
||||||
'ChromeOS' => 'CrOS',
|
|
||||||
];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* List of additional browsers.
|
|
||||||
*
|
|
||||||
* @var array<string, string>
|
|
||||||
*/
|
|
||||||
protected static array $additionalBrowsers = [
|
|
||||||
'Opera Mini' => 'Opera Mini',
|
|
||||||
'Opera' => 'Opera|OPR',
|
|
||||||
'Edge' => 'Edge|Edg',
|
|
||||||
'Coc Coc' => 'coc_coc_browser',
|
|
||||||
'UCBrowser' => 'UCBrowser',
|
|
||||||
'Vivaldi' => 'Vivaldi',
|
|
||||||
'Chrome' => 'Chrome',
|
|
||||||
'Firefox' => 'Firefox',
|
|
||||||
'Safari' => 'Safari',
|
|
||||||
'IE' => 'MSIE|IEMobile|MSIEMobile|Trident/[.0-9]+',
|
|
||||||
'Netscape' => 'Netscape',
|
|
||||||
'Mozilla' => 'Mozilla',
|
|
||||||
'WeChat' => 'MicroMessenger',
|
|
||||||
];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Key value store for resolved strings.
|
|
||||||
*
|
|
||||||
* @var array<string, mixed>
|
|
||||||
*/
|
|
||||||
protected array $store = [];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the platform name from the User Agent.
|
|
||||||
*/
|
|
||||||
public function platform(): ?string
|
|
||||||
{
|
|
||||||
return $this->retrieveUsingCacheOrResolve('platform', function () {
|
|
||||||
return $this->findDetectionRulesAgainstUserAgent(
|
|
||||||
$this->mergeRules(MobileDetect::getOperatingSystems(), static::$additionalOperatingSystems)
|
|
||||||
);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the browser name from the User Agent.
|
|
||||||
*/
|
|
||||||
public function browser(): ?string
|
|
||||||
{
|
|
||||||
return $this->retrieveUsingCacheOrResolve('browser', function (): ?string {
|
|
||||||
return $this->findDetectionRulesAgainstUserAgent(
|
|
||||||
$this->mergeRules(static::$additionalBrowsers, MobileDetect::getBrowsers())
|
|
||||||
);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Determine if the device is a desktop computer.
|
|
||||||
*/
|
|
||||||
public function isDesktop(): bool
|
|
||||||
{
|
|
||||||
return $this->retrieveUsingCacheOrResolve('desktop', function (): bool {
|
|
||||||
// Check specifically for cloudfront headers if the useragent === 'Amazon CloudFront'
|
|
||||||
if (
|
|
||||||
$this->getUserAgent() === static::$cloudFrontUA
|
|
||||||
&& $this->getHttpHeader('HTTP_CLOUDFRONT_IS_DESKTOP_VIEWER') === 'true'
|
|
||||||
) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return ! $this->isMobile() && ! $this->isTablet();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Match a detection rule and return the matched key.
|
|
||||||
*
|
|
||||||
* @param array<string, string|list<string>> $rules
|
|
||||||
*/
|
|
||||||
protected function findDetectionRulesAgainstUserAgent(array $rules): ?string
|
|
||||||
{
|
|
||||||
$userAgent = $this->getUserAgent();
|
|
||||||
|
|
||||||
foreach ($rules as $key => $regex) {
|
|
||||||
if (is_array($regex)) {
|
|
||||||
$regex = implode('|', $regex);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (empty($regex)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($this->match($regex, $userAgent)) {
|
|
||||||
if ($key !== '') {
|
|
||||||
return $key;
|
|
||||||
}
|
|
||||||
|
|
||||||
$match = reset($this->matchesArray);
|
|
||||||
|
|
||||||
return is_string($match) ? $match : null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieve from the given key from the cache or resolve the value.
|
|
||||||
*
|
|
||||||
* @template TReturn of string|bool|null
|
|
||||||
*
|
|
||||||
* @param Closure():TReturn $callback
|
|
||||||
* @return TReturn
|
|
||||||
*/
|
|
||||||
protected function retrieveUsingCacheOrResolve(string $key, Closure $callback): string|bool|null
|
|
||||||
{
|
|
||||||
$cacheKey = $this->createCacheKey($key);
|
|
||||||
|
|
||||||
if (! is_null($cacheItem = $this->store[$cacheKey] ?? null)) {
|
|
||||||
return $cacheItem;
|
|
||||||
}
|
|
||||||
|
|
||||||
return tap(call_user_func($callback), function ($result) use ($cacheKey): void {
|
|
||||||
$this->store[$cacheKey] = $result;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Merge multiple rules into one array.
|
|
||||||
*
|
|
||||||
* @param array<string, string|list<string>> ...$all
|
|
||||||
* @return array<string, string>
|
|
||||||
*/
|
|
||||||
protected function mergeRules(array ...$all): array
|
|
||||||
{
|
|
||||||
$merged = [];
|
|
||||||
|
|
||||||
foreach ($all as $rules) {
|
|
||||||
foreach ($rules as $key => $value) {
|
|
||||||
$value = is_array($value) ? implode('|', $value) : $value;
|
|
||||||
|
|
||||||
if (empty($merged[$key])) {
|
|
||||||
$merged[$key] = $value;
|
|
||||||
} else {
|
|
||||||
$merged[$key] .= '|'.$value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $merged;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -5,7 +5,6 @@ declare(strict_types=1);
|
|||||||
namespace App\Service\Import\Importers;
|
namespace App\Service\Import\Importers;
|
||||||
|
|
||||||
use Exception;
|
use Exception;
|
||||||
use Illuminate\Support\Carbon;
|
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
use League\Csv\Exception as CsvException;
|
use League\Csv\Exception as CsvException;
|
||||||
use League\Csv\Reader;
|
use League\Csv\Reader;
|
||||||
@@ -25,7 +24,6 @@ class ClockifyProjectsImporter extends DefaultImporter
|
|||||||
$header = $reader->getHeader();
|
$header = $reader->getHeader();
|
||||||
$this->validateHeader($header);
|
$this->validateHeader($header);
|
||||||
$billableRateKey = $this->getBillableRateKey($header);
|
$billableRateKey = $this->getBillableRateKey($header);
|
||||||
$tasksKey = $this->getTasksKey($header);
|
|
||||||
$records = $reader->getRecords();
|
$records = $reader->getRecords();
|
||||||
foreach ($records as $record) {
|
foreach ($records as $record) {
|
||||||
$clientId = null;
|
$clientId = null;
|
||||||
@@ -46,12 +44,11 @@ class ClockifyProjectsImporter extends DefaultImporter
|
|||||||
'is_billable' => $record['Billability'] === 'Yes',
|
'is_billable' => $record['Billability'] === 'Yes',
|
||||||
'billable_rate' => $billableRateKey !== null && $record[$billableRateKey] !== '' ? (int) (((float) $record[$billableRateKey]) * 100) : null,
|
'billable_rate' => $billableRateKey !== null && $record[$billableRateKey] !== '' ? (int) (((float) $record[$billableRateKey]) * 100) : null,
|
||||||
'estimated_time' => $record['Estimated (h)'] !== '' && is_numeric($record['Estimated (h)']) ? (int) ($record['Estimated (h)'] * 3600) : null,
|
'estimated_time' => $record['Estimated (h)'] !== '' && is_numeric($record['Estimated (h)']) ? (int) ($record['Estimated (h)'] * 3600) : null,
|
||||||
'archived_at' => $record['Status'] === 'Archived' ? Carbon::now() : null,
|
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($tasksKey !== null && $record[$tasksKey] !== '') {
|
if ($record['Task'] !== '') {
|
||||||
$tasks = explode(', ', $record[$tasksKey]);
|
$tasks = explode(', ', $record['Task']);
|
||||||
foreach ($tasks as $task) {
|
foreach ($tasks as $task) {
|
||||||
$this->taskImportHelper->getKey([
|
$this->taskImportHelper->getKey([
|
||||||
'name' => $task,
|
'name' => $task,
|
||||||
@@ -84,33 +81,13 @@ class ClockifyProjectsImporter extends DefaultImporter
|
|||||||
'Status',
|
'Status',
|
||||||
'Visibility',
|
'Visibility',
|
||||||
'Billability',
|
'Billability',
|
||||||
|
'Task',
|
||||||
];
|
];
|
||||||
foreach ($requiredFields as $requiredField) {
|
foreach ($requiredFields as $requiredField) {
|
||||||
if (! in_array($requiredField, $header, true)) {
|
if (! in_array($requiredField, $header, true)) {
|
||||||
throw new ImportException('Invalid CSV header, missing field: '.$requiredField);
|
throw new ImportException('Invalid CSV header, missing field: '.$requiredField);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Clockify names the tasks column "Task", "Tasks" or "Activities" depending on the export; accept any.
|
|
||||||
if ($this->getTasksKey($header) === null) {
|
|
||||||
throw new ImportException('Invalid CSV header, missing field: Tasks');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Clockify names the tasks column differently depending on the export
|
|
||||||
* version: "Task" (older), "Tasks" (newer) or "Activities".
|
|
||||||
*
|
|
||||||
* @param array<string> $header
|
|
||||||
*/
|
|
||||||
private function getTasksKey(array $header): ?string
|
|
||||||
{
|
|
||||||
foreach (['Tasks', 'Task', 'Activities'] as $field) {
|
|
||||||
if (in_array($field, $header, true)) {
|
|
||||||
return $field;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -54,7 +54,6 @@ class ClockifyTimeEntriesImporter extends DefaultImporter
|
|||||||
$reader->setEscape('');
|
$reader->setEscape('');
|
||||||
$header = $reader->getHeader();
|
$header = $reader->getHeader();
|
||||||
$this->validateHeader($header);
|
$this->validateHeader($header);
|
||||||
$taskKey = $this->getTaskKey($header);
|
|
||||||
$records = $reader->getRecords();
|
$records = $reader->getRecords();
|
||||||
foreach ($records as $record) {
|
foreach ($records as $record) {
|
||||||
$userId = $this->userImportHelper->getKey([
|
$userId = $this->userImportHelper->getKey([
|
||||||
@@ -97,9 +96,9 @@ class ClockifyTimeEntriesImporter extends DefaultImporter
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
$taskId = null;
|
$taskId = null;
|
||||||
if ($taskKey !== null && $record[$taskKey] !== '') {
|
if ($record['Task'] !== '') {
|
||||||
$taskId = $this->taskImportHelper->getKey([
|
$taskId = $this->taskImportHelper->getKey([
|
||||||
'name' => $record[$taskKey],
|
'name' => $record['Task'],
|
||||||
'project_id' => $projectId,
|
'project_id' => $projectId,
|
||||||
'organization_id' => $this->organization->id,
|
'organization_id' => $this->organization->id,
|
||||||
]);
|
]);
|
||||||
@@ -117,12 +116,10 @@ class ClockifyTimeEntriesImporter extends DefaultImporter
|
|||||||
throw new ImportException('Time entry description is too long');
|
throw new ImportException('Time entry description is too long');
|
||||||
}
|
}
|
||||||
$timeEntry->description = $record['Description'];
|
$timeEntry->description = $record['Description'];
|
||||||
if (isset($record['Billable'])) {
|
if (! in_array($record['Billable'], ['Yes', 'No'], true)) {
|
||||||
if (! in_array($record['Billable'], ['Yes', 'No'], true)) {
|
throw new ImportException('Invalid billable value');
|
||||||
throw new ImportException('Invalid billable value');
|
|
||||||
}
|
|
||||||
$timeEntry->billable = $record['Billable'] === 'Yes';
|
|
||||||
}
|
}
|
||||||
|
$timeEntry->billable = $record['Billable'] === 'Yes';
|
||||||
$timeEntry->tags = $this->getTags($record['Tags']);
|
$timeEntry->tags = $this->getTags($record['Tags']);
|
||||||
$timeEntry->is_imported = true;
|
$timeEntry->is_imported = true;
|
||||||
|
|
||||||
@@ -217,10 +214,12 @@ class ClockifyTimeEntriesImporter extends DefaultImporter
|
|||||||
'Project',
|
'Project',
|
||||||
'Client',
|
'Client',
|
||||||
'Description',
|
'Description',
|
||||||
|
'Task',
|
||||||
'User',
|
'User',
|
||||||
'Group',
|
'Group',
|
||||||
'Email',
|
'Email',
|
||||||
'Tags',
|
'Tags',
|
||||||
|
'Billable',
|
||||||
'Start Date',
|
'Start Date',
|
||||||
'Start Time',
|
'Start Time',
|
||||||
'End Date',
|
'End Date',
|
||||||
@@ -231,26 +230,6 @@ class ClockifyTimeEntriesImporter extends DefaultImporter
|
|||||||
throw new ImportException('Invalid CSV header, missing field: '.$requiredField);
|
throw new ImportException('Invalid CSV header, missing field: '.$requiredField);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Clockify names the task column "Task" or "Activity" depending on the export; accept either.
|
|
||||||
if ($this->getTaskKey($header) === null) {
|
|
||||||
throw new ImportException('Invalid CSV header, missing field: Task');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Clockify names the task column "Task" or "Activity" depending on the export version.
|
|
||||||
*
|
|
||||||
* @param array<string> $header
|
|
||||||
*/
|
|
||||||
private function getTaskKey(array $header): ?string
|
|
||||||
{
|
|
||||||
foreach (['Task', 'Activity'] as $field) {
|
|
||||||
if (in_array($field, $header, true)) {
|
|
||||||
return $field;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[\Override]
|
#[\Override]
|
||||||
|
|||||||
@@ -123,7 +123,6 @@ class TogglDataImporter extends DefaultImporter
|
|||||||
}
|
}
|
||||||
|
|
||||||
foreach ($projects as $project) {
|
foreach ($projects as $project) {
|
||||||
$projectExternalId = $this->guardExternalIdentifier($project->id);
|
|
||||||
$clientId = null;
|
$clientId = null;
|
||||||
if ($project->client_id !== null) {
|
if ($project->client_id !== null) {
|
||||||
$clientId = $this->clientImportHelper->getKeyByExternalIdentifier((string) $project->client_id);
|
$clientId = $this->clientImportHelper->getKeyByExternalIdentifier((string) $project->client_id);
|
||||||
@@ -147,16 +146,16 @@ class TogglDataImporter extends DefaultImporter
|
|||||||
'billable_rate' => $project->rate !== null ? (int) ($project->rate * 100) : null,
|
'billable_rate' => $project->rate !== null ? (int) ($project->rate * 100) : null,
|
||||||
], (string) $project->id);
|
], (string) $project->id);
|
||||||
|
|
||||||
if (! file_exists($temporaryDirectory->path('projects_users/'.$projectExternalId.'.json'))) {
|
if (! file_exists($temporaryDirectory->path('projects_users/'.$project->id.'.json'))) {
|
||||||
throw new ImportException('File "projects_users/'.$projectExternalId.'.json" missing in ZIP');
|
throw new ImportException('File "projects_users/'.$project->id.'.json" missing in ZIP');
|
||||||
}
|
}
|
||||||
$projectMembersFileContent = file_get_contents($temporaryDirectory->path('projects_users/'.$projectExternalId.'.json'));
|
$projectMembersFileContent = file_get_contents($temporaryDirectory->path('projects_users/'.$project->id.'.json'));
|
||||||
if ($projectMembersFileContent === false) {
|
if ($projectMembersFileContent === false) {
|
||||||
throw new ImportException('File "projects_users/'.$projectExternalId.'.json" can not be opened');
|
throw new ImportException('File "projects_users/'.$project->id.'.json" can not be opened');
|
||||||
}
|
}
|
||||||
$projectMembers = json_decode($projectMembersFileContent);
|
$projectMembers = json_decode($projectMembersFileContent);
|
||||||
if ($projectMembers === null) {
|
if ($projectMembers === null) {
|
||||||
throw new ImportException('File "projects_users/'.$projectExternalId.'.json" is empty');
|
throw new ImportException('File "projects_users/'.$project->id.'.json" is empty');
|
||||||
}
|
}
|
||||||
foreach ($projectMembers as $projectMember) {
|
foreach ($projectMembers as $projectMember) {
|
||||||
$userId = $this->userImportHelper->getKeyByExternalIdentifier((string) $projectMember->user_id);
|
$userId = $this->userImportHelper->getKeyByExternalIdentifier((string) $projectMember->user_id);
|
||||||
@@ -171,7 +170,6 @@ class TogglDataImporter extends DefaultImporter
|
|||||||
}
|
}
|
||||||
$projectIds = $this->projectImportHelper->getExternalIds();
|
$projectIds = $this->projectImportHelper->getExternalIds();
|
||||||
foreach ($projectIds as $projectIdExternal) {
|
foreach ($projectIds as $projectIdExternal) {
|
||||||
$projectIdExternal = $this->guardExternalIdentifier($projectIdExternal);
|
|
||||||
if (! file_exists($temporaryDirectory->path('tasks/'.$projectIdExternal.'.json'))) {
|
if (! file_exists($temporaryDirectory->path('tasks/'.$projectIdExternal.'.json'))) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -211,30 +209,6 @@ class TogglDataImporter extends DefaultImporter
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Ensure an externally-sourced identifier can be safely used inside a
|
|
||||||
* filesystem path. The identifiers originate from the untrusted uploaded
|
|
||||||
* ZIP, and Spatie's TemporaryDirectory::path() auto-creates any missing
|
|
||||||
* parent directory of the resolved path, so an unfiltered "../" sequence
|
|
||||||
* would escape the import sandbox and create/probe arbitrary paths on the
|
|
||||||
* host (CWE-22). Toggl identifiers are numeric, so restricting them to a
|
|
||||||
* conservative allow-list rejects traversal without affecting real data.
|
|
||||||
*
|
|
||||||
* @throws ImportException
|
|
||||||
*/
|
|
||||||
private function guardExternalIdentifier(mixed $id): string
|
|
||||||
{
|
|
||||||
if (! is_string($id) && ! is_int($id)) {
|
|
||||||
throw new ImportException('Invalid identifier in import data');
|
|
||||||
}
|
|
||||||
$id = (string) $id;
|
|
||||||
if (preg_match('/^[A-Za-z0-9_-]+$/', $id) !== 1) {
|
|
||||||
throw new ImportException('Invalid identifier in import data');
|
|
||||||
}
|
|
||||||
|
|
||||||
return $id;
|
|
||||||
}
|
|
||||||
|
|
||||||
#[Override]
|
#[Override]
|
||||||
public function getName(): string
|
public function getName(): string
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ declare(strict_types=1);
|
|||||||
namespace App\Service;
|
namespace App\Service;
|
||||||
|
|
||||||
use App\Enums\Role;
|
use App\Enums\Role;
|
||||||
use App\Events\OrganizationInvitationAdding;
|
|
||||||
use App\Exceptions\Api\InvitationForTheEmailAlreadyExistsApiException;
|
use App\Exceptions\Api\InvitationForTheEmailAlreadyExistsApiException;
|
||||||
use App\Exceptions\Api\UserIsAlreadyMemberOfOrganizationApiException;
|
use App\Exceptions\Api\UserIsAlreadyMemberOfOrganizationApiException;
|
||||||
use App\Mail\OrganizationInvitationMail;
|
use App\Mail\OrganizationInvitationMail;
|
||||||
@@ -15,13 +14,14 @@ use App\Models\User;
|
|||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
use Illuminate\Support\Facades\Log;
|
use Illuminate\Support\Facades\Log;
|
||||||
use Illuminate\Support\Facades\Mail;
|
use Illuminate\Support\Facades\Mail;
|
||||||
|
use Laravel\Jetstream\Events\InvitingTeamMember;
|
||||||
|
|
||||||
class InvitationService
|
class InvitationService
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @throws UserIsAlreadyMemberOfOrganizationApiException|InvitationForTheEmailAlreadyExistsApiException
|
* @throws UserIsAlreadyMemberOfOrganizationApiException|InvitationForTheEmailAlreadyExistsApiException
|
||||||
*/
|
*/
|
||||||
public function inviteUser(Organization $organization, string $email, Role $role, User $inviter): OrganizationInvitation
|
public function inviteUser(Organization $organization, string $email, Role $role): OrganizationInvitation
|
||||||
{
|
{
|
||||||
if (app(MemberService::class)->isEmailAlreadyMember($organization, $email)) {
|
if (app(MemberService::class)->isEmailAlreadyMember($organization, $email)) {
|
||||||
throw new UserIsAlreadyMemberOfOrganizationApiException;
|
throw new UserIsAlreadyMemberOfOrganizationApiException;
|
||||||
@@ -34,7 +34,7 @@ class InvitationService
|
|||||||
throw new InvitationForTheEmailAlreadyExistsApiException;
|
throw new InvitationForTheEmailAlreadyExistsApiException;
|
||||||
}
|
}
|
||||||
|
|
||||||
OrganizationInvitationAdding::dispatch($organization, $email, $role, $inviter);
|
InvitingTeamMember::dispatch($organization, $email, $role->value);
|
||||||
|
|
||||||
$invitation = new OrganizationInvitation;
|
$invitation = new OrganizationInvitation;
|
||||||
$invitation->email = $email;
|
$invitation->email = $email;
|
||||||
|
|||||||
@@ -23,6 +23,8 @@ use App\Models\User;
|
|||||||
use Illuminate\Database\Eloquent\Builder;
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\DB;
|
||||||
use InvalidArgumentException;
|
use InvalidArgumentException;
|
||||||
|
use Laravel\Jetstream\Events\AddingTeamMember;
|
||||||
|
use Laravel\Jetstream\Events\TeamMemberAdded;
|
||||||
|
|
||||||
class MemberService
|
class MemberService
|
||||||
{
|
{
|
||||||
@@ -37,6 +39,7 @@ class MemberService
|
|||||||
{
|
{
|
||||||
if (! $asSuperAdmin) {
|
if (! $asSuperAdmin) {
|
||||||
MemberAdding::dispatch($user, $organization, $role);
|
MemberAdding::dispatch($user, $organization, $role);
|
||||||
|
AddingTeamMember::dispatch($organization, $user); // Legacy event
|
||||||
}
|
}
|
||||||
|
|
||||||
$member = new Member;
|
$member = new Member;
|
||||||
@@ -53,6 +56,7 @@ class MemberService
|
|||||||
|
|
||||||
if (! $asSuperAdmin) {
|
if (! $asSuperAdmin) {
|
||||||
MemberAdded::dispatch($member, $organization, $user);
|
MemberAdded::dispatch($member, $organization, $user);
|
||||||
|
TeamMemberAdded::dispatch($organization, $user); // Legacy event
|
||||||
}
|
}
|
||||||
|
|
||||||
return $member;
|
return $member;
|
||||||
|
|||||||
@@ -62,7 +62,6 @@ class UserService
|
|||||||
$intervalFormat,
|
$intervalFormat,
|
||||||
$timeFormat,
|
$timeFormat,
|
||||||
);
|
);
|
||||||
$this->switchCurrentOrganization($user, $organization);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $user;
|
return $user;
|
||||||
|
|||||||
@@ -18,8 +18,8 @@
|
|||||||
"korridor/laravel-computed-attributes": "^3.1",
|
"korridor/laravel-computed-attributes": "^3.1",
|
||||||
"korridor/laravel-has-many-sync": "^3.1",
|
"korridor/laravel-has-many-sync": "^3.1",
|
||||||
"korridor/laravel-model-validation-rules": "^3.0",
|
"korridor/laravel-model-validation-rules": "^3.0",
|
||||||
"laravel/fortify": "^1.37",
|
|
||||||
"laravel/framework": "^12.19.3",
|
"laravel/framework": "^12.19.3",
|
||||||
|
"laravel/jetstream": "^5.0",
|
||||||
"laravel/octane": "^2.3",
|
"laravel/octane": "^2.3",
|
||||||
"laravel/passport": "^13.0.5",
|
"laravel/passport": "^13.0.5",
|
||||||
"laravel/tinker": "^2.8",
|
"laravel/tinker": "^2.8",
|
||||||
@@ -27,7 +27,6 @@
|
|||||||
"league/flysystem-aws-s3-v3": "^3.0",
|
"league/flysystem-aws-s3-v3": "^3.0",
|
||||||
"league/iso3166": "^4.3",
|
"league/iso3166": "^4.3",
|
||||||
"maatwebsite/excel": "^3.1",
|
"maatwebsite/excel": "^3.1",
|
||||||
"mobiledetect/mobiledetectlib": "^4.11",
|
|
||||||
"novadaemon/filament-pretty-json": "^2.2",
|
"novadaemon/filament-pretty-json": "^2.2",
|
||||||
"nwidart/laravel-modules": "^12.0.4",
|
"nwidart/laravel-modules": "^12.0.4",
|
||||||
"owen-it/laravel-auditing": "^14.0.0",
|
"owen-it/laravel-auditing": "^14.0.0",
|
||||||
@@ -132,8 +131,7 @@
|
|||||||
"pestphp/pest-plugin": true,
|
"pestphp/pest-plugin": true,
|
||||||
"php-http/discovery": true,
|
"php-http/discovery": true,
|
||||||
"wikimedia/composer-merge-plugin": true
|
"wikimedia/composer-merge-plugin": true
|
||||||
},
|
}
|
||||||
"process-timeout": 900
|
|
||||||
},
|
},
|
||||||
"minimum-stability": "stable",
|
"minimum-stability": "stable",
|
||||||
"prefer-stable": true
|
"prefer-stable": true
|
||||||
|
|||||||
92
composer.lock
generated
92
composer.lock
generated
@@ -4,7 +4,7 @@
|
|||||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||||
"This file is @generated automatically"
|
"This file is @generated automatically"
|
||||||
],
|
],
|
||||||
"content-hash": "897ca7bc13f827db641f7affa54a8523",
|
"content-hash": "4c728f01d2beb426b2d157143618fdae",
|
||||||
"packages": [
|
"packages": [
|
||||||
{
|
{
|
||||||
"name": "anourvalar/eloquent-serialize",
|
"name": "anourvalar/eloquent-serialize",
|
||||||
@@ -4413,6 +4413,72 @@
|
|||||||
},
|
},
|
||||||
"time": "2026-05-20T11:48:19+00:00"
|
"time": "2026-05-20T11:48:19+00:00"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "laravel/jetstream",
|
||||||
|
"version": "v5.5.3",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/laravel/jetstream.git",
|
||||||
|
"reference": "61cac5cde455311890f6981fb2da47acd298e4e2"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/laravel/jetstream/zipball/61cac5cde455311890f6981fb2da47acd298e4e2",
|
||||||
|
"reference": "61cac5cde455311890f6981fb2da47acd298e4e2",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"ext-json": "*",
|
||||||
|
"illuminate/console": "^11.0|^12.0|^13.0",
|
||||||
|
"illuminate/support": "^11.0|^12.0|^13.0",
|
||||||
|
"laravel/fortify": "^1.20",
|
||||||
|
"mobiledetect/mobiledetectlib": "^4.8.08",
|
||||||
|
"php": "^8.2.0",
|
||||||
|
"symfony/console": "^7.0|^8.0"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"inertiajs/inertia-laravel": "^2.0",
|
||||||
|
"laravel/sanctum": "^4.0",
|
||||||
|
"livewire/livewire": "^3.3",
|
||||||
|
"mockery/mockery": "^1.0",
|
||||||
|
"orchestra/testbench": "^9.15|^10.8|^11.0",
|
||||||
|
"phpstan/phpstan": "^1.10"
|
||||||
|
},
|
||||||
|
"type": "library",
|
||||||
|
"extra": {
|
||||||
|
"laravel": {
|
||||||
|
"providers": [
|
||||||
|
"Laravel\\Jetstream\\JetstreamServiceProvider"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"Laravel\\Jetstream\\": "src/"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"MIT"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "Taylor Otwell",
|
||||||
|
"email": "taylor@laravel.com"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "Tailwind scaffolding for the Laravel framework.",
|
||||||
|
"keywords": [
|
||||||
|
"auth",
|
||||||
|
"laravel",
|
||||||
|
"tailwind"
|
||||||
|
],
|
||||||
|
"support": {
|
||||||
|
"issues": "https://github.com/laravel/jetstream/issues",
|
||||||
|
"source": "https://github.com/laravel/jetstream"
|
||||||
|
},
|
||||||
|
"time": "2026-05-19T01:30:03+00:00"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "laravel/octane",
|
"name": "laravel/octane",
|
||||||
"version": "v2.17.4",
|
"version": "v2.17.4",
|
||||||
@@ -6379,16 +6445,16 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "mobiledetect/mobiledetectlib",
|
"name": "mobiledetect/mobiledetectlib",
|
||||||
"version": "4.11.0",
|
"version": "4.10.0",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/serbanghita/Mobile-Detect.git",
|
"url": "https://github.com/serbanghita/Mobile-Detect.git",
|
||||||
"reference": "ab39168b7556f44c11c80be1222b44b239f5c2e4"
|
"reference": "1473bd9d6aa40158f75f1e05116e6dd081148b2c"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/serbanghita/Mobile-Detect/zipball/ab39168b7556f44c11c80be1222b44b239f5c2e4",
|
"url": "https://api.github.com/repos/serbanghita/Mobile-Detect/zipball/1473bd9d6aa40158f75f1e05116e6dd081148b2c",
|
||||||
"reference": "ab39168b7556f44c11c80be1222b44b239f5c2e4",
|
"reference": "1473bd9d6aa40158f75f1e05116e6dd081148b2c",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
@@ -6431,7 +6497,7 @@
|
|||||||
],
|
],
|
||||||
"support": {
|
"support": {
|
||||||
"issues": "https://github.com/serbanghita/Mobile-Detect/issues",
|
"issues": "https://github.com/serbanghita/Mobile-Detect/issues",
|
||||||
"source": "https://github.com/serbanghita/Mobile-Detect/tree/4.11.0"
|
"source": "https://github.com/serbanghita/Mobile-Detect/tree/4.10.0"
|
||||||
},
|
},
|
||||||
"funding": [
|
"funding": [
|
||||||
{
|
{
|
||||||
@@ -6439,7 +6505,7 @@
|
|||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"time": "2026-05-24T12:32:40+00:00"
|
"time": "2026-04-23T13:05:57+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "monolog/monolog",
|
"name": "monolog/monolog",
|
||||||
@@ -13737,16 +13803,16 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "web-auth/webauthn-lib",
|
"name": "web-auth/webauthn-lib",
|
||||||
"version": "5.3.5",
|
"version": "5.3.3",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/web-auth/webauthn-lib.git",
|
"url": "https://github.com/web-auth/webauthn-lib.git",
|
||||||
"reference": "9e0986d999f4102e24ac8a598d3a80d98b56c19f"
|
"reference": "e6f656d6c6b29fa305382fe6a0a3be8177d177df"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/web-auth/webauthn-lib/zipball/9e0986d999f4102e24ac8a598d3a80d98b56c19f",
|
"url": "https://api.github.com/repos/web-auth/webauthn-lib/zipball/e6f656d6c6b29fa305382fe6a0a3be8177d177df",
|
||||||
"reference": "9e0986d999f4102e24ac8a598d3a80d98b56c19f",
|
"reference": "e6f656d6c6b29fa305382fe6a0a3be8177d177df",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
@@ -13807,7 +13873,7 @@
|
|||||||
"webauthn"
|
"webauthn"
|
||||||
],
|
],
|
||||||
"support": {
|
"support": {
|
||||||
"source": "https://github.com/web-auth/webauthn-lib/tree/5.3.5"
|
"source": "https://github.com/web-auth/webauthn-lib/tree/5.3.3"
|
||||||
},
|
},
|
||||||
"funding": [
|
"funding": [
|
||||||
{
|
{
|
||||||
@@ -13819,7 +13885,7 @@
|
|||||||
"type": "patreon"
|
"type": "patreon"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"time": "2026-05-31T15:00:08+00:00"
|
"time": "2026-05-17T19:04:30+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "webmozart/assert",
|
"name": "webmozart/assert",
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ use App\Providers\AuthServiceProvider;
|
|||||||
use App\Providers\EventServiceProvider;
|
use App\Providers\EventServiceProvider;
|
||||||
use App\Providers\Filament\AdminPanelProvider;
|
use App\Providers\Filament\AdminPanelProvider;
|
||||||
use App\Providers\FortifyServiceProvider;
|
use App\Providers\FortifyServiceProvider;
|
||||||
|
use App\Providers\JetstreamServiceProvider;
|
||||||
use App\Providers\RouteServiceProvider;
|
use App\Providers\RouteServiceProvider;
|
||||||
use Illuminate\Support\Facades\Facade;
|
use Illuminate\Support\Facades\Facade;
|
||||||
use Illuminate\Support\ServiceProvider;
|
use Illuminate\Support\ServiceProvider;
|
||||||
@@ -81,8 +82,6 @@ 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
|
||||||
@@ -204,6 +203,7 @@ return [
|
|||||||
AdminPanelProvider::class,
|
AdminPanelProvider::class,
|
||||||
RouteServiceProvider::class,
|
RouteServiceProvider::class,
|
||||||
FortifyServiceProvider::class,
|
FortifyServiceProvider::class,
|
||||||
|
JetstreamServiceProvider::class,
|
||||||
// Warning: Do not add TelescopeServiceProvider here since it is already conditionally registered in AppServiceProvider
|
// Warning: Do not add TelescopeServiceProvider here since it is already conditionally registered in AppServiceProvider
|
||||||
LaravelModulesServiceProvider::class,
|
LaravelModulesServiceProvider::class,
|
||||||
])->toArray(),
|
])->toArray(),
|
||||||
|
|||||||
82
config/jetstream.php
Normal file
82
config/jetstream.php
Normal file
@@ -0,0 +1,82 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
use Laravel\Jetstream\Features;
|
||||||
|
use Laravel\Jetstream\Http\Middleware\AuthenticateSession;
|
||||||
|
|
||||||
|
return [
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Jetstream Stack
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| This configuration value informs Jetstream which "stack" you will be
|
||||||
|
| using for your application. In general, this value is set for you
|
||||||
|
| during installation and will not need to be changed after that.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'stack' => 'inertia',
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Jetstream Route Middleware
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Here you may specify which middleware Jetstream will assign to the routes
|
||||||
|
| that it registers with the application. When necessary, you may modify
|
||||||
|
| these middleware; however, this default value is usually sufficient.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'middleware' => ['web'],
|
||||||
|
|
||||||
|
'auth_session' => AuthenticateSession::class,
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Jetstream Guard
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Here you may specify the authentication guard Jetstream will use while
|
||||||
|
| authenticating users. This value should correspond with one of your
|
||||||
|
| guards that is already present in your "auth" configuration file.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'guard' => 'web',
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Features
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Some of Jetstream's features are optional. You may disable the features
|
||||||
|
| by removing them from this array. You're free to only remove some of
|
||||||
|
| these features or you can even remove all of these if you need to.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'features' => [
|
||||||
|
Features::termsAndPrivacyPolicy(),
|
||||||
|
Features::profilePhotos(),
|
||||||
|
Features::teams(['invitations' => true]),
|
||||||
|
Features::accountDeletion(),
|
||||||
|
],
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Profile Photo Disk
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| This configuration value determines the default disk that will be used
|
||||||
|
| when storing profile photos for your application's users. Typically
|
||||||
|
| this will be the "public" disk but you may adjust this if needed.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'profile_photo_disk' => env('PROFILE_PHOTO_DISK', env('PUBLIC_FILESYSTEM_DISK', 'public')),
|
||||||
|
|
||||||
|
];
|
||||||
@@ -94,7 +94,7 @@ class UserFactory extends Factory
|
|||||||
$profilePhoto = $this->faker->image(null, 500, 500);
|
$profilePhoto = $this->faker->image(null, 500, 500);
|
||||||
/** @see FileHelpers::hashName */
|
/** @see FileHelpers::hashName */
|
||||||
$path = 'profile-photos/'.Str::random(40).'.png';
|
$path = 'profile-photos/'.Str::random(40).'.png';
|
||||||
Storage::disk(config('filesystems.public'))->put($path, $profilePhoto);
|
Storage::disk(config('jetstream.profile_photo_disk', 'public'))->put($path, $profilePhoto);
|
||||||
|
|
||||||
return $this->state(function (array $attributes) use ($path): array {
|
return $this->state(function (array $attributes) use ($path): array {
|
||||||
return [
|
return [
|
||||||
|
|||||||
@@ -107,7 +107,7 @@ services:
|
|||||||
- sail
|
- sail
|
||||||
- reverse-proxy
|
- reverse-proxy
|
||||||
playwright:
|
playwright:
|
||||||
image: mcr.microsoft.com/playwright:v1.60.0-jammy
|
image: mcr.microsoft.com/playwright:v1.59.1-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:
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import {
|
|||||||
createRunningTimeEntryWithStartViaApi,
|
createRunningTimeEntryWithStartViaApi,
|
||||||
createTaskViaApi,
|
createTaskViaApi,
|
||||||
createProjectWithClientViaApi,
|
createProjectWithClientViaApi,
|
||||||
updateUserProfileViaApi,
|
updateUserProfileViaWeb,
|
||||||
updateOrganizationSettingViaApi,
|
updateOrganizationSettingViaApi,
|
||||||
} from './utils/api';
|
} from './utils/api';
|
||||||
|
|
||||||
@@ -1803,22 +1803,28 @@ test.describe('Click-Drag Selection to Create', () => {
|
|||||||
// =============================================
|
// =============================================
|
||||||
|
|
||||||
test.describe('Timezone & Localization', () => {
|
test.describe('Timezone & Localization', () => {
|
||||||
test('week start day: monday shows Mon as first column', async ({ page, ctx }) => {
|
test('week start day: monday shows Mon as first column', async ({ page }) => {
|
||||||
await updateUserProfileViaApi(ctx, { week_start: 'monday' });
|
// Navigate to calendar first to load Inertia page props
|
||||||
await goToCalendar(page);
|
await goToCalendar(page);
|
||||||
|
await updateUserProfileViaWeb(page, { week_start: 'monday' });
|
||||||
|
await page.reload();
|
||||||
await expect(page.locator('.fc')).toBeVisible();
|
await expect(page.locator('.fc')).toBeVisible();
|
||||||
|
|
||||||
const firstHeader = page.locator('.fc-col-header-cell').first();
|
const firstHeader = page.locator('.fc-col-header-cell').first();
|
||||||
await expect(firstHeader).toContainText('Mon');
|
await expect(firstHeader).toContainText('Mon');
|
||||||
});
|
});
|
||||||
|
|
||||||
test('week start day: sunday shows Sun as first column', async ({ page, ctx }) => {
|
test('week start day: sunday shows Sun as first column', async ({ page }) => {
|
||||||
await updateUserProfileViaApi(ctx, { week_start: 'sunday' });
|
|
||||||
await goToCalendar(page);
|
await goToCalendar(page);
|
||||||
|
await updateUserProfileViaWeb(page, { week_start: 'sunday' });
|
||||||
|
await page.reload();
|
||||||
await expect(page.locator('.fc')).toBeVisible();
|
await expect(page.locator('.fc')).toBeVisible();
|
||||||
|
|
||||||
const firstHeader = page.locator('.fc-col-header-cell').first();
|
const firstHeader = page.locator('.fc-col-header-cell').first();
|
||||||
await expect(firstHeader).toContainText('Sun');
|
await expect(firstHeader).toContainText('Sun');
|
||||||
|
|
||||||
|
// Reset to monday for other tests
|
||||||
|
await updateUserProfileViaWeb(page, { week_start: 'monday' });
|
||||||
});
|
});
|
||||||
|
|
||||||
test('12-hour time format shows AM/PM on slot labels', async ({ page, ctx }) => {
|
test('12-hour time format shows AM/PM on slot labels', async ({ page, ctx }) => {
|
||||||
|
|||||||
@@ -246,7 +246,7 @@ test('test that sorting clients by name and status works', async ({ page, ctx })
|
|||||||
|
|
||||||
test('test that sorting clients by project count works', async ({ page, ctx }) => {
|
test('test that sorting clients by project count works', async ({ page, ctx }) => {
|
||||||
const clientWithMany = await createClientViaApi(ctx, { name: 'ManyProjects Client' });
|
const clientWithMany = await createClientViaApi(ctx, { name: 'ManyProjects Client' });
|
||||||
await createClientViaApi(ctx, { name: 'NoProjects Client' });
|
const clientWithNone = await createClientViaApi(ctx, { name: 'NoProjects Client' });
|
||||||
|
|
||||||
// Create projects for the first client
|
// Create projects for the first client
|
||||||
await createProjectViaApi(ctx, { name: 'Proj1', client_id: clientWithMany.id });
|
await createProjectViaApi(ctx, { name: 'Proj1', client_id: clientWithMany.id });
|
||||||
@@ -374,119 +374,3 @@ test.describe('Employee Clients Restrictions', () => {
|
|||||||
await expect(employee.page.getByText(clientName)).toBeVisible({ timeout: 10000 });
|
await expect(employee.page.getByText(clientName)).toBeVisible({ timeout: 10000 });
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// ──────────────────────────────────────────────────
|
|
||||||
// Pagination Tests
|
|
||||||
// ──────────────────────────────────────────────────
|
|
||||||
|
|
||||||
test.describe('Clients Pagination', () => {
|
|
||||||
test.describe.configure({ timeout: 30000 });
|
|
||||||
|
|
||||||
test('test that client table paginates when there are more than 15 clients', async ({
|
|
||||||
page,
|
|
||||||
ctx,
|
|
||||||
}) => {
|
|
||||||
// Create 17 clients with zero-padded names so alphabetical sort is predictable.
|
|
||||||
// Page size is 15 → page 1 shows indices 00–14, page 2 shows 15–16.
|
|
||||||
const seed = Math.floor(Math.random() * 100000);
|
|
||||||
const prefix = `PaginationClient ${seed} `;
|
|
||||||
await Promise.all(
|
|
||||||
Array.from({ length: 17 }, (_, i) =>
|
|
||||||
createClientViaApi(ctx, { name: prefix + String(i).padStart(2, '0') })
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
await goToClientsOverview(page);
|
|
||||||
await clearClientTableState(page);
|
|
||||||
await page.reload();
|
|
||||||
|
|
||||||
// Default sort is name asc; first 15 clients (00–14) on page 1.
|
|
||||||
await expect(page.getByText(prefix + '00')).toBeVisible({ timeout: 10000 });
|
|
||||||
await expect(page.getByRole('button', { name: 'Next Page' })).toBeVisible();
|
|
||||||
// Client 15 should be on page 2, not visible on page 1.
|
|
||||||
await expect(page.getByText(prefix + '15')).not.toBeVisible();
|
|
||||||
|
|
||||||
// Exactly 15 data rows mounted on page 1.
|
|
||||||
await expect(page.getByRole('row')).toHaveCount(15);
|
|
||||||
|
|
||||||
// Navigation to page 2.
|
|
||||||
await page.getByRole('button', { name: 'Next Page' }).click();
|
|
||||||
await expect(page.getByText(prefix + '15')).toBeVisible();
|
|
||||||
await expect(page.getByText(prefix + '00')).not.toBeVisible();
|
|
||||||
// Page 2 contains the remaining 2 clients.
|
|
||||||
await expect(page.getByRole('row')).toHaveCount(2);
|
|
||||||
|
|
||||||
// Back to page 1 via Previous Page.
|
|
||||||
await page.getByRole('button', { name: 'Previous Page' }).click();
|
|
||||||
await expect(page.getByText(prefix + '00')).toBeVisible();
|
|
||||||
await expect(page.getByText(prefix + '15')).not.toBeVisible();
|
|
||||||
|
|
||||||
// First / Last page jumps.
|
|
||||||
await page.getByRole('button', { name: 'Last Page' }).click();
|
|
||||||
await expect(page.getByText(prefix + '15')).toBeVisible();
|
|
||||||
await page.getByRole('button', { name: 'First Page' }).click();
|
|
||||||
await expect(page.getByText(prefix + '00')).toBeVisible();
|
|
||||||
await expect(page.getByText(prefix + '15')).not.toBeVisible();
|
|
||||||
|
|
||||||
// Direct page-number button navigation + selected state.
|
|
||||||
await page.getByRole('button', { name: 'Page 2' }).click();
|
|
||||||
await expect(page.getByText(prefix + '15')).toBeVisible();
|
|
||||||
await expect(page.getByRole('button', { name: 'Page 2' })).toHaveAttribute(
|
|
||||||
'aria-current',
|
|
||||||
'page'
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
test('test that client pagination is not shown when there are 15 or fewer clients', async ({
|
|
||||||
page,
|
|
||||||
ctx,
|
|
||||||
}) => {
|
|
||||||
await Promise.all(
|
|
||||||
Array.from({ length: 10 }, (_, i) =>
|
|
||||||
createClientViaApi(ctx, {
|
|
||||||
name: `FewClient ${Math.floor(Math.random() * 100000)} ${i}`,
|
|
||||||
})
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
await goToClientsOverview(page);
|
|
||||||
await clearClientTableState(page);
|
|
||||||
await page.reload();
|
|
||||||
|
|
||||||
await expect(page.getByTestId('client_table')).toBeVisible();
|
|
||||||
await expect(page.getByRole('button', { name: 'Next Page' })).toHaveCount(0);
|
|
||||||
});
|
|
||||||
|
|
||||||
test('test that changing the sort resets client pagination to page 1', async ({
|
|
||||||
page,
|
|
||||||
ctx,
|
|
||||||
}) => {
|
|
||||||
const seed = Math.floor(Math.random() * 100000);
|
|
||||||
const prefix = `SortPagClient ${seed} `;
|
|
||||||
await Promise.all(
|
|
||||||
Array.from({ length: 17 }, (_, i) =>
|
|
||||||
createClientViaApi(ctx, { name: prefix + String(i).padStart(2, '0') })
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
await goToClientsOverview(page);
|
|
||||||
await clearClientTableState(page);
|
|
||||||
await page.reload();
|
|
||||||
|
|
||||||
await expect(page.getByText(prefix + '00')).toBeVisible({ timeout: 10000 });
|
|
||||||
|
|
||||||
// Go to page 2.
|
|
||||||
await page.getByRole('button', { name: 'Next Page' }).click();
|
|
||||||
await expect(page.getByText(prefix + '15')).toBeVisible();
|
|
||||||
|
|
||||||
// Sort by name descending.
|
|
||||||
const table = page.getByTestId('client_table');
|
|
||||||
const nameHeader = table.getByText('Name').first();
|
|
||||||
await nameHeader.click();
|
|
||||||
|
|
||||||
// Pagination reset to page 1; desc order → 16, 15 visible, 00 on page 2.
|
|
||||||
await expect(page.getByText(prefix + '16')).toBeVisible();
|
|
||||||
await expect(page.getByText(prefix + '15')).toBeVisible();
|
|
||||||
await expect(page.getByText(prefix + '00')).not.toBeVisible();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|||||||
@@ -348,7 +348,7 @@ test.describe('Command Palette', () => {
|
|||||||
const newOrgName = 'TestOrg' + Math.floor(Math.random() * 10000);
|
const newOrgName = 'TestOrg' + Math.floor(Math.random() * 10000);
|
||||||
|
|
||||||
// Create a new organization
|
// Create a new organization
|
||||||
await page.goto(PLAYWRIGHT_BASE_URL + '/organizations/create');
|
await page.goto(PLAYWRIGHT_BASE_URL + '/teams/create');
|
||||||
await page.getByLabel('Organization Name').fill(newOrgName);
|
await page.getByLabel('Organization Name').fill(newOrgName);
|
||||||
await page.getByRole('button', { name: 'Create' }).click();
|
await page.getByRole('button', { name: 'Create' }).click();
|
||||||
|
|
||||||
@@ -393,7 +393,7 @@ test.describe('Command Palette', () => {
|
|||||||
const newOrgName = 'GroupTestOrg' + Math.floor(Math.random() * 10000);
|
const newOrgName = 'GroupTestOrg' + Math.floor(Math.random() * 10000);
|
||||||
|
|
||||||
// Create a new organization to ensure we have multiple
|
// Create a new organization to ensure we have multiple
|
||||||
await page.goto(PLAYWRIGHT_BASE_URL + '/organizations/create');
|
await page.goto(PLAYWRIGHT_BASE_URL + '/teams/create');
|
||||||
await page.getByLabel('Organization Name').fill(newOrgName);
|
await page.getByLabel('Organization Name').fill(newOrgName);
|
||||||
await page.getByRole('button', { name: 'Create' }).click();
|
await page.getByRole('button', { name: 'Create' }).click();
|
||||||
await expect(page.getByTestId('dashboard_view')).toBeVisible({ timeout: 10000 });
|
await expect(page.getByTestId('dashboard_view')).toBeVisible({ timeout: 10000 });
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { expect, test } from '../playwright/fixtures';
|
import { expect, test } from '../playwright/fixtures';
|
||||||
import { PLAYWRIGHT_BASE_URL, TEST_USER_PASSWORD } from '../playwright/config';
|
import { PLAYWRIGHT_BASE_URL } 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');
|
||||||
@@ -36,52 +36,13 @@ async function createTimeEntry(page, duration: string) {
|
|||||||
test('test that organization name can be updated', async ({ page }) => {
|
test('test that organization name can be updated', async ({ page }) => {
|
||||||
await goToOrganizationSettings(page);
|
await goToOrganizationSettings(page);
|
||||||
await page.getByLabel('Organization Name').fill('NEW ORG NAME');
|
await page.getByLabel('Organization Name').fill('NEW ORG NAME');
|
||||||
await Promise.all([
|
await page.getByLabel('Organization Name').press('Enter');
|
||||||
page.waitForResponse(
|
await page.getByLabel('Organization Name').press('Meta+r');
|
||||||
(response) =>
|
|
||||||
response.url().includes('/api/v1/organizations/') &&
|
|
||||||
response.request().method() === 'PUT' &&
|
|
||||||
response.status() === 200
|
|
||||||
),
|
|
||||||
page
|
|
||||||
.locator('form')
|
|
||||||
.filter({ hasText: 'Organization Name' })
|
|
||||||
.getByRole('button', { name: 'Save' })
|
|
||||||
.click(),
|
|
||||||
]);
|
|
||||||
await page.reload();
|
|
||||||
await expect(page.locator('[data-testid="organization_switcher"]:visible')).toContainText(
|
await expect(page.locator('[data-testid="organization_switcher"]:visible')).toContainText(
|
||||||
'NEW ORG NAME'
|
'NEW ORG NAME'
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('test that organization currency can be updated', async ({ page }) => {
|
|
||||||
await goToOrganizationSettings(page);
|
|
||||||
await page.getByLabel('Currency', { exact: true }).selectOption('USD');
|
|
||||||
await Promise.all([
|
|
||||||
page.waitForRequest(
|
|
||||||
(request) =>
|
|
||||||
request.url().includes('/api/v1/organizations/') &&
|
|
||||||
request.method() === 'PUT' &&
|
|
||||||
request.postDataJSON().currency === 'USD'
|
|
||||||
),
|
|
||||||
page.waitForResponse(
|
|
||||||
async (response) =>
|
|
||||||
response.url().includes('/api/v1/organizations/') &&
|
|
||||||
response.request().method() === 'PUT' &&
|
|
||||||
response.status() === 200 &&
|
|
||||||
(await response.json()).data.currency === 'USD'
|
|
||||||
),
|
|
||||||
page
|
|
||||||
.locator('form')
|
|
||||||
.filter({ hasText: 'Organization Name' })
|
|
||||||
.getByRole('button', { name: 'Save' })
|
|
||||||
.click(),
|
|
||||||
]);
|
|
||||||
await page.reload();
|
|
||||||
await expect(page.getByLabel('Currency', { exact: true })).toHaveValue('USD');
|
|
||||||
});
|
|
||||||
|
|
||||||
test('test that organization billable rate can be updated with all existing time entries', async ({
|
test('test that organization billable rate can be updated with all existing time entries', async ({
|
||||||
page,
|
page,
|
||||||
}) => {
|
}) => {
|
||||||
@@ -408,153 +369,13 @@ test('test that format settings persist after page reload', async ({ page }) =>
|
|||||||
await expect(page.getByLabel('Date Format')).toContainText('DD/MM/YYYY');
|
await expect(page.getByLabel('Date Format')).toContainText('DD/MM/YYYY');
|
||||||
});
|
});
|
||||||
|
|
||||||
// =============================================
|
|
||||||
// Create, Delete & Switch
|
|
||||||
// =============================================
|
|
||||||
|
|
||||||
test.describe('Organization Create, Delete & Switch', () => {
|
|
||||||
async function createOrganization(page, name: string) {
|
|
||||||
await page.goto(PLAYWRIGHT_BASE_URL + '/organizations/create');
|
|
||||||
await page.getByLabel('Organization Name').fill(name);
|
|
||||||
await Promise.all([
|
|
||||||
page.waitForResponse(
|
|
||||||
(response) =>
|
|
||||||
response.url().includes('/api/v1/organizations') &&
|
|
||||||
response.request().method() === 'POST' &&
|
|
||||||
response.status() === 201
|
|
||||||
),
|
|
||||||
page.getByRole('button', { name: 'Create' }).click(),
|
|
||||||
]);
|
|
||||||
// The backend switches the current organization to the new one and the
|
|
||||||
// frontend reloads into its dashboard.
|
|
||||||
await expect(page.getByTestId('dashboard_view')).toBeVisible({ timeout: 10000 });
|
|
||||||
}
|
|
||||||
|
|
||||||
test('can create a new organization and switches to it automatically', async ({ page }) => {
|
|
||||||
const newOrgName = 'CreateOrg' + Math.floor(Math.random() * 100000);
|
|
||||||
await createOrganization(page, newOrgName);
|
|
||||||
|
|
||||||
await expect(page.locator('[data-testid="organization_switcher"]:visible')).toContainText(
|
|
||||||
newOrgName
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
test('does not create an organization when the name is empty', async ({ page }) => {
|
|
||||||
await page.goto(PLAYWRIGHT_BASE_URL + '/organizations/create');
|
|
||||||
|
|
||||||
// The form posts to the API, which rejects the empty name with a 422.
|
|
||||||
await Promise.all([
|
|
||||||
page.waitForResponse(
|
|
||||||
(response) =>
|
|
||||||
response.url().includes('/api/v1/organizations') &&
|
|
||||||
response.request().method() === 'POST' &&
|
|
||||||
response.status() === 422
|
|
||||||
),
|
|
||||||
page.getByRole('button', { name: 'Create' }).click(),
|
|
||||||
]);
|
|
||||||
|
|
||||||
// Validation failed, so we stay on the create form and never reach a
|
|
||||||
// dashboard. Assert on the form rather than the URL.
|
|
||||||
await expect(page.getByText('Organization Details')).toBeVisible();
|
|
||||||
await expect(page.getByRole('alert')).toContainText('The name field is required.');
|
|
||||||
await expect(page.getByLabel('Organization Name')).toHaveAttribute('aria-invalid', 'true');
|
|
||||||
await expect(page.getByTestId('dashboard_view')).toHaveCount(0);
|
|
||||||
});
|
|
||||||
|
|
||||||
test('can delete an organization', async ({ page }) => {
|
|
||||||
// Create a throwaway organization so the primary one is never deleted.
|
|
||||||
const orgName = 'DeleteOrg' + Math.floor(Math.random() * 100000);
|
|
||||||
await createOrganization(page, orgName);
|
|
||||||
|
|
||||||
// Open the (now current) throwaway organization's settings.
|
|
||||||
await goToOrganizationSettings(page);
|
|
||||||
|
|
||||||
// Open the confirmation modal, then confirm inside the dialog.
|
|
||||||
await page.getByRole('button', { name: 'Delete Organization' }).click();
|
|
||||||
await page.getByRole('dialog').getByPlaceholder('Password').fill(TEST_USER_PASSWORD);
|
|
||||||
await Promise.all([
|
|
||||||
page.waitForResponse(
|
|
||||||
(response) =>
|
|
||||||
response.url().includes('/api/v1/organizations') &&
|
|
||||||
response.request().method() === 'DELETE' &&
|
|
||||||
response.status() === 204
|
|
||||||
),
|
|
||||||
page.getByRole('dialog').getByRole('button', { name: 'Delete Organization' }).click(),
|
|
||||||
]);
|
|
||||||
|
|
||||||
// We are redirected to the dashboard of a different organization.
|
|
||||||
await expect(page.getByTestId('dashboard_view')).toBeVisible({ timeout: 10000 });
|
|
||||||
await expect(
|
|
||||||
page.locator('[data-testid="organization_switcher"]:visible')
|
|
||||||
).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 }) => {
|
|
||||||
await page.goto(PLAYWRIGHT_BASE_URL + '/dashboard');
|
|
||||||
const orgSwitcher = page.locator('[data-testid="organization_switcher"]:visible');
|
|
||||||
await expect(orgSwitcher).toBeVisible();
|
|
||||||
const previousOrgNameLines = (await orgSwitcher.innerText())
|
|
||||||
.split('\n')
|
|
||||||
.map((line) => line.trim())
|
|
||||||
.filter(Boolean);
|
|
||||||
const previousOrgName = previousOrgNameLines[previousOrgNameLines.length - 1];
|
|
||||||
|
|
||||||
// Ensure there are at least two organizations to switch between.
|
|
||||||
const orgName = 'SwitchOrg' + Math.floor(Math.random() * 100000);
|
|
||||||
await createOrganization(page, orgName);
|
|
||||||
|
|
||||||
await expect(orgSwitcher).toContainText(orgName);
|
|
||||||
|
|
||||||
// Open the switcher and pick a different organization.
|
|
||||||
await orgSwitcher.click();
|
|
||||||
await expect(page.getByText('Switch Organizations')).toBeVisible();
|
|
||||||
const otherOrgButton = page.getByRole('menuitem', { name: previousOrgName });
|
|
||||||
await expect(otherOrgButton).toBeVisible();
|
|
||||||
|
|
||||||
await Promise.all([
|
|
||||||
page.waitForResponse(
|
|
||||||
(response) =>
|
|
||||||
response.url().includes('/users/me/current-organization') &&
|
|
||||||
response.request().method() === 'PUT' &&
|
|
||||||
response.status() === 200
|
|
||||||
),
|
|
||||||
otherOrgButton.click(),
|
|
||||||
]);
|
|
||||||
|
|
||||||
await expect(orgSwitcher).not.toContainText(orgName, { timeout: 10000 });
|
|
||||||
await expect(orgSwitcher).toContainText(previousOrgName, { timeout: 10000 });
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
// =============================================
|
// =============================================
|
||||||
// Admin Permission Tests
|
// Admin Permission Tests
|
||||||
// =============================================
|
// =============================================
|
||||||
|
|
||||||
test.describe('Admin Organization Settings Access', () => {
|
test.describe('Admin Organization Settings Access', () => {
|
||||||
test('admin can see and edit organization settings', async ({ ctx, admin }) => {
|
test('admin can see and edit organization settings', async ({ ctx, admin }) => {
|
||||||
await admin.page.goto(PLAYWRIGHT_BASE_URL + '/organizations/' + ctx.orgId);
|
await admin.page.goto(PLAYWRIGHT_BASE_URL + '/teams/' + ctx.orgId);
|
||||||
|
|
||||||
// Organization Name section is visible
|
// Organization Name section is visible
|
||||||
await expect(
|
await expect(
|
||||||
@@ -575,9 +396,6 @@ test.describe('Admin Organization Settings Access', () => {
|
|||||||
// Save buttons should be visible (admin can update)
|
// Save buttons should be visible (admin can update)
|
||||||
await expect(admin.page.getByRole('button', { name: 'Save' }).first()).toBeVisible();
|
await expect(admin.page.getByRole('button', { name: 'Save' }).first()).toBeVisible();
|
||||||
|
|
||||||
// The Organization Name input is editable (admin can update)
|
|
||||||
await expect(admin.page.getByLabel('Organization Name')).toBeEnabled();
|
|
||||||
|
|
||||||
// Delete organization should NOT be visible (owner only)
|
// Delete organization should NOT be visible (owner only)
|
||||||
await expect(
|
await expect(
|
||||||
admin.page.getByRole('heading', { name: 'Delete Organization' })
|
admin.page.getByRole('heading', { name: 'Delete Organization' })
|
||||||
@@ -591,17 +409,13 @@ test.describe('Admin Organization Settings Access', () => {
|
|||||||
|
|
||||||
test.describe('Employee Organization Settings Restrictions', () => {
|
test.describe('Employee Organization Settings Restrictions', () => {
|
||||||
test('employee can see org name but not editable settings', async ({ ctx, employee }) => {
|
test('employee can see org name but not editable settings', async ({ ctx, employee }) => {
|
||||||
await employee.page.goto(PLAYWRIGHT_BASE_URL + '/organizations/' + ctx.orgId);
|
await employee.page.goto(PLAYWRIGHT_BASE_URL + '/teams/' + ctx.orgId);
|
||||||
|
|
||||||
// Organization Name section is visible (but inputs are disabled)
|
// Organization Name section is visible (but inputs are disabled)
|
||||||
await expect(
|
await expect(
|
||||||
employee.page.getByRole('heading', { name: 'Organization Name', level: 3 })
|
employee.page.getByRole('heading', { name: 'Organization Name', level: 3 })
|
||||||
).toBeVisible({ timeout: 10000 });
|
).toBeVisible({ timeout: 10000 });
|
||||||
|
|
||||||
// The name and currency inputs are rendered but disabled (employee cannot update)
|
|
||||||
await expect(employee.page.getByLabel('Organization Name')).toBeDisabled();
|
|
||||||
await expect(employee.page.getByLabel('Currency')).toBeDisabled();
|
|
||||||
|
|
||||||
// Editable settings sections should NOT be visible
|
// Editable settings sections should NOT be visible
|
||||||
await expect(
|
await expect(
|
||||||
employee.page.getByRole('heading', { name: 'Billable Rate', level: 3 })
|
employee.page.getByRole('heading', { name: 'Billable Rate', level: 3 })
|
||||||
@@ -615,10 +429,5 @@ test.describe('Employee Organization Settings Restrictions', () => {
|
|||||||
|
|
||||||
// Save button should not be visible (employee cannot update)
|
// Save button should not be visible (employee cannot update)
|
||||||
await expect(employee.page.getByRole('button', { name: 'Save' })).not.toBeVisible();
|
await expect(employee.page.getByRole('button', { name: 'Save' })).not.toBeVisible();
|
||||||
|
|
||||||
// Delete organization should NOT be visible (owner only)
|
|
||||||
await expect(
|
|
||||||
employee.page.getByRole('heading', { name: 'Delete Organization' })
|
|
||||||
).not.toBeVisible();
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -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('/api/v1/users/') &&
|
response.url().includes('/user/confirm-password') &&
|
||||||
response.request().method() === 'DELETE' &&
|
response.request().method() === 'POST' &&
|
||||||
response.status() === 422
|
response.status() === 422
|
||||||
),
|
),
|
||||||
dialog.getByRole('button', { name: 'Delete Account' }).click(),
|
dialog.getByRole('button', { name: 'Delete Account' }).click(),
|
||||||
|
|||||||
@@ -117,43 +117,6 @@ test('test that archiving and unarchiving projects works', async ({ page, ctx })
|
|||||||
await expect(page.getByText(newProjectName)).toBeVisible();
|
await expect(page.getByText(newProjectName)).toBeVisible();
|
||||||
});
|
});
|
||||||
|
|
||||||
test('test that the client can be changed in the edit project modal', async ({ page, ctx }) => {
|
|
||||||
const projectName = 'Edit Client Project ' + Math.floor(1 + Math.random() * 100000);
|
|
||||||
const clientName = 'Assigned Client ' + Math.floor(1 + Math.random() * 100000);
|
|
||||||
await createProjectViaApi(ctx, { name: projectName });
|
|
||||||
const client = await createClientViaApi(ctx, { name: clientName });
|
|
||||||
|
|
||||||
await page.goto(PLAYWRIGHT_BASE_URL + '/projects');
|
|
||||||
await expect(page.getByText(projectName)).toBeVisible({ timeout: 10000 });
|
|
||||||
|
|
||||||
// Open the project's Edit modal.
|
|
||||||
await page.getByRole('row').first().getByRole('button').click();
|
|
||||||
await page.getByRole('menuitem').getByText('Edit').first().click();
|
|
||||||
await expect(page.getByRole('dialog')).toBeVisible();
|
|
||||||
|
|
||||||
// Open the client dropdown (currently "No Client"), confirm it focuses, and pick the client.
|
|
||||||
await page.getByRole('dialog').getByRole('button', { name: 'No Client' }).click();
|
|
||||||
const clientSearch = page.getByPlaceholder('Search for a client...');
|
|
||||||
await expect(clientSearch).toBeFocused();
|
|
||||||
await clientSearch.fill(clientName);
|
|
||||||
await page.getByRole('option', { name: clientName }).click();
|
|
||||||
|
|
||||||
// The trigger updates to the chosen client.
|
|
||||||
await expect(page.getByRole('dialog').getByRole('button', { name: clientName })).toBeVisible();
|
|
||||||
|
|
||||||
// Saving persists the client assignment.
|
|
||||||
await Promise.all([
|
|
||||||
page.getByRole('button', { name: 'Update Project' }).click(),
|
|
||||||
page.waitForResponse(
|
|
||||||
async (response) =>
|
|
||||||
response.url().includes('/projects/') &&
|
|
||||||
response.request().method() === 'PUT' &&
|
|
||||||
response.status() === 200 &&
|
|
||||||
(await response.json()).data.client_id === client.id
|
|
||||||
),
|
|
||||||
]);
|
|
||||||
});
|
|
||||||
|
|
||||||
test('test that updating billable rate works with existing time entries', async ({ page, ctx }) => {
|
test('test that updating billable rate works with existing time entries', async ({ page, ctx }) => {
|
||||||
const newProjectName = 'New Project ' + Math.floor(1 + Math.random() * 10000);
|
const newProjectName = 'New Project ' + Math.floor(1 + Math.random() * 10000);
|
||||||
const newBillableRate = Math.round(Math.random() * 10000);
|
const newBillableRate = Math.round(Math.random() * 10000);
|
||||||
@@ -1091,119 +1054,3 @@ test.describe('Employee Billable Rate Visibility', () => {
|
|||||||
await expect(projectRow).toContainText('200');
|
await expect(projectRow).toContainText('200');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// ──────────────────────────────────────────────────
|
|
||||||
// Pagination Tests
|
|
||||||
// ──────────────────────────────────────────────────
|
|
||||||
|
|
||||||
test.describe('Projects Pagination', () => {
|
|
||||||
test.describe.configure({ timeout: 30000 });
|
|
||||||
|
|
||||||
test('test that project table paginates when there are more than 15 projects', async ({
|
|
||||||
page,
|
|
||||||
ctx,
|
|
||||||
}) => {
|
|
||||||
// Create 17 projects with zero-padded names so alphabetical sort is predictable.
|
|
||||||
// Page size is 15 → page 1 shows indices 00–14, page 2 shows 15–16.
|
|
||||||
const seed = Math.floor(Math.random() * 100000);
|
|
||||||
const prefix = `PaginationProj ${seed} `;
|
|
||||||
await Promise.all(
|
|
||||||
Array.from({ length: 17 }, (_, i) =>
|
|
||||||
createProjectViaApi(ctx, { name: prefix + String(i).padStart(2, '0') })
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
await goToProjectsOverview(page);
|
|
||||||
await clearProjectTableState(page);
|
|
||||||
await page.reload();
|
|
||||||
|
|
||||||
// Default sort is name asc; first 15 projects (00–14) should be on page 1.
|
|
||||||
await expect(page.getByText(prefix + '00')).toBeVisible({ timeout: 10000 });
|
|
||||||
await expect(page.getByRole('button', { name: 'Next Page' })).toBeVisible();
|
|
||||||
// Project 15 should be on page 2, not visible on page 1.
|
|
||||||
await expect(page.getByText(prefix + '15')).not.toBeVisible();
|
|
||||||
|
|
||||||
// Exactly 15 data rows should be mounted on page 1.
|
|
||||||
await expect(page.getByRole('row')).toHaveCount(15);
|
|
||||||
|
|
||||||
// Go to page 2.
|
|
||||||
await page.getByRole('button', { name: 'Next Page' }).click();
|
|
||||||
await expect(page.getByText(prefix + '15')).toBeVisible();
|
|
||||||
await expect(page.getByText(prefix + '00')).not.toBeVisible();
|
|
||||||
// Page 2 contains the remaining 2 projects (15, 16).
|
|
||||||
await expect(page.getByRole('row')).toHaveCount(2);
|
|
||||||
|
|
||||||
// Return to page 1 via Previous Page.
|
|
||||||
await page.getByRole('button', { name: 'Previous Page' }).click();
|
|
||||||
await expect(page.getByText(prefix + '00')).toBeVisible();
|
|
||||||
await expect(page.getByText(prefix + '15')).not.toBeVisible();
|
|
||||||
|
|
||||||
// Jump to last page then back to first page.
|
|
||||||
await page.getByRole('button', { name: 'Last Page' }).click();
|
|
||||||
await expect(page.getByText(prefix + '15')).toBeVisible();
|
|
||||||
await page.getByRole('button', { name: 'First Page' }).click();
|
|
||||||
await expect(page.getByText(prefix + '00')).toBeVisible();
|
|
||||||
await expect(page.getByText(prefix + '15')).not.toBeVisible();
|
|
||||||
|
|
||||||
// Direct page-number button navigation.
|
|
||||||
await page.getByRole('button', { name: 'Page 2' }).click();
|
|
||||||
await expect(page.getByText(prefix + '15')).toBeVisible();
|
|
||||||
// Page 2 button should be marked as selected.
|
|
||||||
await expect(page.getByRole('button', { name: 'Page 2' })).toHaveAttribute(
|
|
||||||
'aria-current',
|
|
||||||
'page'
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
test('test that project pagination is not shown when there are 15 or fewer projects', async ({
|
|
||||||
page,
|
|
||||||
ctx,
|
|
||||||
}) => {
|
|
||||||
await Promise.all(
|
|
||||||
Array.from({ length: 10 }, (_, i) =>
|
|
||||||
createProjectViaApi(ctx, {
|
|
||||||
name: `FewProj ${Math.floor(Math.random() * 100000)} ${i}`,
|
|
||||||
})
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
await goToProjectsOverview(page);
|
|
||||||
await clearProjectTableState(page);
|
|
||||||
await page.reload();
|
|
||||||
|
|
||||||
await expect(page.getByTestId('project_table')).toBeVisible();
|
|
||||||
await expect(page.getByRole('button', { name: 'Next Page' })).toHaveCount(0);
|
|
||||||
});
|
|
||||||
|
|
||||||
test('test that changing the sort resets pagination to page 1', async ({ page, ctx }) => {
|
|
||||||
const seed = Math.floor(Math.random() * 100000);
|
|
||||||
const prefix = `SortPagProj ${seed} `;
|
|
||||||
await Promise.all(
|
|
||||||
Array.from({ length: 17 }, (_, i) =>
|
|
||||||
createProjectViaApi(ctx, { name: prefix + String(i).padStart(2, '0') })
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
await goToProjectsOverview(page);
|
|
||||||
await clearProjectTableState(page);
|
|
||||||
await page.reload();
|
|
||||||
|
|
||||||
await expect(page.getByText(prefix + '00')).toBeVisible({ timeout: 10000 });
|
|
||||||
|
|
||||||
// Go to page 2.
|
|
||||||
await page.getByRole('button', { name: 'Next Page' }).click();
|
|
||||||
await expect(page.getByText(prefix + '15')).toBeVisible();
|
|
||||||
|
|
||||||
// Sort by name descending: header click toggles asc → desc.
|
|
||||||
const nameHeader = page
|
|
||||||
.locator('[data-testid="project_table"] .select-none', { hasText: 'Name' })
|
|
||||||
.first();
|
|
||||||
await nameHeader.click();
|
|
||||||
|
|
||||||
// After sorting, pagination resets to page 1; desc order → 16, 15, ... 02 visible.
|
|
||||||
await expect(page.getByText(prefix + '16')).toBeVisible();
|
|
||||||
await expect(page.getByText(prefix + '15')).toBeVisible();
|
|
||||||
// Index 00 should now be on page 2 (last in desc order).
|
|
||||||
await expect(page.getByText(prefix + '00')).not.toBeVisible();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|||||||
@@ -717,108 +717,3 @@ test('test that keyboard navigation works in multiselect dropdown', async ({ pag
|
|||||||
page.getByRole('button', { name: 'Projects' }).first().getByText('1')
|
page.getByRole('button', { name: 'Projects' }).first().getByText('1')
|
||||||
).toBeVisible();
|
).toBeVisible();
|
||||||
});
|
});
|
||||||
|
|
||||||
// ──────────────────────────────────────────────────
|
|
||||||
// Pagination Tests
|
|
||||||
// ──────────────────────────────────────────────────
|
|
||||||
|
|
||||||
test.describe('Reporting Detailed Pagination', () => {
|
|
||||||
test('test that detailed reporting paginates when there are more than 15 time entries', async ({
|
|
||||||
page,
|
|
||||||
ctx,
|
|
||||||
}) => {
|
|
||||||
// The detailed report paginates server-side with a page limit of 15.
|
|
||||||
// Create 17 time entries on a single project so we get exactly 2 pages.
|
|
||||||
const seed = Math.floor(Math.random() * 100000);
|
|
||||||
const projectName = `ReportPagProj ${seed}`;
|
|
||||||
const project = await createProjectViaApi(ctx, { name: projectName });
|
|
||||||
const descriptions = Array.from(
|
|
||||||
{ length: 17 },
|
|
||||||
(_, i) => `ReportPagEntry ${String(i).padStart(2, '0')} ${seed}`
|
|
||||||
);
|
|
||||||
await Promise.all(
|
|
||||||
descriptions.map((description) =>
|
|
||||||
createTimeEntryViaApi(ctx, {
|
|
||||||
description,
|
|
||||||
duration: '30min',
|
|
||||||
projectId: project.id,
|
|
||||||
})
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
await goToReportingDetailed(page);
|
|
||||||
await expect(page.getByText(descriptions[0]!).first()).toBeVisible({
|
|
||||||
timeout: 10000,
|
|
||||||
});
|
|
||||||
|
|
||||||
// Pagination nav should be rendered.
|
|
||||||
await expect(page.getByRole('button', { name: 'Next Page' })).toBeVisible();
|
|
||||||
|
|
||||||
// Collect which descriptions are currently visible on page 1.
|
|
||||||
const visiblePage1 = new Set<string>();
|
|
||||||
for (const description of descriptions) {
|
|
||||||
if ((await page.getByText(description).count()) > 0) {
|
|
||||||
visiblePage1.add(description);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// The page limit is 15 → exactly 15 entries visible on page 1.
|
|
||||||
expect(visiblePage1.size).toBe(15);
|
|
||||||
|
|
||||||
// Go to page 2 and wait for the server fetch.
|
|
||||||
await Promise.all([
|
|
||||||
page.getByRole('button', { name: 'Next Page' }).click(),
|
|
||||||
waitForDetailedReportingUpdate(page),
|
|
||||||
]);
|
|
||||||
|
|
||||||
const visiblePage2 = new Set<string>();
|
|
||||||
for (const description of descriptions) {
|
|
||||||
if ((await page.getByText(description).count()) > 0) {
|
|
||||||
visiblePage2.add(description);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Page 2 should hold the remaining 2 entries, disjoint from page 1.
|
|
||||||
expect(visiblePage2.size).toBe(2);
|
|
||||||
for (const description of visiblePage2) {
|
|
||||||
expect(visiblePage1.has(description)).toBe(false);
|
|
||||||
}
|
|
||||||
// Across both pages, all 17 entries should have been visible.
|
|
||||||
expect(visiblePage1.size + visiblePage2.size).toBe(17);
|
|
||||||
|
|
||||||
// Page 2 button is selected.
|
|
||||||
await expect(page.getByRole('button', { name: 'Page 2' })).toHaveAttribute(
|
|
||||||
'aria-current',
|
|
||||||
'page'
|
|
||||||
);
|
|
||||||
|
|
||||||
// Previous page returns to page 1.
|
|
||||||
await Promise.all([
|
|
||||||
page.getByRole('button', { name: 'Previous Page' }).click(),
|
|
||||||
waitForDetailedReportingUpdate(page),
|
|
||||||
]);
|
|
||||||
expect((await page.getByText(descriptions[0]!).count()) > 0).toBe(true);
|
|
||||||
});
|
|
||||||
|
|
||||||
test('test that reporting pagination is not shown when there are 15 or fewer time entries', async ({
|
|
||||||
page,
|
|
||||||
ctx,
|
|
||||||
}) => {
|
|
||||||
const seed = Math.floor(Math.random() * 100000);
|
|
||||||
const projectName = `FewEntriesProj ${seed}`;
|
|
||||||
const project = await createProjectViaApi(ctx, { name: projectName });
|
|
||||||
await Promise.all(
|
|
||||||
Array.from({ length: 5 }, (_, i) =>
|
|
||||||
createTimeEntryViaApi(ctx, {
|
|
||||||
description: `FewEntries ${i} ${seed}`,
|
|
||||||
duration: '30min',
|
|
||||||
projectId: project.id,
|
|
||||||
})
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
await goToReportingDetailed(page);
|
|
||||||
await expect(page.getByText(`FewEntries 0 ${seed}`).first()).toBeVisible({
|
|
||||||
timeout: 10000,
|
|
||||||
});
|
|
||||||
await expect(page.getByRole('button', { name: 'Next Page' })).toHaveCount(0);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|||||||
@@ -96,37 +96,6 @@ test('test that project multiselect search filters the option list', async ({ pa
|
|||||||
await page.keyboard.press('Escape');
|
await page.keyboard.press('Escape');
|
||||||
});
|
});
|
||||||
|
|
||||||
test('test that the project filter virtualizes a long list (renders only a window)', async ({
|
|
||||||
page,
|
|
||||||
ctx,
|
|
||||||
}) => {
|
|
||||||
// Create many projects so the dropdown must virtualize rather than render all of them.
|
|
||||||
const projectNames = Array.from(
|
|
||||||
{ length: 80 },
|
|
||||||
(_, i) => `VirtProj ${String(i).padStart(2, '0')}`
|
|
||||||
);
|
|
||||||
await Promise.all(projectNames.map((name) => createProjectViaApi(ctx, { name })));
|
|
||||||
|
|
||||||
await goToReporting(page);
|
|
||||||
await expect(page.getByRole('button', { name: 'Export' })).toBeVisible();
|
|
||||||
await page.getByRole('button', { name: 'Projects' }).first().click();
|
|
||||||
|
|
||||||
// Only a small window of options is mounted, far fewer than the 80+ projects that exist.
|
|
||||||
await expect(page.getByRole('option').first()).toBeVisible();
|
|
||||||
const renderedCount = await page.getByRole('option').count();
|
|
||||||
expect(renderedCount).toBeGreaterThan(0);
|
|
||||||
expect(renderedCount).toBeLessThan(60);
|
|
||||||
|
|
||||||
// Virtualization must not drop options: searching narrows the list to the one deep match.
|
|
||||||
// Wait for the filtered count to settle to 1 before asserting — checking the option while
|
|
||||||
// the virtualizer is still re-rendering can transiently match a stale row (Firefox CI flake).
|
|
||||||
await page.getByPlaceholder('Search for a Project...').fill('VirtProj 79');
|
|
||||||
await expect(page.getByRole('option')).toHaveCount(1);
|
|
||||||
await expect(page.getByRole('option')).toContainText('VirtProj 79');
|
|
||||||
|
|
||||||
await page.keyboard.press('Escape');
|
|
||||||
});
|
|
||||||
|
|
||||||
test('test that selecting multiple projects shows correct badge count', async ({ page, ctx }) => {
|
test('test that selecting multiple projects shows correct badge count', async ({ page, ctx }) => {
|
||||||
const project1Name = 'MultiProj1 ' + Math.floor(Math.random() * 10000);
|
const project1Name = 'MultiProj1 ' + Math.floor(Math.random() * 10000);
|
||||||
const project2Name = 'MultiProj2 ' + Math.floor(Math.random() * 10000);
|
const project2Name = 'MultiProj2 ' + Math.floor(Math.random() * 10000);
|
||||||
|
|||||||
@@ -152,49 +152,6 @@ test('test that editing a task name works', async ({ page, ctx }) => {
|
|||||||
await expect(page.getByTestId('task_table')).not.toContainText(originalTaskName);
|
await expect(page.getByTestId('task_table')).not.toContainText(originalTaskName);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('test that the project can be searched and changed in the create task modal', async ({
|
|
||||||
page,
|
|
||||||
ctx,
|
|
||||||
}) => {
|
|
||||||
const sourceProject = 'Source Project ' + Math.floor(1 + Math.random() * 100000);
|
|
||||||
const targetProject = 'Target Project ' + Math.floor(1 + Math.random() * 100000);
|
|
||||||
await createProjectViaApi(ctx, { name: sourceProject });
|
|
||||||
const target = await createProjectViaApi(ctx, { name: targetProject });
|
|
||||||
|
|
||||||
await goToProjectsOverview(page);
|
|
||||||
await page.getByText(sourceProject).first().click();
|
|
||||||
await page.getByRole('button', { name: 'Create Task' }).click();
|
|
||||||
await expect(page.getByRole('dialog')).toBeVisible();
|
|
||||||
|
|
||||||
// The project dropdown is pre-filled with the source project; open it.
|
|
||||||
await page.getByRole('dialog').getByRole('button', { name: sourceProject }).click();
|
|
||||||
|
|
||||||
// Opening the dropdown focuses the search input; searching narrows it to the target project.
|
|
||||||
const projectSearch = page.getByPlaceholder('Search for a project...');
|
|
||||||
await expect(projectSearch).toBeFocused();
|
|
||||||
await projectSearch.fill('Target Project');
|
|
||||||
await page.getByRole('option', { name: targetProject }).click();
|
|
||||||
|
|
||||||
// Selecting closes the dropdown and updates the trigger to the chosen project.
|
|
||||||
await expect(
|
|
||||||
page.getByRole('dialog').getByRole('button', { name: targetProject })
|
|
||||||
).toBeVisible();
|
|
||||||
|
|
||||||
// The new selection is what gets used when the task is created.
|
|
||||||
const taskName = 'Switched Task ' + Math.floor(1 + Math.random() * 100000);
|
|
||||||
await page.getByPlaceholder('Task Name').fill(taskName);
|
|
||||||
await Promise.all([
|
|
||||||
page.getByRole('dialog').getByRole('button', { name: 'Create Task' }).click(),
|
|
||||||
page.waitForResponse(
|
|
||||||
async (response) =>
|
|
||||||
response.url().includes('/tasks') &&
|
|
||||||
response.request().method() === 'POST' &&
|
|
||||||
response.status() === 201 &&
|
|
||||||
(await response.json()).data.project_id === target.id
|
|
||||||
),
|
|
||||||
]);
|
|
||||||
});
|
|
||||||
|
|
||||||
test('test that creating a project with an existing client works', async ({ page, ctx }) => {
|
test('test that creating a project with an existing client works', async ({ page, ctx }) => {
|
||||||
const clientName = 'Existing Client ' + Math.floor(1 + Math.random() * 10000);
|
const clientName = 'Existing Client ' + Math.floor(1 + Math.random() * 10000);
|
||||||
const projectName = 'Project With Client ' + Math.floor(1 + Math.random() * 10000);
|
const projectName = 'Project With Client ' + Math.floor(1 + Math.random() * 10000);
|
||||||
|
|||||||
@@ -9,14 +9,7 @@ import {
|
|||||||
} from './utils/currentTimeEntry';
|
} from './utils/currentTimeEntry';
|
||||||
import type { Page } from '@playwright/test';
|
import type { Page } from '@playwright/test';
|
||||||
import { newTagResponse } from './utils/tags';
|
import { newTagResponse } from './utils/tags';
|
||||||
import {
|
import { createProjectViaApi, updateOrganizationCurrencyViaWeb } from './utils/api';
|
||||||
createProjectViaApi,
|
|
||||||
createTaskViaApi,
|
|
||||||
createClientViaApi,
|
|
||||||
archiveProjectViaApi,
|
|
||||||
markTaskDoneViaApi,
|
|
||||||
updateOrganizationCurrencyViaWeb,
|
|
||||||
} from './utils/api';
|
|
||||||
|
|
||||||
// Date picker button name patterns for different date formats
|
// Date picker button name patterns for different date formats
|
||||||
const DATE_DISPLAY_PATTERN = /^\d{4}-\d{2}-\d{2}$|^\d{2}\/\d{2}\/\d{4}$|^\d{2}\.\d{2}\.\d{4}$/;
|
const DATE_DISPLAY_PATTERN = /^\d{4}-\d{2}-\d{2}$|^\d{2}\/\d{2}\/\d{4}$|^\d{2}\.\d{2}\.\d{4}$/;
|
||||||
@@ -448,236 +441,3 @@ test('test that adding a project and tag before starting timer works', async ({
|
|||||||
]);
|
]);
|
||||||
await assertThatTimerIsStopped(page);
|
await assertThatTimerIsStopped(page);
|
||||||
});
|
});
|
||||||
|
|
||||||
// ──────────────────────────────────────────────────
|
|
||||||
// Project / Task selector dropdown
|
|
||||||
// Regression coverage for the virtualized + lookup-map refactor of
|
|
||||||
// TimeTrackerProjectTaskDropdown. The dropdown only (re)filters on open and on search
|
|
||||||
// change, so we wait for the dashboard prefetch to settle before opening it.
|
|
||||||
// ──────────────────────────────────────────────────
|
|
||||||
|
|
||||||
test.describe('Project Task Dropdown', () => {
|
|
||||||
test.describe.configure({ timeout: 60_000 });
|
|
||||||
|
|
||||||
test('test that a project far down a long list can be found via search and selected', async ({
|
|
||||||
page,
|
|
||||||
ctx,
|
|
||||||
}) => {
|
|
||||||
// Seed enough projects that the target sits outside the initially rendered window.
|
|
||||||
const seed = Math.floor(Math.random() * 100000);
|
|
||||||
const prefix = `VirtProj ${seed} `;
|
|
||||||
await Promise.all(
|
|
||||||
Array.from({ length: 30 }, (_, i) =>
|
|
||||||
createProjectViaApi(ctx, { name: prefix + String(i).padStart(2, '0') })
|
|
||||||
)
|
|
||||||
);
|
|
||||||
const target = prefix + '27';
|
|
||||||
|
|
||||||
await goToDashboard(page);
|
|
||||||
await page.waitForLoadState('networkidle');
|
|
||||||
|
|
||||||
await page.getByRole('button', { name: 'No Project' }).click();
|
|
||||||
await page.getByTestId('client_dropdown_search').fill(target);
|
|
||||||
await page.getByRole('option').filter({ hasText: target }).click();
|
|
||||||
|
|
||||||
// The trigger now reflects the selected project.
|
|
||||||
await expect(page.getByRole('button', { name: target })).toBeVisible();
|
|
||||||
});
|
|
||||||
|
|
||||||
test('test that expanding a project and selecting a task works', async ({ page, ctx }) => {
|
|
||||||
const seed = Math.floor(Math.random() * 100000);
|
|
||||||
const projectName = `ExpandProj ${seed}`;
|
|
||||||
const taskName = `ExpandTask ${seed}`;
|
|
||||||
const project = await createProjectViaApi(ctx, { name: projectName });
|
|
||||||
await createTaskViaApi(ctx, { name: taskName, project_id: project.id });
|
|
||||||
|
|
||||||
await goToDashboard(page);
|
|
||||||
await page.waitForLoadState('networkidle');
|
|
||||||
|
|
||||||
await page.getByRole('button', { name: 'No Project' }).click();
|
|
||||||
const projectOption = page.getByRole('option').filter({ hasText: projectName });
|
|
||||||
await expect(projectOption).toBeVisible();
|
|
||||||
|
|
||||||
// Expand the project's tasks via the "N Tasks" button, then select the task.
|
|
||||||
await projectOption.getByText(/Tasks/).click();
|
|
||||||
await page.getByText(taskName, { exact: true }).click();
|
|
||||||
|
|
||||||
// Scoped to the trigger button: the closing dropdown also contains the name while animating out.
|
|
||||||
await expect(
|
|
||||||
page.getByRole('button', { name: `${projectName} ${taskName}` })
|
|
||||||
).toBeVisible();
|
|
||||||
});
|
|
||||||
|
|
||||||
test('test that keyboard navigation selects a project', async ({ page, ctx }) => {
|
|
||||||
const seed = Math.floor(Math.random() * 100000);
|
|
||||||
const projectName = `KbProj ${seed}`;
|
|
||||||
await createProjectViaApi(ctx, { name: projectName });
|
|
||||||
|
|
||||||
await goToDashboard(page);
|
|
||||||
await page.waitForLoadState('networkidle');
|
|
||||||
|
|
||||||
await page.getByRole('button', { name: 'No Project' }).click();
|
|
||||||
const search = page.getByTestId('client_dropdown_search');
|
|
||||||
// On open the search is focused and "No Project" is highlighted.
|
|
||||||
await expect(search).toBeFocused();
|
|
||||||
|
|
||||||
// Arrow down from "No Project" to the project, then select it with Enter.
|
|
||||||
await search.press('ArrowDown');
|
|
||||||
await search.press('Enter');
|
|
||||||
|
|
||||||
await expect(page.getByRole('button', { name: projectName })).toBeVisible();
|
|
||||||
});
|
|
||||||
|
|
||||||
test('test that search filters the dropdown by project and client name', async ({
|
|
||||||
page,
|
|
||||||
ctx,
|
|
||||||
}) => {
|
|
||||||
const seed = Math.floor(Math.random() * 100000);
|
|
||||||
const clientName = `FilterClient ${seed}`;
|
|
||||||
const alphaProject = `AlphaProj ${seed}`;
|
|
||||||
const betaProject = `BetaProj ${seed}`;
|
|
||||||
const client = await createClientViaApi(ctx, { name: clientName });
|
|
||||||
await createProjectViaApi(ctx, { name: alphaProject, client_id: client.id });
|
|
||||||
await createProjectViaApi(ctx, { name: betaProject });
|
|
||||||
|
|
||||||
await goToDashboard(page);
|
|
||||||
await page.waitForLoadState('networkidle');
|
|
||||||
|
|
||||||
await page.getByRole('button', { name: 'No Project' }).click();
|
|
||||||
const search = page.getByTestId('client_dropdown_search');
|
|
||||||
const alphaOption = page.getByRole('option').filter({ hasText: alphaProject });
|
|
||||||
const betaOption = page.getByRole('option').filter({ hasText: betaProject });
|
|
||||||
|
|
||||||
// Both projects are visible before filtering.
|
|
||||||
await expect(alphaOption).toBeVisible();
|
|
||||||
await expect(betaOption).toBeVisible();
|
|
||||||
|
|
||||||
// Project-name search shows only the matching project.
|
|
||||||
await search.fill('AlphaProj');
|
|
||||||
await expect(alphaOption).toBeVisible();
|
|
||||||
await expect(betaOption).not.toBeVisible();
|
|
||||||
|
|
||||||
// Client-name search shows the project that belongs to that client.
|
|
||||||
await search.fill(clientName);
|
|
||||||
await expect(alphaOption).toBeVisible();
|
|
||||||
await expect(betaOption).not.toBeVisible();
|
|
||||||
});
|
|
||||||
|
|
||||||
test("test that searching by task name surfaces the task's project", async ({ page, ctx }) => {
|
|
||||||
const seed = Math.floor(Math.random() * 100000);
|
|
||||||
const projectWithTask = `TaskSearchProj ${seed}`;
|
|
||||||
const taskName = `Findable Task ${seed}`;
|
|
||||||
const unrelatedProject = `Unrelated Proj ${seed}`;
|
|
||||||
const project = await createProjectViaApi(ctx, { name: projectWithTask });
|
|
||||||
await createTaskViaApi(ctx, { name: taskName, project_id: project.id });
|
|
||||||
await createProjectViaApi(ctx, { name: unrelatedProject });
|
|
||||||
|
|
||||||
await goToDashboard(page);
|
|
||||||
await page.waitForLoadState('networkidle');
|
|
||||||
|
|
||||||
await page.getByRole('button', { name: 'No Project' }).click();
|
|
||||||
await page.getByTestId('client_dropdown_search').fill(taskName);
|
|
||||||
|
|
||||||
// The project owning the task is shown (with the task), the unrelated project is not.
|
|
||||||
await expect(page.getByRole('option').filter({ hasText: projectWithTask })).toBeVisible();
|
|
||||||
await expect(page.getByText(taskName, { exact: true })).toBeVisible();
|
|
||||||
await expect(
|
|
||||||
page.getByRole('option').filter({ hasText: unrelatedProject })
|
|
||||||
).not.toBeVisible();
|
|
||||||
});
|
|
||||||
|
|
||||||
test('test that archived projects are hidden from the dropdown', async ({ page, ctx }) => {
|
|
||||||
const seed = Math.floor(Math.random() * 100000);
|
|
||||||
const activeProject = `ActiveProj ${seed}`;
|
|
||||||
const archivedProject = `ArchivedProj ${seed}`;
|
|
||||||
await createProjectViaApi(ctx, { name: activeProject });
|
|
||||||
const toArchive = await createProjectViaApi(ctx, { name: archivedProject });
|
|
||||||
await archiveProjectViaApi(ctx, toArchive);
|
|
||||||
|
|
||||||
await goToDashboard(page);
|
|
||||||
await page.waitForLoadState('networkidle');
|
|
||||||
|
|
||||||
await page.getByRole('button', { name: 'No Project' }).click();
|
|
||||||
|
|
||||||
// Wait for the list to load, then confirm the archived project is filtered out.
|
|
||||||
await expect(page.getByRole('option').filter({ hasText: activeProject })).toBeVisible();
|
|
||||||
await expect(
|
|
||||||
page.getByRole('option').filter({ hasText: archivedProject })
|
|
||||||
).not.toBeVisible();
|
|
||||||
});
|
|
||||||
|
|
||||||
test('test that done tasks are hidden when expanding a project', async ({ page, ctx }) => {
|
|
||||||
const seed = Math.floor(Math.random() * 100000);
|
|
||||||
const projectName = `DoneTaskProj ${seed}`;
|
|
||||||
const activeTask = `Active Task ${seed}`;
|
|
||||||
const doneTask = `Done Task ${seed}`;
|
|
||||||
const project = await createProjectViaApi(ctx, { name: projectName });
|
|
||||||
await createTaskViaApi(ctx, { name: activeTask, project_id: project.id });
|
|
||||||
const taskToFinish = await createTaskViaApi(ctx, {
|
|
||||||
name: doneTask,
|
|
||||||
project_id: project.id,
|
|
||||||
});
|
|
||||||
await markTaskDoneViaApi(ctx, taskToFinish);
|
|
||||||
|
|
||||||
await goToDashboard(page);
|
|
||||||
await page.waitForLoadState('networkidle');
|
|
||||||
|
|
||||||
await page.getByRole('button', { name: 'No Project' }).click();
|
|
||||||
const projectOption = page.getByRole('option').filter({ hasText: projectName });
|
|
||||||
await expect(projectOption).toBeVisible();
|
|
||||||
await projectOption.getByText(/Tasks/).click();
|
|
||||||
|
|
||||||
// Only the active task shows; the done task is filtered out.
|
|
||||||
await expect(page.getByText(activeTask, { exact: true })).toBeVisible();
|
|
||||||
await expect(page.getByText(doneTask, { exact: true })).not.toBeVisible();
|
|
||||||
});
|
|
||||||
|
|
||||||
test('test that keyboard navigation can expand a project and select a task', async ({
|
|
||||||
page,
|
|
||||||
ctx,
|
|
||||||
}) => {
|
|
||||||
const seed = Math.floor(Math.random() * 100000);
|
|
||||||
const projectName = `KbTaskProj ${seed}`;
|
|
||||||
const taskName = `KbTask ${seed}`;
|
|
||||||
const project = await createProjectViaApi(ctx, { name: projectName });
|
|
||||||
await createTaskViaApi(ctx, { name: taskName, project_id: project.id });
|
|
||||||
|
|
||||||
await goToDashboard(page);
|
|
||||||
await page.waitForLoadState('networkidle');
|
|
||||||
|
|
||||||
await page.getByRole('button', { name: 'No Project' }).click();
|
|
||||||
const search = page.getByTestId('client_dropdown_search');
|
|
||||||
await expect(search).toBeFocused();
|
|
||||||
|
|
||||||
// No Project is highlighted on open: down to the project, right to expand its tasks,
|
|
||||||
// down to the task, Enter to select it.
|
|
||||||
await search.press('ArrowDown');
|
|
||||||
await search.press('ArrowRight');
|
|
||||||
await search.press('ArrowDown');
|
|
||||||
await search.press('Enter');
|
|
||||||
|
|
||||||
// Scoped to the trigger button: the closing dropdown also contains the name while animating out.
|
|
||||||
await expect(
|
|
||||||
page.getByRole('button', { name: `${projectName} ${taskName}` })
|
|
||||||
).toBeVisible();
|
|
||||||
});
|
|
||||||
|
|
||||||
test('test that pressing space selects the highlighted project', async ({ page, ctx }) => {
|
|
||||||
const seed = Math.floor(Math.random() * 100000);
|
|
||||||
const projectName = `SpaceProj ${seed}`;
|
|
||||||
await createProjectViaApi(ctx, { name: projectName });
|
|
||||||
|
|
||||||
await goToDashboard(page);
|
|
||||||
await page.waitForLoadState('networkidle');
|
|
||||||
|
|
||||||
await page.getByRole('button', { name: 'No Project' }).click();
|
|
||||||
const search = page.getByTestId('client_dropdown_search');
|
|
||||||
await expect(search).toBeFocused();
|
|
||||||
|
|
||||||
// Arrow down from "No Project" to the project, then the space shortcut selects it.
|
|
||||||
await search.press('ArrowDown');
|
|
||||||
await search.press('Space');
|
|
||||||
|
|
||||||
await expect(page.getByRole('button', { name: projectName })).toBeVisible();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|||||||
@@ -1,192 +0,0 @@
|
|||||||
import { test, expect } from '../playwright/fixtures';
|
|
||||||
import { PLAYWRIGHT_BASE_URL, TEST_USER_PASSWORD } from '../playwright/config';
|
|
||||||
import { generateTotpCode, generateInvalidTotpCode } from './utils/totp';
|
|
||||||
import type { Page } from '@playwright/test';
|
|
||||||
|
|
||||||
async function goToProfilePage(page: Page) {
|
|
||||||
await page.goto(PLAYWRIGHT_BASE_URL + '/user/profile');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* ConfirmsPassword only opens the dialog when the password has not been
|
|
||||||
* confirmed recently, so fill it only when it actually shows up.
|
|
||||||
*/
|
|
||||||
async function confirmPasswordIfPrompted(page: Page) {
|
|
||||||
const dialog = page.getByRole('dialog');
|
|
||||||
const appeared = await dialog
|
|
||||||
.waitFor({ state: 'visible', timeout: 2500 })
|
|
||||||
.then(() => true)
|
|
||||||
.catch(() => false);
|
|
||||||
if (appeared) {
|
|
||||||
await dialog.getByPlaceholder('Password').fill(TEST_USER_PASSWORD);
|
|
||||||
await dialog.getByRole('button', { name: 'Confirm' }).click();
|
|
||||||
await expect(dialog).not.toBeVisible();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Enables 2FA from the profile page and returns the TOTP secret (setup key)
|
|
||||||
* and the recovery codes fetched right after enabling.
|
|
||||||
*/
|
|
||||||
async function enableTwoFactor(page: Page): Promise<{ secret: string; recoveryCodes: string[] }> {
|
|
||||||
await goToProfilePage(page);
|
|
||||||
await page
|
|
||||||
.getByText('You have not enabled two factor authentication.')
|
|
||||||
.locator('..')
|
|
||||||
.getByRole('button', { name: 'Enable' })
|
|
||||||
.click();
|
|
||||||
|
|
||||||
const dialog = page.getByRole('dialog');
|
|
||||||
await expect(dialog).toBeVisible();
|
|
||||||
|
|
||||||
const recoveryCodesResponse = page.waitForResponse(
|
|
||||||
(response) =>
|
|
||||||
response.url().includes('/user/two-factor-recovery-codes') &&
|
|
||||||
response.request().method() === 'GET'
|
|
||||||
);
|
|
||||||
await dialog.getByPlaceholder('Password').fill(TEST_USER_PASSWORD);
|
|
||||||
await dialog.getByRole('button', { name: 'Confirm' }).click();
|
|
||||||
|
|
||||||
await expect(page.getByRole('heading', { name: 'Finish enabling two factor' })).toBeVisible();
|
|
||||||
const recoveryCodes: string[] = await (await recoveryCodesResponse).json();
|
|
||||||
|
|
||||||
const setupKeyText = await page.getByText('Setup Key:').textContent();
|
|
||||||
const secret = setupKeyText!.replace('Setup Key:', '').trim();
|
|
||||||
expect(secret.length).toBeGreaterThan(0);
|
|
||||||
|
|
||||||
return { secret, recoveryCodes };
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Confirms a freshly enabled 2FA setup with a valid TOTP code.
|
|
||||||
*/
|
|
||||||
async function confirmTwoFactor(page: Page, secret: string) {
|
|
||||||
await page.getByLabel('Code').fill(generateTotpCode(secret));
|
|
||||||
await page.getByRole('button', { name: 'Confirm', exact: true }).click();
|
|
||||||
await confirmPasswordIfPrompted(page);
|
|
||||||
await expect(page.getByText('You have enabled two factor authentication.')).toBeVisible();
|
|
||||||
}
|
|
||||||
|
|
||||||
async function logout(page: Page) {
|
|
||||||
await page.getByTestId('current_user_button').click();
|
|
||||||
await page.getByText('Log Out', { exact: true }).click();
|
|
||||||
await page.waitForURL(PLAYWRIGHT_BASE_URL + '/login');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Reads the email of the current user from the profile form, waiting until
|
|
||||||
* the user query has populated it.
|
|
||||||
*/
|
|
||||||
async function getProfileEmail(page: Page): Promise<string> {
|
|
||||||
await goToProfilePage(page);
|
|
||||||
const emailInput = page.getByLabel('Email', { exact: true });
|
|
||||||
await expect(emailInput).toHaveValue(/@/);
|
|
||||||
return await emailInput.inputValue();
|
|
||||||
}
|
|
||||||
|
|
||||||
async function loginUntilTwoFactorChallenge(page: Page, email: string) {
|
|
||||||
await page.goto(PLAYWRIGHT_BASE_URL + '/login');
|
|
||||||
await page.getByLabel('Email').fill(email);
|
|
||||||
await page.getByLabel('Password').fill(TEST_USER_PASSWORD);
|
|
||||||
await page.getByRole('button', { name: 'Log in' }).click();
|
|
||||||
await page.waitForURL(PLAYWRIGHT_BASE_URL + '/two-factor-challenge');
|
|
||||||
}
|
|
||||||
|
|
||||||
test('test that 2FA can be confirmed with a TOTP code and shows recovery codes', async ({
|
|
||||||
page,
|
|
||||||
}) => {
|
|
||||||
const { secret, recoveryCodes } = await enableTwoFactor(page);
|
|
||||||
await confirmTwoFactor(page, secret);
|
|
||||||
|
|
||||||
await expect(page.getByText('Store these recovery codes')).toBeVisible();
|
|
||||||
expect(recoveryCodes.length).toBeGreaterThan(0);
|
|
||||||
for (const code of recoveryCodes) {
|
|
||||||
await expect(page.getByText(code)).toBeVisible();
|
|
||||||
}
|
|
||||||
|
|
||||||
// The confirmed state survives a reload
|
|
||||||
await page.reload();
|
|
||||||
await expect(page.getByText('You have enabled two factor authentication.')).toBeVisible();
|
|
||||||
});
|
|
||||||
|
|
||||||
test('test that 2FA confirmation fails with an invalid TOTP code', async ({ page }) => {
|
|
||||||
const { secret } = await enableTwoFactor(page);
|
|
||||||
|
|
||||||
await page.getByLabel('Code').fill(generateInvalidTotpCode(secret));
|
|
||||||
await page.getByRole('button', { name: 'Confirm', exact: true }).click();
|
|
||||||
await confirmPasswordIfPrompted(page);
|
|
||||||
|
|
||||||
await expect(page.getByRole('alert')).toContainText(
|
|
||||||
'The provided two factor authentication code was invalid.'
|
|
||||||
);
|
|
||||||
await expect(page.getByRole('heading', { name: 'Finish enabling two factor' })).toBeVisible();
|
|
||||||
});
|
|
||||||
|
|
||||||
test('test that recovery codes can be regenerated', async ({ page }) => {
|
|
||||||
const { secret, recoveryCodes } = await enableTwoFactor(page);
|
|
||||||
await confirmTwoFactor(page, secret);
|
|
||||||
|
|
||||||
const newCodesResponse = page.waitForResponse(
|
|
||||||
(response) =>
|
|
||||||
response.url().includes('/user/two-factor-recovery-codes') &&
|
|
||||||
response.request().method() === 'GET'
|
|
||||||
);
|
|
||||||
await page.getByRole('button', { name: 'Regenerate Recovery Codes' }).click();
|
|
||||||
await confirmPasswordIfPrompted(page);
|
|
||||||
const newCodes: string[] = await (await newCodesResponse).json();
|
|
||||||
|
|
||||||
expect(newCodes).not.toEqual(recoveryCodes);
|
|
||||||
await expect(page.getByText(newCodes[0])).toBeVisible();
|
|
||||||
await expect(page.getByText(recoveryCodes[0])).not.toBeVisible();
|
|
||||||
});
|
|
||||||
|
|
||||||
test('test that 2FA can be disabled', async ({ page }) => {
|
|
||||||
const { secret } = await enableTwoFactor(page);
|
|
||||||
await confirmTwoFactor(page, secret);
|
|
||||||
|
|
||||||
await page.getByRole('button', { name: 'Disable' }).click();
|
|
||||||
await confirmPasswordIfPrompted(page);
|
|
||||||
await expect(page.getByText('You have not enabled two factor authentication.')).toBeVisible();
|
|
||||||
|
|
||||||
// The disabled state survives a reload
|
|
||||||
await page.reload();
|
|
||||||
await expect(page.getByText('You have not enabled two factor authentication.')).toBeVisible();
|
|
||||||
});
|
|
||||||
|
|
||||||
test('test that login challenges for a TOTP code and rejects an invalid code', async ({ page }) => {
|
|
||||||
const email = await getProfileEmail(page);
|
|
||||||
|
|
||||||
const { secret } = await enableTwoFactor(page);
|
|
||||||
await confirmTwoFactor(page, secret);
|
|
||||||
await logout(page);
|
|
||||||
|
|
||||||
await loginUntilTwoFactorChallenge(page, email);
|
|
||||||
|
|
||||||
await page.getByLabel('Code').fill(generateInvalidTotpCode(secret));
|
|
||||||
await page.getByRole('button', { name: 'Log in' }).click();
|
|
||||||
await expect(page.getByRole('alert')).toContainText(
|
|
||||||
'The provided two factor authentication code was invalid.'
|
|
||||||
);
|
|
||||||
|
|
||||||
// Fortify rejects replayed codes, and the current window's code was
|
|
||||||
// already consumed when confirming the setup — use the next window's
|
|
||||||
// code, which the +/- 1 step verification window also accepts.
|
|
||||||
await page.getByLabel('Code').fill(generateTotpCode(secret, Date.now() + 30_000));
|
|
||||||
await page.getByRole('button', { name: 'Log in' }).click();
|
|
||||||
await expect(page.getByTestId('dashboard_view')).toBeVisible();
|
|
||||||
});
|
|
||||||
|
|
||||||
test('test that login works with a recovery code', async ({ page }) => {
|
|
||||||
const email = await getProfileEmail(page);
|
|
||||||
|
|
||||||
const { secret, recoveryCodes } = await enableTwoFactor(page);
|
|
||||||
await confirmTwoFactor(page, secret);
|
|
||||||
await logout(page);
|
|
||||||
|
|
||||||
await loginUntilTwoFactorChallenge(page, email);
|
|
||||||
|
|
||||||
await page.getByRole('button', { name: 'Use a recovery code' }).click();
|
|
||||||
await page.getByLabel('Recovery Code').fill(recoveryCodes[0]);
|
|
||||||
await page.getByRole('button', { name: 'Log in' }).click();
|
|
||||||
await expect(page.getByTestId('dashboard_view')).toBeVisible();
|
|
||||||
});
|
|
||||||
@@ -373,20 +373,6 @@ export async function createTaskViaApi(
|
|||||||
return body.data as { id: string; name: string; project_id: string };
|
return body.data as { id: string; name: string; project_id: string };
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function markTaskDoneViaApi(ctx: TestContext, task: { id: string; name: string }) {
|
|
||||||
const response = await ctx.request.put(
|
|
||||||
`${PLAYWRIGHT_BASE_URL}/api/v1/organizations/${ctx.orgId}/tasks/${task.id}`,
|
|
||||||
{
|
|
||||||
data: {
|
|
||||||
name: task.name,
|
|
||||||
is_done: true,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
);
|
|
||||||
expect(response.status()).toBe(200);
|
|
||||||
return (await response.json()).data;
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function createTagViaApi(ctx: TestContext, data: { name: string }) {
|
export async function createTagViaApi(ctx: TestContext, data: { name: string }) {
|
||||||
const response = await ctx.request.post(
|
const response = await ctx.request.post(
|
||||||
`${PLAYWRIGHT_BASE_URL}/api/v1/organizations/${ctx.orgId}/tags`,
|
`${PLAYWRIGHT_BASE_URL}/api/v1/organizations/${ctx.orgId}/tags`,
|
||||||
@@ -655,13 +641,10 @@ export async function updateOrganizationCurrencyViaWeb(
|
|||||||
const xsrfCookie = cookies.find((c) => c.name === 'XSRF-TOKEN');
|
const xsrfCookie = cookies.find((c) => c.name === 'XSRF-TOKEN');
|
||||||
const xsrfToken = xsrfCookie ? decodeURIComponent(xsrfCookie.value) : '';
|
const xsrfToken = xsrfCookie ? decodeURIComponent(xsrfCookie.value) : '';
|
||||||
|
|
||||||
const response = await page.request.put(
|
const response = await page.request.put(`${PLAYWRIGHT_BASE_URL}/teams/${ctx.orgId}`, {
|
||||||
`${PLAYWRIGHT_BASE_URL}/api/v1/organizations/${ctx.orgId}`,
|
headers: { 'X-XSRF-TOKEN': xsrfToken },
|
||||||
{
|
data: { name, currency },
|
||||||
headers: { 'X-XSRF-TOKEN': xsrfToken },
|
});
|
||||||
data: { name, currency },
|
|
||||||
}
|
|
||||||
);
|
|
||||||
expect(response.status()).toBe(200);
|
expect(response.status()).toBe(200);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -818,23 +801,53 @@ export async function getCurrentUserViaApi(ctx: TestContext) {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function updateUserProfileViaApi(
|
export async function updateUserProfileViaWeb(
|
||||||
ctx: TestContext,
|
page: Page,
|
||||||
settings: { timezone?: string; week_start?: string }
|
settings: { timezone?: string; week_start?: string }
|
||||||
) {
|
) {
|
||||||
const user = await getCurrentUserViaApi(ctx);
|
// Read user info from Inertia's data-page attribute on the root element
|
||||||
|
const userInfo = await page.evaluate(() => {
|
||||||
|
// Try Inertia's data-page attribute (stores initial page props as JSON)
|
||||||
|
const appEl = document.getElementById('app');
|
||||||
|
if (appEl) {
|
||||||
|
const dataPage = appEl.getAttribute('data-page');
|
||||||
|
if (dataPage) {
|
||||||
|
try {
|
||||||
|
const parsed = JSON.parse(dataPage);
|
||||||
|
const user = parsed?.props?.auth?.user;
|
||||||
|
if (user) {
|
||||||
|
return {
|
||||||
|
name: user.name,
|
||||||
|
email: user.email,
|
||||||
|
timezone: user.timezone,
|
||||||
|
week_start: user.week_start,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
// JSON parse failed
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
});
|
||||||
|
if (!userInfo) throw new Error('Could not read user info from Inertia data-page attribute');
|
||||||
|
|
||||||
// Only send the fields under test; the endpoint leaves omitted fields untouched.
|
const cookies = await page.context().cookies();
|
||||||
const data: Record<string, string> = {};
|
const xsrfCookie = cookies.find((c) => c.name === 'XSRF-TOKEN');
|
||||||
if (settings.timezone !== undefined) {
|
const xsrfToken = xsrfCookie ? decodeURIComponent(xsrfCookie.value) : '';
|
||||||
data.timezone = settings.timezone;
|
|
||||||
}
|
|
||||||
if (settings.week_start !== undefined) {
|
|
||||||
data.week_start = settings.week_start;
|
|
||||||
}
|
|
||||||
|
|
||||||
const response = await ctx.request.put(`${PLAYWRIGHT_BASE_URL}/api/v1/users/${user.id}`, {
|
const response = await page.request.put(`${PLAYWRIGHT_BASE_URL}/user/profile-information`, {
|
||||||
data,
|
headers: {
|
||||||
|
'X-XSRF-TOKEN': xsrfToken,
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
Accept: 'application/json',
|
||||||
|
},
|
||||||
|
data: {
|
||||||
|
name: userInfo.name,
|
||||||
|
email: userInfo.email,
|
||||||
|
timezone: settings.timezone ?? userInfo.timezone,
|
||||||
|
week_start: settings.week_start ?? userInfo.week_start,
|
||||||
|
},
|
||||||
});
|
});
|
||||||
expect(response.status()).toBe(200);
|
expect(response.status()).toBe(200);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,58 +0,0 @@
|
|||||||
import { createHmac } from 'node:crypto';
|
|
||||||
|
|
||||||
const BASE32_ALPHABET = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ234567';
|
|
||||||
|
|
||||||
function base32Decode(input: string): Buffer {
|
|
||||||
const normalized = input
|
|
||||||
.toUpperCase()
|
|
||||||
.replace(/=+$/, '')
|
|
||||||
.replace(/[^A-Z2-7]/g, '');
|
|
||||||
let bits = 0;
|
|
||||||
let value = 0;
|
|
||||||
const bytes: number[] = [];
|
|
||||||
for (const char of normalized) {
|
|
||||||
value = (value << 5) | BASE32_ALPHABET.indexOf(char);
|
|
||||||
bits += 5;
|
|
||||||
if (bits >= 8) {
|
|
||||||
bytes.push((value >>> (bits - 8)) & 0xff);
|
|
||||||
bits -= 8;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return Buffer.from(bytes);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Generates a 6-digit TOTP code (RFC 6238, SHA-1, 30 second period) for the
|
|
||||||
* given base32 secret — the "Setup Key" shown while enabling 2FA.
|
|
||||||
*/
|
|
||||||
export function generateTotpCode(base32Secret: string, atMs: number = Date.now()): string {
|
|
||||||
const counter = Math.floor(atMs / 1000 / 30);
|
|
||||||
const counterBuffer = Buffer.alloc(8);
|
|
||||||
counterBuffer.writeBigUInt64BE(BigInt(counter));
|
|
||||||
const digest = createHmac('sha1', base32Decode(base32Secret)).update(counterBuffer).digest();
|
|
||||||
const offset = digest[digest.length - 1] & 0x0f;
|
|
||||||
const code =
|
|
||||||
((digest[offset] & 0x7f) << 24) |
|
|
||||||
((digest[offset + 1] & 0xff) << 16) |
|
|
||||||
((digest[offset + 2] & 0xff) << 8) |
|
|
||||||
(digest[offset + 3] & 0xff);
|
|
||||||
return (code % 1_000_000).toString().padStart(6, '0');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Generates a syntactically valid TOTP code that is guaranteed to be rejected,
|
|
||||||
* by using a timestamp far outside the accepted verification window.
|
|
||||||
*/
|
|
||||||
export function generateInvalidTotpCode(base32Secret: string): string {
|
|
||||||
const validNow = [
|
|
||||||
generateTotpCode(base32Secret, Date.now() - 30_000),
|
|
||||||
generateTotpCode(base32Secret),
|
|
||||||
generateTotpCode(base32Secret, Date.now() + 30_000),
|
|
||||||
];
|
|
||||||
for (let minutes = 10; ; minutes++) {
|
|
||||||
const candidate = generateTotpCode(base32Secret, Date.now() + minutes * 60_000);
|
|
||||||
if (!validNow.includes(candidate)) {
|
|
||||||
return candidate;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -5,8 +5,7 @@ declare(strict_types=1);
|
|||||||
return [
|
return [
|
||||||
'clockify_time_entries' => [
|
'clockify_time_entries' => [
|
||||||
'name' => 'Clockify Time Entries',
|
'name' => 'Clockify Time Entries',
|
||||||
'description' => '<strong>Important:</strong> If you also want to import your projects use the "Clockify Projects" importer before this one, since that export contains more details such as billable status, billable rates and estimated time.<br><br>'.
|
'description' => '1. First make sure that you set the Date format to "MM/DD/YYYY" and the Time format to "12-hour" in the user settings.<br>'.
|
||||||
'1. First make sure that you set the Date format to "MM/DD/YYYY" and the Time format to "12-hour" in the user settings.<br>'.
|
|
||||||
'2. In the same preferences page change the language of Clockfiy to English.<br>'.
|
'2. In the same preferences page change the language of Clockfiy to English.<br>'.
|
||||||
'3. Go to REPORTS -> TIME -> Detailed in the navigation on the left. <br>'.
|
'3. Go to REPORTS -> TIME -> Detailed in the navigation on the left. <br>'.
|
||||||
'4. Now select the date range that you want to export in the right top. '.
|
'4. Now select the date range that you want to export in the right top. '.
|
||||||
@@ -62,8 +61,7 @@ return [
|
|||||||
],
|
],
|
||||||
'harvest_time_entries' => [
|
'harvest_time_entries' => [
|
||||||
'name' => 'Harvest Time Entries',
|
'name' => 'Harvest Time Entries',
|
||||||
'description' => '<strong>Important:</strong> If you also want to import your projects use the "Harvest Projects" importer before this one, since that export contains more details such as billable status and estimated time.<br><br>'.
|
'description' => '1. Go to Settings (right top corner)<br>2. Click on "Import/Export" in the left navigation'.
|
||||||
'1. Go to Settings (right top corner)<br>2. Click on "Import/Export" in the left navigation'.
|
|
||||||
'<br>3. Now click on "Export all time" '.
|
'<br>3. Now click on "Export all time" '.
|
||||||
'<br><br>Before you import make sure that the Timezone settings in Harvest are the same as in solidtime.',
|
'<br><br>Before you import make sure that the Timezone settings in Harvest are the same as in solidtime.',
|
||||||
],
|
],
|
||||||
|
|||||||
23
package-lock.json
generated
23
package-lock.json
generated
@@ -20,7 +20,6 @@
|
|||||||
"@tanstack/vue-query": "^5.100.10",
|
"@tanstack/vue-query": "^5.100.10",
|
||||||
"@tanstack/vue-query-devtools": "^5.91.0",
|
"@tanstack/vue-query-devtools": "^5.91.0",
|
||||||
"@tanstack/vue-table": "^8.21.3",
|
"@tanstack/vue-table": "^8.21.3",
|
||||||
"@tanstack/vue-virtual": "^3.13.24",
|
|
||||||
"@vue/eslint-config-prettier": "^10.2.0",
|
"@vue/eslint-config-prettier": "^10.2.0",
|
||||||
"@vue/eslint-config-typescript": "^14.7.0",
|
"@vue/eslint-config-typescript": "^14.7.0",
|
||||||
"@vueuse/core": "^14.3.0",
|
"@vueuse/core": "^14.3.0",
|
||||||
@@ -5465,6 +5464,17 @@
|
|||||||
"yallist": "^3.0.2"
|
"yallist": "^3.0.2"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/lucide-vue-next": {
|
||||||
|
"version": "1.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/lucide-vue-next/-/lucide-vue-next-1.0.0.tgz",
|
||||||
|
"integrity": "sha512-V6SPvx1IHTj/UY+FrIYWV5faISsPSb8BnWSFDxAtezWKvWc9ZZ40PDrdu1/Qb5vg4lHWr1hs1BAMGVGm6V1Xdg==",
|
||||||
|
"deprecated": "Package deprecated. Please use @lucide/vue instead.",
|
||||||
|
"license": "ISC",
|
||||||
|
"peer": true,
|
||||||
|
"peerDependencies": {
|
||||||
|
"vue": ">=3.0.1"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/magic-string": {
|
"node_modules/magic-string": {
|
||||||
"version": "0.30.21",
|
"version": "0.30.21",
|
||||||
"resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.21.tgz",
|
"resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.21.tgz",
|
||||||
@@ -8399,7 +8409,7 @@
|
|||||||
"version": "0.0.6",
|
"version": "0.0.6",
|
||||||
"license": "AGPL-3.0",
|
"license": "AGPL-3.0",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"vite-plugin-dts": "^4.5.4"
|
"vite-plugin-dts": "^4.0.3"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"@zodios/core": "^10.9.6",
|
"@zodios/core": "^10.9.6",
|
||||||
@@ -8414,17 +8424,15 @@
|
|||||||
"version": "0.0.21",
|
"version": "0.0.21",
|
||||||
"license": "AGPL-3.0",
|
"license": "AGPL-3.0",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/chroma-js": "^3.1.2",
|
"@types/chroma-js": "^3.1.0",
|
||||||
"@zodios/core": "^10.9.6",
|
"@zodios/core": "^10.9.6",
|
||||||
"vite-plugin-dts": "^4.5.4",
|
"vite-plugin-dts": "^4.0.3",
|
||||||
"zod": "^3.25.76"
|
"zod": "^3.23.8"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"@floating-ui/vue": "^1.1.4",
|
"@floating-ui/vue": "^1.1.4",
|
||||||
"@heroicons/vue": "^2.1.5",
|
"@heroicons/vue": "^2.1.5",
|
||||||
"@internationalized/date": "^3.0.0",
|
"@internationalized/date": "^3.0.0",
|
||||||
"@lucide/vue": ">=1.0.0",
|
|
||||||
"@tanstack/vue-virtual": "^3.13.24",
|
|
||||||
"@vitejs/plugin-vue": "^5.1.2 || ^6.0.0",
|
"@vitejs/plugin-vue": "^5.1.2 || ^6.0.0",
|
||||||
"@vueuse/core": "^12.5.0 || ^14.0.0",
|
"@vueuse/core": "^12.5.0 || ^14.0.0",
|
||||||
"@vueuse/integrations": "^12.5.0 || ^14.0.0",
|
"@vueuse/integrations": "^12.5.0 || ^14.0.0",
|
||||||
@@ -8433,6 +8441,7 @@
|
|||||||
"clsx": "^2.1.1",
|
"clsx": "^2.1.1",
|
||||||
"dayjs": "^1.11.13",
|
"dayjs": "^1.11.13",
|
||||||
"focus-trap": "^7.0.0 || ^8.0.0",
|
"focus-trap": "^7.0.0 || ^8.0.0",
|
||||||
|
"lucide-vue-next": ">=0.453.0",
|
||||||
"parse-duration": "^2.0.1",
|
"parse-duration": "^2.0.1",
|
||||||
"radix-vue": "^1.9.0",
|
"radix-vue": "^1.9.0",
|
||||||
"reka-ui": "^2.2.0",
|
"reka-ui": "^2.2.0",
|
||||||
|
|||||||
@@ -64,7 +64,6 @@
|
|||||||
"@tanstack/vue-query": "^5.100.10",
|
"@tanstack/vue-query": "^5.100.10",
|
||||||
"@tanstack/vue-query-devtools": "^5.91.0",
|
"@tanstack/vue-query-devtools": "^5.91.0",
|
||||||
"@tanstack/vue-table": "^8.21.3",
|
"@tanstack/vue-table": "^8.21.3",
|
||||||
"@tanstack/vue-virtual": "^3.13.24",
|
|
||||||
"@vue/eslint-config-prettier": "^10.2.0",
|
"@vue/eslint-config-prettier": "^10.2.0",
|
||||||
"@vue/eslint-config-typescript": "^14.7.0",
|
"@vue/eslint-config-typescript": "^14.7.0",
|
||||||
"@vueuse/core": "^14.3.0",
|
"@vueuse/core": "^14.3.0",
|
||||||
|
|||||||
@@ -2,12 +2,11 @@
|
|||||||
import SecondaryButton from '@/packages/ui/src/Buttons/SecondaryButton.vue';
|
import SecondaryButton from '@/packages/ui/src/Buttons/SecondaryButton.vue';
|
||||||
import { UserCircleIcon } from '@heroicons/vue/24/solid';
|
import { UserCircleIcon } from '@heroicons/vue/24/solid';
|
||||||
import { PlusIcon } from '@heroicons/vue/16/solid';
|
import { PlusIcon } from '@heroicons/vue/16/solid';
|
||||||
import { type Component, computed, ref, watch } from 'vue';
|
import { type Component, computed, ref } from 'vue';
|
||||||
import { type Client } from '@/packages/api/src';
|
import { type Client } from '@/packages/api/src';
|
||||||
import ClientTableRow from '@/Components/Common/Client/ClientTableRow.vue';
|
import ClientTableRow from '@/Components/Common/Client/ClientTableRow.vue';
|
||||||
import ClientCreateModal from '@/Components/Common/Client/ClientCreateModal.vue';
|
import ClientCreateModal from '@/Components/Common/Client/ClientCreateModal.vue';
|
||||||
import ClientTableHeading from '@/Components/Common/Client/ClientTableHeading.vue';
|
import ClientTableHeading from '@/Components/Common/Client/ClientTableHeading.vue';
|
||||||
import Pagination from '@/Components/Common/Pagination.vue';
|
|
||||||
import { canCreateClients } from '@/utils/permissions';
|
import { canCreateClients } from '@/utils/permissions';
|
||||||
import { useProjectsQuery } from '@/utils/useProjectsQuery';
|
import { useProjectsQuery } from '@/utils/useProjectsQuery';
|
||||||
import {
|
import {
|
||||||
@@ -44,14 +43,11 @@ const projectCountMap = computed(() => {
|
|||||||
return map;
|
return map;
|
||||||
});
|
});
|
||||||
|
|
||||||
// Name is always the secondary sort so rows with equal values render
|
|
||||||
// alphabetically instead of in API (created_at) order.
|
|
||||||
const sorting = computed<SortingState>(() => [
|
const sorting = computed<SortingState>(() => [
|
||||||
{
|
{
|
||||||
id: props.sortColumn,
|
id: props.sortColumn,
|
||||||
desc: props.sortDirection === 'desc',
|
desc: props.sortDirection === 'desc',
|
||||||
},
|
},
|
||||||
...(props.sortColumn !== 'name' ? [{ id: 'name', desc: false }] : []),
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
const columns = computed(() => [
|
const columns = computed(() => [
|
||||||
@@ -104,19 +100,6 @@ const table = useVueTable({
|
|||||||
const sortedClients = computed(() => {
|
const sortedClients = computed(() => {
|
||||||
return table.getRowModel().rows.map((row) => row.original);
|
return table.getRowModel().rows.map((row) => row.original);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Client-side pagination: the full list is in memory, only one page is mounted at a time.
|
|
||||||
const PAGE_SIZE = 15;
|
|
||||||
const currentPage = ref(1);
|
|
||||||
|
|
||||||
watch([() => props.sortColumn, () => props.sortDirection, () => props.clients], () => {
|
|
||||||
currentPage.value = 1;
|
|
||||||
});
|
|
||||||
|
|
||||||
const paginatedClients = computed(() => {
|
|
||||||
const start = (currentPage.value - 1) * PAGE_SIZE;
|
|
||||||
return sortedClients.value.slice(start, start + PAGE_SIZE);
|
|
||||||
});
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
@@ -143,14 +126,10 @@ const paginatedClients = computed(() => {
|
|||||||
>Create your First Client
|
>Create your First Client
|
||||||
</SecondaryButton>
|
</SecondaryButton>
|
||||||
</div>
|
</div>
|
||||||
<template v-for="client in paginatedClients" :key="client.id">
|
<template v-for="client in sortedClients" :key="client.id">
|
||||||
<ClientTableRow :client="client"></ClientTableRow>
|
<ClientTableRow :client="client"></ClientTableRow>
|
||||||
</template>
|
</template>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<Pagination
|
|
||||||
v-model:page="currentPage"
|
|
||||||
:total="sortedClients.length"
|
|
||||||
:items-per-page="PAGE_SIZE"></Pagination>
|
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -89,17 +89,11 @@ function selectMember(member: Member) {
|
|||||||
</Button>
|
</Button>
|
||||||
</template>
|
</template>
|
||||||
<template #content>
|
<template #content>
|
||||||
<!-- kept open so the list stays visible during the popover close animation -->
|
|
||||||
<ComboboxRoot
|
<ComboboxRoot
|
||||||
v-model:search-term="searchValue"
|
v-model:search-term="searchValue"
|
||||||
:open="true"
|
v-model:open="open"
|
||||||
class="relative"
|
class="relative"
|
||||||
:filter-function="(val: string[]) => val"
|
:filter-function="(val: string[]) => val">
|
||||||
@update:open="
|
|
||||||
(value: boolean) => {
|
|
||||||
if (!value) open = false;
|
|
||||||
}
|
|
||||||
">
|
|
||||||
<ComboboxAnchor>
|
<ComboboxAnchor>
|
||||||
<ComboboxInput
|
<ComboboxInput
|
||||||
ref="searchInput"
|
ref="searchInput"
|
||||||
|
|||||||
@@ -1,104 +0,0 @@
|
|||||||
<script setup lang="ts">
|
|
||||||
import {
|
|
||||||
PaginationEllipsis,
|
|
||||||
PaginationFirst,
|
|
||||||
PaginationLast,
|
|
||||||
PaginationList,
|
|
||||||
PaginationListItem,
|
|
||||||
PaginationNext,
|
|
||||||
PaginationPrev,
|
|
||||||
PaginationRoot,
|
|
||||||
} from 'radix-vue';
|
|
||||||
import {
|
|
||||||
ChevronDoubleLeftIcon,
|
|
||||||
ChevronDoubleRightIcon,
|
|
||||||
ChevronLeftIcon,
|
|
||||||
ChevronRightIcon,
|
|
||||||
EllipsisHorizontalIcon,
|
|
||||||
} from '@heroicons/vue/20/solid';
|
|
||||||
import { buttonVariants } from '@/packages/ui/src';
|
|
||||||
import { cn } from '@/lib/utils';
|
|
||||||
import { computed, watch } from 'vue';
|
|
||||||
|
|
||||||
const page = defineModel<number>('page', { default: 1 });
|
|
||||||
|
|
||||||
const props = withDefaults(
|
|
||||||
defineProps<{
|
|
||||||
total: number;
|
|
||||||
itemsPerPage?: number;
|
|
||||||
siblingCount?: number;
|
|
||||||
showEdges?: boolean;
|
|
||||||
}>(),
|
|
||||||
{
|
|
||||||
itemsPerPage: 15,
|
|
||||||
siblingCount: 1,
|
|
||||||
showEdges: true,
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
const pageCount = computed(() => Math.max(1, Math.ceil(props.total / props.itemsPerPage)));
|
|
||||||
|
|
||||||
watch(page, (value) => {
|
|
||||||
if (value > pageCount.value) {
|
|
||||||
page.value = pageCount.value;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
watch(pageCount, (value) => {
|
|
||||||
if (page.value > value) {
|
|
||||||
page.value = value;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// The shared buttonVariants ghost/outline hover is `bg-white/5`, which is invisible in light
|
|
||||||
// mode. Override it with a theme-aware hover that shows in both light and dark mode.
|
|
||||||
const hoverClass = 'hover:bg-black/5 dark:hover:bg-white/5';
|
|
||||||
const navButtonClass = cn(buttonVariants({ variant: 'ghost', size: 'icon' }), hoverClass);
|
|
||||||
|
|
||||||
function pageButtonClass(isActive: boolean): string {
|
|
||||||
return cn(
|
|
||||||
buttonVariants({ variant: isActive ? 'outline' : 'ghost', size: 'icon' }),
|
|
||||||
hoverClass
|
|
||||||
);
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<template>
|
|
||||||
<PaginationRoot
|
|
||||||
v-if="pageCount > 1"
|
|
||||||
v-model:page="page"
|
|
||||||
:total="props.total"
|
|
||||||
:items-per-page="props.itemsPerPage"
|
|
||||||
:sibling-count="props.siblingCount"
|
|
||||||
:show-edges="props.showEdges"
|
|
||||||
class="mx-auto flex w-full justify-center py-8">
|
|
||||||
<PaginationList v-slot="{ items }" class="flex items-center gap-1">
|
|
||||||
<PaginationFirst :class="navButtonClass">
|
|
||||||
<ChevronDoubleLeftIcon class="size-4" />
|
|
||||||
</PaginationFirst>
|
|
||||||
<PaginationPrev :class="navButtonClass">
|
|
||||||
<ChevronLeftIcon class="size-4" />
|
|
||||||
</PaginationPrev>
|
|
||||||
<template v-for="(item, index) in items" :key="index">
|
|
||||||
<PaginationListItem
|
|
||||||
v-if="item.type === 'page'"
|
|
||||||
:value="item.value"
|
|
||||||
:class="pageButtonClass(item.value === page)">
|
|
||||||
{{ item.value }}
|
|
||||||
</PaginationListItem>
|
|
||||||
<PaginationEllipsis
|
|
||||||
v-else
|
|
||||||
:index="index"
|
|
||||||
class="flex size-9 items-center justify-center text-text-tertiary">
|
|
||||||
<EllipsisHorizontalIcon class="size-4" />
|
|
||||||
</PaginationEllipsis>
|
|
||||||
</template>
|
|
||||||
<PaginationNext :class="navButtonClass">
|
|
||||||
<ChevronRightIcon class="size-4" />
|
|
||||||
</PaginationNext>
|
|
||||||
<PaginationLast :class="navButtonClass">
|
|
||||||
<ChevronDoubleRightIcon class="size-4" />
|
|
||||||
</PaginationLast>
|
|
||||||
</PaginationList>
|
|
||||||
</PaginationRoot>
|
|
||||||
</template>
|
|
||||||
@@ -9,10 +9,10 @@ import {
|
|||||||
ComboboxItem,
|
ComboboxItem,
|
||||||
ComboboxRoot,
|
ComboboxRoot,
|
||||||
ComboboxViewport,
|
ComboboxViewport,
|
||||||
ComboboxVirtualizer,
|
} from 'radix-vue';
|
||||||
} from 'reka-ui';
|
|
||||||
import { Check, Plus } from '@lucide/vue';
|
import { Check, Plus } from '@lucide/vue';
|
||||||
import type { CreateClientBody, CreateProjectBody, Project } from '@/packages/api/src';
|
import type { CreateClientBody, CreateProjectBody, Project } from '@/packages/api/src';
|
||||||
|
import { UseFocusTrap } from '@vueuse/integrations/useFocusTrap/component';
|
||||||
import ProjectCreateModal from '@/packages/ui/src/Project/ProjectCreateModal.vue';
|
import ProjectCreateModal from '@/packages/ui/src/Project/ProjectCreateModal.vue';
|
||||||
import { useProjectsStore } from '@/utils/useProjects';
|
import { useProjectsStore } from '@/utils/useProjects';
|
||||||
import { useClientsStore } from '@/utils/useClients';
|
import { useClientsStore } from '@/utils/useClients';
|
||||||
@@ -37,16 +37,7 @@ const emit = defineEmits(['update:modelValue', 'changed']);
|
|||||||
|
|
||||||
const activeClients = computed(() => clients.value.filter((c) => !c.is_archived));
|
const activeClients = computed(() => clients.value.filter((c) => !c.is_archived));
|
||||||
|
|
||||||
// Pinned on open so rows don't re-sort while interacting; the project list itself stays reactive.
|
const sortedProjects = ref<Project[]>([]);
|
||||||
const pinnedProjectId = ref<string | null>(null);
|
|
||||||
|
|
||||||
const sortedProjects = computed(() => {
|
|
||||||
return [...projects.value].sort((a, b) => {
|
|
||||||
const aPinned = pinnedProjectId.value === a.id ? 0 : 1;
|
|
||||||
const bPinned = pinnedProjectId.value === b.id ? 0 : 1;
|
|
||||||
return aPinned - bPinned;
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
const shownProjects = computed(() => {
|
const shownProjects = computed(() => {
|
||||||
return sortedProjects.value.filter((project) => {
|
return sortedProjects.value.filter((project) => {
|
||||||
@@ -74,7 +65,9 @@ watch(open, (isOpen) => {
|
|||||||
searchInput.value?.$el?.focus();
|
searchInput.value?.$el?.focus();
|
||||||
});
|
});
|
||||||
|
|
||||||
pinnedProjectId.value = model.value;
|
sortedProjects.value = [...projects.value].sort((iteratingProject) => {
|
||||||
|
return model.value === iteratingProject.id ? -1 : 1;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -110,51 +103,40 @@ function updateValue(project: Project) {
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<template #content>
|
<template #content>
|
||||||
<!-- kept open so the list stays visible during the popover close animation -->
|
<UseFocusTrap v-if="open" :options="{ immediate: true, allowOutsideClick: true }">
|
||||||
<div>
|
|
||||||
<ComboboxRoot
|
<ComboboxRoot
|
||||||
:open="true"
|
v-model:search-term="searchValue"
|
||||||
|
v-model:open="open"
|
||||||
:model-value="currentProject"
|
:model-value="currentProject"
|
||||||
class="relative"
|
class="relative"
|
||||||
:ignore-filter="true"
|
@update:model-value="updateValue">
|
||||||
@update:model-value="updateValue"
|
|
||||||
@update:open="
|
|
||||||
(value: boolean) => {
|
|
||||||
if (!value) open = false;
|
|
||||||
}
|
|
||||||
">
|
|
||||||
<ComboboxAnchor>
|
<ComboboxAnchor>
|
||||||
<ComboboxInput
|
<ComboboxInput
|
||||||
ref="searchInput"
|
ref="searchInput"
|
||||||
v-model="searchValue"
|
|
||||||
class="bg-transparent border-0 placeholder-muted-foreground text-sm text-popover-foreground py-2 px-3 focus:ring-0 border-b border-popover-border focus:border-popover-border w-full"
|
class="bg-transparent border-0 placeholder-muted-foreground text-sm text-popover-foreground py-2 px-3 focus:ring-0 border-b border-popover-border focus:border-popover-border w-full"
|
||||||
placeholder="Search for a project..." />
|
placeholder="Search for a project..." />
|
||||||
</ComboboxAnchor>
|
</ComboboxAnchor>
|
||||||
<ComboboxContent>
|
<ComboboxContent>
|
||||||
<ComboboxViewport
|
<ComboboxViewport
|
||||||
class="w-[--reka-popper-anchor-width] max-h-60 overflow-y-scroll p-1">
|
class="w-[--reka-popper-anchor-width] max-h-60 overflow-y-scroll p-1">
|
||||||
<ComboboxVirtualizer
|
<ComboboxItem
|
||||||
v-slot="{ option: project }"
|
v-for="project in shownProjects"
|
||||||
:options="shownProjects"
|
:key="project.id"
|
||||||
:estimate-size="32"
|
:value="project"
|
||||||
:text-content="(p: Project) => p.name">
|
class="relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-2 pr-8 text-sm outline-none data-[highlighted]:bg-accent data-[highlighted]:text-accent-foreground"
|
||||||
<ComboboxItem
|
:data-project-id="project.id">
|
||||||
:value="project"
|
<span class="flex items-center gap-2">
|
||||||
class="relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-2 pr-8 text-sm outline-none data-[highlighted]:bg-accent data-[highlighted]:text-accent-foreground"
|
|
||||||
:data-project-id="project.id">
|
|
||||||
<span class="flex min-w-0 flex-1 items-center gap-2">
|
|
||||||
<span
|
|
||||||
:style="{ backgroundColor: project.color }"
|
|
||||||
class="w-3 h-3 rounded-full shrink-0"></span>
|
|
||||||
<span class="truncate">{{ project.name }}</span>
|
|
||||||
</span>
|
|
||||||
<span
|
<span
|
||||||
v-if="isProjectSelected(project)"
|
:style="{ backgroundColor: project.color }"
|
||||||
class="absolute right-2 flex h-3.5 w-3.5 items-center justify-center">
|
class="w-3 h-3 rounded-full shrink-0"></span>
|
||||||
<Check class="h-4 w-4" />
|
<span>{{ project.name }}</span>
|
||||||
</span>
|
</span>
|
||||||
</ComboboxItem>
|
<span
|
||||||
</ComboboxVirtualizer>
|
v-if="isProjectSelected(project)"
|
||||||
|
class="absolute right-2 flex h-3.5 w-3.5 items-center justify-center">
|
||||||
|
<Check class="h-4 w-4" />
|
||||||
|
</span>
|
||||||
|
</ComboboxItem>
|
||||||
</ComboboxViewport>
|
</ComboboxViewport>
|
||||||
<div
|
<div
|
||||||
v-if="canCreateProjects()"
|
v-if="canCreateProjects()"
|
||||||
@@ -168,7 +150,7 @@ function updateValue(project: Project) {
|
|||||||
</div>
|
</div>
|
||||||
</ComboboxContent>
|
</ComboboxContent>
|
||||||
</ComboboxRoot>
|
</ComboboxRoot>
|
||||||
</div>
|
</UseFocusTrap>
|
||||||
</template>
|
</template>
|
||||||
</Dropdown>
|
</Dropdown>
|
||||||
<ProjectCreateModal
|
<ProjectCreateModal
|
||||||
|
|||||||
@@ -2,11 +2,10 @@
|
|||||||
import SecondaryButton from '@/packages/ui/src/Buttons/SecondaryButton.vue';
|
import SecondaryButton from '@/packages/ui/src/Buttons/SecondaryButton.vue';
|
||||||
import { FolderPlusIcon } from '@heroicons/vue/24/solid';
|
import { FolderPlusIcon } from '@heroicons/vue/24/solid';
|
||||||
import { PlusIcon } from '@heroicons/vue/16/solid';
|
import { PlusIcon } from '@heroicons/vue/16/solid';
|
||||||
import { computed, ref, watch } from 'vue';
|
import { computed, ref } from 'vue';
|
||||||
import ProjectCreateModal from '@/packages/ui/src/Project/ProjectCreateModal.vue';
|
import ProjectCreateModal from '@/packages/ui/src/Project/ProjectCreateModal.vue';
|
||||||
import ProjectTableHeading from '@/Components/Common/Project/ProjectTableHeading.vue';
|
import ProjectTableHeading from '@/Components/Common/Project/ProjectTableHeading.vue';
|
||||||
import ProjectTableRow from '@/Components/Common/Project/ProjectTableRow.vue';
|
import ProjectTableRow from '@/Components/Common/Project/ProjectTableRow.vue';
|
||||||
import Pagination from '@/Components/Common/Pagination.vue';
|
|
||||||
|
|
||||||
export type SortColumn =
|
export type SortColumn =
|
||||||
| 'name'
|
| 'name'
|
||||||
@@ -57,15 +56,12 @@ const clientNameMap = computed(() => {
|
|||||||
return map;
|
return map;
|
||||||
});
|
});
|
||||||
|
|
||||||
// Convert sort props to TanStack Table format.
|
// Convert sort props to TanStack Table format
|
||||||
// Name is always the secondary sort so rows with equal values render
|
|
||||||
// alphabetically instead of in API (created_at) order.
|
|
||||||
const sorting = computed<SortingState>(() => [
|
const sorting = computed<SortingState>(() => [
|
||||||
{
|
{
|
||||||
id: props.sortColumn,
|
id: props.sortColumn,
|
||||||
desc: props.sortDirection === 'desc',
|
desc: props.sortDirection === 'desc',
|
||||||
},
|
},
|
||||||
...(props.sortColumn !== 'name' ? [{ id: 'name', desc: false }] : []),
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// Define column accessors for sorting.
|
// Define column accessors for sorting.
|
||||||
@@ -147,19 +143,6 @@ const sortedProjects = computed(() => {
|
|||||||
return table.getRowModel().rows.map((row) => row.original);
|
return table.getRowModel().rows.map((row) => row.original);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Client-side pagination: the full list is in memory, only one page is mounted at a time.
|
|
||||||
const PAGE_SIZE = 15;
|
|
||||||
const currentPage = ref(1);
|
|
||||||
|
|
||||||
watch([() => props.sortColumn, () => props.sortDirection, () => props.projects], () => {
|
|
||||||
currentPage.value = 1;
|
|
||||||
});
|
|
||||||
|
|
||||||
const paginatedProjects = computed(() => {
|
|
||||||
const start = (currentPage.value - 1) * PAGE_SIZE;
|
|
||||||
return sortedProjects.value.slice(start, start + PAGE_SIZE);
|
|
||||||
});
|
|
||||||
|
|
||||||
const showCreateProjectModal = ref(false);
|
const showCreateProjectModal = ref(false);
|
||||||
|
|
||||||
async function createProject(project: CreateProjectBody): Promise<Project | undefined> {
|
async function createProject(project: CreateProjectBody): Promise<Project | undefined> {
|
||||||
@@ -216,7 +199,7 @@ const gridTemplate = computed(() => {
|
|||||||
>Create your First Project
|
>Create your First Project
|
||||||
</SecondaryButton>
|
</SecondaryButton>
|
||||||
</div>
|
</div>
|
||||||
<template v-for="project in paginatedProjects" :key="project.id">
|
<template v-for="project in sortedProjects" :key="project.id">
|
||||||
<ProjectTableRow
|
<ProjectTableRow
|
||||||
:show-billable-rate="props.showBillableRate"
|
:show-billable-rate="props.showBillableRate"
|
||||||
:project="project"></ProjectTableRow>
|
:project="project"></ProjectTableRow>
|
||||||
@@ -224,8 +207,4 @@ const gridTemplate = computed(() => {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<Pagination
|
|
||||||
v-model:page="currentPage"
|
|
||||||
:total="sortedProjects.length"
|
|
||||||
:items-per-page="PAGE_SIZE"></Pagination>
|
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -20,6 +20,12 @@ import {
|
|||||||
} from '@/packages/ui/src';
|
} from '@/packages/ui/src';
|
||||||
|
|
||||||
const page = usePage<{
|
const page = usePage<{
|
||||||
|
jetstream: {
|
||||||
|
canCreateTeams: boolean;
|
||||||
|
hasTeamFeatures: boolean;
|
||||||
|
managesProfilePhotos: boolean;
|
||||||
|
hasApiFeatures: boolean;
|
||||||
|
};
|
||||||
auth: {
|
auth: {
|
||||||
user: User & {
|
user: User & {
|
||||||
all_teams: Organization[];
|
all_teams: Organization[];
|
||||||
@@ -33,7 +39,7 @@ const switchToTeam = (organization: Organization) => {
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<DropdownMenu>
|
<DropdownMenu v-if="page.props.jetstream.hasTeamFeatures">
|
||||||
<DropdownMenuTrigger
|
<DropdownMenuTrigger
|
||||||
class="flex w-full text-left hover:bg-white/10 focus-visible:ring-2 focus-visible:ring-ring cursor-pointer transition pl-2 py-1 rounded w-full items-center justify-between"
|
class="flex w-full text-left hover:bg-white/10 focus-visible:ring-2 focus-visible:ring-ring cursor-pointer transition pl-2 py-1 rounded w-full items-center justify-between"
|
||||||
as-child>
|
as-child>
|
||||||
@@ -61,7 +67,7 @@ const switchToTeam = (organization: Organization) => {
|
|||||||
|
|
||||||
<DropdownMenuItem as-child>
|
<DropdownMenuItem as-child>
|
||||||
<Link
|
<Link
|
||||||
:href="route('organizations.show', page.props.auth.user.current_team.id)"
|
:href="route('teams.show', page.props.auth.user.current_team.id)"
|
||||||
class="inline-flex items-center gap-2.5 w-full">
|
class="inline-flex items-center gap-2.5 w-full">
|
||||||
<Cog6ToothIcon class="w-5 h-5 text-icon-default" />
|
<Cog6ToothIcon class="w-5 h-5 text-icon-default" />
|
||||||
<span>Organization Settings</span>
|
<span>Organization Settings</span>
|
||||||
@@ -72,9 +78,9 @@ const switchToTeam = (organization: Organization) => {
|
|||||||
<Link href="/billing" class="inline-flex items-center w-full"> Billing </Link>
|
<Link href="/billing" class="inline-flex items-center w-full"> Billing </Link>
|
||||||
</DropdownMenuItem>
|
</DropdownMenuItem>
|
||||||
|
|
||||||
<DropdownMenuItem as-child>
|
<DropdownMenuItem v-if="page.props.jetstream.canCreateTeams" as-child>
|
||||||
<Link
|
<Link
|
||||||
:href="route('organizations.create')"
|
:href="route('teams.create')"
|
||||||
class="inline-flex items-center gap-2.5 w-full">
|
class="inline-flex items-center gap-2.5 w-full">
|
||||||
<PlusCircleIcon class="w-5 h-5 text-icon-default" />
|
<PlusCircleIcon class="w-5 h-5 text-icon-default" />
|
||||||
<span>Create new organization</span>
|
<span>Create new organization</span>
|
||||||
|
|||||||
@@ -62,35 +62,4 @@ 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,8 +1,5 @@
|
|||||||
<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,
|
||||||
@@ -10,40 +7,18 @@ 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';
|
|
||||||
|
|
||||||
const props = defineProps<{
|
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>
|
||||||
@@ -71,26 +46,18 @@ const inputClass = computed(() => {
|
|||||||
<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>
|
||||||
<template v-else>
|
<DurationSecondsInput
|
||||||
<span class="relative inline-flex items-center">
|
v-else
|
||||||
<DurationSecondsInput
|
:model-value="cell?.totalSeconds ?? 0"
|
||||||
:model-value="displaySeconds"
|
default-unit="hours"
|
||||||
default-unit="hours"
|
placeholder="-"
|
||||||
placeholder="-"
|
size="sm"
|
||||||
size="sm"
|
input-class="w-[80px] mx-auto text-center font-medium
|
||||||
:disabled="isSaving"
|
bg-transparent text-text-primary placeholder:text-text-quaternary
|
||||||
:input-class="inputClass"
|
rounded-lg border border-input-border shadow-none
|
||||||
@commit="(seconds) => emit('update', seconds ?? 0)" />
|
hover:bg-card-background
|
||||||
<span
|
focus-visible:bg-tertiary focus-visible:border-transparent
|
||||||
v-if="saveStatus === 'saving' || saveStatus === 'saved'"
|
focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none"
|
||||||
class="pointer-events-none absolute left-full top-1/2 ml-1.5 flex -translate-y-1/2 items-center"
|
@commit="(seconds) => emit('update', seconds ?? 0)" />
|
||||||
: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,7 +15,6 @@ 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();
|
||||||
@@ -37,8 +36,6 @@ 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<{
|
||||||
@@ -63,7 +60,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(116px, 120px)) minmax(100px, auto)
|
minmax(420px, 1fr) repeat(7, minmax(96px, 120px)) minmax(100px, auto)
|
||||||
40px;
|
40px;
|
||||||
">
|
">
|
||||||
<!-- Header row -->
|
<!-- Header row -->
|
||||||
@@ -103,8 +100,6 @@ 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,10 +15,6 @@ 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');
|
||||||
@@ -38,8 +34,6 @@ 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<{
|
||||||
@@ -115,8 +109,6 @@ 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 -->
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user