2 * ============LICENSE_START========================================================================
3 * ONAP : ccsdk feature sdnr wt odlux
4 * =================================================================================================
5 * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved.
6 * =================================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
8 * in compliance with the License. You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software distributed under the License
13 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
14 * or implied. See the License for the specific language governing permissions and limitations under
16 * ============LICENSE_END==========================================================================
18 import React from 'react';
20 import Button from '@mui/material/Button';
21 import Dialog from '@mui/material/Dialog';
22 import DialogActions from '@mui/material/DialogActions';
23 import DialogContent from '@mui/material/DialogContent';
24 import DialogContentText from '@mui/material/DialogContentText';
25 import DialogTitle from '@mui/material/DialogTitle';
27 import { connect, Connect, IDispatcher } from '../../../../framework/src/flux/connect';
29 import { networkElementsReloadAction } from '../handlers/networkElementsHandler';
30 import { NetworkElementConnection } from '../models/networkElementConnection';
32 export enum RefreshNetworkElementsDialogMode {
34 RefreshNetworkElementsTable = 'RefreshNetworkElementsTable',
37 const mapDispatch = (dispatcher: IDispatcher) => ({
38 refreshNetworkElement: () => dispatcher.dispatch(networkElementsReloadAction),
41 type DialogSettings = {
43 dialogDescription: string;
44 applyButtonText: string;
45 cancelButtonText: string;
46 enableMountIdEditor: boolean;
47 enableUsernameEditor: boolean;
48 enableExtendedEditor: boolean;
51 const settings: { [key: string]: DialogSettings } = {
52 [RefreshNetworkElementsDialogMode.None]: {
54 dialogDescription: '',
57 enableMountIdEditor: false,
58 enableUsernameEditor: false,
59 enableExtendedEditor: false,
61 [RefreshNetworkElementsDialogMode.RefreshNetworkElementsTable]: {
62 dialogTitle: 'Do you want to refresh the nodes table?',
63 dialogDescription: '',
64 applyButtonText: 'Yes',
65 cancelButtonText: 'Cancel',
66 enableMountIdEditor: true,
67 enableUsernameEditor: true,
68 enableExtendedEditor: true,
72 type RefreshNetworkElementsDialogComponentProps = Connect<undefined, typeof mapDispatch> & {
73 mode: RefreshNetworkElementsDialogMode;
77 type RefreshNetworkElementsDialogComponentState = NetworkElementConnection & { isNameValid: boolean; isHostSet: boolean };
79 class RefreshNetworkElementsDialogComponent extends React.Component<RefreshNetworkElementsDialogComponentProps, RefreshNetworkElementsDialogComponentState> {
81 render(): JSX.Element {
82 const setting = settings[this.props.mode];
84 <Dialog open={this.props.mode !== RefreshNetworkElementsDialogMode.None}>
85 <DialogTitle id="form-dialog-title" aria-label={`${setting.dialogTitle.replace(/ /g, '-').toLowerCase()}-dialog`}>{setting.dialogTitle}</DialogTitle>
88 {setting.dialogDescription}
92 <Button aria-label="dialog-confirm-button" onClick={() => {
94 }} color="inherit" > {setting.applyButtonText} </Button>
95 <Button aria-label="dialog-cancel-button" onClick={() => {
97 }} color="secondary"> {setting.cancelButtonText} </Button>
103 private onRefresh = () => {
104 this.props.refreshNetworkElement();
105 this.props.onClose();
108 private onCancel = () => {
109 this.props.onClose();
113 export const RefreshNetworkElementsDialog = connect(undefined, mapDispatch)(RefreshNetworkElementsDialogComponent);
114 export default RefreshNetworkElementsDialog;