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

Saleor 1906 user should be able to delete a channel if there are no orders associated with it #901

Conversation

MarekChoinski
Copy link
Contributor

I want to merge this change because... it

  • fixes bug with deleting channels when hasOrders was false
  • adds "DELETE" button on detail page of channel

PR intended to be tested with API branch:

Screenshots

image

Pull Request Checklist

  1. All visible strings are translated with proper context.
  2. All data-formatting is locale-aware (dates, numbers, and so on).
  3. Translated strings are extracted.
  4. Number of API calls is optimized.
  5. The changes are tested.
  6. Data-test are added for new elements.
  7. Type definitions are up to date.
  8. Changes are mentioned in the changelog.

Test environment config

API_URI=https://master.staging.saleor.rocks/graphql/

@github-actions github-actions bot temporarily deployed to saleor-1906-user-should-be-able-to-create-a-channel-if-there-ar December 14, 2020 10:51 Inactive
@github-actions github-actions bot temporarily deployed to storybook saleor-1906-user-should-be-able-to-create-a-channel-if-there-ar December 14, 2020 10:51 Inactive
@github-actions github-actions bot temporarily deployed to saleor-1906-user-should-be-able-to-create-a-channel-if-there-ar December 14, 2020 11:01 Inactive
@github-actions github-actions bot temporarily deployed to storybook saleor-1906-user-should-be-able-to-create-a-channel-if-there-ar December 14, 2020 11:01 Inactive
Copy link
Member

@krzysztofwolski krzysztofwolski left a comment

Choose a reason for hiding this comment

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

One change, besides that, LGTM

@@ -42,52 +44,56 @@ const ChannelDeleteDialog: React.FC<ChannelDeleteDialogProps> = ({
confirmButtonState={confirmButtonState}
open={open}
onClose={onClose}
onConfirm={() => (hasChannels ? onConfirm(choice) : onBack())}
onConfirm={() =>
hasChannels || !hasOrders ? onConfirm(choice) : onBack()
Copy link
Member

Choose a reason for hiding this comment

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

It seems to be reused multiple times. How about :
const canBeDeleted = hasChannels || !hasOrders

@github-actions github-actions bot temporarily deployed to saleor-1906-user-should-be-able-to-create-a-channel-if-there-ar December 14, 2020 17:00 Inactive
@github-actions github-actions bot temporarily deployed to storybook saleor-1906-user-should-be-able-to-create-a-channel-if-there-ar December 14, 2020 17:00 Inactive
src/channels/index.tsx Outdated Show resolved Hide resolved
<>
<Typography>
<FormattedMessage
defaultMessage="All order information from this channel need to be moved to a different channel. Please select channel orders need to be moved to:."
Copy link
Contributor

Choose a reason for hiding this comment

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

There are quite some long messages in this component, would rather want to have them in defineMessages somewhere above, so they don't stand out so much (especially considering the line length) in the component code itself

onCompleted
});

const channelsChoices = id
Copy link
Contributor

Choose a reason for hiding this comment

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

Seems close enough copy pasted from src/channels/views/ChannelsList/ChannelsList.tsx - can we make a utils function (like getParsedChannelsChoices or something similar) out of this?

: [];

const handleRemoveConfirm = (targetChannelId?: string) => {
if (targetChannelId) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Don't think we need and if/else here, since the same action happens in both cases, maybe we can simplify:

Suggested change
if (targetChannelId) {
const data = targetChannelId
? { id, input: { targetChannel: targetChannelId } }
: { id }
deleteChannel({ variables: data })

deleteChannel({
variables: { id: params.id, input: { targetChannel: id } }
});
const handleRemoveConfirm = (targetChannelId?: string) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Same as above

@github-actions github-actions bot temporarily deployed to saleor-1906-user-should-be-able-to-create-a-channel-if-there-ar December 16, 2020 10:11 Inactive
@github-actions github-actions bot temporarily deployed to storybook saleor-1906-user-should-be-able-to-create-a-channel-if-there-ar December 16, 2020 10:11 Inactive
@github-actions github-actions bot temporarily deployed to saleor-1906-user-should-be-able-to-create-a-channel-if-there-ar December 16, 2020 14:47 Inactive
@github-actions github-actions bot temporarily deployed to storybook saleor-1906-user-should-be-able-to-create-a-channel-if-there-ar December 16, 2020 14:47 Inactive
@github-actions github-actions bot temporarily deployed to saleor-1906-user-should-be-able-to-create-a-channel-if-there-ar December 16, 2020 14:56 Inactive
@github-actions github-actions bot temporarily deployed to storybook saleor-1906-user-should-be-able-to-create-a-channel-if-there-ar December 16, 2020 14:56 Inactive
@dominik-zeglen dominik-zeglen changed the title Saleor 1906 user should be able to create a channel if there are no orders associated with it Saleor 1906 user should be able to delete a channel if there are no orders associated with it Jan 12, 2021
src/channels/utils.ts Outdated Show resolved Hide resolved
@MarekChoinski MarekChoinski force-pushed the SALEOR-1906-user-should-be-able-to-create-a-channel-if-there-are-no-orders-associated-with-it branch from 5e4db93 to 4f58c2e Compare January 12, 2021 12:44
@github-actions github-actions bot temporarily deployed to saleor-1906-user-should-be-able-to-create-a-channel-if-there-ar January 12, 2021 12:44 Inactive
@jwm0 jwm0 merged commit 3f5cacb into master Jan 12, 2021
@jwm0 jwm0 deleted the SALEOR-1906-user-should-be-able-to-create-a-channel-if-there-are-no-orders-associated-with-it branch January 12, 2021 14:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants