mirror of
https://github.com/farcasclaudiu/Flowise.git
synced 2026-06-28 21:00:58 +03:00
Bugfix/shared credentials not showing on ui (#5383)
* fix shared credentials not showing on ui * Enhance credential retrieval by including createdDate, updatedDate, and workspaceId fields; sanitize shared item data by omitting encryptedData.
This commit is contained in:
@@ -264,7 +264,7 @@ export class WorkspaceService {
|
|||||||
const itemIds = sharedItems.map((item) => item.sharedItemId)
|
const itemIds = sharedItems.map((item) => item.sharedItemId)
|
||||||
if (itemType === 'credential') {
|
if (itemType === 'credential') {
|
||||||
return await this.dataSource.getRepository(Credential).find({
|
return await this.dataSource.getRepository(Credential).find({
|
||||||
select: ['id', 'name', 'credentialName'],
|
select: ['id', 'name', 'credentialName', 'createdDate', 'updatedDate', 'workspaceId'],
|
||||||
where: { id: In(itemIds) }
|
where: { id: In(itemIds) }
|
||||||
})
|
})
|
||||||
} else if (itemType === 'custom_template') {
|
} else if (itemType === 'custom_template') {
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ const deleteCredentials = async (credentialId: string): Promise<any> => {
|
|||||||
const getAllCredentials = async (paramCredentialName: any, workspaceId?: string) => {
|
const getAllCredentials = async (paramCredentialName: any, workspaceId?: string) => {
|
||||||
try {
|
try {
|
||||||
const appServer = getRunningExpressApp()
|
const appServer = getRunningExpressApp()
|
||||||
let dbResponse = []
|
let dbResponse: any[] = []
|
||||||
if (paramCredentialName) {
|
if (paramCredentialName) {
|
||||||
if (Array.isArray(paramCredentialName)) {
|
if (Array.isArray(paramCredentialName)) {
|
||||||
for (let i = 0; i < paramCredentialName.length; i += 1) {
|
for (let i = 0; i < paramCredentialName.length; i += 1) {
|
||||||
@@ -83,14 +83,14 @@ const getAllCredentials = async (paramCredentialName: any, workspaceId?: string)
|
|||||||
if (sharedItem.credentialName === name) {
|
if (sharedItem.credentialName === name) {
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
sharedItem.shared = true
|
sharedItem.shared = true
|
||||||
dbResponse.push(sharedItem)
|
dbResponse.push(omit(sharedItem, ['encryptedData']))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (sharedItem.credentialName === paramCredentialName) {
|
if (sharedItem.credentialName === paramCredentialName) {
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
sharedItem.shared = true
|
sharedItem.shared = true
|
||||||
dbResponse.push(sharedItem)
|
dbResponse.push(omit(sharedItem, ['encryptedData']))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -110,7 +110,7 @@ const getAllCredentials = async (paramCredentialName: any, workspaceId?: string)
|
|||||||
for (const sharedItem of sharedItems) {
|
for (const sharedItem of sharedItems) {
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
sharedItem.shared = true
|
sharedItem.shared = true
|
||||||
dbResponse.push(sharedItem)
|
dbResponse.push(omit(sharedItem, ['encryptedData']))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -70,44 +70,29 @@ const ShareWithWorkspaceDialog = ({ show, dialogProps, onCancel, setError }) =>
|
|||||||
)
|
)
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (getSharedWorkspacesForItemApi.data) {
|
if (getWorkspacesByOrganizationIdUserIdApi.data && getSharedWorkspacesForItemApi.data) {
|
||||||
const data = getSharedWorkspacesForItemApi.data
|
const workspaces = []
|
||||||
if (data && data.length > 0) {
|
const sharedWorkspaces = getSharedWorkspacesForItemApi.data || []
|
||||||
outputSchema.map((row) => {
|
|
||||||
data.map((ws) => {
|
getWorkspacesByOrganizationIdUserIdApi.data
|
||||||
if (row.id === ws.workspaceId) {
|
.filter((ws) => ws.workspace.id !== user.activeWorkspaceId)
|
||||||
row.shared = true
|
.map((ws) => {
|
||||||
}
|
const isShared = sharedWorkspaces.some((sw) => sw.workspaceId === ws.workspace.id)
|
||||||
|
workspaces.push({
|
||||||
|
id: ws.workspace.id,
|
||||||
|
workspaceName: ws.workspace.name,
|
||||||
|
shared: isShared
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
setOutputSchema([...outputSchema])
|
setOutputSchema(workspaces)
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
}, [getWorkspacesByOrganizationIdUserIdApi.data, getSharedWorkspacesForItemApi.data, user.activeWorkspaceId])
|
||||||
}, [getSharedWorkspacesForItemApi.data])
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (getSharedWorkspacesForItemApi.error && setError) {
|
if (getSharedWorkspacesForItemApi.error && setError) {
|
||||||
setError(getSharedWorkspacesForItemApi.error)
|
setError(getSharedWorkspacesForItemApi.error)
|
||||||
}
|
}
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
}, [getSharedWorkspacesForItemApi.error, setError])
|
||||||
}, [getSharedWorkspacesForItemApi.error])
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (getWorkspacesByOrganizationIdUserIdApi.data) {
|
|
||||||
const workspaces = []
|
|
||||||
getWorkspacesByOrganizationIdUserIdApi.data
|
|
||||||
.filter((ws) => ws.workspace.id !== user.activeWorkspaceId)
|
|
||||||
.map((ws) => {
|
|
||||||
workspaces.push({
|
|
||||||
id: ws.workspace.id,
|
|
||||||
workspaceName: ws.workspace.name,
|
|
||||||
shared: false
|
|
||||||
})
|
|
||||||
})
|
|
||||||
setOutputSchema([...workspaces])
|
|
||||||
}
|
|
||||||
}, [getWorkspacesByOrganizationIdUserIdApi.data, user.activeWorkspaceId])
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (getWorkspacesByOrganizationIdUserIdApi.error && setError) {
|
if (getWorkspacesByOrganizationIdUserIdApi.error && setError) {
|
||||||
|
|||||||
Reference in New Issue
Block a user