Skip to content

Commit

Permalink
Merge branch 'main' into dev/tnaum/sync-doc-deletion-across-views
Browse files Browse the repository at this point in the history
  • Loading branch information
tnaum-ms authored Dec 4, 2024
2 parents faabcd4 + dc98abe commit 4598120
Show file tree
Hide file tree
Showing 16 changed files with 1,197 additions and 603 deletions.
7 changes: 6 additions & 1 deletion .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
* @Microsoft/vscodeazuretoolsdev @Microsoft/vscode-cosmosdb-extension
/.azure-pipelines @Microsoft/vscodeazuretoolsdev @Microsoft/cosmosdb-vscode-engineering
/.config @Microsoft/vscodeazuretoolsdev @Microsoft/cosmosdb-vscode-engineering
/src/mongoClusters @tnaum-ms @sevoku
/src/mongo @tnaum-ms @sevoku
/src/docdb @bk201- @sevoku
* @Microsoft/cosmosdb-vscode-engineering
11 changes: 10 additions & 1 deletion src/webviews/Document/DocumentPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,10 @@ export const DocumentPanel = () => {
const state = useDocumentState();
const dispatcher = useDocumentDispatcher();

const isReady = state.isReady;
const isReadOnly = state.mode === 'view';
const inProgress = state.isSaving || state.isRefreshing;
const hasDocumentInDB = state.documentId !== undefined;
const hasDocumentInDB = state.documentId !== '';

const onSave = async () => {
// Save document to the database
Expand Down Expand Up @@ -178,6 +179,14 @@ export const DocumentPanel = () => {
void dispatcher?.notifyDirty?.(state.isDirty);
}, [dispatcher, state.isDirty]);

if (!isReady || !state.currentDocumentContent) {
return (
<section className={classes.container}>
<ProgressBar />
</section>
);
}

return (
<section className={classes.container}>
<UnsavedChangesDialog open={open} setOpen={setOpen} doAction={doAction} />
Expand Down
9 changes: 5 additions & 4 deletions src/webviews/Document/DocumentToolbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@ export type DocumentToolbarProps = {
export const DocumentToolbar = (props: DocumentToolbarProps) => {
const state = useDocumentState();

const isReady = state.isReady;
const inProgress = state.isSaving || state.isRefreshing;
const hasDocumentInDB = state.documentId !== undefined;
const isReadOnly = state.mode === 'view';
const hasDocumentInDB = state.documentId !== '';
const isReadOnly = isReady && state.mode === 'view'; // If the document is not initialized, it is considered as not state
const isMac = navigator.platform.toLowerCase().includes('mac');

const onSaveHotkeyTitle = isMac ? '\u2318 S' : 'Ctrl+S';
Expand All @@ -32,7 +33,7 @@ export const DocumentToolbar = (props: DocumentToolbarProps) => {
return (
<>
<Toolbar size={'small'}>
{!isReadOnly && (
{isReady && !isReadOnly && (
<Tooltip
content={`Save document to the database (${onSaveHotkeyTitle})`}
relationship="description"
Expand All @@ -49,7 +50,7 @@ export const DocumentToolbar = (props: DocumentToolbarProps) => {
</ToolbarButton>
</Tooltip>
)}
{isReadOnly && (
{isReady && isReadOnly && (
<Tooltip
content={`Open document for editing (${onEditHotkeyTitle})`}
relationship="description"
Expand Down
1 change: 1 addition & 0 deletions src/webviews/Document/state/DocumentContextProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ export class DocumentContextProvider extends BaseContextProvider {
}

this.dispatch({ type: 'initState', mode, databaseId, containerId, documentId, partitionKey });
this.dispatch({ type: 'setRefreshing', isRefreshing: true });
},
);

Expand Down
5 changes: 4 additions & 1 deletion src/webviews/Document/state/DocumentState.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ export type DocumentState = {
isDirty: boolean; // Document has been modified
isSaving: boolean; // Document is being saved
isRefreshing: boolean; // Document is being refreshed
isReady: boolean; // Document is being initialized

currentDocumentContent: string; // Current content of the document
error: string | undefined; // Error message
Expand All @@ -81,7 +82,8 @@ export const defaultState: DocumentState = {
isValid: true,
isDirty: false,
isSaving: false,
isRefreshing: true,
isRefreshing: false,
isReady: false,
currentDocumentContent: '',
error: undefined,
};
Expand All @@ -106,6 +108,7 @@ export function dispatch(state: DocumentState, action: DispatchAction): Document
documentId: action.documentId,
dbName: action.databaseId,
collectionName: action.containerId,
isReady: true,
};
case 'setDocument':
return {
Expand Down
2 changes: 1 addition & 1 deletion src/webviews/QueryEditor/QueryEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const useStyles = makeStyles({
root: {
display: 'grid',
gridTemplateRows: '100vh',
minWidth: '900px',
// minWidth: '520px',
},
});

Expand Down
4 changes: 2 additions & 2 deletions src/webviews/QueryEditor/QueryPanel/QueryPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import { makeStyles } from '@fluentui/react-components';
import { QueryMonaco } from './QueryMonaco';
import { QueryToolbar } from './QueryToolbar';
import { QueryToolbarOverflow } from './QueryToolbarOverflow';

const useClasses = makeStyles({
monacoContainer: {
Expand All @@ -26,7 +26,7 @@ export const QueryPanel = () => {

return (
<section className={classes.container}>
<QueryToolbar />
<QueryToolbarOverflow />
<section className={classes.monacoContainer}>
<QueryMonaco />
</section>
Expand Down
207 changes: 0 additions & 207 deletions src/webviews/QueryEditor/QueryPanel/QueryToolbar.tsx

This file was deleted.

Loading

0 comments on commit 4598120

Please sign in to comment.