Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[IMPROVE] Changed the buttons of Integrations #24110

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions client/views/admin/integrations/edit/EditIncomingWebhook.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ function EditIncomingWebhook({ data, onChange, ...props }) {
const t = useTranslation();
const dispatchToastMessage = useToastMessageDispatch();

const { values: formValues, handlers: formHandlers, reset } = useForm(getInitialValue(data));
const { values: formValues, handlers: formHandlers, hasUnsavedChanges, reset } = useForm(getInitialValue(data));
const setModal = useSetModal();

const deleteQuery = useMemo(() => ({ type: 'webhook-incoming', integrationId: data._id }), [data._id]);
Expand Down Expand Up @@ -81,10 +81,10 @@ function EditIncomingWebhook({ data, onChange, ...props }) {
<Field.Row display='flex' flexDirection='column'>
<Box display='flex' flexDirection='row' justifyContent='space-between' w='full'>
<Margins inlineEnd='x4'>
<Button flexGrow={1} type='reset' onClick={reset}>
<Button flexGrow={1} type='reset' disabled={!hasUnsavedChanges} onClick={reset}>
{t('Reset')}
</Button>
<Button mie='none' flexGrow={1} onClick={handleSave}>
<Button mie='none' flexGrow={1} primary disabled={!hasUnsavedChanges} onClick={handleSave}>
{t('Save')}
</Button>
</Margins>
Expand Down
6 changes: 3 additions & 3 deletions client/views/admin/integrations/edit/EditOutgoingWebhook.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ function EditOutgoingWebhook({ data, onChange, setSaveAction, ...props }) {
const t = useTranslation();
const dispatchToastMessage = useToastMessageDispatch();

const { handlers: formHandlers, values: formValues, reset } = useForm(getInitialValue(data));
const { handlers: formHandlers, values: formValues, hasUnsavedChanges, reset } = useForm(getInitialValue(data));
const setModal = useSetModal();

const saveIntegration = useMethod('updateOutgoingIntegration');
Expand Down Expand Up @@ -101,10 +101,10 @@ function EditOutgoingWebhook({ data, onChange, setSaveAction, ...props }) {
<Field.Row display='flex' flexDirection='column'>
<Box display='flex' flexDirection='row' justifyContent='space-between' w='full'>
<Margins inlineEnd='x4'>
<Button flexGrow={1} type='reset' onClick={reset}>
<Button flexGrow={1} type='reset' disabled={!hasUnsavedChanges} onClick={reset}>
{t('Reset')}
</Button>
<Button mie='none' flexGrow={1} onClick={handleSave}>
<Button mie='none' flexGrow={1} primary disabled={!hasUnsavedChanges} onClick={handleSave}>
{t('Save')}
</Button>
</Margins>
Expand Down
6 changes: 3 additions & 3 deletions client/views/admin/integrations/new/NewIncomingWebhook.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export default function NewIncomingWebhook(props) {

const router = useRoute('admin-integrations');

const { values: formValues, handlers: formHandlers, reset } = useForm(initialState);
const { values: formValues, handlers: formHandlers, hasUnsavedChanges, reset } = useForm(initialState);

const params = useMemo(() => ({ ...formValues, type: 'webhook-incoming' }), [formValues]);
const saveAction = useEndpointAction('POST', 'integrations.create', params, t('Integration_added'));
Expand All @@ -42,10 +42,10 @@ export default function NewIncomingWebhook(props) {
<Field.Row>
<Box display='flex' flexDirection='row' justifyContent='space-between' w='full'>
<Margins inlineEnd='x4'>
<Button flexGrow={1} type='reset' onClick={reset}>
<Button flexGrow={1} type='reset' disabled={!hasUnsavedChanges} onClick={reset}>
{t('Reset')}
</Button>
<Button mie='none' flexGrow={1} onClick={handleSave}>
<Button mie='none' flexGrow={1} primary disabled={!hasUnsavedChanges} onClick={handleSave}>
{t('Save')}
</Button>
</Margins>
Expand Down
17 changes: 12 additions & 5 deletions client/views/admin/integrations/new/NewOutgoingWebhook.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Field, Button } from '@rocket.chat/fuselage';
import { Field, Box, Margins, Button } from '@rocket.chat/fuselage';
import { useUniqueId } from '@rocket.chat/fuselage-hooks';
import React, { useMemo, useCallback } from 'react';

Expand Down Expand Up @@ -36,7 +36,7 @@ export default function NewOutgoingWebhook({ data = defaultData, onChange, setSa
const t = useTranslation();
const router = useRoute('admin-integrations');

const { values: formValues, handlers: formHandlers } = useForm({ ...data, token: useUniqueId() });
const { values: formValues, handlers: formHandlers, hasUnsavedChanges, reset } = useForm({ ...data, token: useUniqueId() });

const { urls, triggerWords } = formValues;

Expand All @@ -61,9 +61,16 @@ export default function NewOutgoingWebhook({ data = defaultData, onChange, setSa
() => (
<Field>
<Field.Row>
<Button w='full' mie='none' flexGrow={1} onClick={handleSave}>
{t('Save')}
</Button>
<Box display='flex' flexDirection='row' justifyContent='space-between' w='full'>
<Margins inlineEnd='x4'>
<Button flexGrow={1} type='reset' disabled={!hasUnsavedChanges} onClick={reset}>
{t('Reset')}
</Button>
<Button mie='none' flexGrow={1} primary disabled={!hasUnsavedChanges} onClick={handleSave}>
{t('Save')}
</Button>
</Margins>
</Box>
</Field.Row>
</Field>
),
Expand Down
Loading