mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2025-04-22 01:24:21 +01:00
Fix UX with buttons behavior and editor display
This commit is contained in:
parent
5f92a62e4f
commit
8d099b9c1b
@ -333,7 +333,15 @@ const DocumentsTabComponent: React.FunctionComponent<{
|
|||||||
// TODO Put whatever the buttons callback use in the dependency array: find a better way to maintain
|
// TODO Put whatever the buttons callback use in the dependency array: find a better way to maintain
|
||||||
useEffect(
|
useEffect(
|
||||||
() => updateNavbarWithTabsButtons(),
|
() => updateNavbarWithTabsButtons(),
|
||||||
[editorState, selectedDocumentContent, initialDocumentContent, selectedRows, documentIds],
|
[
|
||||||
|
editorState,
|
||||||
|
selectedDocumentContent,
|
||||||
|
selectedDocumentContentBaseline,
|
||||||
|
initialDocumentContent,
|
||||||
|
selectedRows,
|
||||||
|
documentIds,
|
||||||
|
clickedRow,
|
||||||
|
],
|
||||||
);
|
);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@ -365,6 +373,8 @@ const DocumentsTabComponent: React.FunctionComponent<{
|
|||||||
setInitialDocumentContent(defaultDocument);
|
setInitialDocumentContent(defaultDocument);
|
||||||
setSelectedDocumentContent(defaultDocument);
|
setSelectedDocumentContent(defaultDocument);
|
||||||
setSelectedDocumentContentBaseline(defaultDocument);
|
setSelectedDocumentContentBaseline(defaultDocument);
|
||||||
|
setSelectedRows(new Set());
|
||||||
|
setClickedRow(undefined);
|
||||||
setEditorState(ViewModels.DocumentExplorerState.newDocumentValid);
|
setEditorState(ViewModels.DocumentExplorerState.newDocumentValid);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -698,15 +708,6 @@ const DocumentsTabComponent: React.FunctionComponent<{
|
|||||||
// }
|
// }
|
||||||
// });
|
// });
|
||||||
|
|
||||||
const onRefreshButtonKeyDown: KeyboardEventHandler<HTMLSpanElement> = (event) => {
|
|
||||||
if (event.keyCode === KeyCodes.Enter || event.keyCode === KeyCodes.Space) {
|
|
||||||
refreshDocumentsGrid();
|
|
||||||
event.stopPropagation();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
};
|
|
||||||
|
|
||||||
const loadNextPage = (applyFilterButtonClicked?: boolean): Promise<unknown> => {
|
const loadNextPage = (applyFilterButtonClicked?: boolean): Promise<unknown> => {
|
||||||
setIsExecuting(true);
|
setIsExecuting(true);
|
||||||
setIsExecutionError(false);
|
setIsExecutionError(false);
|
||||||
@ -818,16 +819,6 @@ const DocumentsTabComponent: React.FunctionComponent<{
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const onLoadMoreKeyInput: KeyboardEventHandler<HTMLAnchorElement> = (event): void => {
|
|
||||||
if (event.key === " " || event.key === "Enter") {
|
|
||||||
const focusElement = document.getElementById(this.documentContentsGridId);
|
|
||||||
this.loadNextPage();
|
|
||||||
focusElement && focusElement.focus();
|
|
||||||
event.stopPropagation();
|
|
||||||
event.preventDefault();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const _loadNextPageInternal = (): Promise<DataModels.DocumentId[]> => {
|
const _loadNextPageInternal = (): Promise<DataModels.DocumentId[]> => {
|
||||||
return documentsIterator.iterator.fetchNext().then((response) => response.resources);
|
return documentsIterator.iterator.fetchNext().then((response) => response.resources);
|
||||||
};
|
};
|
||||||
@ -982,10 +973,11 @@ const DocumentsTabComponent: React.FunctionComponent<{
|
|||||||
return true;
|
return true;
|
||||||
|
|
||||||
case ViewModels.DocumentExplorerState.exisitingDocumentDirtyValid:
|
case ViewModels.DocumentExplorerState.exisitingDocumentDirtyValid:
|
||||||
return (
|
return true;
|
||||||
this.selectedDocumentContent.getEditableOriginalValue() !==
|
// return (
|
||||||
this.selectedDocumentContent.getEditableCurrentValue()
|
// this.selectedDocumentContent.getEditableOriginalValue() !==
|
||||||
);
|
// this.selectedDocumentContent.getEditableCurrentValue()
|
||||||
|
// );
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
@ -1043,7 +1035,7 @@ const DocumentsTabComponent: React.FunctionComponent<{
|
|||||||
|
|
||||||
if (
|
if (
|
||||||
selectedDocumentContentBaseline === initialDocumentContent &&
|
selectedDocumentContentBaseline === initialDocumentContent &&
|
||||||
selectedDocumentContent === initialDocumentContent &&
|
newContent === initialDocumentContent &&
|
||||||
editorState !== ViewModels.DocumentExplorerState.newDocumentValid
|
editorState !== ViewModels.DocumentExplorerState.newDocumentValid
|
||||||
) {
|
) {
|
||||||
setEditorState(ViewModels.DocumentExplorerState.exisitingDocumentNoEdits);
|
setEditorState(ViewModels.DocumentExplorerState.exisitingDocumentNoEdits);
|
||||||
@ -1132,6 +1124,7 @@ const DocumentsTabComponent: React.FunctionComponent<{
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<FluentProvider theme={dataExplorerLightTheme} style={{ height: "100%" }}>
|
<FluentProvider theme={dataExplorerLightTheme} style={{ height: "100%" }}>
|
||||||
|
{editorState}
|
||||||
<div
|
<div
|
||||||
className="tab-pane active"
|
className="tab-pane active"
|
||||||
/* data-bind="
|
/* data-bind="
|
||||||
@ -1209,12 +1202,12 @@ const DocumentsTabComponent: React.FunctionComponent<{
|
|||||||
onChange={(e) => setFilterContent(e.target.value)}
|
onChange={(e) => setFilterContent(e.target.value)}
|
||||||
/*
|
/*
|
||||||
data-bind="
|
data-bind="
|
||||||
W attr:{
|
W attr:{
|
||||||
placeholder:isPreferredApiMongoDB?'Type a query predicate (e.g., {´a´:´foo´}), or choose one from the drop down list, or leave empty to query all documents.':'Type a query predicate (e.g., WHERE c.id=´1´), or choose one from the drop down list, or leave empty to query all documents.'
|
placeholder:isPreferredApiMongoDB?'Type a query predicate (e.g., {´a´:´foo´}), or choose one from the drop down list, or leave empty to query all documents.':'Type a query predicate (e.g., WHERE c.id=´1´), or choose one from the drop down list, or leave empty to query all documents.'
|
||||||
},
|
},
|
||||||
css: { placeholderVisible: filterContent().length === 0 },
|
css: { placeholderVisible: filterContent().length === 0 },
|
||||||
textInput: filterContent"
|
textInput: filterContent"
|
||||||
*/
|
*/
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<datalist id="filtersList" /*data-bind="foreach: lastFilterContents"*/>
|
<datalist id="filtersList" /*data-bind="foreach: lastFilterContents"*/>
|
||||||
@ -1287,12 +1280,17 @@ data-bind="
|
|||||||
columnHeaders={columnHeaders}
|
columnHeaders={columnHeaders}
|
||||||
onRefreshClicked={refreshDocumentsGrid}
|
onRefreshClicked={refreshDocumentsGrid}
|
||||||
/>
|
/>
|
||||||
<a className="loadMore" role="button" onClick={() => loadNextPage(false)}>
|
<a
|
||||||
|
className="loadMore"
|
||||||
|
role="button"
|
||||||
|
onClick={() => loadNextPage(false)}
|
||||||
|
onKeyDown={() => loadNextPage(false)}
|
||||||
|
>
|
||||||
Load more
|
Load more
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
<div style={{ minWidth: "20%", width: "100%" }}>
|
<div style={{ minWidth: "20%", width: "100%" }}>
|
||||||
{selectedDocumentContent && selectedRows.size === 1 && (
|
{selectedDocumentContent && selectedRows.size <= 1 && (
|
||||||
<EditorReact
|
<EditorReact
|
||||||
language={"json"}
|
language={"json"}
|
||||||
content={selectedDocumentContent}
|
content={selectedDocumentContent}
|
||||||
|
@ -125,6 +125,7 @@ export const DocumentsTableComponent: React.FC<IDocumentsTableComponentProps> =
|
|||||||
icon={<ArrowClockwise16Filled />}
|
icon={<ArrowClockwise16Filled />}
|
||||||
style={{ position: "absolute", right: 0 }}
|
style={{ position: "absolute", right: 0 }}
|
||||||
onClick={onRefreshClicked}
|
onClick={onRefreshClicked}
|
||||||
|
onKeyDown={onRefreshClicked}
|
||||||
/>
|
/>
|
||||||
</>
|
</>
|
||||||
) : (
|
) : (
|
||||||
|
Loading…
x
Reference in New Issue
Block a user