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 * as React from 'react';
20 import Button from '@material-ui/core/Button';
21 import Dialog from '@material-ui/core/Dialog';
22 import DialogActions from '@material-ui/core/DialogActions';
23 import DialogContent from '@material-ui/core/DialogContent';
24 import DialogContentText from '@material-ui/core/DialogContentText';
25 import DialogTitle from '@material-ui/core/DialogTitle';
27 import { connectionStatusLogReloadAction } from '../handlers/connectionStatusLogHandler';
28 import { IDispatcher, connect, Connect } from '../../../../framework/src/flux/connect';
30 import { ConnectionStatusLogType } from '../models/connectionStatusLog';
32 export enum RefreshConnectionStatusLogDialogMode {
34 RefreshConnectionStatusLogTable = "RefreshConnectionStatusLogTable",
37 const mapDispatch = (dispatcher: IDispatcher) => ({
38 refreshConnectionStatusLog: () => dispatcher.dispatch(connectionStatusLogReloadAction)
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 [RefreshConnectionStatusLogDialogMode.None]: {
54 dialogDescription: "",
57 enableMountIdEditor: false,
58 enableUsernameEditor: false,
59 enableExtendedEditor: false,
61 [RefreshConnectionStatusLogDialogMode.RefreshConnectionStatusLogTable]: {
62 dialogTitle: "Do you want to refresh the Connection Status Log table?",
63 dialogDescription: "",
64 applyButtonText: "Yes",
65 cancelButtonText: "Cancel",
66 enableMountIdEditor: true,
67 enableUsernameEditor: true,
68 enableExtendedEditor: true,
72 type RefreshConnectionStatusLogDialogComponentProps = Connect<undefined, typeof mapDispatch> & {
73 mode: RefreshConnectionStatusLogDialogMode;
77 type RefreshConnectionStatusLogDialogComponentState = ConnectionStatusLogType & { isNameValid: boolean, isHostSet: boolean };
79 class RefreshConnectionStatusLogDialogComponent extends React.Component<RefreshConnectionStatusLogDialogComponentProps, RefreshConnectionStatusLogDialogComponentState> {
80 constructor(props: RefreshConnectionStatusLogDialogComponentProps) {
84 render(): JSX.Element {
85 const setting = settings[this.props.mode];
87 <Dialog open={this.props.mode !== RefreshConnectionStatusLogDialogMode.None}>
88 <DialogTitle id="form-dialog-title" aria-label={`${setting.dialogTitle.replace(/ /g, "-").toLowerCase()}-dialog`}>{setting.dialogTitle}</DialogTitle>
91 {setting.dialogDescription}
95 <Button aria-label="dialog-confirm-button" onClick={(event) => {
97 }} > {setting.applyButtonText} </Button>
98 <Button aria-label="dialog-cancel-button" onClick={(event) => {
100 }} color="secondary"> {setting.cancelButtonText} </Button>
106 private onRefresh = () => {
107 this.props.refreshConnectionStatusLog();
108 this.props.onClose();
111 private onCancel = () => {
112 this.props.onClose();
116 export const RefreshConnectionStatusLogDialog = connect(undefined, mapDispatch)(RefreshConnectionStatusLogDialogComponent);
117 export default RefreshConnectionStatusLogDialog;