Merge pull request #395 from automatisch/issue-369
feat: add non-auth apps and flowCount in getConnectedApps
This commit is contained in:
@@ -20,18 +20,37 @@ const getConnectedApps = async (
|
|||||||
.count('connections.id as count')
|
.count('connections.id as count')
|
||||||
.groupBy('connections.key');
|
.groupBy('connections.key');
|
||||||
|
|
||||||
const connectionKeys = connections.map((connection) => connection.key);
|
const flows = await context.currentUser
|
||||||
|
.$relatedQuery('flows')
|
||||||
|
.withGraphJoined('steps')
|
||||||
|
.orderBy('created_at', 'desc');
|
||||||
|
|
||||||
|
const duplicatedUsedApps = flows
|
||||||
|
.map((flow) => flow.steps.map((step) => step.appKey))
|
||||||
|
.flat()
|
||||||
|
.filter(Boolean);
|
||||||
|
|
||||||
|
const usedApps = [...new Set(duplicatedUsedApps)];
|
||||||
|
|
||||||
apps = apps
|
apps = apps
|
||||||
.filter((app: IApp) => connectionKeys.includes(app.key))
|
.filter((app: IApp) => {
|
||||||
|
return usedApps.includes(app.key);
|
||||||
|
})
|
||||||
.map((app: IApp) => {
|
.map((app: IApp) => {
|
||||||
const connection = connections.find(
|
const connection = connections.find(
|
||||||
(connection) => (connection as IConnection).key === app.key
|
(connection) => (connection as IConnection).key === app.key
|
||||||
);
|
);
|
||||||
|
|
||||||
if (connection) {
|
app.connectionCount = connection?.count || 0;
|
||||||
app.connectionCount = connection.count;
|
app.flowCount = 0;
|
||||||
|
|
||||||
|
flows.forEach((flow) => {
|
||||||
|
const usedFlow = flow.steps.find((step) => step.appKey === app.key);
|
||||||
|
|
||||||
|
if (usedFlow) {
|
||||||
|
app.flowCount += 1;
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
|
||||||
return app;
|
return app;
|
||||||
});
|
});
|
||||||
|
@@ -90,6 +90,7 @@ type App {
|
|||||||
name: String
|
name: String
|
||||||
key: String
|
key: String
|
||||||
connectionCount: Int
|
connectionCount: Int
|
||||||
|
flowCount: Int
|
||||||
iconUrl: String
|
iconUrl: String
|
||||||
docUrl: String
|
docUrl: String
|
||||||
primaryColor: String
|
primaryColor: String
|
||||||
|
1
packages/types/index.d.ts
vendored
1
packages/types/index.d.ts
vendored
@@ -152,6 +152,7 @@ export interface IApp {
|
|||||||
authenticationSteps: IAuthenticationStep[];
|
authenticationSteps: IAuthenticationStep[];
|
||||||
reconnectionSteps: IAuthenticationStep[];
|
reconnectionSteps: IAuthenticationStep[];
|
||||||
connectionCount: number;
|
connectionCount: number;
|
||||||
|
flowCount: number;
|
||||||
triggers: any[];
|
triggers: any[];
|
||||||
actions: any[];
|
actions: any[];
|
||||||
connections: IConnection[];
|
connections: IConnection[];
|
||||||
|
@@ -27,7 +27,7 @@ const countTranslation = (value: React.ReactNode) => (
|
|||||||
|
|
||||||
function AppRow(props: AppRowProps): React.ReactElement {
|
function AppRow(props: AppRowProps): React.ReactElement {
|
||||||
const formatMessage = useFormatMessage();
|
const formatMessage = useFormatMessage();
|
||||||
const { name, primaryColor, iconUrl, connectionCount } = props.application;
|
const { name, primaryColor, iconUrl, connectionCount, flowCount } = props.application;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Link to={URLS.APP(name.toLowerCase())}>
|
<Link to={URLS.APP(name.toLowerCase())}>
|
||||||
@@ -52,7 +52,7 @@ function AppRow(props: AppRowProps): React.ReactElement {
|
|||||||
|
|
||||||
<Box sx={{ px: 2 }}>
|
<Box sx={{ px: 2 }}>
|
||||||
<Typography variant="caption" color="textSecondary" sx={{ display: ['none', 'inline-block'] }}>
|
<Typography variant="caption" color="textSecondary" sx={{ display: ['none', 'inline-block'] }}>
|
||||||
{formatMessage('app.flowCount', { count: countTranslation(0) })}
|
{formatMessage('app.flowCount', { count: countTranslation(flowCount) })}
|
||||||
</Typography>
|
</Typography>
|
||||||
</Box>
|
</Box>
|
||||||
|
|
||||||
|
@@ -9,6 +9,7 @@ export const GET_CONNECTED_APPS = gql`
|
|||||||
docUrl
|
docUrl
|
||||||
primaryColor
|
primaryColor
|
||||||
connectionCount
|
connectionCount
|
||||||
|
flowCount
|
||||||
supportsConnections
|
supportsConnections
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user