mirror of
https://github.com/appwrite/console.git
synced 2026-11-18 20:47:21 +00:00
remove: dismiss confirmation!
This commit is contained in:
1 parent
8e92c78881
commit
8aff15d5bf
5 files changed
+7
-101
No files matched your search
@@ -1,5 +1,4 @@
|
||||
<script lang="ts">
|
||||
import { navigationCancelled } from '$lib/stores/navigation';
|
||||
import { afterNavigate, beforeNavigate } from '$app/navigation';
|
||||
|
||||
const minimum = 0.08;
|
||||
@@ -98,13 +97,6 @@
|
||||
complete();
|
||||
});
|
||||
|
||||
navigationCancelled.subscribe((cancelled) => {
|
||||
if (cancelled) {
|
||||
complete();
|
||||
navigationCancelled.set(false);
|
||||
}
|
||||
});
|
||||
|
||||
$: barStyle = (width && width * 100 && `width: ${width * 100}%;`) || '';
|
||||
</script>
|
||||
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
import { writable } from 'svelte/store';
|
||||
|
||||
export const navigationCancelled = writable(false);
|
||||
+5
-78
@@ -25,23 +25,18 @@
|
||||
tableColumnSuggestions,
|
||||
basicColumnOptions,
|
||||
mockSuggestions,
|
||||
createTableRequest,
|
||||
showIndexesSuggestions
|
||||
} from './store';
|
||||
import { addNotification, dismissNotification } from '$lib/stores/notifications';
|
||||
import { Submit, trackError, trackEvent } from '$lib/actions/analytics';
|
||||
import { sleep } from '$lib/helpers/promises';
|
||||
import { invalidate, beforeNavigate, goto } from '$app/navigation';
|
||||
import { showCreateTable } from '../store';
|
||||
import { showSubNavigation } from '$lib/stores/layout';
|
||||
import { navigationCancelled } from '$lib/stores/navigation';
|
||||
import { invalidate } from '$app/navigation';
|
||||
import { Dependencies } from '$lib/constants';
|
||||
import { isWithinSafeRange } from '$lib/helpers/numbers';
|
||||
import type { Columns } from '../table-[table]/store';
|
||||
import { columnOptions } from '../table-[table]/columns/store';
|
||||
import Options from './options.svelte';
|
||||
import { InputSelect, InputText } from '$lib/elements/forms';
|
||||
import { Confirm } from '$lib/components';
|
||||
import { isCloud, VARS } from '$lib/system';
|
||||
|
||||
import IconAINotification from './icon/aiNotification.svelte';
|
||||
@@ -62,10 +57,6 @@
|
||||
let hasTransitioned = $state(false);
|
||||
let scrollAnimationFrame: number | null = null;
|
||||
|
||||
let confirmDismiss = $state(false);
|
||||
let confirmNavigation = $state(false);
|
||||
let pendingNavigationUrl: string | null = null;
|
||||
|
||||
let creatingColumns = $state(false);
|
||||
const baseColProps = { draggable: false, resizable: false };
|
||||
|
||||
@@ -289,26 +280,6 @@
|
||||
});
|
||||
};
|
||||
|
||||
// Handle create table requests from subNavigation
|
||||
const unsubscribeCreateTable = createTableRequest.subscribe((requested) => {
|
||||
if (requested) {
|
||||
const hasRealColumns = customColumns.some((col) => !col.isPlaceholder);
|
||||
if (hasRealColumns && !creatingColumns) {
|
||||
confirmNavigation = true;
|
||||
pendingNavigationUrl = 'create-table';
|
||||
} else {
|
||||
executeCreateTable();
|
||||
}
|
||||
|
||||
createTableRequest.set(false);
|
||||
}
|
||||
});
|
||||
|
||||
function executeCreateTable() {
|
||||
$showCreateTable = true;
|
||||
$showSubNavigation = false;
|
||||
}
|
||||
|
||||
const customSuggestedColumns = $derived.by(() => {
|
||||
return customColumns.map((col: SuggestedColumnSchema) => {
|
||||
const columnOption = getColumnOption(col.type, col.format);
|
||||
@@ -405,16 +376,6 @@
|
||||
await suggestColumns();
|
||||
});
|
||||
|
||||
beforeNavigate(({ cancel, to }) => {
|
||||
const hasRealColumns = customColumns.some((col) => !col.isPlaceholder);
|
||||
if (hasRealColumns && !creatingColumns) {
|
||||
cancel();
|
||||
confirmNavigation = true;
|
||||
$navigationCancelled = true;
|
||||
pendingNavigationUrl = to?.url?.pathname || null;
|
||||
}
|
||||
});
|
||||
|
||||
function resetSuggestionsStore(fullReset: boolean = true) {
|
||||
if ($tableColumnSuggestions.table?.id !== page.params.table) {
|
||||
return;
|
||||
@@ -740,7 +701,6 @@
|
||||
|
||||
customColumns = [];
|
||||
resetSuggestionsStore();
|
||||
unsubscribeCreateTable();
|
||||
});
|
||||
</script>
|
||||
|
||||
@@ -1023,7 +983,10 @@
|
||||
size="xs"
|
||||
variant="text"
|
||||
disabled={creatingColumns}
|
||||
on:click={() => (confirmDismiss = true)}
|
||||
on:click={() => {
|
||||
customColumns = [];
|
||||
resetSuggestionsStore();
|
||||
}}
|
||||
style="opacity: {creatingColumns ? '0' : '1'}"
|
||||
>Dismiss
|
||||
</Button.Button>
|
||||
@@ -1042,42 +1005,6 @@
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
<Confirm
|
||||
confirmDeletion
|
||||
action="Dismiss"
|
||||
title="Dismiss columns"
|
||||
bind:open={confirmDismiss}
|
||||
onSubmit={() => {
|
||||
customColumns = [];
|
||||
resetSuggestionsStore();
|
||||
}}>
|
||||
Are you sure you want to dismiss these columns suggested by AI? This action is irreversible.
|
||||
</Confirm>
|
||||
|
||||
<Confirm
|
||||
confirmDeletion
|
||||
action="Leave"
|
||||
title="Leave page"
|
||||
bind:open={confirmNavigation}
|
||||
onSubmit={() => {
|
||||
customColumns = [];
|
||||
resetSuggestionsStore();
|
||||
confirmNavigation = false;
|
||||
|
||||
if (pendingNavigationUrl) {
|
||||
if (pendingNavigationUrl === 'create-table') {
|
||||
executeCreateTable();
|
||||
} else {
|
||||
goto(pendingNavigationUrl);
|
||||
}
|
||||
|
||||
pendingNavigationUrl = null;
|
||||
}
|
||||
}}>
|
||||
You have unsaved column suggestions. If you leave this page, you'll lose these suggestions. Are
|
||||
you sure you want to continue?
|
||||
</Confirm>
|
||||
|
||||
<style lang="scss">
|
||||
.spreadsheet-container-outer {
|
||||
width: 100%;
|
||||
|
||||
-2
@@ -46,8 +46,6 @@ export const tableColumnSuggestions = writable<TableColumnSuggestions>({
|
||||
table: null
|
||||
});
|
||||
|
||||
export const createTableRequest = writable<boolean>(false);
|
||||
|
||||
export const showIndexesSuggestions = writable<boolean>(false);
|
||||
|
||||
export const mockSuggestions: { total: number; columns: ColumnInput[] } = {
|
||||
|
||||
+2
-10
@@ -28,7 +28,6 @@
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import { onMount } from 'svelte';
|
||||
import { subNavigation } from '$lib/stores/database';
|
||||
import { createTableRequest, tableColumnSuggestions } from './(suggestions)/store';
|
||||
|
||||
let data = $derived(page.data) as PageData;
|
||||
|
||||
@@ -147,15 +146,8 @@
|
||||
<Button
|
||||
compact
|
||||
on:click={() => {
|
||||
if (
|
||||
$tableColumnSuggestions.enabled &&
|
||||
$tableColumnSuggestions.table?.id
|
||||
) {
|
||||
$createTableRequest = true;
|
||||
} else {
|
||||
$showCreateTable = true;
|
||||
$showSubNavigation = false;
|
||||
}
|
||||
$showCreateTable = true;
|
||||
$showSubNavigation = false;
|
||||
}}>
|
||||
Create table
|
||||
</Button>
|
||||
|
||||
Reference in new issue
Block a user