Skip to content

Commit

Permalink
Introduce WaitIt button
Browse files Browse the repository at this point in the history
  • Loading branch information
misery committed Aug 30, 2024
1 parent 189a8ff commit 2b8ce23
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 22 deletions.
6 changes: 3 additions & 3 deletions extended_approval/extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ class ExtendedApproval(Extension):
js_bundles = {
'default': {
'source_filenames': (
'js/extension.js',
'js/extension.ts',
),
}
}
Expand All @@ -460,7 +460,7 @@ class ExtendedApproval(Extension):
CONFIG_ENABLE_REVOKE_SHIPITS: False,
CONFIG_ENABLE_TARGET_SHIPITS: False,
CONFIG_ENABLE_LEGACY_BUTTONS: False,
# CONFIG_ENABLE_WAIT_IT_BUTTON: False,
CONFIG_ENABLE_WAIT_IT_BUTTON: False,
CONFIG_FORBIDDEN_USER_SHIPITS: '',
CONFIG_FORBIDDEN_APPROVE_PREFIXES: 'WIP|work in progress',
CONFIG_FORBIDDEN_APPROVE_SUFFIXES: '',
Expand All @@ -480,8 +480,8 @@ def initialize(self):
AdvancedPingItAction(self.settings),
AdvancedLegacyEditReviewAction(self.settings),
AdvancedLegacyAddGeneralCommentAction(self.settings),
AdvancedLegacyWaitItAction(self.settings),
AdvancedLegacyShipItAction(self.settings),
# AdvancedLegacyWaitItAction(self.settings),
])

self._init_dict(CONFIG_FORBIDDEN_APPROVE_PREFIXES)
Expand Down
8 changes: 4 additions & 4 deletions extended_approval/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ class ExtendedApprovalSettingsForm(SettingsForm):
label='Show legacy buttons on review request',
help_text=('Shows old "Review", "General Comment" and "ShipIt".'))

# enable_wait_it_button = BooleanField(
# required=False,
# label='Show "Wait It" button on review request',
# help_text=('Shows custom "ShipIt" button with added issue.'))
enable_wait_it_button = BooleanField(
required=False,
label='Show "Wait It" button on review request',
help_text=('Shows custom "ShipIt" button with added issue.'))

forbidden_user_shipits = CharField(
required=False,
Expand Down
15 changes: 0 additions & 15 deletions extended_approval/static/js/extension.js

This file was deleted.

40 changes: 40 additions & 0 deletions extended_approval/static/js/extension.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
const ActionView = Spina.spina(class extends RB.Actions.ActionView {
static events = {
'click': 'waitIt',
}

async waitIt(e?: JQuery.ClickEvent) {
if (e) {
e.preventDefault();
e.stopPropagation();
}

if (confirm(_`Are you sure you want to ShipIt?`)) {
const page = RB.PageManager.getPage();
const pageModel = page.model;

const pendingReview = pageModel.get('pendingReview')
await pendingReview.ready();
pendingReview.set({
bodyTop: _`Ship It!`,
shipIt: true,
});

const comment = pendingReview.createGeneralComment(undefined, true);
comment.set({
text: _`Wait for CI!`,
});
await comment.save();

await pendingReview.publish();
const reviewRequest = pageModel.get('reviewRequest');
RB.navigateTo(reviewRequest.get('reviewURL'));
}

return false;
}
});

ExtendedApprovalExtension = {
ActionView,
}

0 comments on commit 2b8ce23

Please sign in to comment.