import { ArchiveIcon, DeleteIcon, FileCopyIcon, KeyboardTabIcon, OpenInNewIcon } from "@firecms/ui"; import { EntityAction } from "../../types"; import { DeleteEntityDialog } from "../DeleteEntityDialog"; export const editEntityAction: EntityAction = { icon: , name: "Edit", collapsed: false, onClick({ entity, collection, fullPath, context, highlightEntity, unhighlightEntity, }): Promise { highlightEntity?.(entity); context.analyticsController?.onAnalyticsEvent?.("entity_click", { path: entity.path, entityId: entity.id }); const path = collection?.collectionGroup ? entity.path : (fullPath ?? entity.path); context.sideEntityController.open({ entityId: entity.id, path, collection, updateUrl: true, onClose: () => unhighlightEntity?.(entity), }); return Promise.resolve(undefined); } } export const copyEntityAction: EntityAction = { icon: , name: "Copy", onClick({ entity, collection, context, highlightEntity, unhighlightEntity, }): Promise { highlightEntity?.(entity); context.analyticsController?.onAnalyticsEvent?.("copy_entity_click", { path: entity.path, entityId: entity.id }); context.sideEntityController.open({ entityId: entity.id, path: entity.path, copy: true, collection, updateUrl: true, onClose: () => unhighlightEntity?.(entity), }); return Promise.resolve(undefined); } } export const archiveEntityAction: EntityAction = { icon: , name: "Archive", onClick({ entity, collection, context: { dataSource, } }): Promise { // Add your code here return Promise.resolve(undefined); } } export const openWebsiteAction: EntityAction = { icon: , name: "See in website", onClick({ entity, collection, context, }): Promise { // open a new tab window.open(`https://example.com/${entity.id}`, "_blank"); return Promise.resolve(undefined); } } export const deleteEntityAction: EntityAction = { icon: , name: "Delete", onClick({ entity, fullPath, collection, context, selectionController, onCollectionChange, sideEntityController }): Promise { const { closeDialog } = context.dialogsController.open({ key: "delete_entity_dialog_" + entity.id, Component: ({ open }) => { if (!collection || !fullPath) throw new Error("deleteEntityAction: Collection is undefined"); return { context.analyticsController?.onAnalyticsEvent?.("single_entity_deleted", { path: fullPath }); selectionController?.setSelectedEntities(selectionController.selectedEntities.filter(e => e.id !== entity.id)); onCollectionChange?.(); sideEntityController?.close(); }} onClose={closeDialog}/>; } }) return Promise.resolve(undefined); } }