diff --git a/services/web-ui/src/pages/Integrations/TypeDetailNew/Credentials/Update/index.tsx b/services/web-ui/src/pages/Integrations/TypeDetailNew/Credentials/Update/index.tsx index 0c5ac79c6..fe74f5225 100644 --- a/services/web-ui/src/pages/Integrations/TypeDetailNew/Credentials/Update/index.tsx +++ b/services/web-ui/src/pages/Integrations/TypeDetailNew/Credentials/Update/index.tsx @@ -22,7 +22,9 @@ import { AppLayout, Box, Button, + FormField, Header, + Input, Modal, Multiselect, Pagination, @@ -69,6 +71,7 @@ export default function UpdateCredentials({ const [credentialId, setCredentialId] = useState('') const [described, setDescribed] = useState(false) const [credentialType, setCredentialType] = useState('') + const [description, setDescription] = useState('') const UpdateCredentials = () => { setLoading(true) @@ -90,6 +93,8 @@ export default function UpdateCredentials({ const formData = new FormData() // @ts-ignore formData.append('credential_type', credentialType) + formData.append('description', description) + Object.keys(credential).forEach((key) => { formData.append(`credentials.${key}`, credential[key]) }) @@ -124,6 +129,7 @@ export default function UpdateCredentials({ const body = { credentials: credential, credential_type: credentialType, + description: description } axios .put( @@ -181,7 +187,9 @@ export default function UpdateCredentials({ credential_type: cred.label, }) - setCredentialType(cred.label) + setCredentialType( + cred.label + ) }} > {cred.label} @@ -224,6 +232,20 @@ export default function UpdateCredentials({ ) })} + + + setDescription(detail.value) + } + /> + ([]) + const navigate = useNavigate() + const [row, setRow] = useState([]) - const [loading, setLoading] = useState(false) - const [actionLoading, setActionLoading] = useState({ - update: false, - delete: false, - health_check: false, - }) + const [loading, setLoading] = useState(false) + const [actionLoading, setActionLoading] = useState({ + update: false, + delete: false, + health_check: false, + }) - const [error, setError] = useState('') - const [total_count, setTotalCount] = useState(0) - const [selectedItem, setSelectedItem] = useState() - const [page, setPage] = useState(0) - const [open, setOpen] = useState(false) - const [edit, setEdit] = useState(false) - const [openInfo, setOpenInfo] = useState(false) - const [confirmModal, setConfirmModal] = useState(false) - const [action, setAction] = useState() + const [error, setError] = useState('') + const [total_count, setTotalCount] = useState(0) + const [selectedItem, setSelectedItem] = useState() + const [page, setPage] = useState(0) + const [open, setOpen] = useState(false) + const [edit, setEdit] = useState(false) + const [openInfo, setOpenInfo] = useState(false) + const [confirmModal, setConfirmModal] = useState(false) + const [action, setAction] = useState() - const GetCredentials = () => { - setLoading(true) - let url = '' - if (window.location.origin === 'http://localhost:3000') { - url = window.__RUNTIME_CONFIG__.REACT_APP_BASE_URL - } else { - url = window.location.origin - } - // @ts-ignore - const token = JSON.parse(localStorage.getItem('openg_auth')).token + const GetCredentials = () => { + setLoading(true) + let url = '' + if (window.location.origin === 'http://localhost:3000') { + url = window.__RUNTIME_CONFIG__.REACT_APP_BASE_URL + } else { + url = window.location.origin + } + // @ts-ignore + const token = JSON.parse(localStorage.getItem('openg_auth')).token - const config = { - headers: { - Authorization: `Bearer ${token}`, - }, - } + const config = { + headers: { + Authorization: `Bearer ${token}`, + }, + } - const body = { - integration_type: [integration_type], - } - axios - .post( - `${url}/main/integration/api/v1/credentials/list`, - body, - config - ) - .then((res) => { - const data = res.data + const body = { + integration_type: [integration_type], + } + axios + .post( + `${url}/main/integration/api/v1/credentials/list`, + body, + config + ) + .then((res) => { + const data = res.data - setTotalCount(data.total_count) - setRow(data.credentials) - setLoading(false) - }) - .catch((err) => { - console.log(err) - setLoading(false) - }) - } - const CheckActionsClick = (action: any) => { - setAction(action) - if (action.type === 'update') { - setEdit(true) - } else if (action.type === 'delete') { - if (action?.confirm?.message && action?.confirm?.message !== '') { - setConfirmModal(true) - } else { - CheckActionsSumbit(action) - } - } - } - const CheckActionsSumbit = (action: any) => { - if (action?.type === 'update') { - setEdit(true) - } else if (action?.type === 'delete') { - DeleteIntegration() - } - } + setTotalCount(data.total_count) + setRow(data.credentials) + setLoading(false) + }) + .catch((err) => { + console.log(err) + setLoading(false) + }) + } + const CheckActionsClick = (action: any) => { + setAction(action) + if (action.type === 'update') { + setEdit(true) + } else if (action.type === 'delete') { + if (action?.confirm?.message && action?.confirm?.message !== '') { + setConfirmModal(true) + } else { + CheckActionsSumbit(action) + } + } + } + const CheckActionsSumbit = (action: any) => { + if (action?.type === 'update') { + setEdit(true) + } else if (action?.type === 'delete') { + DeleteIntegration() + } + } - const DeleteIntegration = () => { - setActionLoading({ ...actionLoading, delete: true }) + const DeleteIntegration = () => { + setActionLoading({ ...actionLoading, delete: true }) - let url = '' - if (window.location.origin === 'http://localhost:3000') { - url = window.__RUNTIME_CONFIG__.REACT_APP_BASE_URL - } else { - url = window.location.origin - } - // @ts-ignore - const token = JSON.parse(localStorage.getItem('openg_auth')).token + let url = '' + if (window.location.origin === 'http://localhost:3000') { + url = window.__RUNTIME_CONFIG__.REACT_APP_BASE_URL + } else { + url = window.location.origin + } + // @ts-ignore + const token = JSON.parse(localStorage.getItem('openg_auth')).token - const config = { - headers: { - Authorization: `Bearer ${token}`, - }, - } + const config = { + headers: { + Authorization: `Bearer ${token}`, + }, + } - axios - .delete( - `${url}/main/integration/api/v1/credentials/${selectedItem?.id}`, + axios + .delete( + `${url}/main/integration/api/v1/credentials/${selectedItem?.id}`, - config - ) - .then((res) => { - GetCredentials() - setConfirmModal(false) - setOpenInfo(false) - setActionLoading({ ...actionLoading, delete: false }) - }) - .catch((err) => { - console.log(err) - setActionLoading({ - ...actionLoading, - delete: false, - }) - }) - } - + config + ) + .then((res) => { + GetCredentials() + setConfirmModal(false) + setOpenInfo(false) + setActionLoading({ ...actionLoading, delete: false }) + }) + .catch((err) => { + console.log(err) + setActionLoading({ + ...actionLoading, + delete: false, + }) + }) + } + const GetMarkedSecrets = () => { + // iterate over key value pair + // @ts-ignore + if (selectedItem?.masked_secret) { + return Object.keys(selectedItem?.masked_secret)?.map((key) => { + return { + label: key, + value: selectedItem?.masked_secret[key], + } + }) + } + return [] + } - useEffect(() => { - GetCredentials() - }, []) + useEffect(() => { + GetCredentials() + }, []) - return ( - <> - {schema ? ( - <> - { - setOpenInfo(!openInfo) - }} - splitPanel={ - - 4 - ? 4 - : GetViewFields(schema, 1)?.length - } - // @ts-ignore - items={GetViewFields(schema, 1)?.map( - (field) => { - return { - label: field.title, - value: selectedItem - ? RenderTableField( - field, - selectedItem - ) - : '', - } - } - )} - /> - - <> - {GetActions(1, schema)?.map( - (action) => { - if (action.type !== 'view') { - return ( - <> - - + return ( + <> + {schema ? ( + <> + { + setOpenInfo(!openInfo) + }} + splitPanel={ + + 4 + ? 4 + : GetViewFields(schema, 1)?.length + } + // @ts-ignore + items={GetViewFields(schema, 1)?.map( + (field) => { + return { + label: field.title, + value: selectedItem + ? RenderTableField( + field, + selectedItem ) - } - } - )} - - - - } - content={ - - `Displaying items ${firstIndex} to ${lastIndex} of ${totalItemsCount}` - } - onSortingChange={(event) => { - // setSort(event.detail.sortingColumn.sortingField) - // setSortOrder(!sortOrder) - }} - // sortingColumn={sort} - // sortingDescending={sortOrder} - // sortingDescending={sortOrder == 'desc' ? true : false} - // @ts-ignore - onRowClick={(event) => { - const row = event.detail.item - // @ts-ignore - setSelectedItem(row) - setOpenInfo(true) - }} - // @ts-ignore + : '', + } + } + )} + /> + 4 + ? 4 + : GetMarkedSecrets().length + } + items={GetMarkedSecrets()} + /> + + <> + {GetActions(1, schema)?.map( + (action) => { + if (action.type !== 'view') { + return ( + <> + + + ) + } + } + )} + + + + } + content={ +
+ `Displaying items ${firstIndex} to ${lastIndex} of ${totalItemsCount}` + } + onSortingChange={(event) => { + // setSort(event.detail.sortingColumn.sortingField) + // setSortOrder(!sortOrder) + }} + // sortingColumn={sort} + // sortingDescending={sortOrder} + // sortingDescending={sortOrder == 'desc' ? true : false} + // @ts-ignore + onRowClick={(event) => { + const row = event.detail.item + // @ts-ignore + setSelectedItem(row) + setOpenInfo(true) + }} + // @ts-ignore - columnDefinitions={GetTableColumns( - 1, - schema - )?.map((field) => { - return { - id: field.key, - header: field.title, - // @ts-ignore - cell: (item) => ( - <> - {RenderTableField( - field, - item - )} - - ), - // sortingField: 'providerConnectionID', - isRowHeader: true, - maxWidth: 100, - } - })} - columnDisplay={GetTableColumnsDefintion( - 1, - schema - )} - enableKeyboardNavigation - // @ts-ignore - items={row?.length > 0 ? row : []} - loading={loading} - loadingText="Loading resources" - // stickyColumns={{ first: 0, last: 1 }} - // stripedRows - trackBy="id" - empty={ - - - No resources - - - } - filter={ - '' - // { - // // @ts-ignore - // setQueries(detail) - // }} - // // countText="5 matches" - // enableTokenGroups - // expandToViewport - // filteringAriaLabel="Control Categories" - // // @ts-ignore - // // filteringOptions={filters} - // filteringPlaceholder="Control Categories" - // // @ts-ignore - // filteringOptions={undefined} - // // @ts-ignore + columnDefinitions={GetTableColumns( + 1, + schema + )?.map((field) => { + return { + id: field.key, + header: field.title, + // @ts-ignore + cell: (item) => ( + <>{RenderTableField(field, item)} + ), + // sortingField: 'providerConnectionID', + isRowHeader: true, + maxWidth: 100, + } + })} + columnDisplay={GetTableColumnsDefintion( + 1, + schema + )} + enableKeyboardNavigation + // @ts-ignore + items={row?.length > 0 ? row : []} + loading={loading} + loadingText="Loading resources" + // stickyColumns={{ first: 0, last: 1 }} + // stripedRows + trackBy="id" + empty={ + + + No resources + + + } + filter={ + '' + // { + // // @ts-ignore + // setQueries(detail) + // }} + // // countText="5 matches" + // enableTokenGroups + // expandToViewport + // filteringAriaLabel="Control Categories" + // // @ts-ignore + // // filteringOptions={filters} + // filteringPlaceholder="Control Categories" + // // @ts-ignore + // filteringOptions={undefined} + // // @ts-ignore - // filteringProperties={undefined} - // // filteringProperties={ - // // filterOption - // // } - // /> - } - header={ -
- {/* */} - {/* */} - - - } - className="w-full" - > - {name} Credentials{' '} - - ({total_count}) - -
- } - pagination={ - - setPage( - detail.currentPageIndex - 1 - ) - } - /> - } - /> - } - /> - setEdit(false)} - GetList={GetCredentials} - selectedItem={selectedItem} - /> - setConfirmModal(false)} - // @ts-ignore - header={ - // @ts-ignore + + + } + className="w-full" + > + {name} Credentials{' '} + + ({total_count}) + + + } + pagination={ + + setPage(detail.currentPageIndex - 1) + } + /> + } + /> + } + /> + setEdit(false)} + GetList={GetCredentials} + selectedItem={selectedItem} + /> + setConfirmModal(false)} + // @ts-ignore + header={ + // @ts-ignore - action?.label - ? // @ts-ignore - action.label + ' ' + selectedItem?.name - : '' - } - > - - {/* @ts-ignore */} - {action?.confirm?.message} - - - - - - - - ) : ( - - )} - - ) + action?.label + ? // @ts-ignore + action.label + ' ' + selectedItem?.name + : '' + } + > + + {/* @ts-ignore */} + {action?.confirm?.message} + + + + + + + + ) : ( + + )} + + ) } diff --git a/services/web-ui/src/pages/Integrations/TypeDetailNew/Integration/Create/index.tsx b/services/web-ui/src/pages/Integrations/TypeDetailNew/Integration/Create/index.tsx index 11ecc0c86..08b749d6f 100644 --- a/services/web-ui/src/pages/Integrations/TypeDetailNew/Integration/Create/index.tsx +++ b/services/web-ui/src/pages/Integrations/TypeDetailNew/Integration/Create/index.tsx @@ -17,7 +17,9 @@ import { AppLayout, Box, Button, + FormField, Header, + Input, Modal, Multiselect, Pagination, @@ -57,6 +59,7 @@ export default function CreateIntegration({ const [credentialId, setCredentialId] = useState('') const [described, setDescribed] = useState(false) const [credentialType, setCredentialType] = useState('') + const [description, setDescription] = useState('') const DiscoverIntegrations = () => { setLoading(true) @@ -85,6 +88,7 @@ export default function CreateIntegration({ const formData = new FormData() // @ts-ignore formData.append('integration_type', integration_type) + formData.append('description', description) formData.append('credential_type', credentialType) Object.keys(integration).forEach((key) => { formData.append(`credentials.${key}`, integration[key]) @@ -125,6 +129,7 @@ export default function CreateIntegration({ integration_type: integration_type, credentials: integration, credential_type: credentialType, + description: description, } axios .post( @@ -222,14 +227,15 @@ export default function CreateIntegration({ return ( <> @@ -377,6 +383,22 @@ export default function CreateIntegration({ ) })} + + + setDescription(detail.value) + } + /> + ([]) const [selectedResourceType, setSelectedResourceType] = useState() const [runOpen, setRunOpen] = useState(false) - const [runAll, setRunAll] = useState(false) - + const [selectedIntegrations, setSelectedIntegrations] = useState([]) const GetIntegrations = () => { setLoading(true) let url = '' @@ -260,7 +259,7 @@ export default function IntegrationList({ }) } - const RunDiscovery = (flag: boolean) => { + const RunDiscovery = () => { setActionLoading({ ...actionLoading, discovery: true }) let url = '' if (window.location.origin === 'http://localhost:3000') { @@ -277,29 +276,15 @@ export default function IntegrationList({ }, } let body ={} - if(flag){ - body = { - integration_info:row?.map((item)=>{ - return { - integration_type: integration_type, - provider_id: item.provider_id, - integration_id: item.integration_id, - name: item.name, - } - }) , - } - } - else{ - body = { - integration_info: [ - { - integration_type: integration_type, - provider_id: selectedItem?.provider_id, - integration_id: selectedItem?.integration_id, - name: selectedItem?.name, - }, - ], - } + body = { + integration_info: selectedIntegrations?.map((item:any) => { + return { + integration_type: integration_type, + provider_id: item.provider_id, + integration_id: item.integration_id, + name: item.name, + } + }), } if(selectedResourceType?.length > 0 && selectedResourceType?.length < resourceTypes?.length){ // @ts-ignore @@ -462,17 +447,6 @@ export default function IntegrationList({ } } )} - @@ -604,7 +578,7 @@ export default function IntegrationList({ DisableIntegration() }} > - Disable Integration + Disable Integration Type } @@ -702,7 +674,7 @@ export default function IntegrationList({ // @ts-ignore header={'Run Discovery'} footer={ - +