Skip to content

Commit

Permalink
GUI redundant requests fixes (#3347) Library: fix -effectiveHierarchy…
Browse files Browse the repository at this point in the history
… requests
  • Loading branch information
AleksandrGorodetskii committed Sep 1, 2023
1 parent eab2f86 commit 868c8a6
Showing 1 changed file with 31 additions and 12 deletions.
43 changes: 31 additions & 12 deletions client/src/components/pipelines/browser/data-storage/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,12 +137,6 @@ const isStandardClass = (storageClass) =>
path: decodeURIComponent(queryParameters.path || ''),
showVersions,
showArchives,
restoreInfo: new LifeCycleEffectiveHierarchy(
params.id,
decodeURIComponent(queryParameters.path || ''),
'FOLDER',
false
),
openPreview
};
})
Expand Down Expand Up @@ -177,6 +171,7 @@ export default class DataStorage extends React.Component {
});

@observable generateDownloadUrls;
@observable restoreInfoRequest;

get showMetadata () {
if (this.state.metadata === undefined && this.storage.info) {
Expand Down Expand Up @@ -344,11 +339,10 @@ export default class DataStorage extends React.Component {
@computed
get lifeCycleRestoreInfo () {
const {
restoreInfo,
path
} = this.props;
if (restoreInfo && restoreInfo.loaded) {
const [first, ...rest] = restoreInfo.value || [];
if (this.restoreInfoRequest && this.restoreInfoRequest.loaded) {
const [first, ...rest] = this.restoreInfoRequest.value || [];
const currentPath = path
? [
!path.startsWith('/') && '/',
Expand All @@ -366,7 +360,7 @@ export default class DataStorage extends React.Component {
parentRestore = first;
currentRestores = rest;
} else {
currentRestores = restoreInfo.value;
currentRestores = this.restoreInfoRequest.value;
}
return {
parentRestore,
Expand Down Expand Up @@ -417,6 +411,24 @@ export default class DataStorage extends React.Component {
: this.storage.writeAllowed;
}

loadRestoreInfo = async (storageId, path = '') => {
if (!storageId) {
return;
}
this.restoreInfoRequest = new LifeCycleEffectiveHierarchy(
storageId,
decodeURIComponent(path),
'FOLDER',
false
);
this.restoreInfoPending = true;
await this.restoreInfoRequest.fetch();
if (this.restoreInfoRequest.error) {
message.error(this.restoreInfoRequest.error, 5);
}
this.restoreInfoPending = false;
};

onDataStorageEdit = async (storage) => {
if (!this.storage.info) {
return;
Expand Down Expand Up @@ -808,15 +820,15 @@ export default class DataStorage extends React.Component {
};

restoreFiles = (payload) => {
const {storageId, restoreInfo} = this.props;
const {storageId} = this.props;
const request = new LifeCycleRestoreCreate(storageId);
this.setState({restorePending: true}, async () => {
await request.send(payload);
if (request.error) {
message.error(request.error, 5);
return this.setState({restorePending: false});
}
restoreInfo.fetch()
this.loadRestoreInfo(this.props.storageId, this.props.path)
.then(() => {
this.setState({restorePending: false});
this.closeRestoreFilesDialog();
Expand Down Expand Up @@ -2822,10 +2834,17 @@ export default class DataStorage extends React.Component {
};
this.openPreviewModal(file);
}
this.loadRestoreInfo(this.props.storageId, this.props.path);
this.updateStorageIfRequired();
}

componentDidUpdate (prevProps) {
if (
this.props.storageId !== prevProps.storageId ||
this.props.path !== prevProps.path
) {
this.loadRestoreInfo(this.props.storageId, this.props.path);
}
this.clearSelectedItemsIfRequired();
this.updateStorageIfRequired();
}
Expand Down

0 comments on commit 868c8a6

Please sign in to comment.