mirror of
https://github.com/farcasclaudiu/Flowise.git
synced 2026-06-22 07:01:07 +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)
|
||||
if (itemType === 'credential') {
|
||||
return await this.dataSource.getRepository(Credential).find({
|
||||
select: ['id', 'name', 'credentialName'],
|
||||
select: ['id', 'name', 'credentialName', 'createdDate', 'updatedDate', 'workspaceId'],
|
||||
where: { id: In(itemIds) }
|
||||
})
|
||||
} else if (itemType === 'custom_template') {
|
||||
|
||||
@@ -50,7 +50,7 @@ const deleteCredentials = async (credentialId: string): Promise<any> => {
|
||||
const getAllCredentials = async (paramCredentialName: any, workspaceId?: string) => {
|
||||
try {
|
||||
const appServer = getRunningExpressApp()
|
||||
let dbResponse = []
|
||||
let dbResponse: any[] = []
|
||||
if (paramCredentialName) {
|
||||
if (Array.isArray(paramCredentialName)) {
|
||||
for (let i = 0; i < paramCredentialName.length; i += 1) {
|
||||
@@ -83,14 +83,14 @@ const getAllCredentials = async (paramCredentialName: any, workspaceId?: string)
|
||||
if (sharedItem.credentialName === name) {
|
||||
// @ts-ignore
|
||||
sharedItem.shared = true
|
||||
dbResponse.push(sharedItem)
|
||||
dbResponse.push(omit(sharedItem, ['encryptedData']))
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (sharedItem.credentialName === paramCredentialName) {
|
||||
// @ts-ignore
|
||||
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) {
|
||||
// @ts-ignore
|
||||
sharedItem.shared = true
|
||||
dbResponse.push(sharedItem)
|
||||
dbResponse.push(omit(sharedItem, ['encryptedData']))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,44 +70,29 @@ const ShareWithWorkspaceDialog = ({ show, dialogProps, onCancel, setError }) =>
|
||||
)
|
||||
|
||||
useEffect(() => {
|
||||
if (getSharedWorkspacesForItemApi.data) {
|
||||
const data = getSharedWorkspacesForItemApi.data
|
||||
if (data && data.length > 0) {
|
||||
outputSchema.map((row) => {
|
||||
data.map((ws) => {
|
||||
if (row.id === ws.workspaceId) {
|
||||
row.shared = true
|
||||
}
|
||||
if (getWorkspacesByOrganizationIdUserIdApi.data && getSharedWorkspacesForItemApi.data) {
|
||||
const workspaces = []
|
||||
const sharedWorkspaces = getSharedWorkspacesForItemApi.data || []
|
||||
|
||||
getWorkspacesByOrganizationIdUserIdApi.data
|
||||
.filter((ws) => ws.workspace.id !== user.activeWorkspaceId)
|
||||
.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
|
||||
}, [getSharedWorkspacesForItemApi.data])
|
||||
}, [getWorkspacesByOrganizationIdUserIdApi.data, getSharedWorkspacesForItemApi.data, user.activeWorkspaceId])
|
||||
|
||||
useEffect(() => {
|
||||
if (getSharedWorkspacesForItemApi.error && setError) {
|
||||
setError(getSharedWorkspacesForItemApi.error)
|
||||
}
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [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])
|
||||
}, [getSharedWorkspacesForItemApi.error, setError])
|
||||
|
||||
useEffect(() => {
|
||||
if (getWorkspacesByOrganizationIdUserIdApi.error && setError) {
|
||||
|
||||
Reference in New Issue
Block a user