Skip to content

Commit

Permalink
Grouping templating polishing11 (#2293)
Browse files Browse the repository at this point in the history
- [x] Alert group scroll
- [x] Result scroll right padding
- [x] Cheatsheet scroll right padding
- [x] Template editor and cheatsheet title alight center
- [x] Edit custom payload - left padding
- [x] Change background of Use custom payload title like Template Editor
- [x] No alert groups is missing right border
- [x] Save template - should not close the drawer if there is an error
- [x] Width cheatsheet code 100%
- [x] Edit/close Alert payload margin 8px
- [x] Background secondary Result - when Select alert group message
  • Loading branch information
Ukochka authored Jun 20, 2023
1 parent 89834ee commit e4788d5
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
padding: 16px;
border: var(--border-weak);
min-width: min-content;
overflow-y: scroll;
}

.cheatsheet-container > div {
height: 100%;
max-height: 100%;
overflow-y: scroll;
}

.cheatsheet-item {
Expand Down
2 changes: 1 addition & 1 deletion grafana-plugin/src/components/CheatSheet/CheatSheet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const CheatSheet = (props: CheatSheetProps) => {
<IconButton name="times" onClick={onClose} />
</HorizontalGroup>
<Text type="secondary">{cheatSheetData.description}</Text>
<div>
<div style={{ width: '100%' }}>
{cheatSheetData.fields?.map((field: CheatSheetItem) => {
return (
<div key={field.name} className={cx('cheatsheet-item')}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
max-height: 100%;
width: 100%;
border: var(--border-strong);
padding: 0 16px;
}

.template-block-title {
Expand All @@ -24,7 +23,7 @@
}

.template-editor-block-title {
padding: 8px 16px;
padding: 8px 16px 0;
align-items: baseline;
border: var(--border-weak);
background-color: var(--background-secondary);
Expand Down Expand Up @@ -56,7 +55,7 @@
overflow-y: scroll !important;
}
.result {
padding-left: 16px;
padding: 0 16px;
padding-bottom: 60px;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,8 @@ const IntegrationTemplate = observer((props: IntegrationTemplateProps) => {
const handleSubmit = useCallback(() => {
if (template.isRoute) {
onUpdateRoute({ [template.name]: changedTemplateBody }, channelFilterId);
onHide();
} else {
onUpdateTemplates({ [template.name]: changedTemplateBody });
onHide();
}
}, [onUpdateTemplates, changedTemplateBody]);

Expand Down Expand Up @@ -199,7 +197,7 @@ const IntegrationTemplate = observer((props: IntegrationTemplateProps) => {
<>
<div className={cx('template-block-codeeditor')}>
<div className={cx('template-editor-block-title')}>
<HorizontalGroup justify="space-between" wrap>
<HorizontalGroup justify="space-between" align="center" wrap>
<Text>Template editor</Text>

<Button variant="secondary" fill="outline" onClick={onShowCheatSheet} icon="book" size="sm">
Expand Down Expand Up @@ -299,7 +297,7 @@ const Result = (props: ResultProps) => {
</VerticalGroup>
) : (
<div>
<Block bordered fullWidth className={cx('block-style')}>
<Block bordered fullWidth className={cx('block-style')} withBackground>
<Text>← Select alert group or "Use custom payload"</Text>
</Block>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
.template-block-title {
padding: 16px 16px 16px 0;
padding: 16px;
align-items: baseline;
min-height: 56px;
}

.template-block-title-edit-mode {
padding: 16px;
align-items: baseline;
min-height: 56px;
background-color: var(--background-secondary);
}

.template-block-list {
width: 30%;
height: 100%;
max-width: 100%;
overflow-y: hidden;
overflow-y: scroll;
}

.alert-group-payload-view {
Expand All @@ -17,12 +24,8 @@
padding-left: 0;
}

.alert-groups-list > div {
border-right: none;
}

.alert-groups-list {
padding-right: 16px;
padding: 0 16px;
}

.alert-groups-list button {
Expand All @@ -38,11 +41,6 @@
background-color: var(--background-secondary);
}

.alert-groups-editor {
width: calc(100% + 16px);
margin-left: -16px;
}

.alert-groups-editor div[aria-label='Code editor container'] {
border-bottom: none;
border-right: none;
Expand Down Expand Up @@ -86,4 +84,5 @@
.title-action-icons {
display: flex;
align-items: center;
gap: 4px;
}
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ const TemplatesAlertGroupsList = (props: TemplatesAlertGroupsListProps) => {
<>
{isEditMode ? (
<>
<div className={cx('template-block-title')}>
<div className={cx('template-block-title-edit-mode')}>
<HorizontalGroup justify="space-between">
<Text>Edit custom payload</Text>

Expand Down Expand Up @@ -151,7 +151,7 @@ const TemplatesAlertGroupsList = (props: TemplatesAlertGroupsListProps) => {
<>
{isEditMode ? (
<>
<div className={cx('template-block-title')}>
<div className={cx('template-block-title-edit-mode')}>
<HorizontalGroup justify="space-between">
<Text>Edit custom payload</Text>

Expand All @@ -168,7 +168,7 @@ const TemplatesAlertGroupsList = (props: TemplatesAlertGroupsListProps) => {
language={MONACO_LANGUAGE.json}
data={templates}
monacoOptions={MONACO_PAYLOAD_OPTIONS}
showLineNumbers={false}
showLineNumbers
height={getCodeEditorHeight()}
onChange={getChangeHandler()}
/>
Expand Down
11 changes: 10 additions & 1 deletion grafana-plugin/src/pages/integration_2/Integration2.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -514,6 +514,10 @@ class Integration2 extends React.Component<Integration2Props, Integration2State>
alertReceiveChannelStore.updateChannelFilters(id, true).then(() => {
escalationPolicyStore.updateEscalationPolicies(channelFilter.escalation_chain);
});
this.setState({
isEditTemplateModalOpen: undefined,
});
LocationHelper.update({ template: undefined, routeId: undefined }, 'partial');
})
.catch((err) => {
const errors = get(err, 'response.data');
Expand All @@ -535,12 +539,17 @@ class Integration2 extends React.Component<Integration2Props, Integration2State>
.saveTemplates(id, data)
.then(() => {
openNotification('The Alert templates have been updated');
this.setState({
isEditTemplateModalOpen: undefined,
});
this.setState({ isTemplateSettingsOpen: true });
LocationHelper.update({ template: undefined, routeId: undefined }, 'partial');
})
.catch((err) => {
if (err.response?.data?.length > 0) {
openErrorNotification(err.response.data);
} else {
openErrorNotification(err.message);
openErrorNotification('Template is not valid. Please check your template and try again');
}
});
};
Expand Down

0 comments on commit e4788d5

Please sign in to comment.