From 33dbe1df1c2b4db31e92b93a3225f1d41b45e13b Mon Sep 17 00:00:00 2001 From: dougfabris Date: Thu, 9 Jan 2025 17:52:26 -0300 Subject: [PATCH 1/5] chore: bump packages --- apps/meteor/ee/server/services/package.json | 2 +- apps/meteor/package.json | 8 +- apps/uikit-playground/package.json | 8 +- ee/packages/ui-theming/package.json | 6 +- packages/core-services/package.json | 2 +- packages/core-typings/package.json | 2 +- packages/fuselage-ui-kit/package.json | 6 +- packages/gazzodown/package.json | 2 +- packages/livechat/package.json | 4 +- packages/ui-avatar/package.json | 2 +- packages/ui-client/package.json | 6 +- packages/ui-composer/package.json | 4 +- packages/ui-contexts/package.json | 2 +- packages/ui-kit/package.json | 2 +- packages/ui-video-conf/package.json | 6 +- packages/ui-voip/package.json | 6 +- yarn.lock | 115 +++++++++++--------- 17 files changed, 96 insertions(+), 87 deletions(-) diff --git a/apps/meteor/ee/server/services/package.json b/apps/meteor/ee/server/services/package.json index 1cd10b9ebdef..a9f030847256 100644 --- a/apps/meteor/ee/server/services/package.json +++ b/apps/meteor/ee/server/services/package.json @@ -48,7 +48,7 @@ "ws": "^8.18.0" }, "devDependencies": { - "@rocket.chat/icons": "~0.39.0", + "@rocket.chat/icons": "^0.40.0", "@types/cookie": "^0.5.4", "@types/cookie-parser": "^1.4.7", "@types/ejson": "^2.2.2", diff --git a/apps/meteor/package.json b/apps/meteor/package.json index 9d97ab92379a..3937ffbf9291 100644 --- a/apps/meteor/package.json +++ b/apps/meteor/package.json @@ -248,22 +248,22 @@ "@rocket.chat/emitter": "~0.31.25", "@rocket.chat/favicon": "workspace:^", "@rocket.chat/freeswitch": "workspace:^", - "@rocket.chat/fuselage": "^0.60.0", - "@rocket.chat/fuselage-hooks": "^0.34.0", + "@rocket.chat/fuselage": "^0.60.1", + "@rocket.chat/fuselage-hooks": "^0.34.1", "@rocket.chat/fuselage-polyfills": "~0.31.25", "@rocket.chat/fuselage-toastbar": "^0.33.0", "@rocket.chat/fuselage-tokens": "^0.33.2", "@rocket.chat/fuselage-ui-kit": "workspace:^", "@rocket.chat/gazzodown": "workspace:^", "@rocket.chat/i18n": "workspace:^", - "@rocket.chat/icons": "~0.39.0", + "@rocket.chat/icons": "^0.40.0", "@rocket.chat/instance-status": "workspace:^", "@rocket.chat/jwt": "workspace:^", "@rocket.chat/layout": "~0.31.27", "@rocket.chat/license": "workspace:^", "@rocket.chat/log-format": "workspace:^", "@rocket.chat/logger": "workspace:^", - "@rocket.chat/logo": "^0.31.31", + "@rocket.chat/logo": "^0.31.32", "@rocket.chat/memo": "~0.31.25", "@rocket.chat/message-parser": "workspace:^", "@rocket.chat/model-typings": "workspace:^", diff --git a/apps/uikit-playground/package.json b/apps/uikit-playground/package.json index e3c60b2a032d..558c4562d32d 100644 --- a/apps/uikit-playground/package.json +++ b/apps/uikit-playground/package.json @@ -17,14 +17,14 @@ "@lezer/highlight": "^1.2.1", "@rocket.chat/core-typings": "workspace:^", "@rocket.chat/css-in-js": "~0.31.25", - "@rocket.chat/fuselage": "^0.60.0", - "@rocket.chat/fuselage-hooks": "^0.34.0", + "@rocket.chat/fuselage": "^0.60.1", + "@rocket.chat/fuselage-hooks": "^0.34.1", "@rocket.chat/fuselage-polyfills": "~0.31.25", "@rocket.chat/fuselage-toastbar": "^0.33.0", "@rocket.chat/fuselage-tokens": "^0.33.2", "@rocket.chat/fuselage-ui-kit": "workspace:~", - "@rocket.chat/icons": "~0.39.0", - "@rocket.chat/logo": "^0.31.31", + "@rocket.chat/icons": "^0.40.0", + "@rocket.chat/logo": "^0.31.32", "@rocket.chat/styled": "~0.31.25", "@rocket.chat/ui-avatar": "workspace:^", "@rocket.chat/ui-contexts": "workspace:~", diff --git a/ee/packages/ui-theming/package.json b/ee/packages/ui-theming/package.json index aa0c4c782124..5d9f647dd4cd 100644 --- a/ee/packages/ui-theming/package.json +++ b/ee/packages/ui-theming/package.json @@ -4,9 +4,9 @@ "private": true, "devDependencies": { "@rocket.chat/css-in-js": "~0.31.25", - "@rocket.chat/fuselage": "^0.60.0", - "@rocket.chat/fuselage-hooks": "^0.34.0", - "@rocket.chat/icons": "~0.39.0", + "@rocket.chat/fuselage": "^0.60.1", + "@rocket.chat/fuselage-hooks": "^0.34.1", + "@rocket.chat/icons": "^0.40.0", "@rocket.chat/ui-contexts": "workspace:~", "@types/react": "~17.0.83", "eslint": "~8.45.0", diff --git a/packages/core-services/package.json b/packages/core-services/package.json index c3b317351ca6..318bd4385a10 100644 --- a/packages/core-services/package.json +++ b/packages/core-services/package.json @@ -34,7 +34,7 @@ }, "dependencies": { "@rocket.chat/core-typings": "workspace:^", - "@rocket.chat/icons": "~0.39.0", + "@rocket.chat/icons": "^0.40.0", "@rocket.chat/message-parser": "workspace:^", "@rocket.chat/models": "workspace:^", "@rocket.chat/rest-typings": "workspace:^", diff --git a/packages/core-typings/package.json b/packages/core-typings/package.json index bbfa529fad52..59182158b195 100644 --- a/packages/core-typings/package.json +++ b/packages/core-typings/package.json @@ -24,7 +24,7 @@ "/dist" ], "dependencies": { - "@rocket.chat/icons": "~0.39.0", + "@rocket.chat/icons": "^0.40.0", "@rocket.chat/message-parser": "workspace:^", "@rocket.chat/ui-kit": "workspace:~", "@types/express": "^4.17.21" diff --git a/packages/fuselage-ui-kit/package.json b/packages/fuselage-ui-kit/package.json index 25baef3334fc..6c177e552dee 100644 --- a/packages/fuselage-ui-kit/package.json +++ b/packages/fuselage-ui-kit/package.json @@ -52,10 +52,10 @@ "@rocket.chat/apps-engine": "workspace:^", "@rocket.chat/core-typings": "workspace:^", "@rocket.chat/eslint-config": "workspace:^", - "@rocket.chat/fuselage": "^0.60.0", - "@rocket.chat/fuselage-hooks": "^0.34.0", + "@rocket.chat/fuselage": "^0.60.1", + "@rocket.chat/fuselage-hooks": "^0.34.1", "@rocket.chat/fuselage-polyfills": "~0.31.25", - "@rocket.chat/icons": "~0.39.0", + "@rocket.chat/icons": "^0.40.0", "@rocket.chat/jest-presets": "workspace:~", "@rocket.chat/mock-providers": "workspace:^", "@rocket.chat/prettier-config": "~0.31.25", diff --git a/packages/gazzodown/package.json b/packages/gazzodown/package.json index e0651bca4041..bdb7cd416d8d 100644 --- a/packages/gazzodown/package.json +++ b/packages/gazzodown/package.json @@ -29,7 +29,7 @@ "@babel/core": "~7.26.0", "@rocket.chat/core-typings": "workspace:^", "@rocket.chat/css-in-js": "~0.31.25", - "@rocket.chat/fuselage": "^0.60.0", + "@rocket.chat/fuselage": "^0.60.1", "@rocket.chat/fuselage-tokens": "^0.33.2", "@rocket.chat/jest-presets": "workspace:~", "@rocket.chat/message-parser": "workspace:^", diff --git a/packages/livechat/package.json b/packages/livechat/package.json index 3094db7648f2..6f90c3cb3566 100644 --- a/packages/livechat/package.json +++ b/packages/livechat/package.json @@ -30,9 +30,9 @@ "@rocket.chat/core-typings": "workspace:^", "@rocket.chat/ddp-client": "workspace:^", "@rocket.chat/eslint-config": "workspace:^", - "@rocket.chat/fuselage-hooks": "^0.34.0", + "@rocket.chat/fuselage-hooks": "^0.34.1", "@rocket.chat/fuselage-tokens": "^0.33.2", - "@rocket.chat/logo": "^0.31.31", + "@rocket.chat/logo": "^0.31.32", "@rocket.chat/ui-contexts": "workspace:^", "@storybook/addon-essentials": "^8.4.4", "@storybook/addon-styling-webpack": "~1.0.1", diff --git a/packages/ui-avatar/package.json b/packages/ui-avatar/package.json index 5358ba037e7c..ab595b84b4ed 100644 --- a/packages/ui-avatar/package.json +++ b/packages/ui-avatar/package.json @@ -4,7 +4,7 @@ "private": true, "devDependencies": { "@babel/core": "~7.26.0", - "@rocket.chat/fuselage": "^0.60.0", + "@rocket.chat/fuselage": "^0.60.1", "@rocket.chat/ui-contexts": "workspace:^", "@types/react": "~17.0.83", "@types/react-dom": "~17.0.26", diff --git a/packages/ui-client/package.json b/packages/ui-client/package.json index ef0602ab7e75..68b329fe7865 100644 --- a/packages/ui-client/package.json +++ b/packages/ui-client/package.json @@ -21,9 +21,9 @@ "@babel/core": "~7.26.0", "@react-aria/toolbar": "^3.0.0-nightly.5042", "@rocket.chat/css-in-js": "~0.31.25", - "@rocket.chat/fuselage": "^0.60.0", - "@rocket.chat/fuselage-hooks": "^0.34.0", - "@rocket.chat/icons": "~0.39.0", + "@rocket.chat/fuselage": "^0.60.1", + "@rocket.chat/fuselage-hooks": "^0.34.1", + "@rocket.chat/icons": "^0.40.0", "@rocket.chat/jest-presets": "workspace:~", "@rocket.chat/mock-providers": "workspace:^", "@rocket.chat/ui-avatar": "workspace:~", diff --git a/packages/ui-composer/package.json b/packages/ui-composer/package.json index 34b0fa5bc17f..77b91c51408f 100644 --- a/packages/ui-composer/package.json +++ b/packages/ui-composer/package.json @@ -21,8 +21,8 @@ "@babel/core": "~7.26.0", "@react-aria/toolbar": "^3.0.0-nightly.5042", "@rocket.chat/eslint-config": "workspace:^", - "@rocket.chat/fuselage": "^0.60.0", - "@rocket.chat/icons": "~0.39.0", + "@rocket.chat/fuselage": "^0.60.1", + "@rocket.chat/icons": "^0.40.0", "@storybook/addon-actions": "^8.4.4", "@storybook/addon-docs": "^8.4.4", "@storybook/addon-essentials": "^8.4.4", diff --git a/packages/ui-contexts/package.json b/packages/ui-contexts/package.json index 8826c37982d5..74263d374eae 100644 --- a/packages/ui-contexts/package.json +++ b/packages/ui-contexts/package.json @@ -6,7 +6,7 @@ "@rocket.chat/core-typings": "workspace:^", "@rocket.chat/ddp-client": "workspace:~", "@rocket.chat/emitter": "~0.31.25", - "@rocket.chat/fuselage-hooks": "^0.34.0", + "@rocket.chat/fuselage-hooks": "^0.34.1", "@rocket.chat/i18n": "workspace:~", "@rocket.chat/rest-typings": "workspace:^", "@types/react": "~17.0.83", diff --git a/packages/ui-kit/package.json b/packages/ui-kit/package.json index 655427584868..31e62196caec 100644 --- a/packages/ui-kit/package.json +++ b/packages/ui-kit/package.json @@ -40,7 +40,7 @@ "@babel/plugin-transform-runtime": "~7.25.9", "@babel/preset-env": "~7.26.0", "@rocket.chat/eslint-config": "workspace:~", - "@rocket.chat/icons": "~0.39.0", + "@rocket.chat/icons": "^0.40.0", "@rocket.chat/jest-presets": "workspace:~", "@types/jest": "~29.5.14", "babel-loader": "~9.2.1", diff --git a/packages/ui-video-conf/package.json b/packages/ui-video-conf/package.json index f116d1b9019c..d2d64bbc5aca 100644 --- a/packages/ui-video-conf/package.json +++ b/packages/ui-video-conf/package.json @@ -24,9 +24,9 @@ "@babel/core": "~7.26.0", "@rocket.chat/css-in-js": "~0.31.25", "@rocket.chat/eslint-config": "workspace:^", - "@rocket.chat/fuselage": "^0.60.0", - "@rocket.chat/fuselage-hooks": "^0.34.0", - "@rocket.chat/icons": "~0.39.0", + "@rocket.chat/fuselage": "^0.60.1", + "@rocket.chat/fuselage-hooks": "^0.34.1", + "@rocket.chat/icons": "^0.40.0", "@rocket.chat/jest-presets": "workspace:~", "@rocket.chat/styled": "~0.31.25", "@rocket.chat/ui-avatar": "workspace:^", diff --git a/packages/ui-voip/package.json b/packages/ui-voip/package.json index 1f0adad73206..9919aca0c0b1 100644 --- a/packages/ui-voip/package.json +++ b/packages/ui-voip/package.json @@ -29,9 +29,9 @@ "@react-spectrum/test-utils": "~1.0.0-alpha.2", "@rocket.chat/css-in-js": "~0.31.25", "@rocket.chat/eslint-config": "workspace:^", - "@rocket.chat/fuselage": "^0.60.0", - "@rocket.chat/fuselage-hooks": "^0.34.0", - "@rocket.chat/icons": "~0.39.0", + "@rocket.chat/fuselage": "^0.60.1", + "@rocket.chat/fuselage-hooks": "^0.34.1", + "@rocket.chat/icons": "^0.40.0", "@rocket.chat/jest-presets": "workspace:~", "@rocket.chat/mock-providers": "workspace:~", "@rocket.chat/styled": "~0.31.25", diff --git a/yarn.lock b/yarn.lock index 03336ea31696..f5cea7192fc3 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7602,7 +7602,7 @@ __metadata: "@rocket.chat/apps-engine": "workspace:^" "@rocket.chat/core-typings": "workspace:^" "@rocket.chat/eslint-config": "workspace:^" - "@rocket.chat/icons": "npm:~0.39.0" + "@rocket.chat/icons": "npm:^0.40.0" "@rocket.chat/jest-presets": "workspace:~" "@rocket.chat/message-parser": "workspace:^" "@rocket.chat/models": "workspace:^" @@ -7625,7 +7625,7 @@ __metadata: dependencies: "@rocket.chat/apps-engine": "workspace:^" "@rocket.chat/eslint-config": "workspace:^" - "@rocket.chat/icons": "npm:~0.39.0" + "@rocket.chat/icons": "npm:^0.40.0" "@rocket.chat/message-parser": "workspace:^" "@rocket.chat/ui-kit": "workspace:~" "@types/express": "npm:^4.17.21" @@ -7793,15 +7793,15 @@ __metadata: languageName: unknown linkType: soft -"@rocket.chat/fuselage-hooks@npm:^0.34.0": - version: 0.34.0 - resolution: "@rocket.chat/fuselage-hooks@npm:0.34.0" +"@rocket.chat/fuselage-hooks@npm:^0.34.1": + version: 0.34.1 + resolution: "@rocket.chat/fuselage-hooks@npm:0.34.1" dependencies: - use-sync-external-store: "npm:~1.2.0" + use-sync-external-store: "npm:~1.4.0" peerDependencies: "@rocket.chat/fuselage-tokens": "*" react: ^17.0.2 - checksum: 10/bf73153ef9051430a069c5e4f5df792de123ad65f29c89f1c4a1da237842b64abb9977002bec1ba583a3496923802095a80129bb13768d7d2949678d48cb5a90 + checksum: 10/af20c99c354f75c43ea142d7c383eaec42549941d8a419014a313680b0db5c942d2f84a01415dbd8c21c5ec35bf9b933e487da1a582109fbe5207d2605ff4e2d languageName: node linkType: hard @@ -7853,11 +7853,11 @@ __metadata: "@rocket.chat/apps-engine": "workspace:^" "@rocket.chat/core-typings": "workspace:^" "@rocket.chat/eslint-config": "workspace:^" - "@rocket.chat/fuselage": "npm:^0.60.0" - "@rocket.chat/fuselage-hooks": "npm:^0.34.0" + "@rocket.chat/fuselage": "npm:^0.60.1" + "@rocket.chat/fuselage-hooks": "npm:^0.34.1" "@rocket.chat/fuselage-polyfills": "npm:~0.31.25" "@rocket.chat/gazzodown": "workspace:^" - "@rocket.chat/icons": "npm:~0.39.0" + "@rocket.chat/icons": "npm:^0.40.0" "@rocket.chat/jest-presets": "workspace:~" "@rocket.chat/mock-providers": "workspace:^" "@rocket.chat/prettier-config": "npm:~0.31.25" @@ -7912,9 +7912,9 @@ __metadata: languageName: unknown linkType: soft -"@rocket.chat/fuselage@npm:^0.60.0": - version: 0.60.0 - resolution: "@rocket.chat/fuselage@npm:0.60.0" +"@rocket.chat/fuselage@npm:^0.60.1": + version: 0.60.1 + resolution: "@rocket.chat/fuselage@npm:0.60.1" dependencies: "@rocket.chat/css-in-js": "npm:^0.31.25" "@rocket.chat/css-supports": "npm:^0.31.25" @@ -7932,7 +7932,7 @@ __metadata: react: ^17.0.2 react-dom: ^17.0.2 react-virtuoso: 1.2.4 - checksum: 10/53ea5b9cd535764b1c8e5e3d2e175f095f378ac9aea6d6dddb9aeef66acf74e50fb8ce5eea1806e8f40ed805e6def3ff58684343f301630e191934b2ba6d4178 + checksum: 10/336a77fc89763b550ff60bcf3de5f42a73e111b116d0b4357d56e60c710f783c5ac95836b75a113a54058d04171f403913030ebfe6e20df214038a546e0c5134 languageName: node linkType: hard @@ -7943,7 +7943,7 @@ __metadata: "@babel/core": "npm:~7.26.0" "@rocket.chat/core-typings": "workspace:^" "@rocket.chat/css-in-js": "npm:~0.31.25" - "@rocket.chat/fuselage": "npm:^0.60.0" + "@rocket.chat/fuselage": "npm:^0.60.1" "@rocket.chat/fuselage-tokens": "npm:^0.33.2" "@rocket.chat/jest-presets": "workspace:~" "@rocket.chat/message-parser": "workspace:^" @@ -8008,10 +8008,10 @@ __metadata: languageName: unknown linkType: soft -"@rocket.chat/icons@npm:~0.39.0": - version: 0.39.0 - resolution: "@rocket.chat/icons@npm:0.39.0" - checksum: 10/b46bef7658ea90915aed10d3b021ddee0af64a98b463772289db7be9ec3013c8f4fa842b41abc57f0304171cbbf912bc3f5f8abfad8d29cf5c3dcd57c774b647 +"@rocket.chat/icons@npm:^0.40.0": + version: 0.40.0 + resolution: "@rocket.chat/icons@npm:0.40.0" + checksum: 10/9fb696db75919f3f0bacdb4637e226e0bb078ca620c1130ccb3b113144b140d040205dd232c69d0c951d5b26488b5d9295bedcbbe69c006feb1cc53eea370614 languageName: node linkType: hard @@ -8107,10 +8107,10 @@ __metadata: "@rocket.chat/ddp-client": "workspace:^" "@rocket.chat/emitter": "npm:~0.31.25" "@rocket.chat/eslint-config": "workspace:^" - "@rocket.chat/fuselage-hooks": "npm:^0.34.0" + "@rocket.chat/fuselage-hooks": "npm:^0.34.1" "@rocket.chat/fuselage-tokens": "npm:^0.33.2" "@rocket.chat/gazzodown": "workspace:^" - "@rocket.chat/logo": "npm:^0.31.31" + "@rocket.chat/logo": "npm:^0.31.32" "@rocket.chat/message-parser": "workspace:^" "@rocket.chat/random": "workspace:~" "@rocket.chat/ui-contexts": "workspace:^" @@ -8215,16 +8215,16 @@ __metadata: languageName: unknown linkType: soft -"@rocket.chat/logo@npm:^0.31.31": - version: 0.31.31 - resolution: "@rocket.chat/logo@npm:0.31.31" +"@rocket.chat/logo@npm:^0.31.32": + version: 0.31.32 + resolution: "@rocket.chat/logo@npm:0.31.32" dependencies: - "@rocket.chat/fuselage-hooks": "npm:^0.34.0" + "@rocket.chat/fuselage-hooks": "npm:^0.34.1" "@rocket.chat/styled": "npm:^0.31.25" peerDependencies: react: 17.0.2 react-dom: 17.0.2 - checksum: 10/79e74a42c3ae29aa10e8213e7e88bcc9ec935d105ba33d58bf02a95d79c54ff0798c9a4a99cda8e727f46ce6302c75376db7ea7dd6fa206dea495d1ed50b815e + checksum: 10/cc460ad831fc843377cba15d1f7c6174357c1b27c4f90151013984a3fa54a62879d0b8a77ffcce90c1489b70613110679e0ff5dc3315b80ec52c39235d3e9ef1 languageName: node linkType: hard @@ -8309,15 +8309,15 @@ __metadata: "@rocket.chat/eslint-config": "workspace:^" "@rocket.chat/favicon": "workspace:^" "@rocket.chat/freeswitch": "workspace:^" - "@rocket.chat/fuselage": "npm:^0.60.0" - "@rocket.chat/fuselage-hooks": "npm:^0.34.0" + "@rocket.chat/fuselage": "npm:^0.60.1" + "@rocket.chat/fuselage-hooks": "npm:^0.34.1" "@rocket.chat/fuselage-polyfills": "npm:~0.31.25" "@rocket.chat/fuselage-toastbar": "npm:^0.33.0" "@rocket.chat/fuselage-tokens": "npm:^0.33.2" "@rocket.chat/fuselage-ui-kit": "workspace:^" "@rocket.chat/gazzodown": "workspace:^" "@rocket.chat/i18n": "workspace:^" - "@rocket.chat/icons": "npm:~0.39.0" + "@rocket.chat/icons": "npm:^0.40.0" "@rocket.chat/instance-status": "workspace:^" "@rocket.chat/jest-presets": "workspace:~" "@rocket.chat/jwt": "workspace:^" @@ -8326,7 +8326,7 @@ __metadata: "@rocket.chat/livechat": "workspace:^" "@rocket.chat/log-format": "workspace:^" "@rocket.chat/logger": "workspace:^" - "@rocket.chat/logo": "npm:^0.31.31" + "@rocket.chat/logo": "npm:^0.31.32" "@rocket.chat/memo": "npm:~0.31.25" "@rocket.chat/message-parser": "workspace:^" "@rocket.chat/mock-providers": "workspace:^" @@ -9221,7 +9221,7 @@ __metadata: resolution: "@rocket.chat/ui-avatar@workspace:packages/ui-avatar" dependencies: "@babel/core": "npm:~7.26.0" - "@rocket.chat/fuselage": "npm:^0.60.0" + "@rocket.chat/fuselage": "npm:^0.60.1" "@rocket.chat/ui-contexts": "workspace:^" "@types/react": "npm:~17.0.83" "@types/react-dom": "npm:~17.0.26" @@ -9246,9 +9246,9 @@ __metadata: "@babel/core": "npm:~7.26.0" "@react-aria/toolbar": "npm:^3.0.0-nightly.5042" "@rocket.chat/css-in-js": "npm:~0.31.25" - "@rocket.chat/fuselage": "npm:^0.60.0" - "@rocket.chat/fuselage-hooks": "npm:^0.34.0" - "@rocket.chat/icons": "npm:~0.39.0" + "@rocket.chat/fuselage": "npm:^0.60.1" + "@rocket.chat/fuselage-hooks": "npm:^0.34.1" + "@rocket.chat/icons": "npm:^0.40.0" "@rocket.chat/jest-presets": "workspace:~" "@rocket.chat/mock-providers": "workspace:^" "@rocket.chat/ui-avatar": "workspace:~" @@ -9298,8 +9298,8 @@ __metadata: "@babel/core": "npm:~7.26.0" "@react-aria/toolbar": "npm:^3.0.0-nightly.5042" "@rocket.chat/eslint-config": "workspace:^" - "@rocket.chat/fuselage": "npm:^0.60.0" - "@rocket.chat/icons": "npm:~0.39.0" + "@rocket.chat/fuselage": "npm:^0.60.1" + "@rocket.chat/icons": "npm:^0.40.0" "@storybook/addon-actions": "npm:^8.4.4" "@storybook/addon-docs": "npm:^8.4.4" "@storybook/addon-essentials": "npm:^8.4.4" @@ -9333,7 +9333,7 @@ __metadata: "@rocket.chat/core-typings": "workspace:^" "@rocket.chat/ddp-client": "workspace:~" "@rocket.chat/emitter": "npm:~0.31.25" - "@rocket.chat/fuselage-hooks": "npm:^0.34.0" + "@rocket.chat/fuselage-hooks": "npm:^0.34.1" "@rocket.chat/i18n": "workspace:~" "@rocket.chat/password-policies": "workspace:^" "@rocket.chat/rest-typings": "workspace:^" @@ -9367,7 +9367,7 @@ __metadata: "@babel/plugin-transform-runtime": "npm:~7.25.9" "@babel/preset-env": "npm:~7.26.0" "@rocket.chat/eslint-config": "workspace:~" - "@rocket.chat/icons": "npm:~0.39.0" + "@rocket.chat/icons": "npm:^0.40.0" "@rocket.chat/jest-presets": "workspace:~" "@types/jest": "npm:~29.5.14" babel-loader: "npm:~9.2.1" @@ -9392,9 +9392,9 @@ __metadata: resolution: "@rocket.chat/ui-theming@workspace:ee/packages/ui-theming" dependencies: "@rocket.chat/css-in-js": "npm:~0.31.25" - "@rocket.chat/fuselage": "npm:^0.60.0" - "@rocket.chat/fuselage-hooks": "npm:^0.34.0" - "@rocket.chat/icons": "npm:~0.39.0" + "@rocket.chat/fuselage": "npm:^0.60.1" + "@rocket.chat/fuselage-hooks": "npm:^0.34.1" + "@rocket.chat/icons": "npm:^0.40.0" "@rocket.chat/ui-contexts": "workspace:~" "@types/react": "npm:~17.0.83" eslint: "npm:~8.45.0" @@ -9422,9 +9422,9 @@ __metadata: "@rocket.chat/css-in-js": "npm:~0.31.25" "@rocket.chat/emitter": "npm:~0.31.25" "@rocket.chat/eslint-config": "workspace:^" - "@rocket.chat/fuselage": "npm:^0.60.0" - "@rocket.chat/fuselage-hooks": "npm:^0.34.0" - "@rocket.chat/icons": "npm:~0.39.0" + "@rocket.chat/fuselage": "npm:^0.60.1" + "@rocket.chat/fuselage-hooks": "npm:^0.34.1" + "@rocket.chat/icons": "npm:^0.40.0" "@rocket.chat/jest-presets": "workspace:~" "@rocket.chat/styled": "npm:~0.31.25" "@rocket.chat/ui-avatar": "workspace:^" @@ -9472,9 +9472,9 @@ __metadata: "@rocket.chat/css-in-js": "npm:~0.31.25" "@rocket.chat/emitter": "npm:~0.31.25" "@rocket.chat/eslint-config": "workspace:^" - "@rocket.chat/fuselage": "npm:^0.60.0" - "@rocket.chat/fuselage-hooks": "npm:^0.34.0" - "@rocket.chat/icons": "npm:~0.39.0" + "@rocket.chat/fuselage": "npm:^0.60.1" + "@rocket.chat/fuselage-hooks": "npm:^0.34.1" + "@rocket.chat/icons": "npm:^0.40.0" "@rocket.chat/jest-presets": "workspace:~" "@rocket.chat/mock-providers": "workspace:~" "@rocket.chat/styled": "npm:~0.31.25" @@ -9530,14 +9530,14 @@ __metadata: "@lezer/highlight": "npm:^1.2.1" "@rocket.chat/core-typings": "workspace:^" "@rocket.chat/css-in-js": "npm:~0.31.25" - "@rocket.chat/fuselage": "npm:^0.60.0" - "@rocket.chat/fuselage-hooks": "npm:^0.34.0" + "@rocket.chat/fuselage": "npm:^0.60.1" + "@rocket.chat/fuselage-hooks": "npm:^0.34.1" "@rocket.chat/fuselage-polyfills": "npm:~0.31.25" "@rocket.chat/fuselage-toastbar": "npm:^0.33.0" "@rocket.chat/fuselage-tokens": "npm:^0.33.2" "@rocket.chat/fuselage-ui-kit": "workspace:~" - "@rocket.chat/icons": "npm:~0.39.0" - "@rocket.chat/logo": "npm:^0.31.31" + "@rocket.chat/icons": "npm:^0.40.0" + "@rocket.chat/logo": "npm:^0.31.32" "@rocket.chat/styled": "npm:~0.31.25" "@rocket.chat/ui-avatar": "workspace:^" "@rocket.chat/ui-contexts": "workspace:~" @@ -33350,7 +33350,7 @@ __metadata: "@rocket.chat/core-services": "workspace:^" "@rocket.chat/core-typings": "workspace:^" "@rocket.chat/emitter": "npm:~0.31.25" - "@rocket.chat/icons": "npm:~0.39.0" + "@rocket.chat/icons": "npm:^0.40.0" "@rocket.chat/message-parser": "workspace:^" "@rocket.chat/model-typings": "workspace:^" "@rocket.chat/models": "workspace:^" @@ -37790,7 +37790,7 @@ __metadata: languageName: node linkType: hard -"use-sync-external-store@npm:1.2.2, use-sync-external-store@npm:^1.2.2, use-sync-external-store@npm:~1.2.0, use-sync-external-store@npm:~1.2.2": +"use-sync-external-store@npm:1.2.2, use-sync-external-store@npm:^1.2.2, use-sync-external-store@npm:~1.2.2": version: 1.2.2 resolution: "use-sync-external-store@npm:1.2.2" peerDependencies: @@ -37799,6 +37799,15 @@ __metadata: languageName: node linkType: hard +"use-sync-external-store@npm:~1.4.0": + version: 1.4.0 + resolution: "use-sync-external-store@npm:1.4.0" + peerDependencies: + react: ^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0 + checksum: 10/08bf581a8a2effaefc355e9d18ed025d436230f4cc973db2f593166df357cf63e47b9097b6e5089b594758bde322e1737754ad64905e030d70f8ff7ee671fd01 + languageName: node + linkType: hard + "use@npm:^3.1.0": version: 3.1.1 resolution: "use@npm:3.1.1" From ab5b1a47c6d3a45c793f48d004ef43e8bd005e13 Mon Sep 17 00:00:00 2001 From: dougfabris Date: Thu, 9 Jan 2025 20:12:09 -0300 Subject: [PATCH 2/5] wip --- .../client/hooks/menuActions/useLeaveRoom.tsx | 65 ++++++ .../menuActions/useToggleFavoriteAction.ts | 18 ++ .../hooks/menuActions/useToggleReadAction.ts | 48 ++++ .../meteor/client/hooks/useRoomMenuActions.ts | 118 ++++++++++ .../hooks/useOmnichannelPrioritiesMenu.tsx | 54 ++--- .../omnichannel/priorities/PriorityIcon.tsx | 15 +- apps/meteor/client/sidebar/Item/Condensed.tsx | 8 +- apps/meteor/client/sidebar/Item/Extended.tsx | 9 +- apps/meteor/client/sidebar/Item/Medium.tsx | 8 +- apps/meteor/client/sidebar/RoomMenu.tsx | 201 +---------------- .../client/sidebarv2/Item/Condensed.tsx | 8 +- .../meteor/client/sidebarv2/Item/Extended.tsx | 10 +- apps/meteor/client/sidebarv2/Item/Medium.tsx | 8 +- .../RoomList/SidebarItemTemplateWithData.tsx | 1 + apps/meteor/client/sidebarv2/RoomMenu.tsx | 210 +----------------- .../account/profile/ActionConfirmModal.tsx | 1 + .../GenericMenu/GenericMenuItem.tsx | 5 +- .../GenericMenu/hooks/useHandleMenuAction.tsx | 3 +- 18 files changed, 307 insertions(+), 483 deletions(-) create mode 100644 apps/meteor/client/hooks/menuActions/useLeaveRoom.tsx create mode 100644 apps/meteor/client/hooks/menuActions/useToggleFavoriteAction.ts create mode 100644 apps/meteor/client/hooks/menuActions/useToggleReadAction.ts create mode 100644 apps/meteor/client/hooks/useRoomMenuActions.ts diff --git a/apps/meteor/client/hooks/menuActions/useLeaveRoom.tsx b/apps/meteor/client/hooks/menuActions/useLeaveRoom.tsx new file mode 100644 index 000000000000..96bc0b616bef --- /dev/null +++ b/apps/meteor/client/hooks/menuActions/useLeaveRoom.tsx @@ -0,0 +1,65 @@ +import type { RoomType } from '@rocket.chat/core-typings'; +import { useEffectEvent } from '@rocket.chat/fuselage-hooks'; +import type { TranslationKey } from '@rocket.chat/ui-contexts'; +import { useEndpoint, useRouter, useSetModal, useToastMessageDispatch } from '@rocket.chat/ui-contexts'; +import { useTranslation } from 'react-i18next'; + +import { LegacyRoomManager } from '../../../app/ui-utils/client'; +import { UiTextContext } from '../../../definition/IRoomTypeConfig'; +import WarningModal from '../../components/WarningModal'; +import { roomCoordinator } from '../../lib/rooms/roomCoordinator'; + +const leaveEndpoints = { + p: '/v1/groups.leave', + c: '/v1/channels.leave', + d: '/v1/im.leave', + v: '/v1/channels.leave', + l: '/v1/groups.leave', +} as const; + +type LeaveRoomProps = { + rid: string; + type: RoomType; + name: string; + roomOpen?: boolean; +}; + +// TODO: check leaving modal for teams +export const useLeaveRoomAction = ({ rid, type, name, roomOpen }: LeaveRoomProps) => { + const { t } = useTranslation(); + const setModal = useSetModal(); + const dispatchToastMessage = useToastMessageDispatch(); + const router = useRouter(); + + const leaveRoom = useEndpoint('POST', leaveEndpoints[type]); + + const handleLeave = useEffectEvent(() => { + const leave = async (): Promise => { + try { + await leaveRoom({ roomId: rid }); + if (roomOpen) { + router.navigate('/home'); + } + LegacyRoomManager.close(rid); + } catch (error) { + dispatchToastMessage({ type: 'error', message: error }); + } finally { + setModal(null); + } + }; + + const warnText = roomCoordinator.getRoomDirectives(type).getUiText(UiTextContext.LEAVE_WARNING); + + setModal( + setModal(null)} + cancelText={t('Cancel')} + confirm={leave} + />, + ); + }); + + return handleLeave; +}; diff --git a/apps/meteor/client/hooks/menuActions/useToggleFavoriteAction.ts b/apps/meteor/client/hooks/menuActions/useToggleFavoriteAction.ts new file mode 100644 index 000000000000..70284057aee7 --- /dev/null +++ b/apps/meteor/client/hooks/menuActions/useToggleFavoriteAction.ts @@ -0,0 +1,18 @@ +import type { IRoom } from '@rocket.chat/core-typings'; +import { useEffectEvent } from '@rocket.chat/fuselage-hooks'; +import { useEndpoint, useToastMessageDispatch } from '@rocket.chat/ui-contexts'; + +export const useToggleFavoriteAction = ({ rid, isFavorite }: { rid: IRoom['_id']; isFavorite: boolean }) => { + const toggleFavorite = useEndpoint('POST', '/v1/rooms.favorite'); + const dispatchToastMessage = useToastMessageDispatch(); + + const handleToggleFavorite = useEffectEvent(async () => { + try { + await toggleFavorite({ roomId: rid, favorite: !isFavorite }); + } catch (error) { + dispatchToastMessage({ type: 'error', message: error }); + } + }); + + return handleToggleFavorite; +}; diff --git a/apps/meteor/client/hooks/menuActions/useToggleReadAction.ts b/apps/meteor/client/hooks/menuActions/useToggleReadAction.ts new file mode 100644 index 000000000000..133acd9b0f78 --- /dev/null +++ b/apps/meteor/client/hooks/menuActions/useToggleReadAction.ts @@ -0,0 +1,48 @@ +import type { ISubscription } from '@rocket.chat/core-typings'; +import { useEffectEvent } from '@rocket.chat/fuselage-hooks'; +import { useEndpoint, useMethod, useRouter, useToastMessageDispatch } from '@rocket.chat/ui-contexts'; +import { useQueryClient } from '@tanstack/react-query'; + +import { LegacyRoomManager } from '../../../app/ui-utils/client'; + +type ToggleReadActionProps = { + rid: string; + isUnread?: boolean; + subscription?: ISubscription; +}; + +export const useToggleReadAction = ({ rid, isUnread, subscription }: ToggleReadActionProps) => { + const dispatchToastMessage = useToastMessageDispatch(); + const queryClient = useQueryClient(); + const router = useRouter(); + + const readMessages = useEndpoint('POST', '/v1/subscriptions.read'); + const unreadMessages = useMethod('unreadMessages'); + + const handleToggleRead = useEffectEvent(async () => { + try { + queryClient.invalidateQueries({ + queryKey: ['sidebar/search/spotlight'], + }); + + if (isUnread) { + await readMessages({ rid, readThreads: true }); + return; + } + + if (subscription == null) { + return; + } + + LegacyRoomManager.close(subscription.t + subscription.name); + + router.navigate('/home'); + + await unreadMessages(undefined, rid); + } catch (error) { + dispatchToastMessage({ type: 'error', message: error }); + } + }); + + return handleToggleRead; +}; diff --git a/apps/meteor/client/hooks/useRoomMenuActions.ts b/apps/meteor/client/hooks/useRoomMenuActions.ts new file mode 100644 index 000000000000..46308772b429 --- /dev/null +++ b/apps/meteor/client/hooks/useRoomMenuActions.ts @@ -0,0 +1,118 @@ +import type { RoomType } from '@rocket.chat/core-typings'; +import type { GenericMenuItemProps } from '@rocket.chat/ui-client'; +import { usePermission, useSetting, useUserSubscription } from '@rocket.chat/ui-contexts'; +import type { Fields } from '@rocket.chat/ui-contexts'; +import { useMemo } from 'react'; +import { useTranslation } from 'react-i18next'; + +import { useLeaveRoomAction } from './menuActions/useLeaveRoom'; +import { useToggleFavoriteAction } from './menuActions/useToggleFavoriteAction'; +import { useToggleReadAction } from './menuActions/useToggleReadAction'; +import { useHideRoomAction } from './useHideRoomAction'; +import { useOmnichannelPrioritiesMenu } from '../omnichannel/hooks/useOmnichannelPrioritiesMenu'; + +const fields: Fields = { + f: true, + t: true, + name: true, +}; + +type RoomMenuActionsProps = { + rid: string; + type: RoomType; + name: string; + isUnread?: boolean; + cl?: boolean; + roomOpen?: boolean; + hideDefaultOptions: boolean; +}; + +export const useRoomMenuActions = ({ + rid, + type, + name, + isUnread, + cl, + roomOpen, + hideDefaultOptions, +}: RoomMenuActionsProps): { title: string; items: GenericMenuItemProps[] }[] => { + const { t } = useTranslation(); + const subscription = useUserSubscription(rid, fields); + + const isFavorite = Boolean(subscription?.f); + const canLeaveChannel = usePermission('leave-c'); + const canLeavePrivate = usePermission('leave-p'); + const canFavorite = useSetting('Favorite_Rooms') as boolean; + + const canLeave = ((): boolean => { + if (type === 'c' && !canLeaveChannel) { + return false; + } + if (type === 'p' && !canLeavePrivate) { + return false; + } + return !((cl != null && !cl) || ['d', 'l'].includes(type)); + })(); + + const handleHide = useHideRoomAction({ rid, type, name }, { redirect: false }); + const handleToggleFavorite = useToggleFavoriteAction({ rid, isFavorite }); + const handleToggleRead = useToggleReadAction({ rid, isUnread, subscription }); + const handleLeave = useLeaveRoomAction({ rid, type, name, roomOpen }); + + const isOmnichannelRoom = type === 'l'; + const prioritiesMenu = useOmnichannelPrioritiesMenu(rid); + + const menuOptions = useMemo( + () => + !hideDefaultOptions + ? [ + !isOmnichannelRoom && { + id: 'hideRoom', + icon: 'eye-off', + content: t('Hide'), + onClick: handleHide, + }, + { + id: 'toggleRead', + icon: 'flag', + content: isUnread ? t('Mark_read') : t('Mark_unread'), + onClick: handleToggleRead, + }, + canFavorite && { + id: 'toggleFavorite', + icon: isFavorite ? 'star-filled' : 'star', + content: isFavorite ? t('Unfavorite') : t('Favorite'), + onClick: handleToggleFavorite, + }, + canLeave && { + id: 'leaveRoom', + icon: 'sign-out', + content: t('Leave_room'), + onClick: handleLeave, + }, + ] + : [], + [ + hideDefaultOptions, + t, + handleHide, + isUnread, + handleToggleRead, + canFavorite, + isFavorite, + handleToggleFavorite, + canLeave, + handleLeave, + isOmnichannelRoom, + ], + ); + + if (isOmnichannelRoom && prioritiesMenu.length > 0) { + return [ + { title: '', items: menuOptions.filter(Boolean) as GenericMenuItemProps[] }, + { title: t('Priorities'), items: prioritiesMenu }, + ]; + } + + return [{ title: '', items: menuOptions.filter(Boolean) as GenericMenuItemProps[] }]; +}; diff --git a/apps/meteor/client/omnichannel/hooks/useOmnichannelPrioritiesMenu.tsx b/apps/meteor/client/omnichannel/hooks/useOmnichannelPrioritiesMenu.tsx index 9fbdc8be019c..c628afc34595 100644 --- a/apps/meteor/client/omnichannel/hooks/useOmnichannelPrioritiesMenu.tsx +++ b/apps/meteor/client/omnichannel/hooks/useOmnichannelPrioritiesMenu.tsx @@ -1,17 +1,15 @@ import { LivechatPriorityWeight } from '@rocket.chat/core-typings'; -import type { Menu } from '@rocket.chat/fuselage'; import { useEffectEvent } from '@rocket.chat/fuselage-hooks'; import { useEndpoint } from '@rocket.chat/ui-contexts'; import { useQueryClient } from '@tanstack/react-query'; -import type { ComponentProps } from 'react'; -import { useCallback, useMemo } from 'react'; +import { useMemo } from 'react'; import { useTranslation } from 'react-i18next'; import { useOmnichannelPriorities } from './useOmnichannelPriorities'; import { dispatchToastMessage } from '../../lib/toast'; -import { PriorityIcon } from '../priorities/PriorityIcon'; +import { PRIORITY_ICONS } from '../priorities/PriorityIcon'; -export const useOmnichannelPrioritiesMenu = (rid: string): ComponentProps['options'] | Record => { +export const useOmnichannelPrioritiesMenu = (rid: string) => { const { t } = useTranslation(); const queryClient = useQueryClient(); const updateRoomPriority = useEndpoint('POST', '/v1/livechat/room/:rid/priority', { rid }); @@ -32,41 +30,27 @@ export const useOmnichannelPrioritiesMenu = (rid: string): ComponentProps { - return ( - <> - {label} - - ); - }, []); - - return useMemo['options']>(() => { - const menuHeading = { - type: 'heading', - label: t('Priorities'), - }; - + return useMemo(() => { const unprioritizedOption = { - type: 'option', - action: handlePriorityChange(''), - label: { - label: renderOption(t('Unprioritized'), LivechatPriorityWeight.NOT_SPECIFIED), - }, + id: 'unprioritized', + icon: PRIORITY_ICONS[LivechatPriorityWeight.NOT_SPECIFIED].iconName, + iconColor: PRIORITY_ICONS[LivechatPriorityWeight.NOT_SPECIFIED].color, + content: t('Unprioritized'), + onClick: handlePriorityChange(''), }; - const options = priorities.reduce>((items, { _id: priorityId, name, i18n, dirty, sortItem }) => { + const options = priorities.map(({ _id: priorityId, name, i18n, dirty, sortItem }) => { const label = dirty && name ? name : i18n; - items[label] = { - action: handlePriorityChange(priorityId), - label: { - label: renderOption(label, sortItem), - }, + return { + id: priorityId, + icon: PRIORITY_ICONS[sortItem].iconName, + iconColor: PRIORITY_ICONS[sortItem].color, + content: label, + onClick: handlePriorityChange(priorityId), }; + }); - return items; - }, {}); - - return priorities.length ? { menuHeading, Unprioritized: unprioritizedOption, ...options } : {}; - }, [t, handlePriorityChange, priorities, renderOption]); + return priorities.length ? [unprioritizedOption, ...options] : []; + }, [t, handlePriorityChange, priorities]); }; diff --git a/apps/meteor/client/omnichannel/priorities/PriorityIcon.tsx b/apps/meteor/client/omnichannel/priorities/PriorityIcon.tsx index bad31ac8af3f..e41ef88a2415 100644 --- a/apps/meteor/client/omnichannel/priorities/PriorityIcon.tsx +++ b/apps/meteor/client/omnichannel/priorities/PriorityIcon.tsx @@ -1,5 +1,5 @@ import { LivechatPriorityWeight } from '@rocket.chat/core-typings'; -import { Box, Icon, Palette, StatusBullet } from '@rocket.chat/fuselage'; +import { Icon, Palette } from '@rocket.chat/fuselage'; import type { Keys } from '@rocket.chat/icons'; import type { TranslationKey } from '@rocket.chat/ui-contexts'; import type { ComponentProps, ReactElement } from 'react'; @@ -13,7 +13,10 @@ type PriorityIconProps = Omit, 'name' | 'color'> & { showUnprioritized?: boolean; }; -const PRIORITY_ICONS: Record = { +export const PRIORITY_ICONS: Record = { + [LivechatPriorityWeight.NOT_SPECIFIED]: { + iconName: 'circle-unfilled', + }, [LivechatPriorityWeight.HIGHEST]: { iconName: 'chevron-double-up', color: Palette.badge['badge-background-level-4'].toString(), @@ -51,12 +54,8 @@ export const PriorityIcon = ({ level, size = 20, showUnprioritized = false, ...p return dirty ? name : t(i18n as TranslationKey); }, [level, priorities, t]); - if (showUnprioritized && level === LivechatPriorityWeight.NOT_SPECIFIED) { - return ( - - - - ); + if (!showUnprioritized && level === LivechatPriorityWeight.NOT_SPECIFIED) { + return null; } return iconName ? : null; diff --git a/apps/meteor/client/sidebar/Item/Condensed.tsx b/apps/meteor/client/sidebar/Item/Condensed.tsx index 792c39903393..331a01949aad 100644 --- a/apps/meteor/client/sidebar/Item/Condensed.tsx +++ b/apps/meteor/client/sidebar/Item/Condensed.tsx @@ -1,5 +1,5 @@ import { IconButton, Sidebar } from '@rocket.chat/fuselage'; -import { useEffectEvent, usePrefersReducedMotion } from '@rocket.chat/fuselage-hooks'; +import { usePrefersReducedMotion } from '@rocket.chat/fuselage-hooks'; import type { Keys as IconName } from '@rocket.chat/icons'; import type { ReactElement } from 'react'; import { memo, useState } from 'react'; @@ -21,14 +21,10 @@ type CondensedProps = { const Condensed = ({ icon, title = '', avatar, actions, href, unread, menu, badges, ...props }: CondensedProps) => { const [menuVisibility, setMenuVisibility] = useState(!!window.DISABLE_ANIMATION); - const isReduceMotionEnabled = usePrefersReducedMotion(); - const handleMenu = useEffectEvent((e) => { - setMenuVisibility(e.target.offsetWidth > 0 && Boolean(menu)); - }); const handleMenuEvent = { - [isReduceMotionEnabled ? 'onMouseEnter' : 'onTransitionEnd']: handleMenu, + [isReduceMotionEnabled ? 'onMouseEnter' : 'onTransitionEnd']: setMenuVisibility, }; return ( diff --git a/apps/meteor/client/sidebar/Item/Extended.tsx b/apps/meteor/client/sidebar/Item/Extended.tsx index e236f8660bc7..53015d17e036 100644 --- a/apps/meteor/client/sidebar/Item/Extended.tsx +++ b/apps/meteor/client/sidebar/Item/Extended.tsx @@ -1,5 +1,5 @@ import { Sidebar, IconButton } from '@rocket.chat/fuselage'; -import { useEffectEvent, usePrefersReducedMotion } from '@rocket.chat/fuselage-hooks'; +import { usePrefersReducedMotion } from '@rocket.chat/fuselage-hooks'; import type { Keys as IconName } from '@rocket.chat/icons'; import type { ReactNode } from 'react'; import { memo, useState } from 'react'; @@ -42,15 +42,10 @@ const Extended = ({ }: ExtendedProps) => { const formatDate = useShortTimeAgo(); const [menuVisibility, setMenuVisibility] = useState(!!window.DISABLE_ANIMATION); - const isReduceMotionEnabled = usePrefersReducedMotion(); - const handleMenu = useEffectEvent((e) => { - setMenuVisibility(e.target.offsetWidth > 0 && Boolean(menu)); - }); - const handleMenuEvent = { - [isReduceMotionEnabled ? 'onMouseEnter' : 'onTransitionEnd']: handleMenu, + [isReduceMotionEnabled ? 'onMouseEnter' : 'onTransitionEnd']: setMenuVisibility, }; return ( diff --git a/apps/meteor/client/sidebar/Item/Medium.tsx b/apps/meteor/client/sidebar/Item/Medium.tsx index f1f37047ece4..2b9dd8fef490 100644 --- a/apps/meteor/client/sidebar/Item/Medium.tsx +++ b/apps/meteor/client/sidebar/Item/Medium.tsx @@ -1,5 +1,5 @@ import { Sidebar, IconButton } from '@rocket.chat/fuselage'; -import { useEffectEvent, usePrefersReducedMotion } from '@rocket.chat/fuselage-hooks'; +import { usePrefersReducedMotion } from '@rocket.chat/fuselage-hooks'; import type { ReactNode } from 'react'; import { memo, useState } from 'react'; @@ -19,14 +19,10 @@ type MediumProps = { const Medium = ({ icon, title = '', avatar, actions, href, badges, unread, menu, ...props }: MediumProps) => { const [menuVisibility, setMenuVisibility] = useState(!!window.DISABLE_ANIMATION); - const isReduceMotionEnabled = usePrefersReducedMotion(); - const handleMenu = useEffectEvent((e) => { - setMenuVisibility(e.target.offsetWidth > 0 && Boolean(menu)); - }); const handleMenuEvent = { - [isReduceMotionEnabled ? 'onMouseEnter' : 'onTransitionEnd']: handleMenu, + [isReduceMotionEnabled ? 'onMouseEnter' : 'onTransitionEnd']: setMenuVisibility, }; return ( diff --git a/apps/meteor/client/sidebar/RoomMenu.tsx b/apps/meteor/client/sidebar/RoomMenu.tsx index 14e453da5401..508753263954 100644 --- a/apps/meteor/client/sidebar/RoomMenu.tsx +++ b/apps/meteor/client/sidebar/RoomMenu.tsx @@ -1,34 +1,10 @@ import type { RoomType } from '@rocket.chat/core-typings'; -import { Option, Menu } from '@rocket.chat/fuselage'; -import { useEffectEvent } from '@rocket.chat/fuselage-hooks'; -import type { TranslationKey, Fields } from '@rocket.chat/ui-contexts'; -import { - useRouter, - useSetModal, - useToastMessageDispatch, - useUserSubscription, - useSetting, - usePermission, - useMethod, - useTranslation, - useEndpoint, -} from '@rocket.chat/ui-contexts'; -import { useQueryClient } from '@tanstack/react-query'; +import { GenericMenu } from '@rocket.chat/ui-client'; +import { useTranslation } from '@rocket.chat/ui-contexts'; import type { ReactElement } from 'react'; -import { memo, useMemo } from 'react'; +import { memo } from 'react'; -import { LegacyRoomManager } from '../../app/ui-utils/client'; -import { UiTextContext } from '../../definition/IRoomTypeConfig'; -import WarningModal from '../components/WarningModal'; -import { useHideRoomAction } from '../hooks/useHideRoomAction'; -import { roomCoordinator } from '../lib/rooms/roomCoordinator'; -import { useOmnichannelPrioritiesMenu } from '../omnichannel/hooks/useOmnichannelPrioritiesMenu'; - -const fields: Fields = { - f: true, - t: true, - name: true, -}; +import { useRoomMenuActions } from '../hooks/useRoomMenuActions'; type RoomMenuProps = { rid: string; @@ -42,15 +18,6 @@ type RoomMenuProps = { hideDefaultOptions: boolean; }; -const leaveEndpoints = { - p: '/v1/groups.leave', - c: '/v1/channels.leave', - d: '/v1/im.leave', - - v: '/v1/channels.leave', - l: '/v1/groups.leave', -} as const; - const RoomMenu = ({ rid, unread, @@ -63,167 +30,11 @@ const RoomMenu = ({ hideDefaultOptions = false, }: RoomMenuProps): ReactElement | null => { const t = useTranslation(); - const dispatchToastMessage = useToastMessageDispatch(); - const setModal = useSetModal(); - - const closeModal = useEffectEvent(() => setModal()); - - const router = useRouter(); - - const subscription = useUserSubscription(rid, fields); - const canFavorite = useSetting('Favorite_Rooms'); - const isFavorite = Boolean(subscription?.f); - - const readMessages = useEndpoint('POST', '/v1/subscriptions.read'); - const toggleFavorite = useEndpoint('POST', '/v1/rooms.favorite'); - const leaveRoom = useEndpoint('POST', leaveEndpoints[type]); - - const unreadMessages = useMethod('unreadMessages'); const isUnread = alert || unread || threadUnread; + const sections = useRoomMenuActions({ rid, type, name, isUnread, cl, roomOpen, hideDefaultOptions }); - const canLeaveChannel = usePermission('leave-c'); - const canLeavePrivate = usePermission('leave-p'); - - const isOmnichannelRoom = type === 'l'; - const prioritiesMenu = useOmnichannelPrioritiesMenu(rid); - - const queryClient = useQueryClient(); - - const handleHide = useHideRoomAction({ rid, type, name }, { redirect: false }); - - const canLeave = ((): boolean => { - if (type === 'c' && !canLeaveChannel) { - return false; - } - if (type === 'p' && !canLeavePrivate) { - return false; - } - return !((cl != null && !cl) || ['d', 'l'].includes(type)); - })(); - - const handleLeave = useEffectEvent(() => { - const leave = async (): Promise => { - try { - await leaveRoom({ roomId: rid }); - if (roomOpen) { - router.navigate('/home'); - } - LegacyRoomManager.close(rid); - } catch (error) { - dispatchToastMessage({ type: 'error', message: error }); - } - closeModal(); - }; - - const warnText = roomCoordinator.getRoomDirectives(type).getUiText(UiTextContext.LEAVE_WARNING); - - setModal( - , - ); - }); - - const handleToggleRead = useEffectEvent(async () => { - try { - queryClient.invalidateQueries({ - queryKey: ['sidebar/search/spotlight'], - }); - - if (isUnread) { - await readMessages({ rid, readThreads: true }); - return; - } - - if (subscription == null) { - return; - } - - LegacyRoomManager.close(subscription.t + subscription.name); - - router.navigate('/home'); - - await unreadMessages(undefined, rid); - } catch (error) { - dispatchToastMessage({ type: 'error', message: error }); - } - }); - - const handleToggleFavorite = useEffectEvent(async () => { - try { - await toggleFavorite({ roomId: rid, favorite: !isFavorite }); - } catch (error) { - dispatchToastMessage({ type: 'error', message: error }); - } - }); - - const menuOptions = useMemo( - () => ({ - ...(!hideDefaultOptions && { - ...(isOmnichannelRoom - ? {} - : { - hideRoom: { - label: { label: t('Hide'), icon: 'eye-off' }, - action: handleHide, - }, - }), - toggleRead: { - label: { label: isUnread ? t('Mark_read') : t('Mark_unread'), icon: 'flag' }, - action: handleToggleRead, - }, - ...(canFavorite - ? { - toggleFavorite: { - label: { - label: isFavorite ? t('Unfavorite') : t('Favorite'), - icon: isFavorite ? 'star-filled' : 'star', - }, - action: handleToggleFavorite, - }, - } - : {}), - ...(canLeave && { - leaveRoom: { - label: { label: t('Leave_room'), icon: 'sign-out' }, - action: handleLeave, - }, - }), - }), - ...(isOmnichannelRoom && prioritiesMenu), - }), - [ - hideDefaultOptions, - t, - handleHide, - isUnread, - handleToggleRead, - canFavorite, - isFavorite, - handleToggleFavorite, - canLeave, - handleLeave, - isOmnichannelRoom, - prioritiesMenu, - ], - ); - - return ( -