Modals > HAML > Replace `data-confirm` modals with `GlModal`
We need to replace all `data-confirm` modals in HAML files with `GlModal` implementation. One instance was found by: ```shell: find app ee/app -type f -name "*.haml" | xargs grep -n "data-confirm" ``` and the rest were found by: ```shell: find app ee/app -type f -name "*.haml" | xargs grep -n -E "data:\s*\{.*confirm:" ``` ### Migration strategy :footprints: :footprints: :footprints: :footprints: :footprints: :footprints: :footprints: :footprints: :footprints: :footprints: :shamrock: If you're lucky enough, you should not write any code here. Rather check that the given confirmation modal instance works as expected. :handshake: But you can help us add functionality that is not supported if you know of such cases. :nerd: All elements that have `data-confirm` attribute are handled but `Rails.confirm` which in its original implementation uses `window.confrm` and displays `data-confirm` attribute value as a confirmation modal message. We overwrite `Rails.confirm` implementation so that it displays `GlModal` instead. If you're interested in the implementation details - check [this MR](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/73167). This solution was generously provided to us by `@leipert` :footprints: The code that replaces `Rails.confirm` implementation is currently behind the ~"feature flag" so first you'll have to enable it on your local environment running in Rails console: ```shell: Feature.enable(:bootstrap_confirmation_modals) ``` :footprints: Locate the page where the modal is displayed, make sure that the confirmation modal is displayed, and that it triggers the correct action on `Ok` button click. If not - **fix it**. :footprints: By default, the `OK` button variant in the confirmation modal is `confirm`. But you can change it by providing `data-confirm-btn-variant` attribute on the element that triggers the button, e.g. ```html: <button data-confirm="Are you sure?" data-confirm-btn-variant="danger">Delete</button> ``` Also, if the triggering element (the one that has `data-confirm="confirmationMessage"`) has a child element that has CSS class `gl-sr-only` or `sr-only` or the attribute `aria-label`, its text content or value will be adopted as a confirmation button text. E.g. ```html: <button data-confirm="Are you sure?" aria-label="Delete branch" type="button" class="btn btn-danger btn-md gl-button btn-icon"></button> ``` will display a modal with confirm button text set to `Delete branch` :footprints: Take the screenshot and paste it into the issue description :footprints: Do not worry about the `rspecs`. Currently, each file that tests `window.confirm` has `stub_feature_flags(bootstrap_confirmation_modals: false)` as the FFs are enabled by default on the testing environment and will fail until fixed. All specs will be fixed at once in scope of [this MR](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/75033) replacing Capybara's `accept_confirm` with our new helper [`accept_gl_confirm`](https://docs.gitlab.com/ee/development/testing_guide/best_practices.html#interacting-with-modals). :footprints: In case current confirmation modal implementation lacks any functionality - let us (`@ohoral`, `@leipert` `@markrian` `@mikegreiling`) know or feel free to improve it yourself and still let us know and/or assign for MR review :wink: :footprints: If all works fine - close the issue. Thank you! :handshake: <details> <summary>Example instances of confirms</summary> ### The list of some instances (but not ALL) with the links to related pages ##### http://localhost:3000/admin/users &rarr; `Block` ![Screen_Shot_2017-12-19_at_14.00.37](/uploads/50c8f9d515de8928fa26aa6cc814682a/Screen_Shot_2017-12-19_at_14.00.37.png) ##### http://localhost:3000/admin/users (after entering 20 times wrong password) &rarr; `Unlock` ![Screen_Shot_2017-12-19_at_14.53.36](/uploads/85613beb97873e4b8b760c9dc03d4033/Screen_Shot_2017-12-19_at_14.53.36.png) ##### http://localhost:3000/admin/appearance &rarr; `Remove header logo` ![Screen_Shot_2017-12-19_at_14.03.19](/uploads/3054eafa8b8b1e5ab6f97cdea7a8b662/Screen_Shot_2017-12-19_at_14.03.19.png) ##### http://localhost:3000/admin/appearance &rarr; `Remove logo` ![Screen_Shot_2017-12-19_at_14.03.27](/uploads/fbdcca99017b56a586458e07a434925a/Screen_Shot_2017-12-19_at_14.03.27.png) ##### http://localhost:3000/admin/application_settings &rarr; `Clear all repository checks` ![Screen_Shot_2017-12-19_at_14.05.54](/uploads/e53902485060bbfd99f99c49ed7613df/Screen_Shot_2017-12-19_at_14.05.54.png) ##### http://localhost:3000/admin/deploy_keys &rarr; `Remove` ![Screen_Shot_2017-12-19_at_14.08.05](/uploads/cbd3678c930f7bc9f2e2e9905b7673dc/Screen_Shot_2017-12-19_at_14.08.05.png) ##### http://localhost:3000/admin/health_check &rarr; `Reset health check access token` ![Screen_Shot_2017-12-19_at_14.11.09](/uploads/882240815f21616cbdd3713cb0800941/Screen_Shot_2017-12-19_at_14.11.09.png) ##### http://localhost:3000/admin/hooks &rarr; `Remove` ![Screen_Shot_2017-12-19_at_14.12.42](/uploads/074832a12afdd37c17995c22fb816ad5/Screen_Shot_2017-12-19_at_14.12.42.png) ##### http://localhost:3000/admin/hooks/1/edit &rarr; `Remove` ![Screen_Shot_2017-12-19_at_14.12.42](/uploads/c0414e7a0c2e30f404d4c0f7ee3c646b/Screen_Shot_2017-12-19_at_14.12.42.png) ##### http://localhost:3000/admin/users/john/identities (for LDAP user) &rarr; `Delete` ![Screen_Shot_2017-12-19_at_14.17.59](/uploads/72019e720d587f6bd7a729f6f02d1f77/Screen_Shot_2017-12-19_at_14.17.59.png) ##### http://localhost:3000/admin/users/john/impersonation_tokens &rarr; `Revoke` ![Screen_Shot_2017-12-19_at_14.19.36](/uploads/f470fdbb22a55b61d9ed455571956ff7/Screen_Shot_2017-12-19_at_14.19.36.png) ##### http://localhost:3000/admin/users/john/keys &rarr; ![Screen_Shot_2017-12-19_at_14.23.40](/uploads/6d9ec1250d343ca8674091911526272e/Screen_Shot_2017-12-19_at_14.23.40.png) ![Screen_Shot_2017-12-19_at_14.22.50](/uploads/2ad93055e3122bf1ca037f7ef6b95d73/Screen_Shot_2017-12-19_at_14.22.50.png) ##### http://localhost:3000/admin/users/john/projects &rarr; ![Screen_Shot_2017-12-19_at_14.25.54](/uploads/3568542d49cef160cd57c5e583121a85/Screen_Shot_2017-12-19_at_14.25.54.png) (on group) ![Screen_Shot_2017-12-19_at_14.57.34](/uploads/7dabe6bbcb3b686f670e94838a248dab/Screen_Shot_2017-12-19_at_14.57.34.png) #### http://localhost:3000/admin/users/john/projects &rarr; ![Screen_Shot_2017-12-19_at_14.25.54](/uploads/e73d65d32d9bd4a5acb3a2db9a023add/Screen_Shot_2017-12-19_at_14.25.54.png) (on project) ![Screen_Shot_2017-12-19_at_14.29.01](/uploads/2f37d189d5419632f09ac31a4d19964a/Screen_Shot_2017-12-19_at_14.29.01.png) #### http://localhost:3000/admin/users/john (for blocked user) &rarr; `Unblock user` ![Screen_Shot_2017-12-19_at_14.53.36](/uploads/30bef12a168c53362e156fb58762b35e/Screen_Shot_2017-12-19_at_14.53.36.png) #### http://localhost:3000/admin/users/john (after entering 20 times wrong password) &rarr; `Unlock user` ![Screen_Shot_2017-12-19_at_14.53.36](/uploads/71a06c6c08a7530fe9b117310dcd7e68/Screen_Shot_2017-12-19_at_14.53.36.png) #### http://localhost:3000/admin/users/john &rarr; ![Screen_Shot_2017-12-19_at_15.02.58](/uploads/fa9ec58df4e3fe104bc2ed80f7086d19/Screen_Shot_2017-12-19_at_15.02.58.png) (on secondary email) ![Screen_Shot_2017-12-19_at_15.02.29](/uploads/8e1bf355dbc7530d2379c234b549e771/Screen_Shot_2017-12-19_at_15.02.29.png) #### http://localhost:3000/admin/users/john &rarr; `Disable` (Two-factor Authentication) ![Screen_Shot_2017-12-19_at_15.08.26](/uploads/d50cb292464f9b65b3282eacc37a9b25/Screen_Shot_2017-12-19_at_15.08.26.png) #### http://localhost:3000/admin/users/john &rarr; `Confirm user` (for unconfirmed e-mail address) ![Screen_Shot_2017-12-19_at_15.13.16](/uploads/ee71ef49b297e5d667ed4f6ef3fb2714/Screen_Shot_2017-12-19_at_15.13.16.png) #### http://localhost:3000/admin/labels &rarr; `Delete` ![Screen_Shot_2017-12-19_at_14.34.17](/uploads/2da737c858e624a0926e81e02b0b3f66/Screen_Shot_2017-12-19_at_14.34.17.png) #### http://localhost:3000/admin/runners &rarr; ![Screen_Shot_2017-12-19_at_14.36.31](/uploads/bba0060244eeb36029b5b3815238ef1c/Screen_Shot_2017-12-19_at_14.36.31.png) ![Screen_Shot_2017-12-19_at_14.36.39](/uploads/cc465bf50ae6d3be57cad5914e397948/Screen_Shot_2017-12-19_at_14.36.39.png) #### http://localhost:3000/admin/runners &rarr; ![Screen_Shot_2017-12-19_at_14.36.35](/uploads/755552a58475dc1e31f69db883718ca6/Screen_Shot_2017-12-19_at_14.36.35.png) ![Screen_Shot_2017-12-19_at_14.36.39](/uploads/3ebd2b0155422aed2dc7a5f9955fc985/Screen_Shot_2017-12-19_at_14.36.39.png) #### http://localhost:3000/admin/runners &rarr; `Reset runners registration token` ![Screen_Shot_2017-12-19_at_14.37.54](/uploads/383681ff920047d8cf2b0d44e6c57385/Screen_Shot_2017-12-19_at_14.37.54.png) #### http://localhost:3000/admin/abuse_reports &rarr; `Remove user & report` ![Screen_Shot_2017-12-19_at_14.40.06](/uploads/325e7968356a1472becfa1f27a091154/Screen_Shot_2017-12-19_at_14.40.06.png) #### http://localhost:3000/admin/abuse_reports &rarr; `Block user` ![Screen_Shot_2017-12-19_at_14.40.30](/uploads/4e4546e8061df86a25baaf7b83d35a84/Screen_Shot_2017-12-19_at_14.40.30.png) #### http://localhost:3000/gitlab-org/gitlab-ce/settings/ci_cd &rarr; ![Screen_Shot_2017-12-19_at_15.17.55](/uploads/7d8f8983e50b844925ae4d6e4acc2376/Screen_Shot_2017-12-19_at_15.17.55.png) (Secret variables) ![Screen_Shot_2017-12-19_at_15.18.01](/uploads/afe9e8cc85f2b5b04215ff9809c0d64e/Screen_Shot_2017-12-19_at_15.18.01.png) #### http://localhost:3000/profile/account &rarr; `Disable` (Two-Factor Authentication) ![Screen_Shot_2017-12-19_at_15.06.49](/uploads/390e643d29ea3d9541b1a5b90e9cc609/Screen_Shot_2017-12-19_at_15.06.49.png) #### http://localhost:3000/profile/emails &rarr; ![Screen_Shot_2017-12-19_at_15.01.35](/uploads/4c77b9ccd3690e516091ab204582610b/Screen_Shot_2017-12-19_at_15.01.35.png) ![Screen_Shot_2017-12-19_at_15.01.51](/uploads/140f62cd95ffd67469637d00d6251d10/Screen_Shot_2017-12-19_at_15.01.51.png) #### http://localhost:3000/profile/keys/1 &rarr; `Remove` ![Screen_Shot_2017-12-19_at_14.22.00](/uploads/64f656ddc764c510bd78fdc5818fd4b5/Screen_Shot_2017-12-19_at_14.22.00.png) </summary>
epic