Skip to content

Commit

Permalink
Merge branch 'develop' into regression/composer-border
Browse files Browse the repository at this point in the history
  • Loading branch information
kodiakhq[bot] authored Jan 10, 2023
2 parents 790057f + f2209ee commit 9b098b6
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
9 changes: 7 additions & 2 deletions apps/meteor/client/views/blocks/ModalBlock.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { UiKitComponent, UiKitModal, modalParser } from '@rocket.chat/fuselage-u
import React, { useCallback, useEffect, useMemo, useRef } from 'react';

import { getURL } from '../../../app/utils/lib/getURL';
import { getButtonStyle } from './getButtonStyle';
import './textParsers';

const focusableElementsString = `
Expand Down Expand Up @@ -144,9 +145,13 @@ function ModalBlock({ view, errors, appId, onSubmit, onClose, onCancel }) {
</Modal.Content>
<Modal.Footer>
<Modal.FooterControllers>
{view.close && <Button onClick={onCancel}>{modalParser.text(view.close.text)}</Button>}
{view.close && (
<Button danger={view.close.style === 'danger'} onClick={onCancel}>
{modalParser.text(view.close.text)}
</Button>
)}
{view.submit && (
<Button primary onClick={onSubmit}>
<Button {...getButtonStyle(view)} onClick={onSubmit}>
{modalParser.text(view.submit.text)}
</Button>
)}
Expand Down
5 changes: 5 additions & 0 deletions apps/meteor/client/views/blocks/getButtonStyle.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import type { IUIKitSurface } from '@rocket.chat/apps-engine/definition/uikit';

export const getButtonStyle = (view: IUIKitSurface): { danger: boolean } | { primary: boolean } => {
return view.submit?.style === 'danger' ? { danger: true } : { primary: true };
};
9 changes: 7 additions & 2 deletions apps/meteor/client/views/room/contextualBar/Apps/Apps.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import React from 'react';
import { getURL } from '../../../../../app/utils/lib/getURL';
import VerticalBar from '../../../../components/VerticalBar';
import { modalParser } from '../../../blocks/ModalBlock';
import { getButtonStyle } from '../../../blocks/getButtonStyle';

type AppsProps = {
view: IUIKitSurface;
Expand All @@ -30,9 +31,13 @@ const Apps = ({ view, onSubmit, onClose, onCancel, appId }: AppsProps): JSX.Elem
</VerticalBar.ScrollableContent>
<VerticalBar.Footer>
<ButtonGroup align='end'>
{view.close && <Button onClick={onCancel}>{modalParser.text(view.close.text)}</Button>}
{view.close && (
<Button danger={view.close.style === 'danger'} onClick={onCancel}>
{modalParser.text(view.close.text)}
</Button>
)}
{view.submit && (
<Button primary onClick={onSubmit}>
<Button {...getButtonStyle(view)} onClick={onSubmit}>
{modalParser.text(view.submit.text)}
</Button>
)}
Expand Down

0 comments on commit 9b098b6

Please sign in to comment.