@@ -39,6 +39,8 @@ function viteConfigContent(): string {
3939 export default defineConfig({
4040 root,
4141 base: '/extensions/',
42+ // Load .env from the project root so VITE_* variables are available
43+ envDir: '../../',
4244 plugins: [react()],
4345 build: {
4446 outDir: 'dist',
@@ -169,15 +171,14 @@ function frontendTsConfig(): Record<string, unknown> {
169171}
170172
171173function panelComponentContent ( hasModal : boolean ) : string {
172- const sdkImportLine = hasModal ? "import { Command, Modal } from '@pipedrive/app-extensions-sdk';" : '' ;
173- const runSdkActionDestructure = hasModal ? ', runSdkAction' : '' ;
174174 const openModalHandler = hasModal
175175 ? dedent `
176176 async function openCustomModal(): Promise<void> {
177- await runSdkAction('Custom modal opened', (client) =>
177+ await runSdkAction('Modal opened', (client) =>
178178 client.execute(Command.OPEN_MODAL, {
179179 type: Modal.CUSTOM_MODAL,
180- action_id: 'custom-modal',
180+ // Replace with your Custom Modal's "Extension identifier" from Marketplace Developer Hub → App Extensions
181+ action_id: import.meta.env.VITE_CUSTOM_MODAL_ACTION_ID,
181182 data: { source: 'panel' },
182183 }),
183184 );
@@ -192,11 +193,10 @@ function panelComponentContent(hasModal: boolean): string {
192193 `
193194 : '' ;
194195
195- const sdkImportPrefix = sdkImportLine ? sdkImportLine + '\n' : '' ;
196-
197196 return dedent `
198197 import { useEffect } from 'react';
199- ${ sdkImportPrefix } import { usePipedriveSdk } from '../shared/pipedriveSdk';
198+ import { Command, Modal } from '@pipedrive/app-extensions-sdk';
199+ import { usePipedriveSdk } from '../shared/pipedriveSdk';
200200
201201 function formatQueryValue(key: string, value: string): string {
202202 return /token|secret|code/i.test(key) ? 'Present' : value;
@@ -209,14 +209,27 @@ function panelComponentContent(hasModal: boolean): string {
209209 }
210210
211211 export default function Panel() {
212- const { context, status, theme, visibility, pageState, lastAction, signedTokenPreview, isReady${ runSdkActionDestructure } , actions } =
212+ const { context, status, theme, visibility, pageState, lastAction, signedTokenPreview, isReady, runSdkAction , actions } =
213213 usePipedriveSdk('panel');
214214 const queryEntries = Object.entries(context.query);
215215
216216 useEffect(() => {
217217 document.title = 'Custom Panel';
218218 }, []);
219219
220+ async function logActivity(): Promise<void> {
221+ const dealId = context.query.selectedIds ? parseInt(context.query.selectedIds) : undefined;
222+ await runSdkAction('Activity logged', (client) =>
223+ client.execute(Command.OPEN_MODAL, {
224+ type: Modal.ACTIVITY,
225+ prefill: {
226+ subject: 'Follow-up',
227+ ...(dealId ? { deal: dealId } : {}),
228+ },
229+ }),
230+ );
231+ }
232+
220233 ${ openModalHandler }
221234
222235 if (!isReady && status !== 'Local preview') {
@@ -263,14 +276,17 @@ function panelComponentContent(hasModal: boolean): string {
263276 </section>
264277
265278 <section className="toolbar" aria-label="SDK actions">
279+ <button type="button" disabled={!isReady} onClick={logActivity}>
280+ Log activity
281+ </button>
266282 <button type="button" disabled={!isReady} onClick={actions.showSnackbar}>
267283 Snackbar
268284 </button>
269285 <button type="button" className="secondary" disabled={!isReady} onClick={actions.showConfirmation}>
270286 Confirm
271287 </button>
272288 <button type="button" className="ghost" disabled={!isReady} onClick={actions.resize}>
273- Resize panel
289+ {actions.isExpanded ? 'Collapse panel' : 'Expand panel'}
274290 </button>
275291 <button type="button" className="ghost" disabled={!isReady} onClick={actions.getSignedToken}>
276292 Get token
@@ -400,7 +416,7 @@ function modalComponentContent(): string {
400416 Confirm
401417 </button>
402418 <button type="button" className="ghost" disabled={!isReady} onClick={actions.resize}>
403- Resize modal
419+ {actions.isExpanded ? 'Collapse modal' : 'Expand modal'}
404420 </button>
405421 <button type="button" className="ghost" disabled={!isReady} onClick={actions.getSignedToken}>
406422 Get token
0 commit comments