Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: eda history basic setup #1212

Merged
merged 12 commits into from
Jun 24, 2024
22 changes: 13 additions & 9 deletions packages/safe-ds-eda/src/App.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import TableView from './components/TableView.svelte';
import Sidebar from './components/Sidebar.svelte';
import { throttle } from 'lodash';
import { currentTabIndex, tabs } from './webviewState';
import { currentTabIndex, tableKey, tabs } from './webviewState';
import TabContent from './components/tabs/TabContent.svelte';

let sidebarWidth = 307; // Initial width of the sidebar in pixels
Expand Down Expand Up @@ -45,15 +45,19 @@
</div>
<div class="contentWrapper">
<div class:hide={$currentTabIndex !== undefined}>
<TableView {sidebarWidth} />
{#key $tableKey}
<TableView {sidebarWidth} />
{/key}
</div>
{#if $tabs.length > 0}
{#each $tabs as tab, index}
<div class:hide={index !== $currentTabIndex}>
<TabContent {tab} {sidebarWidth} />
</div>
{/each}
{/if}
{#key $tableKey}
{#if $tabs.length > 0}
{#each $tabs as tab, index}
<div class:hide={index !== $currentTabIndex}>
<TabContent {tab} {sidebarWidth} />
</div>
{/each}
{/if}
{/key}
</div>
</main>

Expand Down
60 changes: 60 additions & 0 deletions packages/safe-ds-eda/src/apis/extensionApi.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { get } from 'svelte/store';
import type { HistoryEntry } from '../../types/state';
import { table } from '../webviewState';
import type { ExecuteRunnerAllEntry } from '../../types/messaging';
import { filterHistoryOnlyInternal } from './historyApi';

export const createInfoToast = function (message: string) {
window.injVscode.postMessage({ command: 'setInfo', value: message });
Expand All @@ -21,6 +23,64 @@ const executeRunnerExcludingHiddenColumns = function (
});
};

export const executeRunnerAll = function (entries: HistoryEntry[], jumpedToHistoryId: number) {
const currentEntries: HistoryEntry[] = [];
const finalEntries: ExecuteRunnerAllEntry[] = entries.map((entry) => {
currentEntries.push(entry);
if (entry.type === 'external-visualizing' && entry.columnNumber === 'none') {
// If the entry is a tab where you do not select columns => don't include hidden columns in visualization
// Hidden columns calculated by filtering the history for not overriden hide column calls up to this point
return {
type: 'excludingHiddenColumns',
entry,
hiddenColumns: filterHistoryOnlyInternal(currentEntries).reduce<string[]>((acc, filteredEntry) => {
if (filteredEntry.action === 'hideColumn') {
acc.push(filteredEntry.columnName);
}
return acc;
}, []),
};
} else {
return { type: 'default', entry };
}
});
window.injVscode.postMessage({
command: 'executeRunnerAll',
value: { entries: finalEntries, jumpedToHistoryId },
});
};

export const executeRunnerAllFuture = function (
futureEntries: HistoryEntry[],
pastEntries: HistoryEntry[],
jumpedToHistoryId: number,
) {
const currentEntries: HistoryEntry[] = pastEntries;
const finalFutureEntries: ExecuteRunnerAllEntry[] = futureEntries.map((entry) => {
currentEntries.push(entry);
if (entry.type === 'external-visualizing' && entry.columnNumber === 'none') {
// If the entry is a tab where you do not select columns => don't include hidden columns in visualization
// Hidden columns calculated by filtering the history for not overriden hide column calls up to this point
return {
type: 'excludingHiddenColumns',
entry,
hiddenColumns: filterHistoryOnlyInternal(currentEntries).reduce<string[]>((acc, filteredEntry) => {
if (filteredEntry.action === 'hideColumn') {
acc.push(filteredEntry.columnName);
}
return acc;
}, []),
};
} else {
return { type: 'default', entry };
}
});
window.injVscode.postMessage({
command: 'executeRunnerAllFuture',
value: { futureEntries: finalFutureEntries, pastEntries, jumpedToHistoryId },
});
};

const executeRunnerDefault = function (pastEntries: HistoryEntry[], newEntry: HistoryEntry) {
window.injVscode.postMessage({
command: 'executeRunner',
Expand Down
Loading