Skip to content

Navigation Menu

Sign in
Appearance settings
Sign up
Appearance settings
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { QueryHistoryItem, SalesforceOrgUi } from '@jetstream/types';
import { Icon, Popover, PopoverRef, Radio, RadioGroup } from '@jetstream/ui';
import { getDexieDb, withReopenOnDatabaseClosed } from '@jetstream/ui/db';
import isDate from 'lodash/isDate';
import { FunctionComponent, useRef, useState } from 'react';
import { FunctionComponent, useEffect, useRef, useState } from 'react';
import { useAmplitude } from '../..';

type ExportScope = 'ALL' | 'CURRENT';
Expand All @@ -21,20 +21,22 @@ export const QueryHistoryExportPopover: FunctionComponent<QueryHistoryExportPopo
const popoverRef = useRef<PopoverRef>(null);
const { trackEvent } = useAmplitude();
const [exportScope, setExportScope] = useState<ExportScope>('ALL');
const [exportType, setExportType] = useState<ExportType>('ALL');
const [exportType, setExportType] = useState<ExportType>(() => (whichType === 'SAVED' ? 'FAVORITES' : 'ALL'));
const [isExporting, setIsExporting] = useState(false);

// Default the query selection to match the active tab, the user can still choose either option before exporting
useEffect(() => {
setExportType(whichType === 'SAVED' ? 'FAVORITES' : 'ALL');
}, [whichType]);

async function handleExport() {
setIsExporting(true);
try {
// Build filter function based on export type and which type
// Build filter function based on the selected options
const filterFn = (item: QueryHistoryItem) => {
if (exportScope === 'CURRENT' && item.org !== selectedOrg.uniqueId) {
return false;
}
if (whichType === 'SAVED' && !item.isFavorite) {
return false;
}
if (exportType === 'FAVORITES' && !item.isFavorite) {
return false;
}
Expand Down
Loading
Morty Proxy This is a proxified and sanitized view of the page, visit original site.