Files
plane/web/ee/services/workspace.service.ts
Akshita Goyal 94be9199d4 Feat elastic search (#2457)
* feat: enhanced search UI.

* chore: initial Setup

* chore: search indexing

* [WEB-3270] Moved ES documents into ee app

* [WEB-3270] Modified Issue Index

* [WEB-3270] 25000 seems to be sweetspot for chunk_size/queryset_pagination but this needs to be revisited later

* [WEB-3270] cleanup commented out code

* [WEB-3270] Added indexes for project and workspace. Also fixed error while processing data for active_member_ids when a single record's index is updated

* Added view for enhanced global search

* [WEB-3311] Enhanced global search endpoint for Issues, Epics, Projects, Workspaces

* [WEB-3311] Moved all the common code into a helper function

* fix: ui improvements

* fix: ui improvements

* [WEB-3311] Minor fixes

* [WEB-3270] Inherit from the base document

* [WEB-3311] Removed query params that are not required anymore

* fix: refactor

* fix: issue icon

* [WEB-3270] Added indexes for all the necessary models

* [WEB-3311] Added search for all the entities

* [WEB-3310] Auto sync indexes usign celery background worker

* Bug fix

* improvement: UI and UX

* fix: minor fixes

* fix: work item results

* fix: types

* minor improvements

* fix: types

* fix: code refactoring + build fix

* fix: removed hardcoded data

* fix: handled hamburger

* fix: refactor

* fix: removed min query criteria

* filter pages based on workspace memebrs instead of project members

* Added logo_props to the ES index and search response

* fix: added logo props for search items

* Fixed page search

* Added some comments

* Only initialize elasticsearch dsl if the settings are available

* fix: added validation on min 3 char for search

* Fixed settings and set celerysignalprocessor as default for index updates

* Fixed page indexing

* Added custom hooks and signals to bulk operations on the queryset

* Use post_bulk_update signal to update indexes on bulk operations

* Feature flagged enhanced search endpoint

* Removed commented out code that's not needed anymore

---------

Co-authored-by: Prateek Shourya <prateekshourya29@gmail.com>
Co-authored-by: sriram veeraghanta <veeraghanta.sriram@gmail.com>
Co-authored-by: pablohashescobar <nikhilschacko@gmail.com>
Co-authored-by: Dheeraj Kumar Ketireddy <dheeru0198@gmail.com>
2025-03-05 21:35:52 +05:30

74 lines
2.8 KiB
TypeScript

// plane imports
import { EViewAccess } from "@plane/constants";
import { ISearchIssueResponse, TWorkspaceEpicsSearchParams } from "@plane/types";
// helpers
import { API_BASE_URL } from "@/helpers/common.helper";
// types
import { TWorkspaceWithProductDetails } from "@/plane-web/types";
// services
import { WorkspaceService as CoreWorkspaceService } from "@/services/workspace.service";
export class WorkspaceService extends CoreWorkspaceService {
constructor() {
super(API_BASE_URL);
}
async updateViewAccess(workspaceSlug: string, viewId: string, access: EViewAccess): Promise<any> {
return this.post(`/api/workspaces/${workspaceSlug}/views/${viewId}/access/`, { access }).catch((error) => {
throw error?.response?.data;
});
}
async lockView(workspaceSlug: string, viewId: string): Promise<any> {
return this.post(`/api/workspaces/${workspaceSlug}/views/${viewId}/lock/`).catch((error) => {
throw error?.response?.data;
});
}
async unLockView(workspaceSlug: string, viewId: string): Promise<any> {
return this.delete(`/api/workspaces/${workspaceSlug}/views/${viewId}/lock/`).catch((error) => {
throw error?.response?.data;
});
}
async getWorkspacesWithPlanDetails(): Promise<TWorkspaceWithProductDetails[]> {
return this.get(`/api/payments/website/workspaces/`)
.then((response) => response?.data)
.catch((error) => {
throw error?.response;
});
}
async searchAcrossWorkspace(
workspaceSlug: string,
params: { search: string; workspace_search?: boolean; projectId?: string }
) {
return this.get(`/api/workspaces/${workspaceSlug}/search/`, { params }).then((response) => response?.data);
}
/**
* Enhanced search across workspace. This endpoint is similar to searchAcrossWorkspace
* but it returns more detailed results for each item. It is used in the search bar.
*
* @param {string} workspaceSlug - The workspace slug.
* @param {Object} params - The search params.
* @param {string} params.search - The search string.
* @param {boolean} [params.workspace_search=false] - If true, search in the whole workspace.
* @param {string} [params.projectId] - The project id to search in.
* @returns {Promise<Object[]>} - The search results.
*/
async enhancedSearchAcrossWorkspace(
workspaceSlug: string,
params: { search: string; workspace_search?: boolean; projectId?: string }
) {
return this.get(`/api/workspaces/${workspaceSlug}/enhanced-search/`, { params }).then((response) => response?.data);
}
async fetchWorkspaceEpics(
workspaceSlug: string,
params: TWorkspaceEpicsSearchParams
): Promise<ISearchIssueResponse[]> {
return this.get(`/api/workspaces/${workspaceSlug}/epics/`, { params }).then((response) => response?.data);
}
}