error when policy toggled but not selected (#31200)

Этот коммит содержится в:
Ibrahim Serdar Acikgoz
2025-05-29 08:13:03 +02:00
коммит произвёл GitHub
родитель d38c27f96f
Коммит 81d3273bc7
2 изменённых файлов: 26 добавлений и 14 удалений

Просмотреть файл

@@ -579,24 +579,35 @@ export default class ChannelDetails extends React.PureComponent<ChannelDetailsPr
actions.setNavigationBlocked(saveNeeded); actions.setNavigationBlocked(saveNeeded);
return; return;
} }
}
if (accessControlPolicies.length > 0) { if (accessControlPolicies.length === 0) {
await actions.assignChannelToAccessControlPolicy(accessControlPolicies[0].id, channelID).catch((error) => { serverError = (
this.setState({ <FormError
serverError: <FormError error={error.message}/>, error={
saving: false, <FormattedMessage
saveNeeded: true, id='admin.channel_details.policy_required_error'
defaultMessage='You must select an access policy when attribute-based channel access is enabled.'
/>}
/>
);
saveNeeded = true;
this.setState({serverError, saving: false, saveNeeded});
actions.setNavigationBlocked(saveNeeded);
return;
}
if (accessControlPolicies.length > 0) {
await actions.assignChannelToAccessControlPolicy(accessControlPolicies[0].id, channelID).catch((error) => {
serverError = <FormError error={error.message}/>;
saveNeeded = true;
}); });
actions.setNavigationBlocked(true); }
});
} else { } else {
await actions.deleteAccessControlPolicy(channelID).catch((error) => { await actions.deleteAccessControlPolicy(channelID).catch((error) => {
this.setState({ if (error.message && !error.message.includes('not found')) {
serverError: <FormError error={error.message}/>, serverError = <FormError error={error.message}/>;
saving: false, saveNeeded = true;
saveNeeded: true, }
});
}); });
} }

Просмотреть файл

@@ -531,6 +531,7 @@
"admin.cacheSettings.redisPasswordDesc": "The password of the Redis server.", "admin.cacheSettings.redisPasswordDesc": "The password of the Redis server.",
"admin.cacheSettings.title": "Cache Settings", "admin.cacheSettings.title": "Cache Settings",
"admin.channel_details.policy_public_error": "You cannot assign a policy to a public channel.", "admin.channel_details.policy_public_error": "You cannot assign a policy to a public channel.",
"admin.channel_details.policy_required_error": "You must select an access policy when attribute-based channel access is enabled.",
"admin.channel_details.policy_synced_error": "You cannot assign a policy to a synced channel.", "admin.channel_details.policy_synced_error": "You cannot assign a policy to a synced channel.",
"admin.channel_list.archived": "Archived", "admin.channel_list.archived": "Archived",
"admin.channel_list.attributed_based": "Attribute Based", "admin.channel_list.attributed_based": "Attribute Based",