-
Notifications
You must be signed in to change notification settings - Fork 202
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[GEN-1797]: keep drawer open after update (#1859)
- Loading branch information
1 parent
a7a7dfa
commit 2eae7e9
Showing
19 changed files
with
346 additions
and
212 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
21 changes: 21 additions & 0 deletions
21
frontend/webapp/containers/main/actions/action-drawer/build-drawer-item.ts
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,21 @@ | ||
import { safeJsonParse } from '@/utils'; | ||
import type { ActionDataParsed, ActionInput } from '@/types'; | ||
|
||
const buildDrawerItem = (id: string, formData: ActionInput, drawerItem: ActionDataParsed): ActionDataParsed => { | ||
const { type, name, notes, signals, disable, details } = formData; | ||
const {} = drawerItem; | ||
|
||
return { | ||
id, | ||
type, | ||
spec: { | ||
actionName: name, | ||
notes: notes, | ||
signals: signals, | ||
disabled: disable, | ||
...safeJsonParse(details, {}), | ||
}, | ||
}; | ||
}; | ||
|
||
export default buildDrawerItem; |
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
32 changes: 32 additions & 0 deletions
32
frontend/webapp/containers/main/destinations/destination-drawer/build-card.ts
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,32 @@ | ||
import { ActualDestination, DestinationDetailsResponse, ExportedSignals } from '@/types'; | ||
import { safeJsonParse } from '@/utils'; | ||
|
||
const buildMonitorsList = (exportedSignals: ExportedSignals): string => | ||
Object.keys(exportedSignals) | ||
.filter((key) => exportedSignals[key]) | ||
.join(', ') || 'N/A'; | ||
|
||
const buildCard = (destination: ActualDestination, destinationTypeDetails: DestinationDetailsResponse['destinationTypeDetails']) => { | ||
const { exportedSignals, destinationType, fields } = destination; | ||
|
||
const arr = [ | ||
{ title: 'Destination', value: destinationType.displayName }, | ||
{ title: 'Monitors', value: buildMonitorsList(exportedSignals) }, | ||
]; | ||
|
||
Object.entries(safeJsonParse<Record<string, string>>(fields, {})).map(([key, value]) => { | ||
const found = destinationTypeDetails?.fields?.find((field) => field.name === key); | ||
|
||
const { type } = safeJsonParse(found?.componentProperties, { type: '' }); | ||
const secret = type === 'password' ? new Array(value.length).fill('•').join('') : ''; | ||
|
||
arr.push({ | ||
title: found?.displayName || key, | ||
value: secret || value || 'N/A', | ||
}); | ||
}); | ||
|
||
return arr; | ||
}; | ||
|
||
export default buildCard; |
21 changes: 21 additions & 0 deletions
21
frontend/webapp/containers/main/destinations/destination-drawer/build-drawer-item.ts
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,21 @@ | ||
import type { ActualDestination, DestinationInput } from '@/types'; | ||
|
||
const buildDrawerItem = (id: string, formData: DestinationInput, drawerItem: ActualDestination): ActualDestination => { | ||
const { name, exportedSignals, fields } = formData; | ||
const { destinationType, conditions } = drawerItem || {}; | ||
|
||
let fieldsStringified: string | Record<string, any> = {}; | ||
fields.forEach(({ key, value }) => (fieldsStringified[key] = value)); | ||
fieldsStringified = JSON.stringify(fieldsStringified); | ||
|
||
return { | ||
id, | ||
name, | ||
exportedSignals, | ||
fields: fieldsStringified, | ||
destinationType, | ||
conditions, | ||
}; | ||
}; | ||
|
||
export default buildDrawerItem; |
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
Oops, something went wrong.