🛠️ Company user search feature (#300)

🛠️ Company user search feature
This commit is contained in:
Montassar Ghanmy
2023-12-20 08:38:59 +01:00
committed by GitHub
parent 8efe4ec194
commit 75dffb1c7a
7 changed files with 281 additions and 273 deletions
@@ -125,6 +125,7 @@
}, },
"drive": { "drive": {
"rootAdmins": "DRIVE_ROOT_ADMINS", "rootAdmins": "DRIVE_ROOT_ADMINS",
"defaultLanguage": "DRIVE_DEFAULT_LANGUAGE" "defaultLanguage": "DRIVE_DEFAULT_LANGUAGE",
"featureSearchUsers": "ENABLE_FEATURE_SEARCH_USERS"
} }
} }
+155 -164
View File
@@ -1,207 +1,202 @@
{ {
"general":{ "general": {
"help_url":false, "help_url": false,
"pricing_plan_url":"", "pricing_plan_url": "",
"app_download_url":"https://twake.app/download", "app_download_url": "https://twake.app/download",
"mobile":{ "mobile": {
"mobile_redirect":"mobile.twake.app", "mobile_redirect": "mobile.twake.app",
"mobile_appstore":"https://apps.apple.com/fr/app/tdrive/id1588764852?l=en", "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" "mobile_googleplay": "https://play.google.com/store/apps/details?id=com.tdrive.tdrive&gl=FR"
}, },
"accounts":{ "accounts": {
"_type":"remote", "_type": "remote",
"type":"internal", "type": "internal",
"internal":{ "internal": {
"disable_account_creation":false "disable_account_creation": false
}, },
"remote":{ "remote": {
"authority":"http://auth.example.com/", "authority": "http://auth.example.com/",
"client_id":"tdriveweb", "client_id": "tdriveweb",
"client_secret":"", "client_secret": "",
"issuer":"", "issuer": "",
"audience":"", "audience": "",
"redirect_uris":[ "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}",
"account_management_url":"http://web.tdrive-console.local/profile?company-code={company_id}", "company_management_url": "http://web.tdrive-console.local/companies?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":{ "console": {
"type":"internal" "type": "internal"
}, },
"sentry":{ "sentry": {
"dsn":"" "dsn": ""
}, },
"logger":{ "logger": {
"level":"debug" "level": "debug"
}, },
"tracker":{ "tracker": {
"type":"segment", "type": "segment",
"segment":{ "segment": {
"key":"" "key": ""
} }
}, },
"webserver":{ "webserver": {
"port":4000, "port": 4000,
"logger":{ "logger": {
"level":"info" "level": "info"
}, },
"cors":{ "cors": {
"origin":"*" "origin": "*"
}, },
"static":{ "static": {
"root":"./public" "root": "./public"
} }
}, },
"websocket":{ "websocket": {
"path":"/socket/", "path": "/socket/",
"adapters":{ "adapters": {
"types":[ "types": [],
"redis": {
], "host": "redis",
"redis":{ "port": 6379
"host":"redis",
"port":6379
} }
}, },
"auth":{ "auth": {
"jwt":{ "jwt": {
"secret":"supersecret" "secret": "supersecret"
} }
} }
}, },
"auth":{ "auth": {
"jwt":{ "jwt": {
"secret":"supersecret", "secret": "supersecret",
"expiration":3600, "expiration": 3600,
"refresh_expiration":2592000 "refresh_expiration": 2592000
} }
}, },
"database":{ "database": {
"secret":"", "secret": "",
"type":"cassandra", "type": "cassandra",
"mongodb":{ "mongodb": {
"uri":"mongodb://mongo:27017", "uri": "mongodb://mongo:27017",
"database":"tdrive" "database": "tdrive"
}, },
"cassandra":{ "cassandra": {
"contactPoints":[ "contactPoints": ["scylladb:9042"],
"scylladb:9042" "localDataCenter": "datacenter1",
], "keyspace": "tdrive",
"localDataCenter":"datacenter1", "wait": false,
"keyspace":"tdrive", "retries": 10,
"wait":false, "delay": 200
"retries":10,
"delay":200
} }
}, },
"message-queue":{ "message-queue": {
"// possible 'type' values are":"'amqp' or 'local'", "// possible 'type' values are": "'amqp' or 'local'",
"type":"amqp", "type": "amqp",
"amqp":{ "amqp": {
"urls":[ "urls": ["amqp://guest:guest@rabbitmq:5672"]
"amqp://guest:guest@rabbitmq:5672"
]
} }
}, },
"search":{ "search": {
"type":"elasticsearch", "type": "elasticsearch",
"elasticsearch":{ "elasticsearch": {
"endpoint":"http://elasticsearch:9200" "endpoint": "http://elasticsearch:9200"
} }
}, },
"push":{ "push": {
"type":false, "type": false,
"fcm":{ "fcm": {
"endpoint":"https://fcm.googleapis.com/fcm/send", "endpoint": "https://fcm.googleapis.com/fcm/send",
"key":"" "key": ""
} }
}, },
"storage":{ "storage": {
"secret":"0ea28a329df23220fa814e005bfb671c", "secret": "0ea28a329df23220fa814e005bfb671c",
"iv":"1234abcd00000000", "iv": "1234abcd00000000",
"type":"local", "type": "local",
"S3":{ "S3": {
"endPoint":"play.min.io", "endPoint": "play.min.io",
"port":9000, "port": 9000,
"useSSL":false, "useSSL": false,
"accessKey":"ABCD", "accessKey": "ABCD",
"secretKey":"x1yz" "secretKey": "x1yz"
}, },
"local":{ "local": {
"path":"/tdrive" "path": "/tdrive"
} }
}, },
"email-pusher":{ "email-pusher": {
"endpoint":"https://api.smtp2go.com/v3/email/send", "endpoint": "https://api.smtp2go.com/v3/email/send",
"api_key":"secret", "api_key": "secret",
"sender":"noreply@twake.app", "sender": "noreply@twake.app",
"debug": true "debug": true
}, },
"applications":{ "drive": {
"grid":[ "featureSearchUsers": true
},
"applications": {
"grid": [
{ {
"name":"Chat", "name": "Chat",
"logo":"/public/img/grid/twake.svg", "logo": "/public/img/grid/twake.svg",
"url":"https://web.twake.app/" "url": "https://web.twake.app/"
}, },
{ {
"name":"Mail", "name": "Mail",
"logo":"/public/img/grid/mail.svg", "logo": "/public/img/grid/mail.svg",
"url":"https://tmail.linagora.com/" "url": "https://tmail.linagora.com/"
}, },
{ {
"name":"Drive", "name": "Drive",
"logo":"/public/img/grid/drive.svg", "logo": "/public/img/grid/drive.svg",
"url":"https://tdrive.qa.lin-saas.com/" "url": "https://tdrive.qa.lin-saas.com/"
}, },
{ {
"name":"Calendar", "name": "Calendar",
"logo":"/public/img/grid/calendar.svg", "logo": "/public/img/grid/calendar.svg",
"url":"https://openpaas.linagora.com/calendar/" "url": "https://openpaas.linagora.com/calendar/"
}, },
{ {
"name":"Contacts", "name": "Contacts",
"logo":"/public/img/grid/contacts.svg", "logo": "/public/img/grid/contacts.svg",
"url":"https://openpaas.linagora.com/contacts" "url": "https://openpaas.linagora.com/contacts"
}, },
{ {
"name":"Visio", "name": "Visio",
"logo":"/public/img/grid/visio.svg", "logo": "/public/img/grid/visio.svg",
"url":"https://jitsi.linagora.com/" "url": "https://jitsi.linagora.com/"
} }
], ],
"plugins":[ "plugins": [
{ {
"api":{ "api": {
"private_key":"c1cc66db78e1d3bb4713c55d5ab2" "private_key": "c1cc66db78e1d3bb4713c55d5ab2"
}, },
"display":{ "display": {
"tdrive":{ "tdrive": {
"files":{ "files": {
"editor":{ "editor": {
"edition_url":"http://localhost:5000/plugins/onlyoffice/", "edition_url": "http://localhost:5000/plugins/onlyoffice/",
"empty_files":[ "empty_files": [
{ {
"filename":"Untitled.docx", "filename": "Untitled.docx",
"name":"ONLYOFFICE Word Document", "name": "ONLYOFFICE Word Document",
"url":"/plugins/onlyoffice/assets/empty.docx" "url": "/plugins/onlyoffice/assets/empty.docx"
}, },
{ {
"filename":"Untitled.xlsx", "filename": "Untitled.xlsx",
"name":"ONLYOFFICE Excel Document", "name": "ONLYOFFICE Excel Document",
"url":"/plugins/onlyoffice/assets/empty.xlsx" "url": "/plugins/onlyoffice/assets/empty.xlsx"
}, },
{ {
"filename":"Untitled.pptx", "filename": "Untitled.pptx",
"name":"ONLYOFFICE PowerPoint Document", "name": "ONLYOFFICE PowerPoint Document",
"url":"/plugins/onlyoffice/assets/empty.pptx" "url": "/plugins/onlyoffice/assets/empty.pptx"
} }
], ],
"extensions":[ "extensions": [
"xlsx", "xlsx",
"pptx", "pptx",
"docx", "docx",
@@ -215,32 +210,28 @@
"html", "html",
"csv" "csv"
], ],
"preview_url":"http://localhost:5000/plugins/onlyoffice/?preview=1" "preview_url": "http://localhost:5000/plugins/onlyoffice/?preview=1"
} }
}, },
"version":1 "version": 1
} }
}, },
"external_prefix":"/plugins/onlyoffice/", "external_prefix": "/plugins/onlyoffice/",
"id":"tdrive_onlyoffice", "id": "tdrive_onlyoffice",
"identity":{ "identity": {
"categories":[ "categories": [],
"code": "only_office",
], "compatibility": ["tdrive"],
"code":"only_office", "description": null,
"compatibility":[ "icon": "/plugins/onlyoffice/assets/logo.png",
"tdrive" "name": "Only Office",
], "website": "http://twake.app/"
"description":null,
"icon":"/plugins/onlyoffice/assets/logo.png",
"name":"Only Office",
"website":"http://twake.app/"
}, },
"internal_domain":"http://localhost:5000/" "internal_domain": "http://localhost:5000/"
} }
] ]
}, },
"services":[ "services": [
"auth", "auth",
"push", "push",
"storage", "storage",
@@ -1,4 +1,5 @@
import Company from "./entities/company"; import Company from "./entities/company";
import config from "../../core/config";
import { import {
CompanyFeaturesEnum, CompanyFeaturesEnum,
CompanyLimitsEnum, CompanyLimitsEnum,
@@ -53,6 +54,9 @@ export function formatCompany(
[CompanyFeaturesEnum.CHAT_EDIT_FILES]: true, [CompanyFeaturesEnum.CHAT_EDIT_FILES]: true,
[CompanyFeaturesEnum.CHAT_UNLIMITED_STORAGE]: true, [CompanyFeaturesEnum.CHAT_UNLIMITED_STORAGE]: true,
[CompanyFeaturesEnum.COMPANY_INVITE_MEMBER]: 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 || {}), ...(res.plan?.features || {}),
@@ -62,6 +66,8 @@ export function formatCompany(
}, },
); );
console.log("🚀🚀 res.plan.features: ", res.plan.features);
return res; return res;
} }
@@ -92,6 +92,7 @@ export const companyObjectSchema = {
[CompanyFeaturesEnum.CHAT_MULTIPLE_WORKSPACES]: { type: "boolean" }, [CompanyFeaturesEnum.CHAT_MULTIPLE_WORKSPACES]: { type: "boolean" },
[CompanyFeaturesEnum.CHAT_UNLIMITED_STORAGE]: { type: "boolean" }, [CompanyFeaturesEnum.CHAT_UNLIMITED_STORAGE]: { type: "boolean" },
[CompanyFeaturesEnum.COMPANY_INVITE_MEMBER]: { type: "boolean" }, [CompanyFeaturesEnum.COMPANY_INVITE_MEMBER]: { type: "boolean" },
[CompanyFeaturesEnum.COMPANY_SEARCH_USERS]: { type: "boolean" },
guests: { type: "number" }, // to rename or delete guests: { type: "number" }, // to rename or delete
members: { type: "number" }, // to rename or delete members: { type: "number" }, // to rename or delete
storage: { type: "number" }, // to rename or delete storage: { type: "number" }, // to rename or delete
@@ -83,6 +83,7 @@ export enum CompanyFeaturesEnum {
CHAT_EDIT_FILES = "chat:edit_files", CHAT_EDIT_FILES = "chat:edit_files",
CHAT_UNLIMITED_STORAGE = "chat:unlimited_storage", CHAT_UNLIMITED_STORAGE = "chat:unlimited_storage",
COMPANY_INVITE_MEMBER = "company:invite_member", COMPANY_INVITE_MEMBER = "company:invite_member",
COMPANY_SEARCH_USERS = "company:search_users",
} }
export type CompanyFeaturesObject = { export type CompanyFeaturesObject = {
@@ -92,6 +93,7 @@ export type CompanyFeaturesObject = {
[CompanyFeaturesEnum.CHAT_EDIT_FILES]?: boolean; [CompanyFeaturesEnum.CHAT_EDIT_FILES]?: boolean;
[CompanyFeaturesEnum.CHAT_UNLIMITED_STORAGE]?: boolean; [CompanyFeaturesEnum.CHAT_UNLIMITED_STORAGE]?: boolean;
[CompanyFeaturesEnum.COMPANY_INVITE_MEMBER]?: boolean; [CompanyFeaturesEnum.COMPANY_INVITE_MEMBER]?: boolean;
[CompanyFeaturesEnum.COMPANY_SEARCH_USERS]?: boolean;
}; };
export type CompanyLimitsObject = { export type CompanyLimitsObject = {
@@ -8,6 +8,7 @@ export enum FeatureNames {
EDIT_FILES = 'chat:edit_files', EDIT_FILES = 'chat:edit_files',
UNLIMITED_STORAGE = 'chat:unlimited_storage', //Currently inactive UNLIMITED_STORAGE = 'chat:unlimited_storage', //Currently inactive
COMPANY_INVITE_MEMBER = 'company:invite_member', COMPANY_INVITE_MEMBER = 'company:invite_member',
COMPANY_SEARCH_USERS = 'company:search_users',
} }
export type FeatureValueType = boolean | number; export type FeatureValueType = boolean | number;
@@ -22,6 +23,7 @@ availableFeaturesWithDefaults.set(FeatureNames.MULTIPLE_WORKSPACES, true);
availableFeaturesWithDefaults.set(FeatureNames.EDIT_FILES, true); availableFeaturesWithDefaults.set(FeatureNames.EDIT_FILES, true);
availableFeaturesWithDefaults.set(FeatureNames.UNLIMITED_STORAGE, true); availableFeaturesWithDefaults.set(FeatureNames.UNLIMITED_STORAGE, true);
availableFeaturesWithDefaults.set(FeatureNames.COMPANY_INVITE_MEMBER, 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 * ChannelServiceImpl that allow you to manage feature flipping in Tdrive using react feature toggles
@@ -4,8 +4,11 @@ import { useEffect } from 'react';
import { atom, useRecoilState } from 'recoil'; import { atom, useRecoilState } from 'recoil';
import { InternalAccessManager } from './internal-access'; import { InternalAccessManager } from './internal-access';
import { PublicLinkManager } from './public-link-access'; import { PublicLinkManager } from './public-link-access';
import { useCurrentCompany } from '@features/companies/hooks/use-companies';
import Languages from 'features/global/services/languages-service'; import Languages from 'features/global/services/languages-service';
import FeatureTogglesService, {
FeatureNames,
} from '@features/global/services/feature-toggles-service';
export type AccessModalType = { export type AccessModalType = {
open: boolean; open: boolean;
@@ -32,17 +35,19 @@ export const AccessModal = () => {
const AccessModalContent = ({ id }: { id: string }) => { const AccessModalContent = ({ id }: { id: string }) => {
const { item, access, refresh } = useDriveItem(id); const { item, access, refresh } = useDriveItem(id);
const { company, refresh: refreshCompany } = useCurrentCompany();
useEffect(() => { useEffect(() => {
refresh(id); refresh(id);
refreshCompany();
}, []); }, []);
console.log(item?.access_info?.public?.level, 'item');
return ( return (
<ModalContent title={Languages.t('components.item_context_menu.manage_access_to') + " " + item?.name}> <ModalContent
title={Languages.t('components.item_context_menu.manage_access_to') + ' ' + item?.name}
>
<PublicLinkManager id={id} disabled={access !== 'manage'} /> <PublicLinkManager id={id} disabled={access !== 'manage'} />
{FeatureTogglesService.isActiveFeatureName(FeatureNames.COMPANY_SEARCH_USERS) && (
<InternalAccessManager id={id} disabled={access !== 'manage'} /> <InternalAccessManager id={id} disabled={access !== 'manage'} />
)}
</ModalContent> </ModalContent>
); );
}; };