From 75dffb1c7aa91823e60c42d1650bec23c6c966cd Mon Sep 17 00:00:00 2001 From: Montassar Ghanmy Date: Wed, 20 Dec 2023 08:38:59 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=9B=A0=EF=B8=8F=20Company=20user=20search?= =?UTF-8?q?=20feature=20(#300)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 🛠️ Company user search feature --- .../config/custom-environment-variables.json | 3 +- tdrive/backend/node/config/default.json | 521 +++++++++--------- .../backend/node/src/services/user/utils.ts | 6 + .../node/src/services/user/web/schemas.ts | 1 + .../node/src/services/user/web/types.ts | 2 + .../services/feature-toggles-service.ts | 2 + .../body/drive/modals/update-access/index.tsx | 19 +- 7 files changed, 281 insertions(+), 273 deletions(-) diff --git a/tdrive/backend/node/config/custom-environment-variables.json b/tdrive/backend/node/config/custom-environment-variables.json index e31478b5..49d3e308 100644 --- a/tdrive/backend/node/config/custom-environment-variables.json +++ b/tdrive/backend/node/config/custom-environment-variables.json @@ -125,6 +125,7 @@ }, "drive": { "rootAdmins": "DRIVE_ROOT_ADMINS", - "defaultLanguage": "DRIVE_DEFAULT_LANGUAGE" + "defaultLanguage": "DRIVE_DEFAULT_LANGUAGE", + "featureSearchUsers": "ENABLE_FEATURE_SEARCH_USERS" } } diff --git a/tdrive/backend/node/config/default.json b/tdrive/backend/node/config/default.json index 98f11c6e..44e79d39 100644 --- a/tdrive/backend/node/config/default.json +++ b/tdrive/backend/node/config/default.json @@ -1,270 +1,261 @@ { - "general":{ - "help_url":false, - "pricing_plan_url":"", - "app_download_url":"https://twake.app/download", - "mobile":{ - "mobile_redirect":"mobile.twake.app", - "mobile_appstore":"https://apps.apple.com/fr/app/tdrive/id1588764852?l=en", - "mobile_googleplay":"https://play.google.com/store/apps/details?id=com.tdrive.tdrive&gl=FR" - }, - "accounts":{ - "_type":"remote", - "type":"internal", - "internal":{ - "disable_account_creation":false + "general": { + "help_url": false, + "pricing_plan_url": "", + "app_download_url": "https://twake.app/download", + "mobile": { + "mobile_redirect": "mobile.twake.app", + "mobile_appstore": "https://apps.apple.com/fr/app/tdrive/id1588764852?l=en", + "mobile_googleplay": "https://play.google.com/store/apps/details?id=com.tdrive.tdrive&gl=FR" + }, + "accounts": { + "_type": "remote", + "type": "internal", + "internal": { + "disable_account_creation": false + }, + "remote": { + "authority": "http://auth.example.com/", + "client_id": "tdriveweb", + "client_secret": "", + "issuer": "", + "audience": "", + "redirect_uris": [""], + "account_management_url": "http://web.tdrive-console.local/profile?company-code={company_id}", + "collaborators_management_url": "http://web.tdrive-console.local/compaies/{company_id}/users?company-code={company_id}", + "company_management_url": "http://web.tdrive-console.local/companies?company-code={company_id}" + } + } + }, + "console": { + "type": "internal" + }, + "sentry": { + "dsn": "" + }, + "logger": { + "level": "debug" + }, + "tracker": { + "type": "segment", + "segment": { + "key": "" + } + }, + "webserver": { + "port": 4000, + "logger": { + "level": "info" + }, + "cors": { + "origin": "*" + }, + "static": { + "root": "./public" + } + }, + "websocket": { + "path": "/socket/", + "adapters": { + "types": [], + "redis": { + "host": "redis", + "port": 6379 + } + }, + "auth": { + "jwt": { + "secret": "supersecret" + } + } + }, + "auth": { + "jwt": { + "secret": "supersecret", + "expiration": 3600, + "refresh_expiration": 2592000 + } + }, + "database": { + "secret": "", + "type": "cassandra", + "mongodb": { + "uri": "mongodb://mongo:27017", + "database": "tdrive" + }, + "cassandra": { + "contactPoints": ["scylladb:9042"], + "localDataCenter": "datacenter1", + "keyspace": "tdrive", + "wait": false, + "retries": 10, + "delay": 200 + } + }, + "message-queue": { + "// possible 'type' values are": "'amqp' or 'local'", + "type": "amqp", + "amqp": { + "urls": ["amqp://guest:guest@rabbitmq:5672"] + } + }, + "search": { + "type": "elasticsearch", + "elasticsearch": { + "endpoint": "http://elasticsearch:9200" + } + }, + "push": { + "type": false, + "fcm": { + "endpoint": "https://fcm.googleapis.com/fcm/send", + "key": "" + } + }, + "storage": { + "secret": "0ea28a329df23220fa814e005bfb671c", + "iv": "1234abcd00000000", + "type": "local", + "S3": { + "endPoint": "play.min.io", + "port": 9000, + "useSSL": false, + "accessKey": "ABCD", + "secretKey": "x1yz" + }, + "local": { + "path": "/tdrive" + } + }, + "email-pusher": { + "endpoint": "https://api.smtp2go.com/v3/email/send", + "api_key": "secret", + "sender": "noreply@twake.app", + "debug": true + }, + "drive": { + "featureSearchUsers": true + }, + "applications": { + "grid": [ + { + "name": "Chat", + "logo": "/public/img/grid/twake.svg", + "url": "https://web.twake.app/" + }, + { + "name": "Mail", + "logo": "/public/img/grid/mail.svg", + "url": "https://tmail.linagora.com/" + }, + { + "name": "Drive", + "logo": "/public/img/grid/drive.svg", + "url": "https://tdrive.qa.lin-saas.com/" + }, + { + "name": "Calendar", + "logo": "/public/img/grid/calendar.svg", + "url": "https://openpaas.linagora.com/calendar/" + }, + { + "name": "Contacts", + "logo": "/public/img/grid/contacts.svg", + "url": "https://openpaas.linagora.com/contacts" + }, + { + "name": "Visio", + "logo": "/public/img/grid/visio.svg", + "url": "https://jitsi.linagora.com/" + } + ], + "plugins": [ + { + "api": { + "private_key": "c1cc66db78e1d3bb4713c55d5ab2" }, - "remote":{ - "authority":"http://auth.example.com/", - "client_id":"tdriveweb", - "client_secret":"", - "issuer":"", - "audience":"", - "redirect_uris":[ - "" - ], - "account_management_url":"http://web.tdrive-console.local/profile?company-code={company_id}", - "collaborators_management_url":"http://web.tdrive-console.local/compaies/{company_id}/users?company-code={company_id}", - "company_management_url":"http://web.tdrive-console.local/companies?company-code={company_id}" - } - } - }, - "console":{ - "type":"internal" - }, - "sentry":{ - "dsn":"" - }, - "logger":{ - "level":"debug" - }, - "tracker":{ - "type":"segment", - "segment":{ - "key":"" - } - }, - "webserver":{ - "port":4000, - "logger":{ - "level":"info" - }, - "cors":{ - "origin":"*" - }, - "static":{ - "root":"./public" - } - }, - "websocket":{ - "path":"/socket/", - "adapters":{ - "types":[ - - ], - "redis":{ - "host":"redis", - "port":6379 - } - }, - "auth":{ - "jwt":{ - "secret":"supersecret" - } - } - }, - "auth":{ - "jwt":{ - "secret":"supersecret", - "expiration":3600, - "refresh_expiration":2592000 - } - }, - "database":{ - "secret":"", - "type":"cassandra", - "mongodb":{ - "uri":"mongodb://mongo:27017", - "database":"tdrive" - }, - "cassandra":{ - "contactPoints":[ - "scylladb:9042" - ], - "localDataCenter":"datacenter1", - "keyspace":"tdrive", - "wait":false, - "retries":10, - "delay":200 - } - }, - "message-queue":{ - "// possible 'type' values are":"'amqp' or 'local'", - "type":"amqp", - "amqp":{ - "urls":[ - "amqp://guest:guest@rabbitmq:5672" - ] - } - }, - "search":{ - "type":"elasticsearch", - "elasticsearch":{ - "endpoint":"http://elasticsearch:9200" - } - }, - "push":{ - "type":false, - "fcm":{ - "endpoint":"https://fcm.googleapis.com/fcm/send", - "key":"" - } - }, - "storage":{ - "secret":"0ea28a329df23220fa814e005bfb671c", - "iv":"1234abcd00000000", - "type":"local", - "S3":{ - "endPoint":"play.min.io", - "port":9000, - "useSSL":false, - "accessKey":"ABCD", - "secretKey":"x1yz" - }, - "local":{ - "path":"/tdrive" - } - }, - "email-pusher":{ - "endpoint":"https://api.smtp2go.com/v3/email/send", - "api_key":"secret", - "sender":"noreply@twake.app", - "debug": true - }, - "applications":{ - "grid":[ - { - "name":"Chat", - "logo":"/public/img/grid/twake.svg", - "url":"https://web.twake.app/" - }, - { - "name":"Mail", - "logo":"/public/img/grid/mail.svg", - "url":"https://tmail.linagora.com/" - }, - { - "name":"Drive", - "logo":"/public/img/grid/drive.svg", - "url":"https://tdrive.qa.lin-saas.com/" - }, - { - "name":"Calendar", - "logo":"/public/img/grid/calendar.svg", - "url":"https://openpaas.linagora.com/calendar/" - }, - { - "name":"Contacts", - "logo":"/public/img/grid/contacts.svg", - "url":"https://openpaas.linagora.com/contacts" - }, - { - "name":"Visio", - "logo":"/public/img/grid/visio.svg", - "url":"https://jitsi.linagora.com/" - } - ], - "plugins":[ - { - "api":{ - "private_key":"c1cc66db78e1d3bb4713c55d5ab2" - }, - "display":{ - "tdrive":{ - "files":{ - "editor":{ - "edition_url":"http://localhost:5000/plugins/onlyoffice/", - "empty_files":[ - { - "filename":"Untitled.docx", - "name":"ONLYOFFICE Word Document", - "url":"/plugins/onlyoffice/assets/empty.docx" - }, - { - "filename":"Untitled.xlsx", - "name":"ONLYOFFICE Excel Document", - "url":"/plugins/onlyoffice/assets/empty.xlsx" - }, - { - "filename":"Untitled.pptx", - "name":"ONLYOFFICE PowerPoint Document", - "url":"/plugins/onlyoffice/assets/empty.pptx" - } - ], - "extensions":[ - "xlsx", - "pptx", - "docx", - "xls", - "ppt", - "doc", - "odt", - "ods", - "odp", - "txt", - "html", - "csv" - ], - "preview_url":"http://localhost:5000/plugins/onlyoffice/?preview=1" - } - }, - "version":1 + "display": { + "tdrive": { + "files": { + "editor": { + "edition_url": "http://localhost:5000/plugins/onlyoffice/", + "empty_files": [ + { + "filename": "Untitled.docx", + "name": "ONLYOFFICE Word Document", + "url": "/plugins/onlyoffice/assets/empty.docx" + }, + { + "filename": "Untitled.xlsx", + "name": "ONLYOFFICE Excel Document", + "url": "/plugins/onlyoffice/assets/empty.xlsx" + }, + { + "filename": "Untitled.pptx", + "name": "ONLYOFFICE PowerPoint Document", + "url": "/plugins/onlyoffice/assets/empty.pptx" + } + ], + "extensions": [ + "xlsx", + "pptx", + "docx", + "xls", + "ppt", + "doc", + "odt", + "ods", + "odp", + "txt", + "html", + "csv" + ], + "preview_url": "http://localhost:5000/plugins/onlyoffice/?preview=1" } - }, - "external_prefix":"/plugins/onlyoffice/", - "id":"tdrive_onlyoffice", - "identity":{ - "categories":[ - - ], - "code":"only_office", - "compatibility":[ - "tdrive" - ], - "description":null, - "icon":"/plugins/onlyoffice/assets/logo.png", - "name":"Only Office", - "website":"http://twake.app/" - }, - "internal_domain":"http://localhost:5000/" - } - ] + }, + "version": 1 + } + }, + "external_prefix": "/plugins/onlyoffice/", + "id": "tdrive_onlyoffice", + "identity": { + "categories": [], + "code": "only_office", + "compatibility": ["tdrive"], + "description": null, + "icon": "/plugins/onlyoffice/assets/logo.png", + "name": "Only Office", + "website": "http://twake.app/" + }, + "internal_domain": "http://localhost:5000/" + } + ] }, - "services":[ - "auth", - "push", - "storage", - "webserver", - "websocket", - "database", - "cron", - "search", - "message-queue", - "realtime", - "tracker", - "general", - "user", - "files", - "workspaces", - "console", - "counter", - "statistics", - "cron", - "online", - "email-pusher", - "documents", - "applications", - "applications-api", - "tags" + "services": [ + "auth", + "push", + "storage", + "webserver", + "websocket", + "database", + "cron", + "search", + "message-queue", + "realtime", + "tracker", + "general", + "user", + "files", + "workspaces", + "console", + "counter", + "statistics", + "cron", + "online", + "email-pusher", + "documents", + "applications", + "applications-api", + "tags" ] -} \ No newline at end of file +} diff --git a/tdrive/backend/node/src/services/user/utils.ts b/tdrive/backend/node/src/services/user/utils.ts index a345be49..0ff65efd 100644 --- a/tdrive/backend/node/src/services/user/utils.ts +++ b/tdrive/backend/node/src/services/user/utils.ts @@ -1,4 +1,5 @@ import Company from "./entities/company"; +import config from "../../core/config"; import { CompanyFeaturesEnum, CompanyLimitsEnum, @@ -53,6 +54,9 @@ export function formatCompany( [CompanyFeaturesEnum.CHAT_EDIT_FILES]: true, [CompanyFeaturesEnum.CHAT_UNLIMITED_STORAGE]: true, [CompanyFeaturesEnum.COMPANY_INVITE_MEMBER]: true, + // use the config value for this one + [CompanyFeaturesEnum.COMPANY_SEARCH_USERS]: + (config.get("drive.featureSearchUsers") as boolean) || true, }, { ...(res.plan?.features || {}), @@ -62,6 +66,8 @@ export function formatCompany( }, ); + console.log("🚀🚀 res.plan.features: ", res.plan.features); + return res; } diff --git a/tdrive/backend/node/src/services/user/web/schemas.ts b/tdrive/backend/node/src/services/user/web/schemas.ts index f97c5c81..22c65017 100644 --- a/tdrive/backend/node/src/services/user/web/schemas.ts +++ b/tdrive/backend/node/src/services/user/web/schemas.ts @@ -92,6 +92,7 @@ export const companyObjectSchema = { [CompanyFeaturesEnum.CHAT_MULTIPLE_WORKSPACES]: { type: "boolean" }, [CompanyFeaturesEnum.CHAT_UNLIMITED_STORAGE]: { type: "boolean" }, [CompanyFeaturesEnum.COMPANY_INVITE_MEMBER]: { type: "boolean" }, + [CompanyFeaturesEnum.COMPANY_SEARCH_USERS]: { type: "boolean" }, guests: { type: "number" }, // to rename or delete members: { type: "number" }, // to rename or delete storage: { type: "number" }, // to rename or delete diff --git a/tdrive/backend/node/src/services/user/web/types.ts b/tdrive/backend/node/src/services/user/web/types.ts index d9667a05..570829ab 100644 --- a/tdrive/backend/node/src/services/user/web/types.ts +++ b/tdrive/backend/node/src/services/user/web/types.ts @@ -83,6 +83,7 @@ export enum CompanyFeaturesEnum { CHAT_EDIT_FILES = "chat:edit_files", CHAT_UNLIMITED_STORAGE = "chat:unlimited_storage", COMPANY_INVITE_MEMBER = "company:invite_member", + COMPANY_SEARCH_USERS = "company:search_users", } export type CompanyFeaturesObject = { @@ -92,6 +93,7 @@ export type CompanyFeaturesObject = { [CompanyFeaturesEnum.CHAT_EDIT_FILES]?: boolean; [CompanyFeaturesEnum.CHAT_UNLIMITED_STORAGE]?: boolean; [CompanyFeaturesEnum.COMPANY_INVITE_MEMBER]?: boolean; + [CompanyFeaturesEnum.COMPANY_SEARCH_USERS]?: boolean; }; export type CompanyLimitsObject = { diff --git a/tdrive/frontend/src/app/features/global/services/feature-toggles-service.ts b/tdrive/frontend/src/app/features/global/services/feature-toggles-service.ts index a3195eef..7680994e 100644 --- a/tdrive/frontend/src/app/features/global/services/feature-toggles-service.ts +++ b/tdrive/frontend/src/app/features/global/services/feature-toggles-service.ts @@ -8,6 +8,7 @@ export enum FeatureNames { EDIT_FILES = 'chat:edit_files', UNLIMITED_STORAGE = 'chat:unlimited_storage', //Currently inactive COMPANY_INVITE_MEMBER = 'company:invite_member', + COMPANY_SEARCH_USERS = 'company:search_users', } export type FeatureValueType = boolean | number; @@ -22,6 +23,7 @@ availableFeaturesWithDefaults.set(FeatureNames.MULTIPLE_WORKSPACES, true); availableFeaturesWithDefaults.set(FeatureNames.EDIT_FILES, true); availableFeaturesWithDefaults.set(FeatureNames.UNLIMITED_STORAGE, true); availableFeaturesWithDefaults.set(FeatureNames.COMPANY_INVITE_MEMBER, true); +availableFeaturesWithDefaults.set(FeatureNames.COMPANY_SEARCH_USERS, true); /** * ChannelServiceImpl that allow you to manage feature flipping in Tdrive using react feature toggles diff --git a/tdrive/frontend/src/app/views/client/body/drive/modals/update-access/index.tsx b/tdrive/frontend/src/app/views/client/body/drive/modals/update-access/index.tsx index 5e9f30ea..98300121 100644 --- a/tdrive/frontend/src/app/views/client/body/drive/modals/update-access/index.tsx +++ b/tdrive/frontend/src/app/views/client/body/drive/modals/update-access/index.tsx @@ -4,8 +4,11 @@ import { useEffect } from 'react'; import { atom, useRecoilState } from 'recoil'; import { InternalAccessManager } from './internal-access'; import { PublicLinkManager } from './public-link-access'; +import { useCurrentCompany } from '@features/companies/hooks/use-companies'; import Languages from 'features/global/services/languages-service'; - +import FeatureTogglesService, { + FeatureNames, +} from '@features/global/services/feature-toggles-service'; export type AccessModalType = { open: boolean; @@ -32,17 +35,19 @@ export const AccessModal = () => { const AccessModalContent = ({ id }: { id: string }) => { const { item, access, refresh } = useDriveItem(id); - + const { company, refresh: refreshCompany } = useCurrentCompany(); useEffect(() => { refresh(id); + refreshCompany(); }, []); - - console.log(item?.access_info?.public?.level, 'item'); - return ( - + - + {FeatureTogglesService.isActiveFeatureName(FeatureNames.COMPANY_SEARCH_USERS) && ( + + )} ); };