Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update undelete poller to poll for undeletions, not deletions #4397

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -13,29 +13,37 @@ undeleteImage.controller('grUnDeleteImageCtrl', [

ctrl.$onInit = () => {

function pollDeleted (image) {
function pollUndeleted (image) {
const findImage = () => mediaApi.find(image.data.id).then(
() => $q.reject(),
// resolve when image cannot be found, i.e. image has been deleted.
() => $q.resolve()
(r) => {
if (r.data.softDeletedMetadata) {
// reject until softdeleted metadata has been removed
return $q.reject();
} else {
return $q.resolve();
}
},
// reject while image cannot be found, i.e. image has been deleted, and not yet recovered.
() => $q.reject()
);

apiPoll(findImage);
}

ctrl.unDeleteImage = function (image) {
ctrl.undeleteImage = function (image) {
return mediaApi.undelete(image.data.id)
.then(() => pollDeleted(image))
.then(() => pollUndeleted(image))
.catch((err) => {
$rootScope.$emit('image-delete-failure', err, image);
});
};

ctrl.unDeleteSelected = function () {
ctrl.undeleteSelected = function () {
// HACK to wait for thrall to process the message so that when we
// poll the api, it will be up to date.
return $q.all(Array.from(ctrl.images.values()).map(image => ctrl.unDeleteImage(image)))
.then(() => $rootScope.$emit('images-deleted', ctrl.images));
return $q.all(Array.from(ctrl.images.values()).map(image => ctrl.undeleteImage(image)))
// Event name is "deleted", but we wait for undeletion too.
.then(() => $rootScope.$emit('images-deleted', ctrl.images));
};
};
}
@@ -46,7 +54,7 @@ undeleteImage.directive('grUnDeleteImage', [function () {
restrict: 'E',
template: `
<gr-confirm-delete class="gr-delete-image"
gr-on-confirm="ctrl.unDeleteSelected()" gr-label="Undelete" gr-confirm="Confirm Undelete" gr-tooltip="Undelete image" >
gr-on-confirm="ctrl.undeleteSelected()" gr-label="Undelete" gr-confirm="Confirm Undelete" gr-tooltip="Undelete image" >
</gr-confirm-delete>`,
controller: 'grUnDeleteImageCtrl',
controllerAs: 'ctrl',

Unchanged files with check annotations Beta

setIsOpen(false);
};
const handleDisplay = (e: any) => {

Check warning on line 42 in kahuna/public/js/components/gr-confirmation-modal/gr-confirmation-modal.tsx

GitHub Actions / CI

Unexpected any. Specify a different type
document.body.setAttribute("aria-hidden", "true");
setOkayFunction(() => e.detail.okayFn);
setTitle(e.detail.title);
},[]);
useEffect(() => {
const handleKeyDown = (e: any) => {

Check warning on line 65 in kahuna/public/js/components/gr-confirmation-modal/gr-confirmation-modal.tsx

GitHub Actions / CI

Unexpected any. Specify a different type
if ((e.target.className === 'closeButtonStyle' || e.target.className === 'confirmButtonStyle') && (e.keyCode === 32 || e.keyCode === 13)) {
e.preventDefault(); // Prevent the default action to avoid scrolling when using Space
e.target.click(); // Trigger the button's onClick event
onCancel(); // Close on ESC
}
};
const trapTabKey = (e: any) => {

Check warning on line 74 in kahuna/public/js/components/gr-confirmation-modal/gr-confirmation-modal.tsx

GitHub Actions / CI

Unexpected any. Specify a different type
if (e.keyCode !== 9) {return;} // Listen for TAB key only
if (!modalRef.current) {return;}
// Collect focusable items inside the modal
}
};
const handleLogoClick = (event: LogoClickEvent) => {

Check warning on line 64 in kahuna/public/js/components/gr-my-uploads/gr-my-uploads.tsx

GitHub Actions / CI

'event' is defined but never used
setMyUploads(false);
};
const NotificationsBanner: React.FC = () => {
const [notifications, setNotifications] = useState<Notification[]>([]);
const autoHideListener = (event: any) => {

Check warning on line 119 in kahuna/public/js/components/gr-notifications-banner/gr-notifications-banner.tsx

GitHub Actions / CI

Unexpected any. Specify a different type
if (event.type === "keydown" && event.key === "Escape") {
setNotifications(prevNotifs => prevNotifs.filter(n => n.lifespan !== TRANSIENT));
} else if (event.type !== "keydown") {
});
};
const newNotification = (event:any) => {

Check warning on line 154 in kahuna/public/js/components/gr-notifications-banner/gr-notifications-banner.tsx

GitHub Actions / CI

Unexpected any. Specify a different type
const notification = event.detail;
setNotifications(prev_notifs => mergeArraysByKey(prev_notifs, [notification], 'announceId'));
};
const [selectedOption, setSelection] = useState(defPerms);
const [currentIndex, setCurrentIndex] = useState(-1);
const autoHideListener = (event: any) => {

Check warning on line 91 in kahuna/public/js/components/gr-permissions-filter/gr-permissions-filter.tsx

GitHub Actions / CI

Unexpected any. Specify a different type
if (event.type === "keydown" && event.key === "Escape") {
setIsOpen(false);
} else if (event.type !== "keydown") {
const [selectedOption, setSelection] = useState(defSort);
const [currentIndex, setCurrentIndex] = useState(-1);
const autoHideListener = (event: any) => {

Check warning on line 81 in kahuna/public/js/components/gr-sort-control/gr-sort-control.tsx

GitHub Actions / CI

Unexpected any. Specify a different type
if (event.type === "keydown" && event.key === "Escape") {
setIsOpen(false);
} else if (event.type !== "keydown") {
}
};
const handleQueryChange = (e: any) => {

Check warning on line 115 in kahuna/public/js/components/gr-sort-control/gr-sort-control.tsx

GitHub Actions / CI

Unexpected any. Specify a different type
const newQuery = e.detail.query ? (" " + e.detail.query) : "";
setHasCollection(checkForCollection(newQuery));
};
const handleLogoClick = (e: any) => {

Check warning on line 120 in kahuna/public/js/components/gr-sort-control/gr-sort-control.tsx

GitHub Actions / CI

'e' is defined but never used
setSelection(defSort);
};