|
| 1 | +import { Tab, Tabs } from "@flanksource-ui/ui/Tabs/Tabs"; |
1 | 2 | import React, { useEffect, useState } from "react";
|
2 | 3 | import { Icon } from "../../ui/Icons/Icon";
|
3 | 4 | import { Modal } from "../../ui/Modal";
|
| 5 | +import PermissionsView from "../Permissions/PermissionsView"; |
4 | 6 | import ConnectionForm from "./ConnectionForm";
|
5 | 7 | import ConnectionListView from "./ConnectionListView";
|
6 | 8 | import ConnectionSpecEditor from "./ConnectionSpecEditor";
|
@@ -81,6 +83,8 @@ export default function ConnectionFormModal({
|
81 | 83 | ConnectionType | undefined
|
82 | 84 | >(() => connectionTypes.find((item) => item.title === formValue?.type));
|
83 | 85 |
|
| 86 | + const [activeTab, setActiveTab] = useState<"form" | "permissions">("form"); |
| 87 | + |
84 | 88 | useEffect(() => {
|
85 | 89 | let connection = connectionTypes.find(
|
86 | 90 | (item) => item.value === formValue?.type
|
@@ -122,16 +126,54 @@ export default function ConnectionFormModal({
|
122 | 126 | helpLink="reference/connections/"
|
123 | 127 | >
|
124 | 128 | {type ? (
|
125 |
| - <ConnectionForm |
126 |
| - handleBack={() => setConnectionType(undefined)} |
127 |
| - connectionType={type} |
128 |
| - onConnectionSubmit={onConnectionSubmit} |
129 |
| - onConnectionDelete={onConnectionDelete} |
130 |
| - formValue={formValue} |
131 |
| - className={className} |
132 |
| - isSubmitting={isSubmitting} |
133 |
| - isDeleting={isDeleting} |
134 |
| - /> |
| 129 | + formValue?.id ? ( |
| 130 | + <Tabs |
| 131 | + activeTab={activeTab} |
| 132 | + onSelectTab={(label) => setActiveTab(label)} |
| 133 | + className="flex-1" |
| 134 | + > |
| 135 | + <Tab |
| 136 | + label="Edit Connection" |
| 137 | + value={"form"} |
| 138 | + className="flex flex-col" |
| 139 | + > |
| 140 | + <ConnectionForm |
| 141 | + handleBack={() => setConnectionType(undefined)} |
| 142 | + connectionType={type} |
| 143 | + onConnectionSubmit={onConnectionSubmit} |
| 144 | + onConnectionDelete={onConnectionDelete} |
| 145 | + formValue={formValue} |
| 146 | + className={className} |
| 147 | + isSubmitting={isSubmitting} |
| 148 | + isDeleting={isDeleting} |
| 149 | + /> |
| 150 | + </Tab> |
| 151 | + |
| 152 | + <Tab |
| 153 | + label="Permissions" |
| 154 | + value={"connections"} |
| 155 | + className="flex flex-col" |
| 156 | + > |
| 157 | + <PermissionsView |
| 158 | + hideResourceColumn |
| 159 | + permissionRequest={{ |
| 160 | + connectionId: formValue.id |
| 161 | + }} |
| 162 | + /> |
| 163 | + </Tab> |
| 164 | + </Tabs> |
| 165 | + ) : ( |
| 166 | + <ConnectionForm |
| 167 | + handleBack={() => setConnectionType(undefined)} |
| 168 | + connectionType={type} |
| 169 | + onConnectionSubmit={onConnectionSubmit} |
| 170 | + onConnectionDelete={onConnectionDelete} |
| 171 | + formValue={formValue} |
| 172 | + className={className} |
| 173 | + isSubmitting={isSubmitting} |
| 174 | + isDeleting={isDeleting} |
| 175 | + /> |
| 176 | + ) |
135 | 177 | ) : formValue?.id ? (
|
136 | 178 | <ConnectionSpecEditor
|
137 | 179 | handleBack={() => setConnectionType(undefined)}
|
|
0 commit comments