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

[MI-3274]: Integrated config table, view action modal & delete config modal #10

Merged
merged 20 commits into from
Aug 31, 2023
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
6dac8b0
[MI-3275]: Fixed indentation and other lint errors
Kshitij-Katiyar Jul 11, 2023
636c417
[MI-3274]: Integrated config table, view action & delete config modal
Kshitij-Katiyar Jul 19, 2023
20e29bb
Merge branch 'MI-3255' into MI-3274
Kshitij-Katiyar Jul 20, 2023
807fa8b
[MI-3274]: Used camelcase in type
Kshitij-Katiyar Aug 2, 2023
aae8daa
[MI-3274]: Resolved the import order issue
Kshitij-Katiyar Aug 2, 2023
5278660
[MI-3274]: Resolved import order
Kshitij-Katiyar Aug 2, 2023
d48a03e
Merge branch 'MI-3255' into MI-3274
Kshitij-Katiyar Aug 2, 2023
eaad84a
Merge branch 'MI-3255' into MI-3274
Kshitij-Katiyar Aug 10, 2023
2f022a5
Merge branch 'MI-3255' into MI-3274
Kshitij-Katiyar Aug 11, 2023
a7fb61b
Merge branch 'MI-3255' into MI-3274
Kshitij-Katiyar Aug 11, 2023
848b7c9
[MI-3274]: Used types instead of interface
Kshitij-Katiyar Aug 16, 2023
babdc3a
Merge branch 'MI-3255' into MI-3274
Kshitij-Katiyar Aug 17, 2023
6bf4451
[MI-3274]: Fixed indentation for CI
Kshitij-Katiyar Aug 17, 2023
83f6f91
[MI-3274]: Fixed indentation for CI
Kshitij-Katiyar Aug 17, 2023
626988b
[MI-3274]: Fixed lint CI
Kshitij-Katiyar Aug 18, 2023
c60c38f
Merge branch 'MI-3255' into MI-3274
Kshitij-Katiyar Aug 25, 2023
b39163e
[MI-3274]: Fixed conflict resolution error
Kshitij-Katiyar Aug 25, 2023
302e7ad
Merge branch 'MI-3274' of github.com:Brightscout/mattermost-plugin-we…
Kshitij-Katiyar Aug 25, 2023
0d66129
[MI-3274]: Fixed error in plugin.json
Kshitij-Katiyar Aug 25, 2023
709f1b2
[MI-3275]: Integrated config modal (#11)
Kshitij-Katiyar Aug 31, 2023
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
7 changes: 3 additions & 4 deletions plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,9 @@
"header": "Configure this plugin directly in the config.json file. Learn more [in our documentation](https://github.com/mattermost/mattermost-plugin-welcomebot/blob/master/README.md).\n\n To report an issue, make a suggestion, or submit a contribution, [check the plugin repository](https://github.com/mattermost/mattermost-plugin-welcomebot).",
"settings": [
{
"key": "ExistingConfigurationTable",
"display_name": "Existing Configurations:",
"type": "custom"
}
"key": "WelcomeMessages",
Kshitij-Katiyar marked this conversation as resolved.
Show resolved Hide resolved
"type": "custom",
"default": []
]
}
}
2 changes: 1 addition & 1 deletion server/configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ type ConfigMessage struct {

// Configuration from config.json
type Configuration struct {
WelcomeMessages []*ConfigMessage
WelcomeMessages []*ConfigMessage `json:"WelcomeMessages"`
}

// List of the welcome messages from the configuration
Expand Down
137 changes: 68 additions & 69 deletions webapp/src/containers/components/modals/actionModal.tsx
Original file line number Diff line number Diff line change
@@ -1,80 +1,79 @@
import React from 'react';

import Button from 'react-bootstrap/Button';
import Modal from 'react-bootstrap/Modal';
import Table from 'react-bootstrap/Table';
import Form from 'react-bootstrap/Form';

import './styles.css';
import {Configs} from 'types/plugin/common';
Kshitij-Katiyar marked this conversation as resolved.
Show resolved Hide resolved

type Props = {
visibility: boolean;
setVisibility: React.Dispatch<React.SetStateAction<boolean>>;
}

const ViewActionsModal = ({visibility, setVisibility}: Props) => {
const handleClose = () => {
setVisibility(false);
};
function ActionModal({visible, setVisible, config, configIndex}: Props) {
const actionsLength = config[configIndex]?.actions?.length ?? 0;
const attachmentMessageLength = config[configIndex]?.attachmentMessage?.length ?? 0;
Kshitij-Katiyar marked this conversation as resolved.
Show resolved Hide resolved

useEffect(() => {
setVisible(visible);
}, [visible]);

return (
<Modal
show={visibility}
onHide={handleClose}
>
<Modal.Header closeButton={false}>
const handleClose = () => {
setVisible(false);
<Modal.Title>{'Actions'}</Modal.Title>
</Modal.Header>

<Modal.Body>
<Form>
<Form.Group className='form-group'>
<Form.Label>{'Attachment Message'}</Form.Label>
<Form.Control
type='long-text'
placeholder='This is an example attachment message'
aria-label='Disabled input example'
readOnly={true}
/>
</Form.Group>
<Form.Group className='action-group'>
<Form.Label>{'Actions'}</Form.Label>
</Form.Group>
</Form>
<Table
striped={true}
className='listTable'
>
<thead>
<tr>
<th>{'Type'}</th>
<th>{'Display Name'}</th>
<th>{'Channels Added to'}</th>
<th>{'Success Message'}</th>
</tr>
</thead>
<tbody>
<tr>
<td>{'Button'}</td>
<td>{'Import'}</td>
<td>{'channel1, channel2, channel3'}</td>
<td>{'Welcome to your new team!'}</td>
</tr>
<tr>
<td>{'Automatic'}</td>
<td>{'Export'}</td>
<td>{'channel1, channel2'}</td>
<td>{'Welcome to your new team!'}</td>
</tr>
<tr>
<td>{'Button'}</td>
<td>{'Deport'}</td>
<td>{'channel1, channel3'}</td>
<td>{'Welcome to your new team!'}</td>
</tr>
</tbody>
</Table>
</Modal.Body>
{(config[configIndex].attachmentMessage && attachmentMessageLength > 0) || (config[configIndex]?.actions && actionsLength > 0) ? (<>
{config[configIndex].attachmentMessage && attachmentMessageLength > 0 ? (
Kshitij-Katiyar marked this conversation as resolved.
Show resolved Hide resolved
<Form>
<Form.Group className='form-group'>
<Form.Label>{'Attachment Message'}</Form.Label>
<Form.Control
type='long-text'
value={config[configIndex].attachmentMessage ?? ''}
placeholder=''
aria-label='Disabled input example'
readOnly={true}
/>
</Form.Group>
</Form>
) : (<p>{'No Attachment message configured'}</p>)
}
{config[configIndex]?.actions && actionsLength > 0 ? (
<div>
<Form>
<Form.Group className='action-group'>
<Form.Label>{'Actions'}</Form.Label>
</Form.Group>
</Form>
<Table
striped={true}
className='listTable'
>
<thead>
<tr>
<th>{'Type'}</th>
<th>{'Name'}</th>
<th>{'Display Name'}</th>
<th>{'Channels Added to'}</th>
<th>{'Success Message'}</th>
</tr>
</thead>
<tbody>
{
config[configIndex].actions?.map((val, i) =>
(
<tr key={i.toString()}>
<td>{val.actionType}</td>
<td>{val.actionName}</td>
<td>{val.actionDisplayName}</td>
<td>{val.channelsAddedTo}</td>
<td>{val.actionSuccessfullMessage}</td>
</tr>
),
)
}
Kshitij-Katiyar marked this conversation as resolved.
Show resolved Hide resolved
</tbody>
</Table>
</div>
) : (<p>{'No Action configured'}</p>)
}
</>) : (<p>{'No Attachment message or Action configured'}</p>)}

<Modal.Footer>
<Button
Expand All @@ -84,6 +83,6 @@ const ViewActionsModal = ({visibility, setVisibility}: Props) => {
</Modal.Footer>
</Modal>
);
};
}

export default ViewActionsModal;
export default ActionModal;
82 changes: 29 additions & 53 deletions webapp/src/containers/components/modals/configModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,38 @@ import {OverlayTrigger, Tooltip, ToggleButton} from 'react-bootstrap';
import './styles.css';

type Props = {
visibility: boolean;
setVisibility: React.Dispatch<React.SetStateAction<boolean>>;
config: Config | null;
visible: boolean;
setVis: React.Dispatch<React.SetStateAction<boolean>>;
Kshitij-Katiyar marked this conversation as resolved.
Show resolved Hide resolved
configIndex: number | null;
config: Configs[];
onChange: any;
modalHeader: string;
}

function ConfigModal({visibility, setVisibility, config}: Props) {
const [show, setShow] = useState(false);
const [isActionVisible, setIsActionVisible] = useState(false);
const [isConfigVisible, setIsConfigVisible] = useState(false);
const [radioValue, setRadioValue] = useState('');
const [isDeleteVisible, setIsDeleteVisible] = useState(false);
const [deleteVisible, setDeleteVisible] = useState(false);
Kshitij-Katiyar marked this conversation as resolved.
Show resolved Hide resolved

const handleCloseButton = (
variant: string,
text: string,
) => (
<Button
variant={variant}
onClick={handleClose}
>
{text}
</Button>
);

const guest = [
{name: 'true', value: 'true'},
{name: 'false', value: 'false'},
];

const buttonTypes = [
{name: 'button', value: 'button'},
{name: 'automatic', value: 'automatic'},
Expand Down Expand Up @@ -189,9 +205,7 @@ function ConfigModal({visibility, setVisibility, config}: Props) {
strokeWidth='1.65'
strokeLinecap='round'
strokeLinejoin='round'
>
<polyline points='3 6 5 6 21 6'/>
<path d='M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2'/>
><polyline points='3 6 5 6 21 6'/><path d='M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2'/>
<line
x1='10'
y1='11'
Expand Down Expand Up @@ -258,8 +272,7 @@ function ConfigModal({visibility, setVisibility, config}: Props) {
strokeWidth='1.65'
strokeLinecap='round'
strokeLinejoin='round'
><polyline points='3 6 5 6 21 6'/>
<path d='M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2'/>
><polyline points='3 6 5 6 21 6'/><path d='M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2'/>
<line
x1='10'
y1='11'
Expand Down Expand Up @@ -326,8 +339,7 @@ function ConfigModal({visibility, setVisibility, config}: Props) {
strokeWidth='1.65'
strokeLinecap='round'
strokeLinejoin='round'
><polyline points='3 6 5 6 21 6'/>
<path d='M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2'/>
><polyline points='3 6 5 6 21 6'/><path d='M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2'/>
<line
x1='10'
y1='11'
Expand Down Expand Up @@ -404,48 +416,12 @@ function ConfigModal({visibility, setVisibility, config}: Props) {
</div>}
</Modal.Body>
<Modal.Footer>
{isConfigVisible &&
<Button
variant='secondary'
onClick={handleClose}
>
{'Close'}
</Button>}
{isActionVisible &&
<Button
variant='secondary'
onClick={handleClose}
>
{'Cancel'}
</Button>}
{isDeleteVisible &&
<Button
variant='secondary'
onClick={handleClose}
>
{'Cancel'}
</Button>}
{isConfigVisible &&
<Button
variant='primary'
onClick={handleClose}
>
{'Save changes'}
</Button>}
{isActionVisible &&
<Button
variant='primary'
onClick={handleClose}
>
{'Add action'}
</Button>}
{isDeleteVisible &&
<Button
variant='danger'
onClick={handleClose}
>
{'Delete action'}
</Button>}
{configVisible && handleCloseButton('primary', 'Save changes')}
{actionVisible && handleCloseButton('primary', 'Add action')}
{configVisible && handleCloseButton('secondary', 'Close')}
{actionVisible && handleCloseButton('secondary', 'Cancel')}
Kshitij-Katiyar marked this conversation as resolved.
Show resolved Hide resolved
{deleteVisible && handleCloseButton('secondary', 'Cancel')}
{deleteVisible && handleCloseButton('danger', 'Delete action')}
</Modal.Footer>
</Modal>
</>
Expand Down
39 changes: 30 additions & 9 deletions webapp/src/containers/components/modals/deleteModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,32 @@ import Modal from 'react-bootstrap/Modal';

import './styles.css';

type Props = {
visibility: boolean;
setVisibility: React.Dispatch<React.SetStateAction<boolean>>;
import {Configs} from 'types/plugin/common';

interface Props {
visible: boolean;
setVisible: React.Dispatch<React.SetStateAction<boolean>>;
config: Configs[];
configIndex: number;
onChange: any;
}

const DeleteConfigModal = ({visibility, setVisibility}: Props) => {
const handleClose = () => setVisibility(false);
const DeleteModal = ({visible, setVisible, config, configIndex, onChange}: Props) => {
const [show, setShow] = useState(false);
Kshitij-Katiyar marked this conversation as resolved.
Show resolved Hide resolved

useEffect(() => {
setShow(visible);
}, [visible]);

const handleClose = () => {
setVisible(false);
};

const handleDelete = () => {
config.splice(configIndex, 1);
onChange(config);
handleClose();
};

return (
<>
Expand All @@ -24,20 +43,22 @@ const DeleteConfigModal = ({visibility, setVisibility}: Props) => {
</Modal.Header>

<Modal.Body>
{/* TODO: Add team name according to the team */}
<p>{'Delete the configs for the team xyz'}</p>
<p>{`Are you sure you would like to delete the configs for the team ${config[configIndex].teamName}?`} </p>
</Modal.Body>

<Modal.Footer>
<Button
variant='secondary'
onClick={handleClose}
>{'Close'}</Button>
<Button variant='danger'>{'Delete'}</Button>
<Button
variant='danger'
onClick={handleDelete}
>{'Delete'}</Button>
</Modal.Footer>
</Modal>
</>
);
};

export default DeleteConfigModal;
export default DeleteModal;
Loading