Compare commits

...

5 Commits

Author SHA1 Message Date
Sung-Hyun Kang
7cf0eb511a Add componentDidMount for initial render 2024-06-17 14:19:23 -05:00
Sung-Hyun Kang
f7b7d135df merge conflict 2024-06-17 13:40:18 -05:00
Sung-Hyun Kang
1ab6bf3d81 Remove dependency on previous prop of deletion id 2024-06-17 13:23:22 -05:00
Sung-Hyun Kang
ac8dbbc0d2 sample db handling 2024-06-17 12:30:28 -05:00
Sung-Hyun Kang
edfd6cfc30 handle sampledb error handling to load the data explorer 2024-06-12 22:41:35 -05:00
2 changed files with 22 additions and 9 deletions

View File

@@ -1158,7 +1158,7 @@ export default class Explorer {
public async refreshSampleData(): Promise<void> { public async refreshSampleData(): Promise<void> {
try { try {
if (!userContext.sampleDataConnectionInfo) { if (!userContext.sampleDataConnectionInfo || useDatabases.getState().sampleDataResourceTokenCollection) {
return; return;
} }
const collection: DataModels.Collection = await readSampleCollection(); const collection: DataModels.Collection = await readSampleCollection();

View File

@@ -57,6 +57,10 @@ export class NotificationConsoleComponent extends React.Component<
this.prevHeaderStatus = undefined; this.prevHeaderStatus = undefined;
} }
public componentDidMount() {
this.componentDidUpdate(this.props, this.state);
}
public componentDidUpdate( public componentDidUpdate(
prevProps: NotificationConsoleComponentProps, prevProps: NotificationConsoleComponentProps,
prevState: NotificationConsoleComponentState, prevState: NotificationConsoleComponentState,
@@ -265,20 +269,29 @@ export class NotificationConsoleComponent extends React.Component<
}; };
private updateConsoleData = (prevProps: NotificationConsoleComponentProps): void => { private updateConsoleData = (prevProps: NotificationConsoleComponentProps): void => {
let updatedConsoleData: ConsoleData[] = [...this.state.allConsoleData];
let refresh = false;
if (!this.areConsoleDataEqual(this.props.consoleData, prevProps.consoleData)) { if (!this.areConsoleDataEqual(this.props.consoleData, prevProps.consoleData)) {
this.setState({ allConsoleData: [this.props.consoleData, ...this.state.allConsoleData] }); updatedConsoleData = [this.props.consoleData, ...updatedConsoleData];
refresh = true;
} }
if ( if (this.props.inProgressConsoleDataIdToBeDeleted) {
this.props.inProgressConsoleDataIdToBeDeleted && const hasMatchingItem = updatedConsoleData.some(
prevProps.inProgressConsoleDataIdToBeDeleted !== this.props.inProgressConsoleDataIdToBeDeleted
) {
const allConsoleData = this.state.allConsoleData.filter(
(data: ConsoleData) => (data: ConsoleData) =>
!(data.type === ConsoleDataType.InProgress && data.id === this.props.inProgressConsoleDataIdToBeDeleted), data.type === ConsoleDataType.InProgress && data.id === this.props.inProgressConsoleDataIdToBeDeleted,
); );
this.setState({ allConsoleData });
if (hasMatchingItem) {
updatedConsoleData = updatedConsoleData.filter(
(data: ConsoleData) =>
!(data.type === ConsoleDataType.InProgress && data.id === this.props.inProgressConsoleDataIdToBeDeleted),
);
refresh = true;
}
} }
refresh && this.setState({ allConsoleData: updatedConsoleData });
}; };
private areConsoleDataEqual = (currentData: ConsoleData, prevData: ConsoleData): boolean => { private areConsoleDataEqual = (currentData: ConsoleData, prevData: ConsoleData): boolean => {