UNPKG

@remotion/studio

Version:

APIs for interacting with the Remotion Studio

35 lines (34 loc) 1.87 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.RenderQueueCancelButton = void 0; const jsx_runtime_1 = require("react/jsx-runtime"); const react_1 = require("react"); const InlineAction_1 = require("../InlineAction"); const NotificationCenter_1 = require("../Notifications/NotificationCenter"); const actions_1 = require("./actions"); const context_1 = require("./context"); const RenderQueueCancelButton = ({ job }) => { const isClientJob = (0, context_1.isClientRenderJob)(job); const { cancelClientJob } = (0, react_1.useContext)(context_1.RenderQueueContext); const onClick = (0, react_1.useCallback)((e) => { e.stopPropagation(); if (isClientJob) { cancelClientJob(job.id); return; } (0, actions_1.cancelRenderJob)(job).catch((err) => { (0, NotificationCenter_1.showNotification)(`Could not cancel job: ${err.message}`, 2000); }); }, [job, isClientJob, cancelClientJob]); const icon = (0, react_1.useMemo)(() => { return { height: 14, color: 'currentColor', }; }, []); const renderAction = (0, react_1.useCallback)((color) => { return (jsx_runtime_1.jsx("svg", { style: icon, xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 512 512", children: jsx_runtime_1.jsx("path", { fill: color, d: "M367.2 412.5L99.5 144.8C77.1 176.1 64 214.5 64 256c0 106 86 192 192 192c41.5 0 79.9-13.1 111.2-35.5zm45.3-45.3C434.9 335.9 448 297.5 448 256c0-106-86-192-192-192c-41.5 0-79.9 13.1-111.2 35.5L412.5 367.2zM512 256c0 141.4-114.6 256-256 256S0 397.4 0 256S114.6 0 256 0S512 114.6 512 256z" }) })); }, [icon]); return jsx_runtime_1.jsx(InlineAction_1.InlineAction, { renderAction: renderAction, onClick: onClick }); }; exports.RenderQueueCancelButton = RenderQueueCancelButton;