|
| 1 | +/* |
| 2 | + * SPDX-License-Identifier: Apache-2.0 |
| 3 | + * SPDX-FileCopyrightText: Huawei Inc. |
| 4 | + */ |
| 5 | + |
| 6 | +import { Table } from 'antd'; |
| 7 | +import { ColumnsType } from 'antd/es/table'; |
| 8 | +import React from 'react'; |
| 9 | +import catalogStyles from '../../../styles/catalog.module.css'; |
| 10 | +import deploymentVariablesStyles from '../../../styles/deployment-variables.module.css'; |
| 11 | +import { ServiceChangeScript } from '../../../xpanse-api/generated'; |
| 12 | + |
| 13 | +function ServiceActionScripts({ actionScripts }: { actionScripts: ServiceChangeScript[] }): React.JSX.Element { |
| 14 | + const columns: ColumnsType<ServiceChangeScript> = [ |
| 15 | + { |
| 16 | + title: <div className={deploymentVariablesStyles.variablesColumns}>ChangeHandler</div>, |
| 17 | + dataIndex: 'changeHandler', |
| 18 | + render: (text: string) => { |
| 19 | + return <div className={deploymentVariablesStyles.variablesColumns}>{text}</div>; |
| 20 | + }, |
| 21 | + }, |
| 22 | + { |
| 23 | + title: <div className={deploymentVariablesStyles.variablesColumns}>RunOnlyOnce</div>, |
| 24 | + dataIndex: 'runOnlyOnce', |
| 25 | + render: (text: boolean | undefined | null) => { |
| 26 | + if (text === true) { |
| 27 | + return <div className={deploymentVariablesStyles.variablesColumns}>{`true`}</div>; |
| 28 | + } else if (text === false) { |
| 29 | + return <div className={deploymentVariablesStyles.variablesColumns}>{`false`}</div>; |
| 30 | + } else { |
| 31 | + return null; |
| 32 | + } |
| 33 | + }, |
| 34 | + }, |
| 35 | + { |
| 36 | + title: <div className={deploymentVariablesStyles.variablesColumns}>AnsibleScriptConfig</div>, |
| 37 | + dataIndex: 'ansibleScriptConfig', |
| 38 | + children: [ |
| 39 | + { |
| 40 | + title: <div className={deploymentVariablesStyles.variablesTableChildrenTitle}>Playbook Name</div>, |
| 41 | + dataIndex: ['ansibleScriptConfig', 'playbookName'], |
| 42 | + key: 'playbookName', |
| 43 | + render: (text: string) => { |
| 44 | + return <div className={deploymentVariablesStyles.variablesColumns}>{text}</div>; |
| 45 | + }, |
| 46 | + }, |
| 47 | + { |
| 48 | + title: <div className={deploymentVariablesStyles.variablesTableChildrenTitle}>Virtual Env</div>, |
| 49 | + dataIndex: ['ansibleScriptConfig', 'virtualEnv'], |
| 50 | + key: 'virtualEnv', |
| 51 | + render: (text: string) => { |
| 52 | + return <div className={deploymentVariablesStyles.variablesColumns}>{text}</div>; |
| 53 | + }, |
| 54 | + }, |
| 55 | + { |
| 56 | + title: <div className={deploymentVariablesStyles.variablesTableChildrenTitle}>Python Version</div>, |
| 57 | + dataIndex: ['ansibleScriptConfig', 'pythonVersion'], |
| 58 | + key: 'pythonVersion', |
| 59 | + render: (text: string) => { |
| 60 | + return <div className={deploymentVariablesStyles.variablesColumns}>{text}</div>; |
| 61 | + }, |
| 62 | + }, |
| 63 | + { |
| 64 | + title: ( |
| 65 | + <div className={deploymentVariablesStyles.variablesTableChildrenTitle}> |
| 66 | + Is Prepare Ansible Environment |
| 67 | + </div> |
| 68 | + ), |
| 69 | + dataIndex: ['ansibleScriptConfig', 'isPrepareAnsibleEnvironment'], |
| 70 | + key: 'isPrepareAnsibleEnvironment', |
| 71 | + render: (text: boolean | undefined | null) => { |
| 72 | + if (text === true) { |
| 73 | + return <div className={deploymentVariablesStyles.variablesColumns}>{`true`}</div>; |
| 74 | + } else if (text === false) { |
| 75 | + return <div className={deploymentVariablesStyles.variablesColumns}>{`false`}</div>; |
| 76 | + } else { |
| 77 | + return null; |
| 78 | + } |
| 79 | + }, |
| 80 | + }, |
| 81 | + { |
| 82 | + title: <div className={deploymentVariablesStyles.variablesTableChildrenTitle}>RepoUrl</div>, |
| 83 | + dataIndex: ['ansibleScriptConfig', 'repoUrl'], |
| 84 | + key: 'repoUrl', |
| 85 | + render: (text: string) => { |
| 86 | + return <div className={deploymentVariablesStyles.variablesColumns}>{text}</div>; |
| 87 | + }, |
| 88 | + }, |
| 89 | + { |
| 90 | + title: <div className={deploymentVariablesStyles.variablesTableChildrenTitle}>Branch</div>, |
| 91 | + dataIndex: ['ansibleScriptConfig', 'branch'], |
| 92 | + key: 'branch', |
| 93 | + render: (text: string) => { |
| 94 | + return <div className={deploymentVariablesStyles.variablesColumns}>{text}</div>; |
| 95 | + }, |
| 96 | + }, |
| 97 | + { |
| 98 | + title: ( |
| 99 | + <div className={deploymentVariablesStyles.variablesTableChildrenTitle}>RequirementsFile</div> |
| 100 | + ), |
| 101 | + dataIndex: ['ansibleScriptConfig', 'requirementsFile'], |
| 102 | + key: 'requirementsFile', |
| 103 | + render: (text: string) => { |
| 104 | + return <div className={deploymentVariablesStyles.variablesColumns}>{text}</div>; |
| 105 | + }, |
| 106 | + }, |
| 107 | + { |
| 108 | + title: <div className={deploymentVariablesStyles.variablesTableChildrenTitle}>GalaxyFile</div>, |
| 109 | + dataIndex: ['ansibleScriptConfig', 'galaxyFile'], |
| 110 | + key: 'galaxyFile', |
| 111 | + render: (text: string) => { |
| 112 | + return <div className={deploymentVariablesStyles.variablesColumns}>{text}</div>; |
| 113 | + }, |
| 114 | + }, |
| 115 | + { |
| 116 | + title: ( |
| 117 | + <div className={deploymentVariablesStyles.variablesTableChildrenTitle}> |
| 118 | + AnsibleInventoryRequired |
| 119 | + </div> |
| 120 | + ), |
| 121 | + dataIndex: ['ansibleScriptConfig', 'ansibleInventoryRequired'], |
| 122 | + key: 'ansibleInventoryRequired', |
| 123 | + render: (text: boolean | undefined | null) => { |
| 124 | + if (text === true) { |
| 125 | + return <div className={deploymentVariablesStyles.variablesColumns}>{`true`}</div>; |
| 126 | + } else if (text === false) { |
| 127 | + return <div className={deploymentVariablesStyles.variablesColumns}>{`false`}</div>; |
| 128 | + } else { |
| 129 | + return null; |
| 130 | + } |
| 131 | + }, |
| 132 | + }, |
| 133 | + ], |
| 134 | + }, |
| 135 | + ]; |
| 136 | + |
| 137 | + return ( |
| 138 | + <> |
| 139 | + <div className={`${catalogStyles.catalogDetailsH6} ${catalogStyles.managementVariable}`}> |
| 140 | + Service Action Scripts |
| 141 | + </div> |
| 142 | + <div className={deploymentVariablesStyles.variablesTableContainer}> |
| 143 | + <Table bordered columns={columns} dataSource={actionScripts} rowKey={'name'} pagination={false} /> |
| 144 | + </div> |
| 145 | + </> |
| 146 | + ); |
| 147 | +} |
| 148 | + |
| 149 | +export default ServiceActionScripts; |
0 commit comments