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-3199]: Developed a table to display the existing config of plugin #5

Merged
merged 22 commits into from
Sep 1, 2023
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
2a973c5
Developed table to display existing configs of plugin
Kshitij-Katiyar Jun 26, 2023
a3b66d0
Updated .gitignore to exclude node_modules
Kshitij-Katiyar Jun 26, 2023
664f8c2
Fixed .gitignore to exclude node_modules
Kshitij-Katiyar Jun 26, 2023
8c3cf4e
Developed a table to display existing config
Kshitij-Katiyar Jun 26, 2023
24e0ec1
Developed a table to show existing plugin config
Kshitij-Katiyar Jun 26, 2023
e5dea39
setup redux store and add reducer to show/hide attachment message modal
Kshitij-Katiyar Jun 27, 2023
cb86cf5
Added modal to show attachment message of config
Kshitij-Katiyar Jun 28, 2023
e3c57b2
Removed node modules
Kshitij-Katiyar Jun 28, 2023
2cd44bf
[MI-3199]: Removed node modules
Kshitij-Katiyar Jun 28, 2023
f0a2e04
Merge branch 'MI-3173' of github.com:Brightscout/mattermost-plugin-we…
Kshitij-Katiyar Jul 3, 2023
584af51
Merge branch 'MI-3173' of github.com:Brightscout/mattermost-plugin-we…
Kshitij-Katiyar Jul 3, 2023
c06c92a
[MI-3199]: Removed extra files and added eod in gitignore
Kshitij-Katiyar Jul 10, 2023
9e59fd3
[MI-3199]: Fixed lint errors
Kshitij-Katiyar Jul 10, 2023
4fd5dd2
Merge branch 'MI-3173' of github.com:Brightscout/mattermost-plugin-we…
Kshitij-Katiyar Jul 11, 2023
b20814b
[MI-3199]: Removed unwanted files from webapp
Kshitij-Katiyar Jul 19, 2023
414e864
[MI-3199]: Removed extra todo comments
Kshitij-Katiyar Aug 1, 2023
5e6f8b5
Merge branch 'MI-3173' of github.com:Brightscout/mattermost-plugin-we…
Kshitij-Katiyar Aug 1, 2023
5f667b0
[MI-3199]: Resolved missing imports in existingConfigTable
Kshitij-Katiyar Aug 1, 2023
4639074
[MI-3199]: removed extra folders
Kshitij-Katiyar Aug 2, 2023
4494be8
[MI-3199]: Added eod to styles.css
Kshitij-Katiyar Aug 21, 2023
2fbf310
[MI-3199]: Fixed review comments by abhishek
Kshitij-Katiyar Aug 24, 2023
4f79ae0
[MI-3230]: Developed a modal which opens on click of view button in c…
Kshitij-Katiyar Sep 1, 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
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1 @@
dist
dist
Kshitij-Katiyar marked this conversation as resolved.
Show resolved Hide resolved
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ endif
.PHONY: webapp/.npminstall
webapp/.npminstall:
ifneq ($(HAS_WEBAPP),)
cd webapp && $(NPM) install
cd webapp && $(NPM) install --legacy-peer-deps
touch $@
endif

Expand Down
4 changes: 2 additions & 2 deletions build/manifest/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,11 @@ func applyManifest(manifest *model.Manifest) error {

if manifest.HasWebapp() {
if err := ioutil.WriteFile(
"webapp/src/manifest.js",
"webapp/src/manifest.ts",
[]byte(fmt.Sprintf(pluginIDJSFileTemplate, manifest.Id, manifest.Version)),
0600,
); err != nil {
return errors.Wrap(err, "failed to open webapp/src/manifest.js")
return errors.Wrap(err, "failed to open webapp/src/manifest.ts")
}
}

Expand Down
12 changes: 11 additions & 1 deletion plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,16 @@
"bundle_path": "webapp/dist/main.js"
},
"settings_schema": {
"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)."
"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",
"help_text": "",
"placeholder": "",
"default": ""
Kshitij-Katiyar marked this conversation as resolved.
Show resolved Hide resolved
}
]
}
}
2 changes: 1 addition & 1 deletion webapp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
"js-cookie": "3.0.1",
"mattermost-redux": "5.27.0",
"react": "16.13.1",
"react-bootstrap": "2.7.4",
"react-bootstrap": "1.0.1",
"react-redux": "7.2.0",
"redux": "4.0.5",
"typescript": "3.9.6"
Expand Down
50 changes: 50 additions & 0 deletions webapp/src/containers/components/modals/attachmentMsgModal.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import React, {useEffect, useState} from 'react';
import Button from 'react-bootstrap/Button';
import Modal from 'react-bootstrap/Modal';

import usePluginApi from 'hooks/usePluginApi';

//TODO: render this modal when view button is clicked in Config table
Kshitij-Katiyar marked this conversation as resolved.
Show resolved Hide resolved
const AttachmentMsgModal = () => {
Kshitij-Katiyar marked this conversation as resolved.
Show resolved Hide resolved
const [show, setShow] = useState(false);
const usePlugin = usePluginApi();

useEffect(() => {
const visibility = usePlugin.state['plugins-com.mattermost.welcomebot'].viewConfigModalSlice.isVisible;
Kshitij-Katiyar marked this conversation as resolved.
Show resolved Hide resolved
setShow(visibility);
}, []);

const handleClose = () => {
setShow(false);
};
Kshitij-Katiyar marked this conversation as resolved.
Show resolved Hide resolved
return (
<>
<div
className='modal show'
style={{display: 'block', position: 'initial'}}
Kshitij-Katiyar marked this conversation as resolved.
Show resolved Hide resolved
>
<Modal show={show}>
<Modal.Header closeButton={true}>
Kshitij-Katiyar marked this conversation as resolved.
Show resolved Hide resolved
<Modal.Title>{'Attachment Message'}</Modal.Title>
</Modal.Header>

<Modal.Body>
<p>{'Attachment message body text goes here.'}</p>
</Modal.Body>

<Modal.Footer>
<Button
variant='secondary'
onClick={handleClose}
>
{'Close'}
</Button>
<Button variant='primary'>{'Save changes'}</Button>
Kshitij-Katiyar marked this conversation as resolved.
Show resolved Hide resolved
</Modal.Footer>
</Modal>
</div>
</>
);
};

export default AttachmentMsgModal;
Kshitij-Katiyar marked this conversation as resolved.
Show resolved Hide resolved
152 changes: 152 additions & 0 deletions webapp/src/containers/components/tables/existingConfigTable.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
import React from 'react';

import {FormGroup, Col, Table, ButtonGroup, Button} from 'react-bootstrap';

import './styles.css';
import {useDispatch} from 'react-redux';

import {showViewConfigModalState} from 'reducers/viewConfigModal';

type HelpText = {
key: string | null;
props: {
isMarkdown: boolean;
isTranslated: boolean;
text: string;
textDefault?: string;
textValues?: string;
Kshitij-Katiyar marked this conversation as resolved.
Show resolved Hide resolved
}
}

type Props = {
id: string;
label: string;
value: string;
helpText: HelpText;
}

//TODO: Will remove this dummy data
const ExistingConfigTable = ({label, helpText}: Props) => {
const dispatch = useDispatch();
const handleView = () => {
dispatch(showViewConfigModalState());
};

return (
<div>
Kshitij-Katiyar marked this conversation as resolved.
Show resolved Hide resolved
<FormGroup>
<Col sm={4}>
{label}
</Col>
<Col sm={8}>
<Table striped={true}>
<thead>
<tr>
<th className='team-name single-line'>{'Team Name'}</th>
<th className='delay'>{'Delay in seconds'}</th>
<th className='message'>{'Message'}</th>
<th className='attachment-message single-line'>{'Attachment message'}</th>
<th className='options'>{'Options'}</th>
</tr>
</thead>
<tbody>
<tr>
<td>{'Standup'}</td>
<td>{'4'}</td>
<td className='ellipsis'>
{'Hello to standup group sdhfvk.'}
Kshitij-Katiyar marked this conversation as resolved.
Show resolved Hide resolved
</td>
<td>
<Button
variant='primary'
onClick={handleView}
>
{'View'}
</Button>
</td>
<td>
<div className='options'>
<ButtonGroup aria-label='Basic example'>
<Button variant='primary'>{'Edit'}</Button>
<Button variant='danger'>{'Delete'}</Button>
</ButtonGroup>
</div>
</td>
</tr>
<tr>
<td>{'Overview'}</td>
<td>{'5'}</td>
<td>{'This group is to share overview'}</td>
<td>
<Button
variant='primary'
onClick={handleView}
>
{'View'}
</Button>
</td>
<td>
<div>
<ButtonGroup aria-label='Basic example'>
<Button variant='primary'>{'Edit'}</Button>
<Button variant='danger'>{'Delete'}</Button>
</ButtonGroup>
</div>
</td>
</tr>
<tr>
<td>{'Result'}</td>
<td>{'2'}</td>
<td>{'Share all your results here'}</td>
<td>
<Button
variant='primary'
onClick={handleView}
>
{'View'}
</Button>
</td>
<td>
<div>
Kshitij-Katiyar marked this conversation as resolved.
Show resolved Hide resolved
<ButtonGroup aria-label='Basic example'>
<Button variant='primary'>{'Edit'}</Button>
<Button variant='danger'>{'Delete'}</Button>
</ButtonGroup>
</div>
</td>
</tr>
<tr>
<td>{'Deploy'}</td>
<td>{'6'}</td>
<td>{'Deployment details here'}</td>
<td>
<Button
variant='primary'
onClick={handleView}
>
{'View'}
</Button>
</td>
<td>
<div>
<ButtonGroup aria-label='Basic example'>
<Button variant='primary'>{'Edit'}</Button>
<Button variant='danger'>{'Delete'}</Button>
</ButtonGroup>
</div>
</td>
</tr>
</tbody>
</Table>
<div className='help-text'>
<span>
{helpText?.props?.text}
</span>
</div>
</Col>
</FormGroup>
</div>
);
};

export default ExistingConfigTable;
27 changes: 27 additions & 0 deletions webapp/src/containers/components/tables/styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
.btn-group {
display: flex;
justify-content: space-between;
gap: 10px;
}

table.table tbody tr td,
table.table thead tr th,
table.table thead {
border: 2px solid #ddd;
Kshitij-Katiyar marked this conversation as resolved.
Show resolved Hide resolved
}

.table td {
text-align: center;
}

.table th {
text-align: center;
vertical-align: bottom;
}

table {
width: 100%;
}
Kshitij-Katiyar marked this conversation as resolved.
Show resolved Hide resolved
.table thead tr th td{
white-space:nowrap
Kshitij-Katiyar marked this conversation as resolved.
Show resolved Hide resolved
}
9 changes: 9 additions & 0 deletions webapp/src/hooks/usePluginApi.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import {useSelector} from 'react-redux';

function usePluginApi() {
const state = useSelector((pluginState: PluginState) => pluginState);

return {state};
}

export default usePluginApi;
17 changes: 13 additions & 4 deletions webapp/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,34 @@ import {GlobalState} from 'mattermost-redux/types/store';
// Constants

// Containers

import {PluginRegistry} from 'types/mattermostWebapp';

import ExistingConfigTable from 'containers/components/tables/existingConfigTable';

Kshitij-Katiyar marked this conversation as resolved.
Show resolved Hide resolved
import AttachmentMsgModal from 'containers/components/modals/attachmentMsgModal';

import ChannelHeaderButton from './containers/components/channelHeaderButton';
import RHS from './containers/rhs';

// Reducer
import reducers from './reducers';

import {PluginRegistry} from './types/mattermostWebapp';

import pluginConstants from './pluginConstants';

import {pluginId} from './manifest';
import {id} from './manifest';

export default class Plugin {
// eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/no-empty-function

Kshitij-Katiyar marked this conversation as resolved.
Show resolved Hide resolved
public async initialize(registry: PluginRegistry, store: Store<GlobalState, Action<Record<string, unknown>>>) {
// @see https://developers.mattermost.com/extend/plugins/webapp/reference/
registry.registerReducer(reducers);
const {showRHSPlugin} = registry.registerRightHandSidebarComponent(RHS, pluginConstants.common.RIGHT_SIDEBAR_HEADER);
registry.registerChannelHeaderButtonAction(<ChannelHeaderButton/>, () => store.dispatch(showRHSPlugin), null, pluginConstants.common.CHANNEL_HEADER_BUTTON_TOOLTIP);
registry.registerAdminConsoleCustomSetting('ExistingConfigurationTable', ExistingConfigTable);
registry.registerRootComponent(AttachmentMsgModal);
registry.registerRootComponent(StaticExample);
}
}

Expand All @@ -37,4 +46,4 @@ declare global {
}
}

window.registerPlugin(pluginId, new Plugin());
window.registerPlugin(id, new Plugin());
6 changes: 3 additions & 3 deletions webapp/src/manifest.test.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {pluginId, pluginVersion} from './manifest';
import {id, version} from './manifest';

// To ease migration, verify separate export of id and version.
test('Plugin id and version are defined', () => {
expect(pluginId).toBeDefined();
expect(pluginVersion).toBeDefined();
expect(id).toBeDefined();
expect(version).toBeDefined();
});
7 changes: 4 additions & 3 deletions webapp/src/manifest.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Code generated .* DO NOT EDIT.
export const pluginId = 'mattermost-plugin-template';
export const pluginVersion = '0.0.1';
// This file is automatically generated. Do not modify it manually.

export const id = 'com.mattermost.welcomebot';
export const version = '1.3.0';
2 changes: 2 additions & 0 deletions webapp/src/reducers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@ import {examplePluginApi} from 'services';
import globalModalSlice from './globalModal';
import apiRequestCompletionSlice from './apiRequest';
import websocketEventSlice from './websocketEvent';
import viewConfigModalSlice from './viewConfigModal';

const reducers = combineReducers({
apiRequestCompletionSlice,
globalModalSlice,
websocketEventSlice,
viewConfigModalSlice,
[examplePluginApi.reducerPath]: examplePluginApi.reducer,
});

Expand Down
22 changes: 22 additions & 0 deletions webapp/src/reducers/viewConfigModal/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import {createSlice} from '@reduxjs/toolkit';

const initialState: ViewConfigModalState = {
isVisible: false,
};

export const viewConfigModalSlice = createSlice({
name: 'viewConfigModalSlice',
initialState,
reducers: {
showViewConfigModalState: (state: ViewConfigModalState) => {
state.isVisible = true;
},
hideViewConfigModalState: (state: ViewConfigModalState) => {
state.isVisible = false;
},
},
});

export const {showViewConfigModalState, hideViewConfigModalState} = viewConfigModalSlice.actions;

export default viewConfigModalSlice.reducer;
Loading