Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions wavefront/client/src/api/app-user-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ export class AppUserService {
/**
* List users with access to an app (owners only)
*/
async listAppUsers(appId: string): Promise<IApiResponse<{ users: IUser[] }>> {
return this.http.get(`/v1/apps/${appId}/users`);
async listAppUsers(): Promise<IApiResponse<{ users: IUser[] }>> {
return this.http.get(`/v1/:appId/floware/v1/users`);
}

/**
Expand Down
14 changes: 10 additions & 4 deletions wavefront/client/src/hooks/data/fetch-hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import {
getApiServiceQueryFn,
getApiServicesQueryFn,
getAppByIdFn,
getAppUsersQueryFn,
getAuthenticatorQueryFn,
getAuthenticatorsQueryFn,
getCurrentUserQueryFn,
Expand All @@ -54,7 +55,7 @@ import {
getToolsQueryFn,
getTtsConfigQueryFn,
getTtsConfigsQueryFn,
getUsersQueryFn,
getConsoleUsersQueryFn,
getVoiceAgentQueryFn,
getVoiceAgentToolQueryFn,
getVoiceAgentToolsQueryFn,
Expand All @@ -74,6 +75,7 @@ import {
getApiServiceKey,
getApiServicesKey,
getAppByIdKey,
getAppUsersKey,
getAuthenticatorKey,
getAuthenticatorsKey,
getCurrentUserKey,
Expand All @@ -100,7 +102,7 @@ import {
getToolsKey,
getTtsConfigKey,
getTtsConfigsKey,
getUsersKey,
getConsoleUsersKey,
getVoiceAgentKey,
getVoiceAgentToolKey,
getVoiceAgentToolsKey,
Expand Down Expand Up @@ -417,8 +419,12 @@ export const useGetAppById = (appId: string, enabled: boolean = true): UseQueryR
return useQueryInit<App | undefined>(getAppByIdKey(appId), () => getAppByIdFn(appId), enabled);
};

export const useGetUsers = (): UseQueryResult<IUser[], Error> => {
return useQueryInit(getUsersKey(), getUsersQueryFn, true);
export const useGetAppUsers = (appId: string | undefined): UseQueryResult<IUser[], Error> => {
return useQueryInit(getAppUsersKey(appId || ''), () => getAppUsersQueryFn(), !!appId);
};

export const useGetConsoleUsers = (): UseQueryResult<IUser[], Error> => {
return useQueryInit(getConsoleUsersKey(), getConsoleUsersQueryFn, true);
};

// Voice Agent Tools Hooks
Expand Down
8 changes: 4 additions & 4 deletions wavefront/client/src/hooks/data/mutation-hooks.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { QueryClient, useMutation, useQueryClient } from '@tanstack/react-query';
import { getAgentKey, getAgentsKey, getAppByIdKey, getUserKey, getUsersKey } from './query-keys';
import { getAgentKey, getAgentsKey, getAppByIdKey, getConsoleUsersKey, getUserKey } from './query-keys';
import {
createUserMutationFn,
deleteAgentMutationFn,
Expand Down Expand Up @@ -90,7 +90,7 @@ export const useCreateUser = () => {
mutationFn: createUserMutationFn,
onSuccess: () => {
notifySuccess('User created successfully');
queryClient.invalidateQueries({ queryKey: getUsersKey() });
queryClient.invalidateQueries({ queryKey: getConsoleUsersKey() });
},
onError: (error) => {
console.error('Error creating user:', error);
Expand All @@ -108,7 +108,7 @@ export const useUpdateUser = (userId: string | undefined) => {
mutationFn: updateUserMutationFn,
onSuccess: () => {
notifySuccess('User updated successfully');
queryClient.invalidateQueries({ queryKey: getUsersKey() });
queryClient.invalidateQueries({ queryKey: getConsoleUsersKey() });
if (userId) {
queryClient.invalidateQueries({ queryKey: getUserKey(userId) });
}
Expand All @@ -129,7 +129,7 @@ export const useDeleteUser = () => {
mutationFn: deleteUserMutationFn,
onSuccess: () => {
notifySuccess('User deleted successfully');
queryClient.invalidateQueries({ queryKey: getUsersKey() });
queryClient.invalidateQueries({ queryKey: getConsoleUsersKey() });
},
onError: (error) => {
console.error('Error deleting user:', error);
Expand Down
13 changes: 11 additions & 2 deletions wavefront/client/src/hooks/data/query-functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,15 @@ const getAgentToolsQueryFn = async (agentId: string): Promise<VoiceAgentToolWith
return [];
};

const getUsersQueryFn = async (): Promise<IUser[]> => {
const getAppUsersQueryFn = async (): Promise<IUser[]> => {
const response = await floConsoleService.appUserService.listAppUsers();
if (response.data?.data?.users && Array.isArray(response.data.data.users)) {
return response.data.data.users;
}
return [];
};

const getConsoleUsersQueryFn = async (): Promise<IUser[]> => {
const response = await floConsoleService.userService.listUsers();
if (response.data?.data?.users && Array.isArray(response.data.data.users)) {
return response.data.data.users;
Expand All @@ -414,6 +422,7 @@ export {
getApiServiceQueryFn,
getApiServicesQueryFn,
getAppByIdFn,
getAppUsersQueryFn,
getAuthenticatorQueryFn,
getAuthenticatorsQueryFn,
getCurrentUserQueryFn,
Expand All @@ -440,7 +449,7 @@ export {
getToolsQueryFn,
getTtsConfigQueryFn,
getTtsConfigsQueryFn,
getUsersQueryFn,
getConsoleUsersQueryFn,
getVoiceAgentQueryFn,
getVoiceAgentToolQueryFn,
getVoiceAgentToolsQueryFn,
Expand Down
6 changes: 4 additions & 2 deletions wavefront/client/src/hooks/data/query-keys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ const getPipelinesKey = (appId: string, statusFilter?: string) => {
const getPipelineKey = (appId: string, pipelineId: string) => ['pipeline', appId, pipelineId];
const getPipelineFilesKey = (appId: string, pipelineId: string) => ['pipeline-files', appId, pipelineId];
const getAppByIdKey = (appId: string) => ['app-by-id', appId];
const getUsersKey = () => ['users'];
const getAppUsersKey = (appId: string) => ['app-users', appId];
const getConsoleUsersKey = () => ['console-users'];
const getUserKey = (userId: string) => ['user', userId];
const getVoiceAgentToolsKey = (appId: string) => ['voice-agent-tools', appId];
const getVoiceAgentToolKey = (appId: string, toolId: string) => ['voice-agent-tool', appId, toolId];
Expand Down Expand Up @@ -105,7 +106,7 @@ export {
getTtsConfigKey,
getTtsConfigsKey,
getUserKey,
getUsersKey,
getConsoleUsersKey,
getVoiceAgentKey,
getVoiceAgentToolKey,
getVoiceAgentToolsKey,
Expand All @@ -114,4 +115,5 @@ export {
getWorkflowRunsKey,
getWorkflowsKey,
getAppByIdKey,
getAppUsersKey,
};
Loading
Loading