-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into refactor-external-dns
- Loading branch information
Showing
88 changed files
with
1,334 additions
and
3,914 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,111 +1,80 @@ | ||
import { Button } from '@equinor/eds-core-react'; | ||
import * as PropTypes from 'prop-types'; | ||
import { FunctionComponent } from 'react'; | ||
|
||
import { | ||
AlertingConfigModel, | ||
AlertingConfigModelValidationMap, | ||
} from '../../models/radix-api/alerting/alerting-config'; | ||
import { | ||
UpdateAlertingConfigModel, | ||
UpdateAlertingConfigModelValidationMap, | ||
} from '../../models/radix-api/alerting/update-alerting-config'; | ||
|
||
import './style.css'; | ||
import { AlertingConfig } from '../../store/radix-api'; | ||
|
||
export const AlertingActions: FunctionComponent<{ | ||
config: AlertingConfigModel; | ||
editConfig?: UpdateAlertingConfigModel; | ||
enableAlertingCallback: () => void; | ||
disableAlertingCallback: () => void; | ||
editAlertingEnableCallback: () => void; | ||
editAlertingDisableCallback: () => void; | ||
saveAlertingCallback: () => void; | ||
type Props = { | ||
config: AlertingConfig; | ||
isSaving: boolean; | ||
isAlertingEditEnabled: boolean; | ||
isAlertingEditDirty: boolean; | ||
}> = ({ | ||
config, | ||
isEdit: boolean; | ||
onEdit: () => void; | ||
onSave: () => void; | ||
onCancel: () => void; | ||
onEnable: () => void; | ||
onDisable: () => void; | ||
}; | ||
|
||
export const AlertingActions = ({ | ||
isEdit, | ||
isSaving, | ||
enableAlertingCallback, | ||
disableAlertingCallback, | ||
editAlertingEnableCallback, | ||
editAlertingDisableCallback, | ||
saveAlertingCallback, | ||
isAlertingEditEnabled, | ||
isAlertingEditDirty, | ||
}) => ( | ||
<div className="alerting-actions"> | ||
<div className="grid grid--gap-small grid--auto-columns"> | ||
{config.enabled ? ( | ||
<> | ||
{isAlertingEditEnabled ? ( | ||
<> | ||
<Button | ||
disabled={!isAlertingEditDirty || isSaving} | ||
onClick={saveAlertingCallback} | ||
> | ||
Save | ||
</Button> | ||
<Button | ||
disabled={isSaving} | ||
variant="outlined" | ||
onClick={editAlertingDisableCallback} | ||
> | ||
Cancel | ||
config, | ||
onEdit, | ||
onCancel, | ||
onEnable, | ||
onDisable, | ||
onSave, | ||
}: Props) => { | ||
return ( | ||
<div className="alerting-actions"> | ||
<div className="grid grid--gap-small grid--auto-columns"> | ||
{config.enabled ? ( | ||
<> | ||
{isEdit ? ( | ||
<> | ||
<Button disabled={isSaving} onClick={onSave}> | ||
Save | ||
</Button> | ||
<Button | ||
disabled={isSaving} | ||
variant="outlined" | ||
onClick={onCancel} | ||
> | ||
Cancel | ||
</Button> | ||
</> | ||
) : ( | ||
<Button disabled={!config.ready} onClick={onEdit}> | ||
Edit | ||
</Button> | ||
</> | ||
) : ( | ||
<Button | ||
disabled={!config.ready} | ||
onClick={editAlertingEnableCallback} | ||
> | ||
Edit | ||
</Button> | ||
)} | ||
</> | ||
) : ( | ||
<Button | ||
disabled={isSaving} | ||
onClick={(ev) => { | ||
ev.preventDefault(); | ||
enableAlertingCallback(); | ||
}} | ||
> | ||
Enable Alerts | ||
</Button> | ||
)} | ||
</div> | ||
)} | ||
</> | ||
) : ( | ||
<Button disabled={isSaving} onClick={onEnable}> | ||
Enable Alerts | ||
</Button> | ||
)} | ||
</div> | ||
|
||
<div className="grid grid--gap-small grid--auto-columns"> | ||
{config.enabled && ( | ||
<Button | ||
disabled={isSaving} | ||
color="danger" | ||
onClick={(ev) => { | ||
ev.preventDefault(); | ||
disableAlertingCallback(); | ||
}} | ||
> | ||
Disable Alerts | ||
</Button> | ||
)} | ||
<div className="grid grid--gap-small grid--auto-columns"> | ||
{config.enabled && ( | ||
<Button disabled={isSaving} color="danger" onClick={onDisable}> | ||
Disable Alerts | ||
</Button> | ||
)} | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
); | ||
}; | ||
|
||
AlertingActions.propTypes = { | ||
config: PropTypes.shape(AlertingConfigModelValidationMap) | ||
.isRequired as PropTypes.Validator<AlertingConfigModel>, | ||
editConfig: PropTypes.shape( | ||
UpdateAlertingConfigModelValidationMap | ||
) as PropTypes.Validator<UpdateAlertingConfigModel>, | ||
enableAlertingCallback: PropTypes.func.isRequired, | ||
disableAlertingCallback: PropTypes.func.isRequired, | ||
editAlertingEnableCallback: PropTypes.func.isRequired, | ||
editAlertingDisableCallback: PropTypes.func.isRequired, | ||
saveAlertingCallback: PropTypes.func.isRequired, | ||
isSaving: PropTypes.bool.isRequired, | ||
isAlertingEditEnabled: PropTypes.bool.isRequired, | ||
isAlertingEditDirty: PropTypes.bool.isRequired, | ||
isEdit: PropTypes.bool.isRequired, | ||
config: PropTypes.object.isRequired as PropTypes.Validator<AlertingConfig>, | ||
|
||
onSave: PropTypes.func.isRequired, | ||
onCancel: PropTypes.func.isRequired, | ||
onEdit: PropTypes.func.isRequired, | ||
onEnable: PropTypes.func.isRequired, | ||
onDisable: PropTypes.func.isRequired, | ||
}; |
Oops, something went wrong.