diff --git a/js/components/__tests__/__snapshots__/confirmation_popover.test.js.snap b/js/components/__tests__/__snapshots__/confirmation_popover.test.js.snap new file mode 100644 index 00000000..232dfb2f --- /dev/null +++ b/js/components/__tests__/__snapshots__/confirmation_popover.test.js.snap @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`ConfirmationPopover matches snapshot 1`] = ` `; diff --git a/js/components/__tests__/confirmation_popover.test.js b/js/components/__tests__/confirmation_popover.test.js new file mode 100644 index 00000000..d82564e5 --- /dev/null +++ b/js/components/__tests__/confirmation_popover.test.js @@ -0,0 +1,22 @@ +import { shallowMount } from '@vue/test-utils' + +import ConfirmationPopover from '../confirmation_popover' + + +describe('ConfirmationPopover', () => { + it('matches snapshot', () => { + const wrapper = shallowMount(ConfirmationPopover, { + propsData: { + action: '/some-url', + btn_text: 'Do something dangerous', + cancel_btn_text: 'Cancel', + confirm_btn_text: 'Confirm', + confirm_msg: 'Are you sure you want to do that?', + csrf_token: '42' + } + }) + + expect(wrapper).toMatchSnapshot() + }) +}) + diff --git a/js/components/confirmation_popover.js b/js/components/confirmation_popover.js new file mode 100644 index 00000000..5bccc719 --- /dev/null +++ b/js/components/confirmation_popover.js @@ -0,0 +1,32 @@ +export default { + name: 'confirmation-popover', + + props: { + action: String, + btn_text: String, + cancel_btn_text: String, + confirm_btn_text: String, + confirm_msg: String, + csrf_token: String + }, + + template: ` + + + + + ` +} diff --git a/js/index.js b/js/index.js index 4edd4c08..2d5b9ff2 100644 --- a/js/index.js +++ b/js/index.js @@ -23,6 +23,7 @@ import CcpoApproval from './components/forms/ccpo_approval' import MembersList from './components/forms/members_list' import LocalDatetime from './components/local_datetime' import RequestsList from './components/forms/requests_list' +import ConfirmationPopover from './components/confirmation_popover' Vue.config.productionTip = false @@ -50,6 +51,7 @@ const app = new Vue({ EditEnvironmentRole, EditProjectRoles, RequestsList, + ConfirmationPopover, }, mounted: function() { diff --git a/templates/components/confirmation_button.html b/templates/components/confirmation_button.html index 71b15a3b..31db3355 100644 --- a/templates/components/confirmation_button.html +++ b/templates/components/confirmation_button.html @@ -1,19 +1,10 @@ -{% macro ConfirmationButton(btn_text, action, csrf_token, confirm_msg="Are you sure?", confirm_btn="Confirm", cancel_btn="Cancel") -%} - - - - +{% macro ConfirmationButton(btn_text, action, confirm_msg="Are you sure?", confirm_btn="Confirm", cancel_btn="Cancel") -%} + + {%- endmacro %} diff --git a/templates/workspaces/members/edit.html b/templates/workspaces/members/edit.html index 0c1e8f7a..0b609e5b 100644 --- a/templates/workspaces/members/edit.html +++ b/templates/workspaces/members/edit.html @@ -44,14 +44,12 @@ {{ ConfirmationButton( "Revoke Invitation", url_for("workspaces.revoke_invitation", workspace_id=workspace.id, token=member.latest_invitation.token), - form.csrf_token ) }} {% endif %} {% if member.can_resend_invitation %} {{ ConfirmationButton ( "Resend Invitation", url_for("workspaces.resend_invitation", workspace_id=workspace.id, token=member.latest_invitation.token), - form.csrf_token, confirm_msg="Are you sure? This will send an email to invite the user to join this workspace." )}} {% endif %}