-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Saleor 1906 user should be able to delete a channel if there are no orders associated with it #901
Conversation
There was a problem hiding this 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() |
There was a problem hiding this comment.
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
<> | ||
<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:." |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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:
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) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above
5e4db93
to
4f58c2e
Compare
I want to merge this change because... it
hasOrders
wasfalse
PR intended to be tested with API branch:
Screenshots
Pull Request Checklist
Test environment config
API_URI=https://master.staging.saleor.rocks/graphql/