diff --git a/.env b/.env index 17e657e8..a6c6a051 100644 --- a/.env +++ b/.env @@ -1,5 +1,5 @@ VITE_DISABLED_EDITORS=powerhouse/document-drive -VITE_DEFAULT_DRIVES_URL=https://apps.powerhouse.io/alpha/makerdao/switchboard/d/monetalis +VITE_DEFAULT_DRIVES_URL=https://apps.powerhouse.io/staging/makerdao/switchboard/d/monetalis VITE_BASE_HREF=/ ASSET_URL=/ diff --git a/.env.prod b/.env.prod index 3f45f7dc..4f208e58 100644 --- a/.env.prod +++ b/.env.prod @@ -1,3 +1,3 @@ -VITE_BASE_HREF=/alpha/powerhouse/connect -ASSET_URL=/alpha/powerhouse/connect -VITE_ROUTER_BASENAME=/alpha/powerhouse/connect \ No newline at end of file +VITE_BASE_HREF=/staging/powerhouse/connect +ASSET_URL=/staging/powerhouse/connect +VITE_ROUTER_BASENAME=/staging/powerhouse/connect \ No newline at end of file diff --git a/.github/workflows/build-and-deploy-arbitrum-staging.yaml b/.github/workflows/build-and-deploy-arbitrum-staging.yaml index 3713143d..df1647e7 100644 --- a/.github/workflows/build-and-deploy-arbitrum-staging.yaml +++ b/.github/workflows/build-and-deploy-arbitrum-staging.yaml @@ -23,9 +23,9 @@ jobs: heroku_api_key: ${{ secrets.HEROKU_API_KEY }} heroku_app_name: ${{ secrets.HEROKU_APP_NAME }} docker_options: >- - --build-arg BASE_PATH=/alpha/arbitrum/connect - --build-arg VITE_BASE_HREF=/alpha/arbitrum/connect/ - --build-arg VITE_ROUTER_BASENAME=/alpha/arbitrum/connect + --build-arg BASE_PATH=/staging/arbitrum/connect + --build-arg VITE_BASE_HREF=/staging/arbitrum/connect/ + --build-arg VITE_ROUTER_BASENAME=/staging/arbitrum/connect --build-arg VITE_ENABLED_EDITORS=ARBLTIPGrantee --build-arg VITE_DISABLE_ADD_PUBLIC_DRIVES=true --build-arg VITE_DISABLE_ADD_CLOUD_DRIVES=true @@ -34,7 +34,7 @@ jobs: --build-arg VITE_DISABLE_DELETE_CLOUD_DRIVES=true --build-arg VITE_DISABLE_DELETE_LOCAL_DRIVES=true --build-arg VITE_LOCAL_DRIVES_ENABLED=false - --build-arg VITE_DEFAULT_DRIVES_URL=https://apps.powerhouse.io/alpha/arbitrum/switchboard/d/arbitrum + --build-arg VITE_DEFAULT_DRIVES_URL=https://apps.powerhouse.io/staging/arbitrum/switchboard/d/arbitrum --build-arg VITE_RENOWN_CHAIN_ID=42161 --build-arg VITE_SENTRY_DSN=${{ secrets.SENTRY_DSN }} --build-arg VITE_SENTRY_ENV=${{ secrets.SENTRY_ENV }} diff --git a/.github/workflows/build-and-deploy-makerdao-staging.yaml b/.github/workflows/build-and-deploy-makerdao-staging.yaml index b6b0de73..bc50acb4 100644 --- a/.github/workflows/build-and-deploy-makerdao-staging.yaml +++ b/.github/workflows/build-and-deploy-makerdao-staging.yaml @@ -23,11 +23,11 @@ jobs: heroku_api_key: ${{ secrets.HEROKU_API_KEY }} heroku_app_name: ${{ secrets.HEROKU_APP_NAME }} docker_options: >- - --build-arg BASE_PATH=/alpha/makerdao/connect - --build-arg VITE_BASE_HREF=/alpha/makerdao/connect/ - --build-arg VITE_ROUTER_BASENAME=/alpha/makerdao/connect + --build-arg BASE_PATH=/staging/makerdao/connect + --build-arg VITE_BASE_HREF=/staging/makerdao/connect/ + --build-arg VITE_ROUTER_BASENAME=/staging/makerdao/connect --build-arg VITE_SENTRY_DSN=${{ secrets.SENTRY_DSN }} --build-arg VITE_SENTRY_ENV=${{ secrets.SENTRY_ENV }} - --build-arg VITE_DEFAULT_DRIVES_URL=https://apps.powerhouse.io/alpha/makerdao/switchboard/d/280dd289-ec51-40f0-adad-c154967fc2b2 + --build-arg VITE_DEFAULT_DRIVES_URL=https://apps.powerhouse.io/staging/makerdao/switchboard/d/280dd289-ec51-40f0-adad-c154967fc2b2 --build-arg VITE_RWA_ALLOW_LIST=${{secrets.VITE_RWA_ALLOW_LIST}} process_type: web \ No newline at end of file diff --git a/.github/workflows/build-and-deploy-powerhouse-staging.yaml b/.github/workflows/build-and-deploy-powerhouse-staging.yaml index 322d1336..be64c577 100644 --- a/.github/workflows/build-and-deploy-powerhouse-staging.yaml +++ b/.github/workflows/build-and-deploy-powerhouse-staging.yaml @@ -23,11 +23,10 @@ jobs: heroku_api_key: ${{ secrets.HEROKU_API_KEY }} heroku_app_name: ${{ secrets.HEROKU_APP_NAME }} docker_options: >- - --build-arg BASE_PATH=/alpha/powerhouse/connect - --build-arg VITE_BASE_HREF=/alpha/powerhouse/connect/ - --build-arg VITE_ROUTER_BASENAME=/alpha/powerhouse/connect + --build-arg BASE_PATH=/staging/powerhouse/connect + --build-arg VITE_BASE_HREF=/staging/powerhouse/connect/ + --build-arg VITE_ROUTER_BASENAME=/staging/powerhouse/connect --build-arg VITE_SENTRY_DSN=${{ secrets.SENTRY_DSN }} --build-arg VITE_SENTRY_ENV=${{ secrets.SENTRY_ENV }} - --build-arg VITE_DEFAULT_DRIVES_URL=https://apps.powerhouse.io/alpha/powerhouse/switchboard/d/powerhouse - --build-arg VITE_RENOWN_URL=https://renown-6bdc9fb67095.herokuapp.com + --build-arg VITE_DEFAULT_DRIVES_URL=https://apps.powerhouse.io/staging/powerhouse/switchboard/d/powerhouse process_type: web \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 3f4ea102..e1f848fe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,116 @@ +# [1.0.0-next.7](https://github.com/powerhouse-inc/document-model-electron/compare/v1.0.0-next.6...v1.0.0-next.7) (2024-08-12) + + +### Features + +* bump libs ([e0b08c3](https://github.com/powerhouse-inc/document-model-electron/commit/e0b08c3af686b9a4e1b2ea02342ae74e35445e7c)) +* bump libs ([a62aaf3](https://github.com/powerhouse-inc/document-model-electron/commit/a62aaf3b350974f50245f424c072a1cfc86c2d87)) +* bump libs ([6729c7a](https://github.com/powerhouse-inc/document-model-electron/commit/6729c7a9ca6efc8971e455ff9ccddf4d78a7f4e1)) +* bump libs ([3ad26e8](https://github.com/powerhouse-inc/document-model-electron/commit/3ad26e8957aaf8ab982c24f42e473886d4ef164e)) +* fixed sentry console capture ([2962d91](https://github.com/powerhouse-inc/document-model-electron/commit/2962d916c6335f9a6cdef864917bdacd0d967d78)) +* log catched errors to sentry ([8e5e9ba](https://github.com/powerhouse-inc/document-model-electron/commit/8e5e9baf3bbe47894b67f0ca9652dfb855996f30)) +* only open document when we know node is file ([9669a74](https://github.com/powerhouse-inc/document-model-electron/commit/9669a74d923d2a5c3b88ab857530731239a3d3f7)) +* remove to lower case from slug generation ([180e747](https://github.com/powerhouse-inc/document-model-electron/commit/180e74792b54b707c15d0192ed01909723ca39fc)) +* show at most one drive error toast ([f7644ae](https://github.com/powerhouse-inc/document-model-electron/commit/f7644ae54ec60c06a176cac8c5f023d81c296052)) + +# [1.0.0-next.6](https://github.com/powerhouse-inc/document-model-electron/compare/v1.0.0-next.5...v1.0.0-next.6) (2024-08-02) + + +### Bug Fixes + +* refresh drive methods when user permissions change ([a9677cd](https://github.com/powerhouse-inc/document-model-electron/commit/a9677cd087bcc4655623aa224cf6bc5d07e99ee3)) +* release ([387a9ed](https://github.com/powerhouse-inc/document-model-electron/commit/387a9edcdfb7de801ed83209a9fa1d127f61c305)) +* set old drive private and new drive public ([fa29b90](https://github.com/powerhouse-inc/document-model-electron/commit/fa29b9042e764cd58f96073f2967478372b289ce)) +* switchboard graphql query ([8d354d3](https://github.com/powerhouse-inc/document-model-electron/commit/8d354d33b8cf63cf4d2b34800b8ff2a77bb79646)) + + +### Features + +<<<<<<< HEAD +* add animated loader for editors ([0ef0cc5](https://github.com/powerhouse-inc/document-model-electron/commit/0ef0cc587bb04d3fa65a4fd133c4c42f5998c92c)) +* add comments ([a5e81b2](https://github.com/powerhouse-inc/document-model-electron/commit/a5e81b22b1d634548a6323ef5b4a5efa2b0a87ec)) +* add file icon logic ([3ba0aae](https://github.com/powerhouse-inc/document-model-electron/commit/3ba0aae6d692a2368b19e1defeb655d582c5c220)) +* add node slugs ([e6a538a](https://github.com/powerhouse-inc/document-model-electron/commit/e6a538a39d00ad7c5fa9873805ae8532ac009259)) +* add suspense for editor component ([62f78e7](https://github.com/powerhouse-inc/document-model-electron/commit/62f78e7b2288c4ce346c9bcfde638c9fc943145f)) +* add wagmi context ([7f638be](https://github.com/powerhouse-inc/document-model-electron/commit/7f638be54fc5b778c7abd9f991d0b01f6606cf59)) +* added base e2e tests ([fab24e1](https://github.com/powerhouse-inc/document-model-electron/commit/fab24e14247b31a96df09ccc17e7a3d05b065194)) +* added debug tools modal ([c88989b](https://github.com/powerhouse-inc/document-model-electron/commit/c88989b3b29f501089234dcfc3a03ae94cc6d009)) +* added sign operation ([0427a11](https://github.com/powerhouse-inc/document-model-electron/commit/0427a11283e675c2c16dca4fd1cccffbeeecb420)) +* added user tracking for sentry ([2a98795](https://github.com/powerhouse-inc/document-model-electron/commit/2a987956c6d77705b73a32090adb34799325f847)) +* allow renown.id ([63fda39](https://github.com/powerhouse-inc/document-model-electron/commit/63fda3999ab7d5748783c89da909ef30d7794407)) +* allow url for file ([d7b762d](https://github.com/powerhouse-inc/document-model-electron/commit/d7b762d7c79c679acb212f4bfc3da50c010d397a)) +* bump design system ([5870d52](https://github.com/powerhouse-inc/document-model-electron/commit/5870d5285014f3ee721af522c042a06cc8b18d51)) +* bump design system ([09079b6](https://github.com/powerhouse-inc/document-model-electron/commit/09079b6534eed29bdacf6017675e720078ff0e80)) +* bump design system ([8d322c1](https://github.com/powerhouse-inc/document-model-electron/commit/8d322c1e1096c0ceb0be787dbd186e6f19ac2a54)) +* bump document-model-libs ([9f5516c](https://github.com/powerhouse-inc/document-model-electron/commit/9f5516c502769a4056e36d92187595c0ea53ea33)) +* bump libs ([67c43fe](https://github.com/powerhouse-inc/document-model-electron/commit/67c43fe7257f9bd5890f89105417ed193353491e)) +* bump libs ([977b43f](https://github.com/powerhouse-inc/document-model-electron/commit/977b43ff4611b34de8591047393f5fc328e80029)) +* bump libs ([2837f01](https://github.com/powerhouse-inc/document-model-electron/commit/2837f01af47c38bb132e887cc5717f52bab71731)) +* bump libs ([72ff365](https://github.com/powerhouse-inc/document-model-electron/commit/72ff365bfd8d76227bad15203366cb49a5297b73)) +* bump libs ([e431ef5](https://github.com/powerhouse-inc/document-model-electron/commit/e431ef529c7e2c6ff3e016b22ef4c1573c8e480e)) +* bump libs ([3db0a2b](https://github.com/powerhouse-inc/document-model-electron/commit/3db0a2baaf3e8739782ff7c7800147d5fcd13e07)) +* bump libs ([415ca8e](https://github.com/powerhouse-inc/document-model-electron/commit/415ca8e37fe56ee2c8c654cc1380cd7586610ca8)) +* check status code and error message when handling invalid listenerId ([86982ff](https://github.com/powerhouse-inc/document-model-electron/commit/86982ffa16aea9667f6083263ecea8c8ac49ad43)) +* disable sync icon for local folders ([9996fa3](https://github.com/powerhouse-inc/document-model-electron/commit/9996fa3f8b11edd5da0d16185c44822ddfec9233)) +* enabled support for multiple default drives ([8f6386b](https://github.com/powerhouse-inc/document-model-electron/commit/8f6386bec7a6e0f5c241baaf8fe153b06dfa33c4)) +* expect undefined document ([d10ef75](https://github.com/powerhouse-inc/document-model-electron/commit/d10ef751d363f56dce29626ec8fbcc7d38fe945a)) +* fix merge conflict when adding a new pullResponder ([6941c0a](https://github.com/powerhouse-inc/document-model-electron/commit/6941c0a836cd43aca631b626f2312957a201ca50)) +* fix renown url ([b46dd75](https://github.com/powerhouse-inc/document-model-electron/commit/b46dd750eaf0fb01f1c25fd63ff150fab8f79484)) +* fix sidebar props ([11b50b4](https://github.com/powerhouse-inc/document-model-electron/commit/11b50b453b802cc97dde620df4b6e1b1ad97cd6a)) +* fixed file import ([b5d4d72](https://github.com/powerhouse-inc/document-model-electron/commit/b5d4d72fbed6f7540b0a33849e829311b4e4af92)) +* handle async editor switching ([453939b](https://github.com/powerhouse-inc/document-model-electron/commit/453939bdb2f110dca48a61e91707aaee3eeb9b9d)) +* handle back button clicked when editor open ([99b58e1](https://github.com/powerhouse-inc/document-model-electron/commit/99b58e1a2fc286b3258e8c0232f7d21deb5516f3)) +* handle delete ([d541580](https://github.com/powerhouse-inc/document-model-electron/commit/d5415807add427e013d71df4cd7754618c423e22)) +* handle drive id change is history ([07c9aeb](https://github.com/powerhouse-inc/document-model-electron/commit/07c9aeb41d345ef4435044352b9d4f417f7e98ff)) +* handle history stack ([c1fb104](https://github.com/powerhouse-inc/document-model-electron/commit/c1fb104bbbe4c8cde3277d62f27348b66b249123)) +* handle invalid listener id with status error 400 instead of 404 ([febbe2d](https://github.com/powerhouse-inc/document-model-electron/commit/febbe2d2499fe68704044ef145cd3fa77c1196a5)) +* handle modal opening ([9404452](https://github.com/powerhouse-inc/document-model-electron/commit/9404452521f66177c859ebcf3fdea1ef5ad8002a)) +* handle url navigation ([fe18c02](https://github.com/powerhouse-inc/document-model-electron/commit/fe18c02cd3a3c795f87a0f7b90fb3ecb21b0ee4c)) +* ignore AbortError when user cancels file picker ([9c3cf4d](https://github.com/powerhouse-inc/document-model-electron/commit/9c3cf4d47b1d28442b21c491e7443c48969b5140)) +* include copy and move handlers ([3b1342f](https://github.com/powerhouse-inc/document-model-electron/commit/3b1342f4ceb9c07eb1e1175daeb4647fde1d8792)) +* integrate revision history ([3edb50a](https://github.com/powerhouse-inc/document-model-electron/commit/3edb50ac4d93693c1caa9adc2a0167d16a1fadb0)) +* make sure move target is not existing parent ([f96a9e3](https://github.com/powerhouse-inc/document-model-electron/commit/f96a9e37a4318aee2dc93690d3288e0b3e2ab4f1)) +* merge branch 'develop' into staging ([92680ec](https://github.com/powerhouse-inc/document-model-electron/commit/92680eca2ffedb80b5f88fb5f671aaced6229f1b)) +* merge branch 'develop' into staging ([5eefcd8](https://github.com/powerhouse-inc/document-model-electron/commit/5eefcd8bb7c3e6cb3a930d0d5fd91c516e07e8ae)) +* merge branch 'staging' into deployments/staging/makerdao ([bc2bd10](https://github.com/powerhouse-inc/document-model-electron/commit/bc2bd10b75865d8b6104be80a464d44375fe3e5a)) +* move modals out of components ([300d094](https://github.com/powerhouse-inc/document-model-electron/commit/300d0947f54eb1893601542c26bb780767356cde)) +* only copy icons post install ([9866258](https://github.com/powerhouse-inc/document-model-electron/commit/9866258f1da336e3161232e279b68bbaf7c901b0)) +* outdated app check improvements ([800b4b2](https://github.com/powerhouse-inc/document-model-electron/commit/800b4b25952417f7ecfdd78ecf3db291776d14a9)) +* push operations by chunks ([ec6c80b](https://github.com/powerhouse-inc/document-model-electron/commit/ec6c80b42fbb08b07d8bbd4ed2aad936da647680)) +* readd drive by slug ([631bcc3](https://github.com/powerhouse-inc/document-model-electron/commit/631bcc36fafaa9fe8502820d9ac872563377d32a)) +* readd drive error handler ([42b647b](https://github.com/powerhouse-inc/document-model-electron/commit/42b647bd570caf94f66bcff9fcaae4368ecc3f42)) +* regenerate lockfile ([b88daf9](https://github.com/powerhouse-inc/document-model-electron/commit/b88daf91e491729e7b25e4e490293be0fa57cd63)) +* regenerate lockfile ([4048486](https://github.com/powerhouse-inc/document-model-electron/commit/404848647c21309a9dd9f0a4a28583a9640c9bd8)) +* regenerate lockfile ([1cda4b3](https://github.com/powerhouse-inc/document-model-electron/commit/1cda4b33f8174ad9b447973a5f074a4cab131bd1)) +* regenerate lockfile ([184a379](https://github.com/powerhouse-inc/document-model-electron/commit/184a379d04c60e2f1404639ad1cd76185bb589e6)) +* regenerate lockfile ([0095c6b](https://github.com/powerhouse-inc/document-model-electron/commit/0095c6b5159f8c768566778454e0286069fed1e5)) +* register new pullResponderTrigger when the current one is not longer valid ([1a96a4d](https://github.com/powerhouse-inc/document-model-electron/commit/1a96a4d291ccb430f8f960ea7450c90dd1e0ae43)) +* reload default drives when config has been updated ([edd9bfc](https://github.com/powerhouse-inc/document-model-electron/commit/edd9bfc1f1914c13855343d77b6fc8029df6f737)) +* remove copy icons script ([23a309a](https://github.com/powerhouse-inc/document-model-electron/commit/23a309a181711bc150c65ee931138f0ba822de0a)) +* remove csp ([fdff1c6](https://github.com/powerhouse-inc/document-model-electron/commit/fdff1c653a0dd744ea5db01561d029ef466bb600)) +* remove old store tabs ([816406e](https://github.com/powerhouse-inc/document-model-electron/commit/816406e8a04a48ac3dc659a8274162693f4d735f)) +* remove old tabs ([8a7f62d](https://github.com/powerhouse-inc/document-model-electron/commit/8a7f62dd4e6f2145f0f86fd3652a63645624e5da)) +* remove react aria drag and drop ([80e0353](https://github.com/powerhouse-inc/document-model-electron/commit/80e035328daa59c423cde9199887df11b54b0934)) +* remove selected node check ([0803390](https://github.com/powerhouse-inc/document-model-electron/commit/0803390c9281bb7c30c9908fca8fffeb55bcb034)) +* removed file extension when importing a document file ([b2da3b0](https://github.com/powerhouse-inc/document-model-electron/commit/b2da3b05eba3af229a99667c6d454d51aaec3bfd)) +* rename hook for clarity ([f48848e](https://github.com/powerhouse-inc/document-model-electron/commit/f48848e269c6a3c494b447097994d34e350d99c9)) +* replaced react-window by tanstack/react-virtual ([7e9b024](https://github.com/powerhouse-inc/document-model-electron/commit/7e9b024fefbadcb36640e5757f33b9f83ed369be)) +* set VITE_RWA_ALLOW_LIST ([34c5dad](https://github.com/powerhouse-inc/document-model-electron/commit/34c5dad0e6c384c81980bd7f6622842d922c9da8)) +* simplify passing of props ([c7c3779](https://github.com/powerhouse-inc/document-model-electron/commit/c7c377933fe83e2612c97194de3d8a22eb1e579c)) +* sort folders and files alphabetically ([74aa081](https://github.com/powerhouse-inc/document-model-electron/commit/74aa081a2b01325101321f5baffe14b523e9b53b)) +* split file creation and operations push ([ce1ede8](https://github.com/powerhouse-inc/document-model-electron/commit/ce1ede8b3df3a13dc12ac89d8106cbfc8ee1efc7)) +* split navigation functions out of hooks ([7be8044](https://github.com/powerhouse-inc/document-model-electron/commit/7be8044978c50f2691121b9e92df4110ef95e906)) +* update document-drive ([2b95857](https://github.com/powerhouse-inc/document-model-electron/commit/2b958573b812147f09e006025f465879c894ca02)) +* update document-model 1.7.0 ([02e8083](https://github.com/powerhouse-inc/document-model-electron/commit/02e80837c097fc339933a74907647c9547156b53)) +* update node lifecycle scripts ([e959228](https://github.com/powerhouse-inc/document-model-electron/commit/e959228254441df256a4477812b941623c64feea)) +* update query ([3ca3f2a](https://github.com/powerhouse-inc/document-model-electron/commit/3ca3f2a4e25f8ab1a650630ae8e67f500097da09)) +* updated document model deps ([efc3814](https://github.com/powerhouse-inc/document-model-electron/commit/efc38147792002975a87e433d2cf7f4091534b5e)) +* updated renown url ([b2ddc9d](https://github.com/powerhouse-inc/document-model-electron/commit/b2ddc9dda69791a75047afd4ad8436ad6e3cc327)) +* use function for slug ([f107e92](https://github.com/powerhouse-inc/document-model-electron/commit/f107e92cff8e8a302abfa8c3822c9385de79c4ac)) +* use new ui nodes context ([fa5dba4](https://github.com/powerhouse-inc/document-model-electron/commit/fa5dba456879cca391f40fbf4d1a6aaa4e2bfeef)) +* use node parent folder in tree item ([8513783](https://github.com/powerhouse-inc/document-model-electron/commit/851378308a8d4cd49ffb1ec462e8e6ac546ed04a)) +* use src name in copy ([409cff0](https://github.com/powerhouse-inc/document-model-electron/commit/409cff0dd75cd827e3103acd8d22a4a6a117d66f)) + # [1.0.0-next.5](https://github.com/powerhouse-inc/document-model-electron/compare/v1.0.0-next.4...v1.0.0-next.5) (2024-07-30) @@ -6,6 +119,11 @@ * renown env var ([0b6bb86](https://github.com/powerhouse-inc/document-model-electron/commit/0b6bb86c10a525462f45db82a1cd5607b16a88be)) # [1.0.0-next.4](https://github.com/powerhouse-inc/document-model-electron/compare/v1.0.0-next.3...v1.0.0-next.4) (2024-07-01) +======= +* updated document model deps ([efc3814](https://github.com/powerhouse-inc/document-model-electron/commit/efc38147792002975a87e433d2cf7f4091534b5e)) + +# [1.0.0-dev.55](https://github.com/powerhouse-inc/document-model-electron/compare/v1.0.0-dev.54...v1.0.0-dev.55) (2024-08-02) +>>>>>>> develop ### Features diff --git a/Dockerfile b/Dockerfile index fc787e3d..0ab6e420 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,11 +1,11 @@ FROM node:lts-alpine AS builder -ARG BASE_PATH=/alpha/powerhouse/connect +ARG BASE_PATH="" ENV BASE_PATH=${BASE_PATH} -ARG VITE_BASE_HREF=/alpha/powerhouse/connect +ARG VITE_BASE_HREF="" ENV VITE_BASE_HREF=${VITE_BASE_HREF} -ARG VITE_ROUTER_BASENAME=/alpha/powerhouse/connect +ARG VITE_ROUTER_BASENAME="" ENV VITE_ROUTER_BASENAME=${VITE_ROUTER_BASENAME} ARG VITE_RENOWN_NETWORK_ID="eip155" @@ -75,7 +75,7 @@ WORKDIR /opt/app ENV NODE_ENV=production ARG PORT=80 ENV PORT=${PORT} -ARG BASE_PATH="/alpha/powerhouse/connect" +ARG BASE_PATH="" ENV BASE_PATH=${BASE_PATH} COPY --from=builder /opt/app/dist /usr/share/nginx/html diff --git a/package-lock.json b/package-lock.json index 809def54..f41f4936 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,21 +1,21 @@ { "name": "@powerhousedao/connect", - "version": "1.0.0-next.5", + "version": "1.0.0-next.6", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@powerhousedao/connect", - "version": "1.0.0-next.5", + "version": "1.0.0-next.6", "license": "AGPL-3.0-only", "dependencies": { - "@powerhousedao/design-system": "1.0.0-alpha.157", + "@powerhousedao/design-system": "1.0.0-alpha.159", "@sentry/react": "^7.109.0", "@tanstack/react-virtual": "^3.8.1", "did-key-creator": "^1.2.0", "document-drive": "^1.0.0-alpha.88", "document-model": "1.7.0", - "document-model-libs": "^1.78.0", + "document-model-libs": "^1.82.0", "electron-is-dev": "^3.0.1", "electron-squirrel-startup": "^1.0.0", "electron-store": "^8.1.0", @@ -6821,9 +6821,9 @@ } }, "node_modules/@powerhousedao/design-system": { - "version": "1.0.0-alpha.157", - "resolved": "https://registry.npmjs.org/@powerhousedao/design-system/-/design-system-1.0.0-alpha.157.tgz", - "integrity": "sha512-w5/F6jze54wDadCCuX3WGEmmwRPHtrhL3k3NCksPVAjxyUuyd88knsvfJ7HWvxJ6XlzYccJJA8trGTuGSOOigA==", + "version": "1.0.0-alpha.159", + "resolved": "https://registry.npmjs.org/@powerhousedao/design-system/-/design-system-1.0.0-alpha.159.tgz", + "integrity": "sha512-h/DedTdv7SCDziPuaoKuYuY7sLnEUAKWyQYKJT/hE1Ih6qCu4M1AiLucJuQxPMvbX8LUiCzn2A4fCm03SMLQ4Q==", "dependencies": { "@internationalized/date": "^3.5.1", "@radix-ui/react-dialog": "^1.0.5", @@ -15642,9 +15642,9 @@ } }, "node_modules/document-model-libs": { - "version": "1.78.0", - "resolved": "https://registry.npmjs.org/document-model-libs/-/document-model-libs-1.78.0.tgz", - "integrity": "sha512-Hy4BZ1evlgcyrRS4N8bYNTbflOmLstcoM9LT8Br9ZLneATty7GAyC30lW9AEu0GYD2z/zouIzi8zaahru0qilQ==", + "version": "1.82.0", + "resolved": "https://registry.npmjs.org/document-model-libs/-/document-model-libs-1.82.0.tgz", + "integrity": "sha512-718kbi3sdWWlOWGmXaujhk0hOEJE/omLZ7wT+DaSkw4+mlnNz4ItBAAo3GoHRWcqucRDsF3wEm8uj5keGpONDA==", "dependencies": { "@acaldas/graphql-codegen-typescript-validation-schema": "^0.12.3", "@graphql-codegen/core": "^4.0.2", diff --git a/package.json b/package.json index c35909e1..f8579e9a 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@powerhousedao/connect", "productName": "Powerhouse-Connect", - "version": "1.0.0-next.5", + "version": "1.0.0-next.7", "description": "Powerhouse Connect", "main": ".vite/build/main.js", "license": "AGPL-3.0-only", @@ -89,13 +89,13 @@ "xvfb-maybe": "^0.2.1" }, "dependencies": { - "@powerhousedao/design-system": "1.0.0-alpha.157", + "@powerhousedao/design-system": "1.0.0-alpha.159", "@sentry/react": "^7.109.0", "@tanstack/react-virtual": "^3.8.1", "did-key-creator": "^1.2.0", "document-drive": "^1.0.0-alpha.88", "document-model": "1.7.0", - "document-model-libs": "^1.78.0", + "document-model-libs": "^1.82.0", "electron-is-dev": "^3.0.1", "electron-squirrel-startup": "^1.0.0", "electron-store": "^8.1.0", diff --git a/src/app/document-drive.ts b/src/app/document-drive.ts index 9b89589c..516810aa 100644 --- a/src/app/document-drive.ts +++ b/src/app/document-drive.ts @@ -16,6 +16,7 @@ import { } from 'document-model/document'; import { IpcMain, webContents } from 'electron'; import { join } from 'path'; +import { logger } from 'src/services/logger'; export default ( documentModels: DocumentModel[], @@ -54,13 +55,13 @@ export default ( triggers: [], }, }) - .catch(console.error); + .catch(logger.error); } }) - .catch(console.error), + .catch(logger.error), ) .then(() => bindEvents(documentDrive)) - .catch(console.error); + .catch(logger.error); ipcMain.handle('documentDrive:getDrives', () => documentDrive.getDrives()); ipcMain.handle('documentDrive:getDrive', (_e, id: string) => diff --git a/src/app/sentry.ts b/src/app/sentry.ts index 91a1cadb..67417dea 100644 --- a/src/app/sentry.ts +++ b/src/app/sentry.ts @@ -9,7 +9,7 @@ import { import config from '../../connect.config'; -export default () => { +function initSenty() { if (!config.sentry.dsn || config.sentry.dsn === '') { return; } @@ -18,6 +18,7 @@ export default () => { dsn: config.sentry.dsn, environment: config.sentry.env, integrations: [ + Sentry.extraErrorDataIntegration({ depth: 5 }), Sentry.reactRouterV6BrowserTracingIntegration({ useEffect: React.useEffect, useLocation, @@ -26,10 +27,17 @@ export default () => { matchRoutes, }), Sentry.replayIntegration(), + Sentry.captureConsoleIntegration({ levels: ['error'] }), + ], + ignoreErrors: [ + 'User is not allowed to create files', + 'User is not allowed to move documents', + 'The user aborted a request.', ], - tracesSampleRate: 1.0, replaysSessionSampleRate: 0.1, replaysOnErrorSampleRate: 1.0, }); -}; +} + +initSenty(); diff --git a/src/components/editors.tsx b/src/components/editors.tsx index ad64e1d7..2386188e 100644 --- a/src/components/editors.tsx +++ b/src/components/editors.tsx @@ -16,9 +16,10 @@ import { import { useAtomValue } from 'jotai'; import { Suspense, useEffect, useMemo, useState } from 'react'; import { useConnectCrypto, useConnectDid } from 'src/hooks/useConnectCrypto'; -import { UiNodes } from 'src/hooks/useUiNodes'; +import { TUiNodes } from 'src/hooks/useUiNodes'; import { useUndoRedoShortcuts } from 'src/hooks/useUndoRedoShortcuts'; import { useUserPermissions } from 'src/hooks/useUserPermissions'; +import { logger } from 'src/services/logger'; import { useDocumentModel } from 'src/store/document-model'; import { useEditor } from 'src/store/editor'; import { themeAtom } from 'src/store/theme'; @@ -34,7 +35,7 @@ export type EditorProps< T = unknown, A extends Action = Action, LocalState = unknown, -> = UiNodes & { +> = TUiNodes & { document: Document; onExport: () => void; onAddOperation: (operation: Operation) => Promise; @@ -54,7 +55,9 @@ const signOperation = async ( if (!operation.context) return operation; if (!operation.context.signer) return operation; if (!reducer) { - console.error('Document model does not have a reducer'); + logger.error( + `Document model '${document.documentType}' does not have a reducer`, + ); return operation; } @@ -162,7 +165,7 @@ export function DocumentEditor(props: EditorProps) { window.documentEditorDebugTools?.pushOperation(operation); return onAddOperation(op); }) - .catch(console.error); + .catch(logger.error); }; _dispatch(addActionContext(action), callback, onErrorCallback); diff --git a/src/components/file-content-view.tsx b/src/components/file-content-view.tsx index 07b18a83..ebcc08d0 100644 --- a/src/components/file-content-view.tsx +++ b/src/components/file-content-view.tsx @@ -2,10 +2,10 @@ import { FileItem, UiFileNode } from '@powerhousedao/design-system'; import { useVirtualizer } from '@tanstack/react-virtual'; import React, { useRef } from 'react'; import { useTranslation } from 'react-i18next'; -import { UiNodes } from 'src/hooks/useUiNodes'; +import { TUiNodes } from 'src/hooks/useUiNodes'; import { useWindowSize } from 'src/hooks/useWindowSize'; -type Props = UiNodes & { +type Props = TUiNodes & { fileNodes: UiFileNode[]; }; diff --git a/src/components/folder-view.tsx b/src/components/folder-view.tsx index 1756b1c1..4c99cd33 100644 --- a/src/components/folder-view.tsx +++ b/src/components/folder-view.tsx @@ -5,13 +5,13 @@ import { useDrop, } from '@powerhousedao/design-system'; import { useTranslation } from 'react-i18next'; -import { UiNodes } from 'src/hooks/useUiNodes'; +import { TUiNodes } from 'src/hooks/useUiNodes'; import { sortUiNodesByName } from 'src/utils'; import { twMerge } from 'tailwind-merge'; import { ContentSection } from './content'; import FileContentView from './file-content-view'; -export function FolderView(props: UiNodes) { +export function FolderView(props: TUiNodes) { const { t } = useTranslation(); const { selectedParentNode } = props; const { isDropTarget, dropProps } = useDrop({ diff --git a/src/components/modal/modals/SettingsModal.tsx b/src/components/modal/modals/SettingsModal.tsx index 499ba51b..43d61492 100644 --- a/src/components/modal/modals/SettingsModal.tsx +++ b/src/components/modal/modals/SettingsModal.tsx @@ -13,6 +13,7 @@ import { useConnectConfig } from 'src/hooks/useConnectConfig'; import { useDocumentDriveServer } from 'src/hooks/useDocumentDriveServer'; import { useFeatureFlag } from 'src/hooks/useFeatureFlags'; import { useLogin } from 'src/hooks/useLogin'; +import { logger } from 'src/services/logger'; import { useDocumentModels, useFilteredDocumentModels, @@ -84,7 +85,7 @@ export const SettingsModal: React.FC = props => { // refreshes the page to reload default drive onRefresh(); }) - .catch(console.error); + .catch(logger.error); }, onCancel: () => showModal('settingsModal', { onRefresh }), }); diff --git a/src/components/root.tsx b/src/components/root.tsx index dc652565..10cc8a8d 100644 --- a/src/components/root.tsx +++ b/src/components/root.tsx @@ -5,6 +5,7 @@ import { Outlet, useNavigate, useSearchParams } from 'react-router-dom'; import { useLoadInitialData } from 'src/hooks/useLoadInitialData'; import { useLogin } from 'src/hooks/useLogin'; import { isElectron, isMac } from 'src/hooks/utils'; +import { logger } from 'src/services/logger'; import Sidebar from './sidebar'; const Root = () => { @@ -24,7 +25,7 @@ const Root = () => { const userDid = decodeURIComponent(userStr); searchParams.delete('user'); setSearchParams(searchParams); - login(userDid).catch(console.error); + login(userDid).catch(logger.error); } }, [login, searchParams, setSearchParams]); diff --git a/src/components/sidebar.tsx b/src/components/sidebar.tsx index b7cb328b..9eca1159 100644 --- a/src/components/sidebar.tsx +++ b/src/components/sidebar.tsx @@ -4,6 +4,7 @@ import { useAtom } from 'jotai'; import { ErrorBoundary } from 'react-error-boundary'; import { useNavigate } from 'react-router-dom'; import { useLogin } from 'src/hooks/useLogin'; +import { logger } from 'src/services/logger'; import { sidebarCollapsedAtom } from 'src/store'; import DriveContainer from './drive-container'; import { useModal } from './modal'; @@ -56,7 +57,7 @@ export default function Sidebar() { There was an error loading drives } - onError={console.error} + onError={logger.error} > diff --git a/src/hooks/useClientErrorHandler.ts b/src/hooks/useClientErrorHandler.ts index 0f090f7c..ffe04956 100644 --- a/src/hooks/useClientErrorHandler.ts +++ b/src/hooks/useClientErrorHandler.ts @@ -5,6 +5,7 @@ import { Trigger, } from 'document-model-libs/document-drive'; import { useCallback, useMemo, useRef, useState } from 'react'; +import { logger } from 'src/services/logger'; import { useDocumentDriveServer } from './useDocumentDriveServer'; import { useSwitchboard } from './useSwitchboard'; @@ -87,7 +88,7 @@ export const useClientErrorHandler = (): ClientErrorHandler => { delay === DELAY_LIMIT ? delay : delay * 10, ); - console.error(error); + logger.error(error); } finally { setHandlingInProgress(state => state.filter(code => code !== handlerCode), @@ -140,7 +141,7 @@ export const useClientErrorHandler = (): ClientErrorHandler => { } } } catch (e: unknown) { - console.error(e); + logger.error(e); } finally { setHandlingInProgress(state => state.filter(code => code !== handlerCode), diff --git a/src/hooks/useConnectCrypto.ts b/src/hooks/useConnectCrypto.ts index 186adcc8..efa7f19a 100644 --- a/src/hooks/useConnectCrypto.ts +++ b/src/hooks/useConnectCrypto.ts @@ -1,6 +1,7 @@ import { atom, useAtom } from 'jotai'; import { useEffect, useMemo } from 'react'; import type { DID, IConnectCrypto } from 'src/services/crypto'; +import { logger } from 'src/services/logger'; // uses electron connect crypto if available, // otherwise dynamically loads browser crypto @@ -48,7 +49,7 @@ export function useConnectDid(): DID | undefined { connectCrypto .then(c => c.did()) .then(did => setDid(did)) - .catch(console.error); + .catch(logger.error); }); return did; diff --git a/src/hooks/useDocumentDriveServer.ts b/src/hooks/useDocumentDriveServer.ts index 62fed1f2..80f2df79 100644 --- a/src/hooks/useDocumentDriveServer.ts +++ b/src/hooks/useDocumentDriveServer.ts @@ -25,6 +25,7 @@ import { } from 'document-model-libs/document-drive'; import { Document, Operation, utils } from 'document-model/document'; import { useCallback, useMemo } from 'react'; +import { logger } from 'src/services/logger'; import { useGetDocumentModel } from 'src/store/document-model'; import { DefaultDocumentDriveServer } from 'src/utils/document-drive-server'; import { loadFile } from 'src/utils/file'; @@ -97,7 +98,7 @@ export function useDocumentDriveServer( ); if (result.status !== 'SUCCESS') { - console.error(result.error); + logger.error(result.error); } if (result.operations.length) { @@ -111,7 +112,7 @@ export function useDocumentDriveServer( } return result.document; } catch (error) { - console.error(error); + logger.error(error); return drive; } }, @@ -414,7 +415,7 @@ export function useDocumentDriveServer( if (result.operations.length) { await refreshDocumentDrives(); } else if (result.status !== 'SUCCESS') { - console.error( + logger.error( `Error copying files: ${result.status}`, result.error, ); @@ -699,3 +700,5 @@ export function useDocumentDriveServer( ], ); } + +export type TDocumentDriveServer = ReturnType; diff --git a/src/hooks/useDocumentDrives.ts b/src/hooks/useDocumentDrives.ts index 54f3aaaf..b307e05a 100644 --- a/src/hooks/useDocumentDrives.ts +++ b/src/hooks/useDocumentDrives.ts @@ -4,6 +4,7 @@ import { OperationScope } from 'document-model/document'; import { atom, useAtom } from 'jotai'; import { atomFamily } from 'jotai/utils'; import { useCallback, useMemo } from 'react'; +import { logger } from 'src/services/logger'; import { ClientErrorHandler } from './useClientErrorHandler'; // map of DocumentDriveServer objects and their Document Drives @@ -65,11 +66,11 @@ export function useDocumentDrives(server: IDocumentDriveServer) { const drive = await server.getDrive(id); documentDrives.push(drive); } catch (error) { - console.error(error); + logger.error(error); } } } catch (error) { - console.error(error); + logger.error(error); } finally { setDocumentDrives(documentDrives); } @@ -94,7 +95,7 @@ export function useDocumentDrives(server: IDocumentDriveServer) { 'syncStatus', async (_event, _status, error) => { if (error) { - console.error(error); + logger.error(error); } await refreshDocumentDrives(); }, diff --git a/src/hooks/useLoadDefaultDrives.ts b/src/hooks/useLoadDefaultDrives.ts index 8d82418e..daed457f 100644 --- a/src/hooks/useLoadDefaultDrives.ts +++ b/src/hooks/useLoadDefaultDrives.ts @@ -1,4 +1,5 @@ import { useEffect, useRef } from 'react'; +import { logger } from 'src/services/logger'; import { useDocumentDriveServer } from './useDocumentDriveServer'; import { useFeatureFlag } from './useFeatureFlags'; import defaultConfig from './useFeatureFlags/default-config'; @@ -124,7 +125,7 @@ export const useLoadDefaultDrives = () => { ], })), ) - .catch(console.error) + .catch(logger.error) .finally(() => { loadingDrives.current = loadingDrives.current.filter( url => url !== defaultDrive.url, diff --git a/src/hooks/useLoadInitialData.tsx b/src/hooks/useLoadInitialData.tsx index 0d2c93bc..cb7a561b 100644 --- a/src/hooks/useLoadInitialData.tsx +++ b/src/hooks/useLoadInitialData.tsx @@ -102,6 +102,7 @@ export const useLoadInitialData = () => { ), { type: 'connect-warning', + toastId: `${drive.syncStatus === CONFLICT ? 'driveSyncConflict' : 'driveSyncError'}-${drive.id}`, }, ); }); diff --git a/src/hooks/useLogin.ts b/src/hooks/useLogin.ts index 6a291269..f44fa1c6 100644 --- a/src/hooks/useLogin.ts +++ b/src/hooks/useLogin.ts @@ -2,6 +2,7 @@ import { atom, useAtom } from 'jotai'; import { useCallback, useEffect, useMemo } from 'react'; import { useConnectCrypto } from 'src/hooks/useConnectCrypto'; import { useRenown } from 'src/hooks/useRenown'; +import { logger } from 'src/services/logger'; import { RENOWN_CHAIN_ID, RENOWN_NETWORK_ID, @@ -62,7 +63,7 @@ export const useLogin = () => { } } catch (error) { setStatus('not-authorized'); - console.error(error); + logger.error(error); } }, [renown], diff --git a/src/hooks/useOpenFile.tsx b/src/hooks/useOpenFile.tsx index ab3c1b8f..89b4c593 100644 --- a/src/hooks/useOpenFile.tsx +++ b/src/hooks/useOpenFile.tsx @@ -1,10 +1,11 @@ import { Document } from 'document-model/document'; +import { logger } from 'src/services/logger'; import { useGetDocumentModel } from 'src/store/document-model'; import { loadFile } from 'src/utils/file'; export function useOpenFile( onDocument: (document: Document, file: File) => void, - onError?: (error: Error) => void + onError?: (error: Error) => void, ) { const getDocumentModel = useGetDocumentModel(); return async () => { @@ -18,7 +19,7 @@ export function useOpenFile( throw new Error('File was not recognized.'); } } catch (error) { - console.error('Error opening file:', error); // TODO improve error handling + logger.error('Error opening file:', error); // TODO improve error handling onError?.(error as Error); } }; diff --git a/src/hooks/useUiNodes.ts b/src/hooks/useUiNodes.ts index 4d21624c..377665e7 100644 --- a/src/hooks/useUiNodes.ts +++ b/src/hooks/useUiNodes.ts @@ -20,6 +20,11 @@ import { DocumentDriveDocument } from 'document-model-libs/document-drive'; import { useCallback, useMemo } from 'react'; import { useTranslation } from 'react-i18next'; import { useModal } from 'src/components/modal'; +import { useFileNodeDocument } from 'src/store/document-drive'; +import { + useFilteredDocumentModels, + useGetDocumentModel, +} from 'src/store/document-model'; import { getNodeOptions } from 'src/utils/drive-sections'; import { makeNodeSlugFromNodeName } from 'src/utils/slug'; import { useDocumentDriveById } from './useDocumentDriveById'; @@ -61,6 +66,12 @@ export function useUiNodes() { const openSwitchboardLink = useOpenSwitchboardLink(selectedDriveNode?.id); const userPermissions = useUserPermissions(); const nodeOptions = getNodeOptions(); + const documentModels = useFilteredDocumentModels(); + const getDocumentModel = useGetDocumentModel(); + const fileNodeDocument = useFileNodeDocument({ + ...uiNodesContext, + ...documentDriveServer, + }); const makeUiDriveNode = useCallback( async (drive: DocumentDriveDocument) => { @@ -493,8 +504,10 @@ export function useUiNodes() { ...uiNodesContext, ...userPermissions, ...selectedDocumentDrive, + ...fileNodeDocument, nodeOptions, driveNodesBySharingType, + documentModels, onAddFolder, onAddFile, onCopyNode, @@ -511,14 +524,17 @@ export function useUiNodes() { onAddTrigger, onRemoveTrigger, onAddInvalidTrigger, + getDocumentModel, }), [ documentDriveServer, uiNodesContext, userPermissions, selectedDocumentDrive, + fileNodeDocument, nodeOptions, driveNodesBySharingType, + documentModels, onAddFolder, onAddFile, onCopyNode, @@ -535,8 +551,9 @@ export function useUiNodes() { onAddTrigger, onRemoveTrigger, onAddInvalidTrigger, + getDocumentModel, ], ); } -export type UiNodes = ReturnType; +export type TUiNodes = ReturnType; diff --git a/src/pages/content.tsx b/src/pages/content.tsx index 0452fb7d..75911cc3 100644 --- a/src/pages/content.tsx +++ b/src/pages/content.tsx @@ -8,14 +8,8 @@ import FolderView from 'src/components/folder-view'; import { useModal } from 'src/components/modal'; import { SearchBar } from 'src/components/search-bar'; import { useConnectConfig } from 'src/hooks/useConnectConfig'; -import { useDocumentDriveServer } from 'src/hooks/useDocumentDriveServer'; import { useNodeNavigation } from 'src/hooks/useNodeNavigation'; import { useUiNodes } from 'src/hooks/useUiNodes'; -import { useFileNodeDocument } from 'src/store/document-drive'; -import { - useFilteredDocumentModels, - useGetDocumentModel, -} from 'src/store/document-model'; import { usePreloadEditor } from 'src/store/editor'; import { exportFile } from 'src/utils'; import { validateDocument } from 'src/utils/validate-document'; @@ -38,15 +32,17 @@ const Content = () => { selectedParentNode, isRemoteDrive, isAllowedToCreateDocuments, + selectedDocument, + documentModels, setSelectedNode, openSwitchboardLink, + setSelectedDocument, + addOperationToSelectedDocument, + addFile, + renameNode, + getDocumentModel, } = useUiNodes(); const { showModal } = useModal(); - const { addFile, renameNode } = useDocumentDriveServer(); - const documentModels = useFilteredDocumentModels(); - const getDocumentModel = useGetDocumentModel(); - const [selectedDocument, setSelectedDocument, addOperation] = - useFileNodeDocument(selectedDriveNode?.id, selectedNode?.id); const preloadEditor = usePreloadEditor(); useNodeNavigation(); @@ -79,14 +75,14 @@ const Content = () => { }); }, [selectedDriveNode, selectedNode, addFile]); - async function handleAddOperation(operation: Operation) { + async function handleAddOperationToSelectedDocument(operation: Operation) { if (!selectedDocument) { throw new Error('No document selected'); } - if (!addOperation) { + if (!addOperationToSelectedDocument) { throw new Error('No add operation function defined'); } - await addOperation(operation); + await addOperationToSelectedDocument(operation); } function createDocument(documentModel: DocumentModel) { @@ -162,7 +158,7 @@ const Content = () => { document={selectedDocument} onChange={onDocumentChangeHandler} onExport={() => exportDocument(selectedDocument)} - onAddOperation={handleAddOperation} + onAddOperation={handleAddOperationToSelectedDocument} {...(isRemoteDrive && { onOpenSwitchboardLink })} /> diff --git a/src/renderer.ts b/src/renderer.ts index 71321b7c..a00fd9d6 100644 --- a/src/renderer.ts +++ b/src/renderer.ts @@ -26,7 +26,7 @@ * ``` */ import { createRoot } from 'react-dom/client'; -import initSentry from './app/sentry'; +import './app/sentry'; import App from './components/app'; import './i18n'; import './index.css'; @@ -36,5 +36,4 @@ if (import.meta.env.MODE === 'development') { window.documentEditorDebugTools = new DocumentEditorDebugTools(); } -initSentry(); createRoot(document.getElementById('app')!).render(App); diff --git a/src/services/logger.ts b/src/services/logger.ts new file mode 100644 index 00000000..3387d9c3 --- /dev/null +++ b/src/services/logger.ts @@ -0,0 +1,57 @@ +/* eslint-disable @typescript-eslint/no-explicit-any */ +import { captureException } from '@sentry/react'; +import { ILogger, setLogger } from 'document-drive/logger'; + +class ConnectLogger implements ILogger { + #logger: ILogger = console; + + set logger(logger: ILogger) { + this.#logger = logger; + } + + log(...data: any[]): void { + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument + return this.#logger.log(...data); + } + + info(...data: any[]): void { + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument + return this.#logger.info(...data); + } + + warn(...data: any[]): void { + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument + return this.#logger.warn(...data); + } + + error(...data: any[]): void { + const errorIndex = data.findIndex(item => item instanceof Error); + if (errorIndex) { + const error = data.at(errorIndex) as Error; + const info = data + .slice(0, errorIndex) + .concat(data.slice(errorIndex + 1)); + captureException(error, { data: info }); + } else if (data.length === 1) { + captureException(data.at(0)); + } else if (data.length > 1) { + captureException(data[0], { data: data.slice(1) }); + } + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument + return this.#logger.error(...data); + } + + debug(...data: any[]): void { + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument + return this.#logger.debug(...data); + } + + trace(...data: any[]): void { + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument + return this.#logger.trace(...data); + } +} + +export const logger: ILogger = new ConnectLogger(); + +setLogger(logger); diff --git a/src/services/renown/index.ts b/src/services/renown/index.ts index 4100e21c..8f3cc984 100644 --- a/src/services/renown/index.ts +++ b/src/services/renown/index.ts @@ -1,4 +1,5 @@ import { EventEmitter } from 'events'; +import { logger } from '../logger'; import type { IStorage } from '../storage'; import { getEnsInfo } from '../viem'; import { RENOWN_URL } from './constants'; @@ -75,7 +76,7 @@ export class Renown { this.#updateUser(user); return user; } catch (error) { - console.error(error); + logger.error(error); this.#updateUser(undefined); throw error; } diff --git a/src/store/document-drive.ts b/src/store/document-drive.ts index d71c8680..3021e330 100644 --- a/src/store/document-drive.ts +++ b/src/store/document-drive.ts @@ -1,6 +1,7 @@ +import { FILE, TUiNodesContext } from '@powerhousedao/design-system'; import { Document, Operation } from 'document-model/document'; -import { useEffect, useMemo, useState } from 'react'; -import { useDocumentDriveServer } from 'src/hooks/useDocumentDriveServer'; +import { useCallback, useEffect, useMemo, useState } from 'react'; +import { TDocumentDriveServer } from 'src/hooks/useDocumentDriveServer'; function debounceOperations( callback: (operations: Operation[]) => Promise, @@ -42,32 +43,42 @@ function debounceOperations( }; } -export const useFileNodeDocument = (drive?: string, id?: string) => { - const { openFile, addOperations, onStrandUpdate } = - useDocumentDriveServer(); +export function useFileNodeDocument( + props: TUiNodesContext & TDocumentDriveServer, +) { + const { selectedNode, openFile, addOperations, onStrandUpdate } = props; const [selectedDocument, setSelectedDocument] = useState< Document | undefined >(); - async function fetchDocument(drive: string, id: string) { + const fetchDocument = useCallback(async () => { + if (selectedNode?.kind !== FILE) { + return; + } try { - const document = await openFile(drive, id); + const document = await openFile( + selectedNode.driveId, + selectedNode.id, + ); setSelectedDocument(document); } catch (error) { setSelectedDocument(undefined); console.error(error); } - } + }, [openFile, selectedNode?.driveId, selectedNode?.id, selectedNode?.kind]); useEffect(() => { let handler: (() => void) | undefined = undefined; - if (drive && id) { + if (selectedNode?.kind === FILE) { handler = onStrandUpdate(strand => { - if (strand.driveId === drive && strand.documentId === id) { - fetchDocument(drive, id); + if ( + strand.driveId === selectedNode.driveId && + strand.documentId === selectedNode.id + ) { + fetchDocument().catch(console.error); } }); - fetchDocument(drive, id); + fetchDocument().catch(console.error); } else { setSelectedDocument(undefined); } @@ -75,17 +86,31 @@ export const useFileNodeDocument = (drive?: string, id?: string) => { return () => { handler?.(); }; - }, [drive, id]); + }, [fetchDocument, onStrandUpdate, selectedNode]); - useEffect(() => {}, [drive, id]); - - const addOperation = useMemo(() => { - if (drive && id) { + const addOperationToSelectedDocument = useMemo(() => { + if (selectedNode?.kind === FILE) { return debounceOperations(operations => - addOperations(drive, id, operations), + addOperations( + selectedNode.driveId, + selectedNode.id, + operations, + ), ); } - }, [addOperations, drive, id]); + }, [ + addOperations, + selectedNode?.driveId, + selectedNode?.id, + selectedNode?.kind, + ]); - return [selectedDocument, setSelectedDocument, addOperation] as const; -}; + return useMemo( + () => ({ + selectedDocument, + setSelectedDocument, + addOperationToSelectedDocument, + }), + [selectedDocument, setSelectedDocument, addOperationToSelectedDocument], + ); +} diff --git a/src/store/user.ts b/src/store/user.ts index 2ed2f433..761c34b0 100644 --- a/src/store/user.ts +++ b/src/store/user.ts @@ -1,3 +1,7 @@ +import { + setUser as setSentryUser, + type User as SentryUser, +} from '@sentry/react'; import { atom, useAtom } from 'jotai'; import { useEffect } from 'react'; import { useRenown } from 'src/hooks/useRenown'; @@ -11,6 +15,16 @@ export const useUser = () => { const [user, setUser] = useAtom(userAtom); const renown = useRenown(); + useEffect(() => { + let sentryUser: SentryUser | null = null; + if (user) { + // saves the user info except the credential + const { credential, ...rest } = user; + sentryUser = { id: rest.did, username: rest.ens?.name, ...rest }; + } + setSentryUser(sentryUser); + }, [user]); + useEffect(() => { if (userInit) return; userInit = true; diff --git a/src/utils/browser-document-drive.ts b/src/utils/browser-document-drive.ts index ee4b1612..b1cc1769 100644 --- a/src/utils/browser-document-drive.ts +++ b/src/utils/browser-document-drive.ts @@ -4,6 +4,7 @@ import { BaseQueueManager } from 'document-drive/queue/base'; import { DocumentDriveServer } from 'document-drive/server'; import { BrowserStorage } from 'document-drive/storage/browser'; import { utils } from 'document-model/document'; +import { logger } from 'src/services/logger'; import { documentModels } from 'src/store/document-model'; export const BrowserDocumentDriveServer = new DocumentDriveServer( @@ -13,30 +14,29 @@ export const BrowserDocumentDriveServer = new DocumentDriveServer( new BaseQueueManager(1, 10), ); -BrowserDocumentDriveServer.initialize() - .then(() => - BrowserDocumentDriveServer.getDrives() - .then(drives => { - if ( - !drives.length && - connectConfig.drives.sections.LOCAL.enabled - ) { - BrowserDocumentDriveServer.addDrive({ - global: { - id: utils.hashKey(), - name: 'My Local Drive', - icon: null, - slug: 'my-local-drive', - }, - local: { - availableOffline: false, - sharingType: 'private', - listeners: [], - triggers: [], - }, - }).catch(console.error); - } - }) - .catch(console.error), - ) - .catch(console.error); +async function init() { + try { + await BrowserDocumentDriveServer.initialize(); + const drives = await BrowserDocumentDriveServer.getDrives(); + if (!drives.length && connectConfig.drives.sections.LOCAL.enabled) { + BrowserDocumentDriveServer.addDrive({ + global: { + id: utils.hashKey(), + name: 'My Local Drive', + icon: null, + slug: 'my-local-drive', + }, + local: { + availableOffline: false, + sharingType: 'private', + listeners: [], + triggers: [], + }, + }).catch(logger.error); + } + } catch (e) { + logger.error(e); + } +} + +init().catch(logger.error); diff --git a/src/utils/document-model.ts b/src/utils/document-model.ts index 738adb8d..cf4a5f18 100644 --- a/src/utils/document-model.ts +++ b/src/utils/document-model.ts @@ -7,6 +7,7 @@ import type { Reducer, } from 'document-model/document'; import { useEffect, useState } from 'react'; +import { logger } from 'src/services/logger'; export type DocumentDispatchCallback = ( operation: Operation, @@ -42,7 +43,7 @@ type OnErrorHandler = (error: unknown) => void; export function useDocumentDispatch( documentReducer: Reducer | undefined, initialState: Document, - onError: OnErrorHandler = console.error, + onError: OnErrorHandler = logger.error, ): readonly [ Document | undefined, DocumentDispatch, diff --git a/src/utils/file.ts b/src/utils/file.ts index 2c111b61..8215a105 100644 --- a/src/utils/file.ts +++ b/src/utils/file.ts @@ -1,5 +1,6 @@ import type { Document, DocumentModel } from 'document-model/document'; import { utils } from 'document-model/document'; +import { logger } from 'src/services/logger'; const downloadFile = async (document: Document) => { const zip = await utils.createZip(document); @@ -15,7 +16,7 @@ const downloadFile = async (document: Document) => { window.document.body.removeChild(link); }) - .catch(console.error); + .catch(logger.error); }; export async function exportFile( diff --git a/src/utils/slug.ts b/src/utils/slug.ts index fd623636..6ace297c 100644 --- a/src/utils/slug.ts +++ b/src/utils/slug.ts @@ -1,3 +1,3 @@ export function makeNodeSlugFromNodeName(name: string) { - return name.replaceAll(/\s/g, '-').toLowerCase(); + return name.replaceAll(/\s/g, '-'); }