mirror of
https://github.com/simstudioai/sim.git
synced 2026-09-24 15:45:35 +08:00
fix(sso): keep an exit affordance in edit mode when clean (#5247)
After clicking Edit on an existing SSO provider, the only header action was SaveDiscardActions, which renders nothing when the form is clean — so there was no way to leave edit mode back to the read-only summary without first changing a field or navigating away. Render a Cancel chip when isEditing && !hasChanges (the dirty-gated Discard already exits when there are changes).
This commit is contained in:
@@ -6,6 +6,7 @@ import { getErrorMessage } from '@sim/utils/errors'
|
||||
import { Check, ChevronDown, Clipboard, Eye, EyeOff } from 'lucide-react'
|
||||
import {
|
||||
Button,
|
||||
Chip,
|
||||
ChipCombobox,
|
||||
ChipInput,
|
||||
ChipSelect,
|
||||
@@ -535,15 +536,22 @@ export function SSO() {
|
||||
|
||||
<SettingsPanel
|
||||
actions={
|
||||
<SaveDiscardActions
|
||||
dirty={hasChanges}
|
||||
saving={configureSSOMutation.isPending}
|
||||
saveDisabled={hasAnyErrors(errors) || !isFormValid()}
|
||||
saveLabel={isEditing ? 'Update' : 'Save'}
|
||||
savingLabel={isEditing ? 'Updating...' : 'Saving...'}
|
||||
onSave={() => void handleSubmit()}
|
||||
onDiscard={handleDiscard}
|
||||
/>
|
||||
<>
|
||||
{isEditing && !hasChanges && (
|
||||
<Chip onClick={handleDiscard} disabled={configureSSOMutation.isPending}>
|
||||
Cancel
|
||||
</Chip>
|
||||
)}
|
||||
<SaveDiscardActions
|
||||
dirty={hasChanges}
|
||||
saving={configureSSOMutation.isPending}
|
||||
saveDisabled={hasAnyErrors(errors) || !isFormValid()}
|
||||
saveLabel={isEditing ? 'Update' : 'Save'}
|
||||
savingLabel={isEditing ? 'Updating...' : 'Saving...'}
|
||||
onSave={() => void handleSubmit()}
|
||||
onDiscard={handleDiscard}
|
||||
/>
|
||||
</>
|
||||
}
|
||||
>
|
||||
<div className='flex flex-col gap-4.5'>
|
||||
|
||||
Reference in New Issue
Block a user