mirror of
https://github.com/Fabio286/antares.git
synced 2025-02-18 12:40:41 +01:00
feat: open saved queries in a tab
This commit is contained in:
parent
a52fc3fd92
commit
9a732ea197
2
.github/workflows/test-e2e-win.yml
vendored
2
.github/workflows/test-e2e-win.yml
vendored
@ -3,7 +3,7 @@ name: Test end-to-end [WINDOWS]
|
|||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- master
|
- develop
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
release:
|
release:
|
||||||
|
@ -67,6 +67,17 @@
|
|||||||
:size="22"
|
:size="22"
|
||||||
/> {{ t('general.undo') }}
|
/> {{ t('general.undo') }}
|
||||||
</button>
|
</button>
|
||||||
|
<button
|
||||||
|
v-if="note.type === 'query'"
|
||||||
|
class="btn btn-link pl-1"
|
||||||
|
@click.stop="$emit('select-query', note.note)"
|
||||||
|
>
|
||||||
|
<BaseIcon
|
||||||
|
icon-name="mdiOpenInApp"
|
||||||
|
class="pr-1"
|
||||||
|
:size="22"
|
||||||
|
/> {{ t('general.select') }}
|
||||||
|
</button>
|
||||||
<button
|
<button
|
||||||
v-if="note.type === 'query'"
|
v-if="note.type === 'query'"
|
||||||
class="btn btn-link pl-1"
|
class="btn btn-link pl-1"
|
||||||
@ -139,7 +150,8 @@ defineEmits([
|
|||||||
'select-note',
|
'select-note',
|
||||||
'toggle-note',
|
'toggle-note',
|
||||||
'archive-note',
|
'archive-note',
|
||||||
'restore-note'
|
'restore-note',
|
||||||
|
'select-query'
|
||||||
]);
|
]);
|
||||||
|
|
||||||
const noteParagraph: Ref<HTMLDivElement> = ref(null);
|
const noteParagraph: Ref<HTMLDivElement> = ref(null);
|
||||||
|
@ -113,6 +113,7 @@
|
|||||||
@delete-note="deleteNote"
|
@delete-note="deleteNote"
|
||||||
@archive-note="archiveNote"
|
@archive-note="archiveNote"
|
||||||
@restore-note="restoreNote"
|
@restore-note="restoreNote"
|
||||||
|
@select-query="selectQuery"
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
</BaseVirtualScroll>
|
</BaseVirtualScroll>
|
||||||
@ -179,13 +180,15 @@ const { t } = useI18n();
|
|||||||
|
|
||||||
const applicationStore = useApplicationStore();
|
const applicationStore = useApplicationStore();
|
||||||
const scratchpadStore = useScratchpadStore();
|
const scratchpadStore = useScratchpadStore();
|
||||||
|
const workspacesStore = useWorkspacesStore();
|
||||||
|
|
||||||
const { connectionNotes, selectedTag } = storeToRefs(scratchpadStore);
|
const { connectionNotes, selectedTag } = storeToRefs(scratchpadStore);
|
||||||
const { changeNotes } = scratchpadStore;
|
const { changeNotes } = scratchpadStore;
|
||||||
const { hideScratchpad } = applicationStore;
|
const { hideScratchpad } = applicationStore;
|
||||||
const { getConnectionName } = useConnectionsStore();
|
const { getConnectionName } = useConnectionsStore();
|
||||||
const { connections } = storeToRefs(useConnectionsStore());
|
const { connections } = storeToRefs(useConnectionsStore());
|
||||||
const { getSelected: selectedWorkspace } = storeToRefs(useWorkspacesStore());
|
const { getSelected: selectedWorkspace } = storeToRefs(workspacesStore);
|
||||||
|
const { getWorkspaceTab, getWorkspace, newTab, updateTabContent } = workspacesStore;
|
||||||
|
|
||||||
const localConnection = ref(null);
|
const localConnection = ref(null);
|
||||||
const table: Ref<HTMLDivElement> = ref(null);
|
const table: Ref<HTMLDivElement> = ref(null);
|
||||||
@ -276,6 +279,32 @@ const deleteNote = (uid: string) => {
|
|||||||
changeNotes(otherNotes);
|
changeNotes(otherNotes);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const selectQuery = (query: string) => {
|
||||||
|
const workspace = getWorkspace(selectedWorkspace.value);
|
||||||
|
const selectedTab = getWorkspaceTab(workspace.selectedTab);
|
||||||
|
|
||||||
|
if (selectedTab.type === 'query') {
|
||||||
|
updateTabContent({
|
||||||
|
tab: selectedTab.uid,
|
||||||
|
uid: selectedWorkspace.value,
|
||||||
|
type: 'query',
|
||||||
|
content: query,
|
||||||
|
schema: workspace.breadcrumbs.schema
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
newTab({
|
||||||
|
uid: selectedWorkspace.value,
|
||||||
|
type: 'query',
|
||||||
|
content: query,
|
||||||
|
autorun: false,
|
||||||
|
schema: workspace.breadcrumbs.schema
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
hideScratchpad();
|
||||||
|
};
|
||||||
|
|
||||||
const closeEditModal = () => {
|
const closeEditModal = () => {
|
||||||
isEditModal.value = false;
|
isEditModal.value = false;
|
||||||
noteToEdit.value = null;
|
noteToEdit.value = null;
|
||||||
|
@ -345,6 +345,7 @@ watch(query, (val) => {
|
|||||||
schema: selectedSchema.value,
|
schema: selectedSchema.value,
|
||||||
content: val
|
content: val
|
||||||
});
|
});
|
||||||
|
|
||||||
isQuerySaved.value = false;
|
isQuerySaved.value = false;
|
||||||
}, 200);
|
}, 200);
|
||||||
});
|
});
|
||||||
@ -368,6 +369,14 @@ watch(databaseSchemas, () => {
|
|||||||
selectedSchema.value = null;
|
selectedSchema.value = null;
|
||||||
}, { deep: true });
|
}, { deep: true });
|
||||||
|
|
||||||
|
watch(() => props.tab.content, () => {
|
||||||
|
query.value = props.tab.content;
|
||||||
|
const editorValue = queryEditor.value.editor.session.getValue();
|
||||||
|
|
||||||
|
if (editorValue !== query.value)// If change not rendered in editor
|
||||||
|
queryEditor.value.editor.session.setValue(query.value);
|
||||||
|
});
|
||||||
|
|
||||||
const runQuery = async (query: string) => {
|
const runQuery = async (query: string) => {
|
||||||
if (!query || isQuering.value) return;
|
if (!query || isQuering.value) return;
|
||||||
isQuering.value = true;
|
isQuering.value = true;
|
||||||
|
@ -67,7 +67,7 @@ export interface Workspace {
|
|||||||
client?: ClientCode;
|
client?: ClientCode;
|
||||||
database?: string;
|
database?: string;
|
||||||
connectionStatus: string;
|
connectionStatus: string;
|
||||||
selectedTab: string | number;
|
selectedTab: string;
|
||||||
searchTerm: string;
|
searchTerm: string;
|
||||||
tabs: WorkspaceTab[];
|
tabs: WorkspaceTab[];
|
||||||
structure: WorkspaceStructure[];
|
structure: WorkspaceStructure[];
|
||||||
@ -119,12 +119,12 @@ export const useWorkspacesStore = defineStore('workspaces', {
|
|||||||
return state.workspaces.find(workspace => workspace.uid === uid).variables.find(variable => variable.name === name);
|
return state.workspaces.find(workspace => workspace.uid === uid).variables.find(variable => variable.name === name);
|
||||||
},
|
},
|
||||||
getWorkspaceTab (state) {
|
getWorkspaceTab (state) {
|
||||||
return (tUid: string) => {
|
return (tUid: string): WorkspaceTab => {
|
||||||
if (!this.getSelected) return;
|
if (!this.getSelected) return;
|
||||||
const workspace = state.workspaces.find(workspace => workspace.uid === this.getSelected);
|
const workspace = state.workspaces.find(workspace => workspace.uid === this.getSelected);
|
||||||
if ('tabs' in workspace)
|
if ('tabs' in workspace)
|
||||||
return workspace.tabs.find(tab => tab.uid === tUid);
|
return workspace.tabs.find(tab => tab.uid === tUid);
|
||||||
return {};
|
return null;
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
getConnected: state => {
|
getConnected: state => {
|
||||||
@ -410,7 +410,7 @@ export const useWorkspacesStore = defineStore('workspaces', {
|
|||||||
const workspace: Workspace = {
|
const workspace: Workspace = {
|
||||||
uid,
|
uid,
|
||||||
connectionStatus: 'disconnected',
|
connectionStatus: 'disconnected',
|
||||||
selectedTab: 0,
|
selectedTab: '0',
|
||||||
searchTerm: '',
|
searchTerm: '',
|
||||||
tabs: [],
|
tabs: [],
|
||||||
structure: [],
|
structure: [],
|
||||||
@ -629,18 +629,43 @@ export const useWorkspacesStore = defineStore('workspaces', {
|
|||||||
: false;
|
: false;
|
||||||
|
|
||||||
if (existentTab) {
|
if (existentTab) {
|
||||||
this._replaceTab({ uid, tab: existentTab.uid, type, database: workspaceTabs.database, schema, elementName, elementType });
|
this._replaceTab({ uid,
|
||||||
|
tab: existentTab.uid,
|
||||||
|
type,
|
||||||
|
database: workspaceTabs.database,
|
||||||
|
schema,
|
||||||
|
elementName,
|
||||||
|
elementType
|
||||||
|
});
|
||||||
tabUid = existentTab.uid;
|
tabUid = existentTab.uid;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
tabUid = uidGen('T');
|
tabUid = uidGen('T');
|
||||||
this._addTab({ uid, tab: tabUid, content, type, autorun, database: workspaceTabs.database, schema, elementName, elementType });
|
this._addTab({ uid,
|
||||||
|
tab: tabUid,
|
||||||
|
content,
|
||||||
|
type,
|
||||||
|
autorun,
|
||||||
|
database: workspaceTabs.database,
|
||||||
|
schema,
|
||||||
|
elementName,
|
||||||
|
elementType
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
tabUid = uidGen('T');
|
tabUid = uidGen('T');
|
||||||
this._addTab({ uid, tab: tabUid, content, type, autorun, database: workspaceTabs.database, schema, elementName, elementType });
|
this._addTab({ uid,
|
||||||
|
tab: tabUid,
|
||||||
|
content,
|
||||||
|
type,
|
||||||
|
autorun,
|
||||||
|
database: workspaceTabs.database,
|
||||||
|
schema,
|
||||||
|
elementName,
|
||||||
|
elementType
|
||||||
|
});
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user