-
Notifications
You must be signed in to change notification settings - Fork 219
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
RND-370-add-info-button-to-the-3-dots
- Loading branch information
svetaStrech
committed
Dec 31, 2023
1 parent
7b6d06d
commit c1b01d8
Showing
5 changed files
with
165 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
// Copyright 2022-2023 The Memphis.dev Authors | ||
// Licensed under the Memphis Business Source License 1.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// Changed License: [Apache License, Version 2.0 (https://www.apache.org/licenses/LICENSE-2.0), as published by the Apache Foundation. | ||
// | ||
// https://github.com/memphisdev/memphis/blob/master/LICENSE | ||
// | ||
// Additional Use Grant: You may make use of the Licensed Work (i) only as part of your own product or service, provided it is not a message broker or a message queue product or service; and (ii) provided that you do not use, provide, distribute, or make available the Licensed Work as a Service. | ||
// A "Service" is a commercial offering, product, hosted, or managed service, that allows third parties (other than your own employees and contractors acting on your behalf) to access and/or use the Licensed Work or a substantial set of the features or functionality of the Licensed Work to third parties as a software-as-a-service, platform-as-a-service, infrastructure-as-a-service or other similar services that compete with Licensor products or services. | ||
|
||
import './style.scss'; | ||
|
||
import React, { useEffect, useState } from 'react'; | ||
import Modal from '../modal'; | ||
import Spinner from '../spinner'; | ||
import { ApiEndpoints } from '../../const/apiEndpoints'; | ||
import { httpRequest } from '../../services/http'; | ||
import { sendTrace } from '../../services/genericServices'; | ||
import { connectorTypesSource, connectorTypesSink } from '../../connectors'; | ||
|
||
const ConnectorInfo = ({ open, clickOutside, connectorId }) => { | ||
const [loading, setLoading] = useState(false); | ||
const [info, setInfo] = useState(null); | ||
|
||
useEffect(() => { | ||
!open && setInfo(null); | ||
open && getConnectorInfo(connectorId); | ||
}, [open]); | ||
|
||
const getConnectorInfo = async (connectorId) => { | ||
setLoading(true); | ||
try { | ||
const data = await httpRequest('GET', `${ApiEndpoints.GET_CONNECTOR_DETAILS}?connector_id=${connectorId}`); | ||
arrangeData(data); | ||
sendTrace('getConnectorInfo', { | ||
connector_type: data?.connector_type, | ||
type: data?.type | ||
}); | ||
} catch (error) { | ||
} finally { | ||
setLoading(false); | ||
} | ||
}; | ||
|
||
const arrangeData = (data) => { | ||
let fieldInputs; | ||
if (data?.connector_type === 'source') { | ||
let field = connectorTypesSource.find((connector) => connector?.name?.toLocaleLowerCase() === data?.type); | ||
fieldInputs = field?.inputs?.Source; | ||
} else if (data?.connector_type === 'sink') { | ||
let field = connectorTypesSink.find((connector) => connector?.name?.toLocaleLowerCase() === data?.type); | ||
fieldInputs = field?.inputs?.Sink; | ||
} | ||
let formFields = []; | ||
fieldInputs?.forEach((field) => { | ||
formFields.push({ name: field?.display, value: data[field?.name] || data?.settings[field?.name] }); | ||
if (field?.children) { | ||
field?.options?.forEach((option) => { | ||
if (data?.settings[option?.toLocaleLowerCase()?.replace(/ /g, '_')]) { | ||
formFields.push({ name: option, value: data?.settings[option?.toLocaleLowerCase()?.replace(/ /g, '_')] }); | ||
} | ||
}); | ||
} | ||
}); | ||
setInfo(formFields); | ||
}; | ||
|
||
return ( | ||
<Modal | ||
header={'Connector Information'} | ||
className={'modal-wrapper produce-modal'} | ||
width="550px" | ||
height="50vh" | ||
clickOutside={clickOutside} | ||
open={open} | ||
displayButtons={true} | ||
rBtnText={'Close'} | ||
rBtnClick={clickOutside} | ||
> | ||
<div className="connector-info"> | ||
{loading && ( | ||
<div className="loader"> | ||
<Spinner /> | ||
</div> | ||
)} | ||
{!loading && | ||
info?.map((field, index) => { | ||
return ( | ||
<div key={index} className="field-conainer"> | ||
<label className="field-name">{field?.name}</label> | ||
<label className="field-value">{field?.value}</label> | ||
</div> | ||
); | ||
})} | ||
</div> | ||
</Modal> | ||
); | ||
}; | ||
|
||
export default ConnectorInfo; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
.connector-info { | ||
width: 100%; | ||
height: 100%; | ||
display: flex; | ||
flex-direction: column; | ||
padding-top: 30px; | ||
overflow-y: auto; | ||
.loader { | ||
width: 100%; | ||
display: flex; | ||
justify-content: center; | ||
margin-top: 10px; | ||
} | ||
.field-conainer { | ||
display: flex; | ||
flex-direction: column; | ||
margin-bottom: 20px; | ||
.field-name { | ||
color: #737373; | ||
font-family: 'Inter'; | ||
font-size: 12px; | ||
text-transform: capitalize; | ||
} | ||
.field-value { | ||
color: #000; | ||
font-family: 'Inter'; | ||
font-size: 14px; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters