mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2025-10-13 23:38:45 +01:00
final refresh fixed
This commit is contained in:
parent
ab1f515613
commit
c9cd5ffdde
@ -307,6 +307,7 @@ export class SettingsComponent extends React.Component<SettingsComponentProps, S
|
||||
this.unsubscribe = useIndexingPolicyStore.subscribe((state) => {
|
||||
this.refreshCollectionData();
|
||||
});
|
||||
this.refreshCollectionData();
|
||||
}
|
||||
componentWillUnmount(): void {
|
||||
if (this.unsubscribe) this.unsubscribe();
|
||||
@ -938,12 +939,13 @@ export class SettingsComponent extends React.Component<SettingsComponentProps, S
|
||||
// Update the observable and state
|
||||
this.collection.rawDataModel = latestCollection;
|
||||
this.collection.indexingPolicy(latestCollection.indexingPolicy);
|
||||
console.log("Fetched latest indexing policy:", latestCollection.indexingPolicy);
|
||||
// console.log("Fetched latest indexing policy:", latestCollection.indexingPolicy);
|
||||
this.setState({
|
||||
indexingPolicyContent: latestCollection.indexingPolicy,
|
||||
indexingPolicyContentBaseline: latestCollection.indexingPolicy,
|
||||
});
|
||||
};
|
||||
|
||||
private saveCollectionSettings = async (startKey: number): Promise<void> => {
|
||||
const newCollection: DataModels.Collection = { ...this.collection.rawDataModel };
|
||||
if (
|
||||
@ -1141,7 +1143,6 @@ export class SettingsComponent extends React.Component<SettingsComponentProps, S
|
||||
},
|
||||
startKey,
|
||||
);
|
||||
// console.log("coll", newCollection.indexingPolicy);
|
||||
};
|
||||
|
||||
public getMongoIndexTabContent = (
|
||||
@ -1175,7 +1176,6 @@ export class SettingsComponent extends React.Component<SettingsComponentProps, S
|
||||
onScaleDiscardableChange: this.onScaleDiscardableChange,
|
||||
throughputError: this.state.throughputError,
|
||||
};
|
||||
// console.log("Rendering IndexingPolicyComponent with:", this.state.indexingPolicyContent); // <-- Add this
|
||||
if (!this.isCollectionSettingsTab) {
|
||||
return (
|
||||
<div className="settingsV2MainContainer">
|
||||
|
@ -1,5 +1,4 @@
|
||||
import { MessageBar, MessageBarType, Stack } from "@fluentui/react";
|
||||
import { useIndexingPolicyStore } from "Explorer/Tabs/QueryTab/ResultsView";
|
||||
import * as monaco from "monaco-editor";
|
||||
import * as React from "react";
|
||||
import * as DataModels from "../../../../Contracts/DataModels";
|
||||
@ -9,7 +8,6 @@ import { isDirty, isIndexTransforming } from "../SettingsUtils";
|
||||
import { IndexingPolicyRefreshComponent } from "./IndexingPolicyRefresh/IndexingPolicyRefreshComponent";
|
||||
|
||||
export interface IndexingPolicyComponentProps {
|
||||
// containerId: string;
|
||||
shouldDiscardIndexingPolicy: boolean;
|
||||
resetShouldDiscardIndexingPolicy: () => void;
|
||||
indexingPolicyContent: DataModels.IndexingPolicy;
|
||||
@ -33,7 +31,7 @@ export class IndexingPolicyComponent extends React.Component<
|
||||
private shouldCheckComponentIsDirty = true;
|
||||
private indexingPolicyDiv = React.createRef<HTMLDivElement>();
|
||||
private indexingPolicyEditor: monaco.editor.IStandaloneCodeEditor;
|
||||
private unsubscribeFromStore: () => void;
|
||||
|
||||
constructor(props: IndexingPolicyComponentProps) {
|
||||
super(props);
|
||||
this.state = {
|
||||
@ -42,7 +40,6 @@ export class IndexingPolicyComponent extends React.Component<
|
||||
}
|
||||
|
||||
componentDidUpdate(): void {
|
||||
// const { indexingPolicy } = useIndexingPolicyStore.getState();
|
||||
if (this.props.shouldDiscardIndexingPolicy) {
|
||||
this.resetIndexingPolicyEditor();
|
||||
this.props.resetShouldDiscardIndexingPolicy();
|
||||
@ -51,13 +48,11 @@ export class IndexingPolicyComponent extends React.Component<
|
||||
}
|
||||
|
||||
componentDidMount(): void {
|
||||
// const { indexingPolicy, baselinePolicy } = useIndexingPolicyStore.getState();
|
||||
this.resetIndexingPolicyEditor();
|
||||
this.onComponentUpdate();
|
||||
}
|
||||
|
||||
public resetIndexingPolicyEditor = (): void => {
|
||||
// const { indexingPolicy, baselinePolicy } = useIndexingPolicyStore.getState();
|
||||
if (!this.indexingPolicyEditor) {
|
||||
this.createIndexingPolicyEditor();
|
||||
} else {
|
||||
@ -76,9 +71,6 @@ export class IndexingPolicyComponent extends React.Component<
|
||||
this.shouldCheckComponentIsDirty = true;
|
||||
return;
|
||||
}
|
||||
// const isDirtyState = isDirty(storeIndexingPolicy, this.props.indexingPolicyContentBaseline);
|
||||
// this.props.onIndexingPolicyDirtyChange(isDirtyState && this.state.indexingPolicyContentIsValid);
|
||||
// this.shouldCheckComponentIsDirty = false;
|
||||
this.props.onIndexingPolicyDirtyChange(this.IsComponentDirty());
|
||||
this.shouldCheckComponentIsDirty = false;
|
||||
};
|
||||
@ -95,10 +87,6 @@ export class IndexingPolicyComponent extends React.Component<
|
||||
};
|
||||
|
||||
private async createIndexingPolicyEditor(): Promise<void> {
|
||||
const { indexingPolicy, baselinePolicy } = useIndexingPolicyStore.getState();
|
||||
const policyToUse = this.props.indexingPolicyContent;
|
||||
|
||||
// const value: string = JSON.stringify(policyToUse, undefined, 4);
|
||||
const value: string = JSON.stringify(this.props.indexingPolicyContent, undefined, 4);
|
||||
const monaco = await loadMonaco();
|
||||
this.indexingPolicyEditor = monaco.editor.create(this.indexingPolicyDiv.current, {
|
||||
@ -112,20 +100,14 @@ export class IndexingPolicyComponent extends React.Component<
|
||||
indexingPolicyEditorModel.onDidChangeContent(this.onEditorContentChange.bind(this));
|
||||
this.props.logIndexingPolicySuccessMessage();
|
||||
}
|
||||
console.log("compp", indexingPolicy);
|
||||
console.log("Accessed policy from Zustand store:", useIndexingPolicyStore.getState().indexingPolicy);
|
||||
console.log("actual indexing content", this.props.indexingPolicyContent);
|
||||
console.log("baseline", this.props.indexingPolicyContentBaseline);
|
||||
}
|
||||
|
||||
private onEditorContentChange = (): void => {
|
||||
const indexingPolicyEditorModel = this.indexingPolicyEditor.getModel();
|
||||
try {
|
||||
const newIndexingPolicyContent = JSON.parse(indexingPolicyEditorModel.getValue()) as DataModels.IndexingPolicy;
|
||||
// useIndexingPolicyStore.getState().setIndexingPolicyOnly(newIndexingPolicyContent);
|
||||
this.props.onIndexingPolicyContentChange(newIndexingPolicyContent);
|
||||
this.setState({ indexingPolicyContentIsValid: true });
|
||||
// console.log("editor", newIndexingPolicyContent);
|
||||
} catch (e) {
|
||||
this.setState({ indexingPolicyContentIsValid: false });
|
||||
}
|
||||
|
@ -542,7 +542,6 @@ interface IIndexMetric {
|
||||
interface IndexAdvisorTabProps {
|
||||
onPolicyUpdated: (newPolicy: DataModels.IndexingPolicy) => void;
|
||||
}
|
||||
// const IndexAdvisorTab: React.FC = () => {
|
||||
const IndexAdvisorTab: React.FC<IndexAdvisorTabProps> = ({ onPolicyUpdated }) => {
|
||||
const { userQuery, databaseId, containerId } = useQueryMetadataStore();
|
||||
const [loading, setLoading] = useState(true);
|
||||
@ -667,7 +666,7 @@ const IndexAdvisorTab: React.FC<IndexAdvisorTabProps> = ({ onPolicyUpdated }) =>
|
||||
.database(databaseId)
|
||||
.container(containerId)
|
||||
.read();
|
||||
console.log("def1", containerDef.indexingPolicy);
|
||||
// console.log("def1", containerDef.indexingPolicy);
|
||||
|
||||
const newIncludedPaths = selectedIndexes
|
||||
.filter(index => !index.composite)
|
||||
@ -692,14 +691,9 @@ const IndexAdvisorTab: React.FC<IndexAdvisorTabProps> = ({ onPolicyUpdated }) =>
|
||||
...(containerDef.indexingPolicy?.compositeIndexes || []),
|
||||
...newCompositeIndexes,
|
||||
],
|
||||
spatialIndexes: [
|
||||
...(containerDef.indexingPolicy?.spatialIndexes || []),
|
||||
// ...newSpatialIndexes,
|
||||
],
|
||||
vectorIndexes: [
|
||||
...(containerDef.indexingPolicy?.vectorIndexes || []),
|
||||
// ...newVectorIndexes,
|
||||
],
|
||||
automatic: containerDef.indexingPolicy?.automatic ?? true,
|
||||
indexingMode: containerDef.indexingPolicy?.indexingMode ?? "consistent",
|
||||
excludedPaths: containerDef.indexingPolicy?.excludedPaths ?? [],
|
||||
};
|
||||
|
||||
await client()
|
||||
@ -710,15 +704,14 @@ const IndexAdvisorTab: React.FC<IndexAdvisorTabProps> = ({ onPolicyUpdated }) =>
|
||||
partitionKey: containerDef.partitionKey,
|
||||
indexingPolicy: updatedPolicy,
|
||||
});
|
||||
|
||||
console.log("Indexing policy successfully updated:", updatedPolicy);
|
||||
useIndexingPolicyStore.getState().setIndexingPolicyOnly(updatedPolicy);
|
||||
// console.log("Indexing policy successfully updated:", updatedPolicy);
|
||||
const { resource: containerDef2 } = await client()
|
||||
.database(databaseId)
|
||||
.container(containerId)
|
||||
.read();
|
||||
onPolicyUpdated(containerDef2.indexingPolicy as DataModels.IndexingPolicy);
|
||||
// externalSetIndexingPolicy(containerDef2.indexingPolicy as DataModels.IndexingPolicy);
|
||||
console.log("def2", containerDef2.indexingPolicy);
|
||||
// console.log("def2", containerDef2.indexingPolicy);
|
||||
|
||||
const newIncluded = [...included, ...notIncluded.filter(item =>
|
||||
selectedIndexes.find(s => s.index === item.index)
|
||||
@ -954,9 +947,6 @@ export const ResultsView: React.FC<ResultsViewProps> = ({ isMongoDB, queryResult
|
||||
const onTabSelect = useCallback((event: SelectTabEvent, data: SelectTabData) => {
|
||||
setActiveTab(data.value as ResultsTabs);
|
||||
}, []);
|
||||
console.log("indeing", indexingPolicy);
|
||||
console.log("baseline", baselinePolicy);
|
||||
|
||||
return (
|
||||
<div data-test="QueryTab/ResultsPane/ResultsView" className={styles.queryResultsTabPanel}>
|
||||
<TabList selectedValue={activeTab} onTabSelect={onTabSelect}>
|
||||
@ -993,8 +983,6 @@ export const ResultsView: React.FC<ResultsViewProps> = ({ isMongoDB, queryResult
|
||||
{activeTab === ResultsTabs.QueryStats && <QueryStatsTab queryResults={queryResults} />}
|
||||
{activeTab === ResultsTabs.IndexAdvisor && <IndexAdvisorTab
|
||||
onPolicyUpdated={(newPolicy) => {
|
||||
// setIndexingPolicy(newPolicy);
|
||||
// setBaselinePolicy(newPolicy);
|
||||
const freshPolicy = JSON.parse(JSON.stringify(newPolicy));
|
||||
setIndexingPolicy(freshPolicy);
|
||||
setBaselinePolicy(freshPolicy);
|
||||
@ -1002,19 +990,6 @@ export const ResultsView: React.FC<ResultsViewProps> = ({ isMongoDB, queryResult
|
||||
}
|
||||
}
|
||||
/>}
|
||||
{/* {indexingPolicy && baselinePolicy && (
|
||||
<IndexingPolicyComponent
|
||||
indexingPolicyContent={indexingPolicy}
|
||||
indexingPolicyContentBaseline={baselinePolicy}
|
||||
onIndexingPolicyContentChange={setIndexingPolicy}
|
||||
resetShouldDiscardIndexingPolicy={() => { }}
|
||||
shouldDiscardIndexingPolicy={false}
|
||||
logIndexingPolicySuccessMessage={() => { }}
|
||||
indexTransformationProgress={100}
|
||||
refreshIndexTransformationProgress={async () => { }}
|
||||
onIndexingPolicyDirtyChange={() => { }}
|
||||
/>
|
||||
)} */}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
@ -1034,8 +1009,6 @@ export const useIndexingPolicyStore = create<IndexingPolicyStore>((set) => ({
|
||||
baselinePolicy: null,
|
||||
setIndexingPolicies: (indexingPolicy, baselinePolicy) =>
|
||||
set({ indexingPolicy, baselinePolicy }),
|
||||
// setIndexingPolicyOnly: (indexingPolicy) =>
|
||||
// set((state) => ({ indexingPolicy })),
|
||||
setIndexingPolicyOnly: (indexingPolicy) =>
|
||||
set((state) => ({ indexingPolicy: { ...indexingPolicy } })),
|
||||
}));
|
||||
|
@ -46,6 +46,7 @@ import DocumentId from "./DocumentId";
|
||||
import StoredProcedure from "./StoredProcedure";
|
||||
import Trigger from "./Trigger";
|
||||
import UserDefinedFunction from "./UserDefinedFunction";
|
||||
|
||||
export default class Collection implements ViewModels.Collection {
|
||||
public nodeKind: string;
|
||||
public container: Explorer;
|
||||
@ -122,55 +123,6 @@ export default class Collection implements ViewModels.Collection {
|
||||
this.vectorEmbeddingPolicy = ko.observable(data.vectorEmbeddingPolicy);
|
||||
this.fullTextPolicy = ko.observable(data.fullTextPolicy);
|
||||
this.indexingPolicy = ko.observable(data.indexingPolicy);
|
||||
// // console.log("Indexing policy changed data.indexngpolicy:", data.indexingPolicy);
|
||||
|
||||
// this.indexingPolicy(data.indexingPolicy);
|
||||
// this.indexingPolicy.subscribe(async (newPolicy) => {
|
||||
// console.log("Indexing policy changed via KO:", newPolicy);
|
||||
|
||||
// // Sync with Zustand (React side, if needed)
|
||||
// useIndexingPolicyStore.getState().setIndexingPolicyOnly(newPolicy);
|
||||
|
||||
// // Prepare a new collection object based on raw data
|
||||
// const updatedCollection: DataModels.Collection = {
|
||||
// ...this.rawDataModel,
|
||||
// indexingPolicy: newPolicy,
|
||||
// };
|
||||
|
||||
// try {
|
||||
// // Send update to backend
|
||||
// const updated = await updateCollection(
|
||||
// this.databaseId,
|
||||
// this.id(),
|
||||
// updatedCollection
|
||||
// );
|
||||
// console.log("updatedcollection", updatedCollection);
|
||||
// // Update the local view model with backend-confirmed values
|
||||
// this.rawDataModel = updated;
|
||||
// this.defaultTtl(updated.defaultTtl);
|
||||
// this.analyticalStorageTtl(updated.analyticalStorageTtl);
|
||||
// this.id(updated.id);
|
||||
// this.indexingPolicy(updated.indexingPolicy);
|
||||
// this.conflictResolutionPolicy(updated.conflictResolutionPolicy);
|
||||
// this.changeFeedPolicy(updated.changeFeedPolicy);
|
||||
// this.geospatialConfig(updated.geospatialConfig);
|
||||
// this.computedProperties(updated.computedProperties);
|
||||
// this.vectorEmbeddingPolicy(updated.vectorEmbeddingPolicy);
|
||||
// this.fullTextPolicy(updated.fullTextPolicy);
|
||||
|
||||
// console.log("✅ Indexing policy update persisted and view model refreshed.");
|
||||
// } catch (error) {
|
||||
// console.error("❌ Failed to update indexing policy:", error);
|
||||
// }
|
||||
// });
|
||||
|
||||
// this.indexingPolicy.subscribe((newPolicy) => {
|
||||
// console.log("Indexing policy changed via KO:", newPolicy);
|
||||
// //func to tigger
|
||||
// useIndexingPolicyStore.getState().setIndexingPolicyOnly(newPolicy);
|
||||
|
||||
// }); console.log(useIndexingPolicyStore.getState().indexingPolicy);
|
||||
|
||||
this.usageSizeInKB = ko.observable();
|
||||
this.offer = ko.observable();
|
||||
this.conflictResolutionPolicy = ko.observable(data.conflictResolutionPolicy);
|
||||
|
Loading…
x
Reference in New Issue
Block a user