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

Fixes #23286 - Add confirmation dialog on delete manifest #7365

Merged
merged 1 commit into from
May 15, 2018

Conversation

johnpmitsch
Copy link
Contributor

No description provided.

@theforeman-bot
Copy link

Issues: #23286

@theforeman-bot
Copy link

There were the following issues with the commit message:

  • length of the first commit message line for 8e3b976 exceeds 65 characters

If you don't have a ticket number, please create an issue in Redmine.

More guidelines are available in Coding Standards or on the Foreman wiki.


This message was auto-generated by Foreman's prprocessor

onConfirm={() => this.hideModal()}
onCancel={() => this.showCancelConfirm(false)}
/>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trailing spaces not allowed no-trailing-spaces

@johnpmitsch
Copy link
Contributor Author

To review: go to new subscriptions page and click "manage manifest" button. Close the modal and you should see another modal confirming you want to exit the modal.

@johnpmitsch
Copy link
Contributor Author

@waldenraines @tstrachota: one loophole I found with this change is that you can click outside of a modal to dismiss it, which will just exit and wont trigger the "confirm you want to exit" dialog modal.

@johnpmitsch
Copy link
Contributor Author

I misunderstood the issue, marking this WIP while I update correctly. Please disregard my earlier question :)

@waldenraines
Copy link
Contributor

As discussed on IRC this modal is supposed to be displayed when delete is clicked to confirm the manifest deletion itself. There is actually no way to not save your changes from within the modal itself since everything is saved on change.

}}
confirmLabel={__('Delete')}
confirmStyle={"danger"}
onConfirm={() => this.deleteManifest() }

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There should be no space before '}' react/jsx-curly-spacing

)
}}
confirmLabel={__('Delete')}
confirmStyle={"danger"}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Curly braces are unnecessary here react/jsx-curly-brace-presence
Strings must use singlequote quotes

dangerouslySetInnerHTML={{
__html: sprintf(
__(DeleteManifestModalText)
)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unexpected newline before ')' function-paren-newline
Missing trailing comma comma-dangle

title={__('Confirm delete manifest')}
dangerouslySetInnerHTML={{
__html: sprintf(
__(DeleteManifestModalText)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing trailing comma comma-dangle

show={this.state.showDeleteManifestModalDialog}
title={__('Confirm delete manifest')}
dangerouslySetInnerHTML={{
__html: sprintf(

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unexpected newline after '(' function-paren-newline

@@ -56,6 +60,13 @@ class ManageManifestModal extends Component {

deleteManifest() {
this.props.deleteManifest().then(this.props.loadOrganization);
this.showDeleteManifestModal(false)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing semicolon semi

@@ -5,13 +5,17 @@ import { bindMethods, Alert, Button, Icon, Modal, ProgressBar, Spinner, OverlayT
import TooltipButton from 'react-bootstrap-tooltip-button';
import { Table } from '../../../move_to_foreman/components/common/table';
import { columns } from './ManifestHistoryTableSchema';
import ConfirmDialog from '../../../move_to_foreman/components/common/ConfirmDialog';
import DeleteManifestModalText from "./DeleteManifestModalText";
import { sprintf } from 'jed';

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Absolute imports should come before relative imports import/first

@@ -5,13 +5,17 @@ import { bindMethods, Alert, Button, Icon, Modal, ProgressBar, Spinner, OverlayT
import TooltipButton from 'react-bootstrap-tooltip-button';
import { Table } from '../../../move_to_foreman/components/common/table';
import { columns } from './ManifestHistoryTableSchema';
import ConfirmDialog from '../../../move_to_foreman/components/common/ConfirmDialog';
import DeleteManifestModalText from "./DeleteManifestModalText";

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Strings must use singlequote quotes

@@ -43,6 +44,7 @@ ConfirmDialog.defaultProps = {
cancelLabel: __('Cancel'),
dangerouslySetInnerHTML: undefined,
message: undefined,
confirmStyle: "primary",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Strings must use singlequote quotes

}}
confirmLabel={__('Delete')}
confirmStyle={"danger"}
onConfirm={() => this.deleteManifest() }

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There should be no space before '}' react/jsx-curly-spacing

)
}}
confirmLabel={__('Delete')}
confirmStyle={"danger"}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Curly braces are unnecessary here react/jsx-curly-brace-presence
Strings must use singlequote quotes

dangerouslySetInnerHTML={{
__html: sprintf(
__(DeleteManifestModalText)
)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unexpected newline before ')' function-paren-newline
Missing trailing comma comma-dangle

title={__('Confirm delete manifest')}
dangerouslySetInnerHTML={{
__html: sprintf(
__(DeleteManifestModalText)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing trailing comma comma-dangle

show={this.state.showDeleteManifestModalDialog}
title={__('Confirm delete manifest')}
dangerouslySetInnerHTML={{
__html: sprintf(

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unexpected newline after '(' function-paren-newline

@@ -56,6 +60,13 @@ class ManageManifestModal extends Component {

deleteManifest() {
this.props.deleteManifest().then(this.props.loadOrganization);
this.showDeleteManifestModal(false)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing semicolon semi

@@ -5,13 +5,17 @@ import { bindMethods, Alert, Button, Icon, Modal, ProgressBar, Spinner, OverlayT
import TooltipButton from 'react-bootstrap-tooltip-button';
import { Table } from '../../../move_to_foreman/components/common/table';
import { columns } from './ManifestHistoryTableSchema';
import ConfirmDialog from '../../../move_to_foreman/components/common/ConfirmDialog';
import DeleteManifestModalText from "./DeleteManifestModalText";
import { sprintf } from 'jed';

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Absolute imports should come before relative imports import/first

@@ -5,13 +5,17 @@ import { bindMethods, Alert, Button, Icon, Modal, ProgressBar, Spinner, OverlayT
import TooltipButton from 'react-bootstrap-tooltip-button';
import { Table } from '../../../move_to_foreman/components/common/table';
import { columns } from './ManifestHistoryTableSchema';
import ConfirmDialog from '../../../move_to_foreman/components/common/ConfirmDialog';
import DeleteManifestModalText from "./DeleteManifestModalText";

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Strings must use singlequote quotes

@@ -43,6 +44,7 @@ ConfirmDialog.defaultProps = {
cancelLabel: __('Cancel'),
dangerouslySetInnerHTML: undefined,
message: undefined,
confirmStyle: "primary",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Strings must use singlequote quotes

@johnpmitsch
Copy link
Contributor Author

@waldenraines I found the refresh/delete buttons were still enabled when there is no manifest imported, I filed an issue here: http://projects.theforeman.org/issues/23571

@johnpmitsch
Copy link
Contributor Author

@tstrachota @waldenraines: updated the modal to show on manifest delete. I'm using a large JSX block inside the modal, I'm not sure what the best way to handle translating that is?

@johnpmitsch johnpmitsch changed the title Fixes #23286 - Add confirmation dialog on manage subscription modal Fixes #23286 - Add confirmation dialog on delete manifest May 11, 2018
show={this.state.showDeleteManifestModalDialog}
title={__('Confirm delete manifest')}
dangerouslySetInnerHTML={{
__html: sprintf(__(DeleteManifestModalText)),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm afraid this is not going to work. AFAIK code isn't evaluated when the translations are being extracted.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BTW sprintf is useless here.

<li>Disable Red Hat Insights</li>
<li>Require you to upload the subscription-manifest and re-attach subscriptions to hosts and activation keys.</li>
</ul>
<p>This action should only be taken in extreme circumstances or for debugging purposes.</p>`;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about splitting it into three parts: "Are you sure..", "Note: ..." and "This action..." to get at least the paragraphs out of the translated text.

const l3 = __("Disable Red Hat Insights.");
const l4 = __("Require you to upload the subscription-manifest and re-attach \
subscriptions to hosts and activation keys.");
const debug = __("This action should only be taken in extreme circumstances or \

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Multiline support is limited to browsers supporting ES5 only no-multi-str
Strings must use singlequote quotes

const l1 = __("Delete all subscriptions that are attached to running hosts.");
const l2 = __("Delete all subscriptions attached to activation keys.");
const l3 = __("Disable Red Hat Insights.");
const l4 = __("Require you to upload the subscription-manifest and re-attach \

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Multiline support is limited to browsers supporting ES5 only no-multi-str
Strings must use singlequote quotes

Deleting a manifest will:");
const l1 = __("Delete all subscriptions that are attached to running hosts.");
const l2 = __("Delete all subscriptions attached to activation keys.");
const l3 = __("Disable Red Hat Insights.");

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Strings must use singlequote quotes

const note = __("Note: Deleting a subscription manifest is STRONGLY discouraged. \
Deleting a manifest will:");
const l1 = __("Delete all subscriptions that are attached to running hosts.");
const l2 = __("Delete all subscriptions attached to activation keys.");

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Strings must use singlequote quotes

const question = __("Are you sure you want to delete the manifest?");
const note = __("Note: Deleting a subscription manifest is STRONGLY discouraged. \
Deleting a manifest will:");
const l1 = __("Delete all subscriptions that are attached to running hosts.");

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Strings must use singlequote quotes

@@ -0,0 +1,22 @@
const question = __("Are you sure you want to delete the manifest?");
const note = __("Note: Deleting a subscription manifest is STRONGLY discouraged. \

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Multiline support is limited to browsers supporting ES5 only no-multi-str
Strings must use singlequote quotes

@@ -0,0 +1,22 @@
const question = __("Are you sure you want to delete the manifest?");

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Strings must use singlequote quotes

@johnpmitsch
Copy link
Contributor Author

Sorry about the hound notifications, I'm having trouble running npm run test locally

@johnpmitsch johnpmitsch force-pushed the 23286_delete_confirmation branch 2 times, most recently from 36a9922 to 24344d5 Compare May 14, 2018 15:34
@@ -3,15 +3,19 @@ import PropTypes from 'prop-types';
import { Col, Tabs, Tab, Form, FormGroup, FormControl, ControlLabel } from 'react-bootstrap';
import { bindMethods, Alert, Button, Icon, Modal, ProgressBar, Spinner, OverlayTrigger, Tooltip } from 'patternfly-react';
import TooltipButton from 'react-bootstrap-tooltip-button';
import { sprintf } from 'jed';

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'sprintf' is defined but never used no-unused-vars

@johnpmitsch
Copy link
Contributor Author

@waldenraines @tstrachota I updated to translate each string and then use it in the JSX, I'm not sure if that is the best solution but I'm open to suggestions 😸

@waldenraines
Copy link
Contributor

@waldenraines I found the refresh/delete buttons were still enabled when there is no manifest imported, I filed an issue here: http://projects.theforeman.org/issues/23571

Nice catch.

Copy link
Contributor

@waldenraines waldenraines left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@waldenraines @tstrachota I updated to translate each string and then use it in the JSX, I'm not sure if that is the best solution but I'm open to suggestions

Responded to this with a code comment below.

const DeleteManifestModalText = `<p>${question}</p>
<p>${note}</p>
<ul class="list-aligned">
<li>${l1}</li>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would something like this work?

<li>{__('Delete all subscriptions that are attached to running hosts.')}</li>

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like this is actually being evaluated as html so that won't work. When I tried <p>{__('does this work?')}</p>, it looks like this:
here

It makes sense since we are passing to dangerouslySetInnerHTML

Copy link
Contributor

@waldenraines waldenraines May 14, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It makes sense since we are passing to dangerouslySetInnerHTML

Oh, right. And same thing with this?

<p>${__('does this work?')}</p>

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, I wonder if we should update the Dialog component to accept children too. That would probably solve the problem because we could easily pass array of components instead of a string.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a good thought but I'd want to do it outside of this PR. Since the above works I am fine merging as is and then fixing this later. See http://projects.theforeman.org/issues/23600

@waldenraines
Copy link
Contributor

[test katello]

1 similar comment
@waldenraines
Copy link
Contributor

[test katello]

@waldenraines waldenraines merged commit e8ff2f4 into Katello:master May 15, 2018
@johnpmitsch johnpmitsch deleted the 23286_delete_confirmation branch May 16, 2018 05:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants