Compare commits

..

2 Commits

Author SHA1 Message Date
Balu Babu
5226c74d0c feat: updated base node version of hoppscotch-old-backend to v20.12.2 2024-05-10 14:16:54 +05:30
Balu Babu
7dbdabb5b8 feat: updated node version to node20-apline3.19 in prod.dockerfile 2024-05-10 14:16:54 +05:30
12 changed files with 39 additions and 85 deletions

View File

@@ -121,7 +121,6 @@ describe('AdminService', () => {
NOT: {
inviteeEmail: {
in: [dbAdminUsers[0].email],
mode: 'insensitive',
},
},
},
@@ -230,10 +229,7 @@ describe('AdminService', () => {
expect(mockPrisma.invitedUsers.deleteMany).toHaveBeenCalledWith({
where: {
inviteeEmail: {
in: [invitedUsers[0].inviteeEmail],
mode: 'insensitive',
},
inviteeEmail: { in: [invitedUsers[0].inviteeEmail] },
},
});
expect(result).toEqualRight(true);

View File

@@ -89,17 +89,12 @@ export class AdminService {
adminEmail: string,
inviteeEmail: string,
) {
if (inviteeEmail.toLowerCase() == adminEmail.toLowerCase()) {
return E.left(DUPLICATE_EMAIL);
}
if (inviteeEmail == adminEmail) return E.left(DUPLICATE_EMAIL);
if (!validateEmail(inviteeEmail)) return E.left(INVALID_EMAIL);
const alreadyInvitedUser = await this.prisma.invitedUsers.findFirst({
where: {
inviteeEmail: {
equals: inviteeEmail,
mode: 'insensitive',
},
inviteeEmail: inviteeEmail,
},
});
if (alreadyInvitedUser != null) return E.left(USER_ALREADY_INVITED);
@@ -164,7 +159,7 @@ export class AdminService {
try {
await this.prisma.invitedUsers.deleteMany({
where: {
inviteeEmail: { in: inviteeEmails, mode: 'insensitive' },
inviteeEmail: { in: inviteeEmails },
},
});
return E.right(true);
@@ -194,7 +189,6 @@ export class AdminService {
NOT: {
inviteeEmail: {
in: userEmailObjs.map((user) => user.email),
mode: 'insensitive',
},
},
},

View File

@@ -299,10 +299,7 @@ export class ShortcodeService implements UserDataHandler, OnModuleInit {
where: userEmail
? {
User: {
email: {
equals: userEmail,
mode: 'insensitive',
},
email: userEmail,
},
}
: undefined,

View File

@@ -75,13 +75,12 @@ export class TeamInvitationService {
if (!isEmailValid) return E.left(INVALID_EMAIL);
try {
const teamInvite = await this.prisma.teamInvitation.findFirstOrThrow({
const teamInvite = await this.prisma.teamInvitation.findUniqueOrThrow({
where: {
inviteeEmail: {
equals: inviteeEmail,
mode: 'insensitive',
teamID_inviteeEmail: {
inviteeEmail: inviteeEmail,
teamID: teamID,
},
teamID,
},
});

View File

@@ -149,7 +149,7 @@ beforeEach(() => {
describe('UserService', () => {
describe('findUserByEmail', () => {
test('should successfully return a valid user given a valid email', async () => {
mockPrisma.user.findFirst.mockResolvedValueOnce(user);
mockPrisma.user.findUniqueOrThrow.mockResolvedValueOnce(user);
const result = await userService.findUserByEmail(
'dwight@dundermifflin.com',
@@ -158,7 +158,7 @@ describe('UserService', () => {
});
test('should return a null user given a invalid email', async () => {
mockPrisma.user.findFirst.mockResolvedValueOnce(null);
mockPrisma.user.findUniqueOrThrow.mockRejectedValueOnce('NotFoundError');
const result = await userService.findUserByEmail('jim@dundermifflin.com');
expect(result).resolves.toBeNone;

View File

@@ -62,16 +62,16 @@ export class UserService {
* @returns Option of found User
*/
async findUserByEmail(email: string): Promise<O.None | O.Some<AuthUser>> {
const user = await this.prisma.user.findFirst({
where: {
email: {
equals: email,
mode: 'insensitive',
try {
const user = await this.prisma.user.findUniqueOrThrow({
where: {
email: email,
},
},
});
if (!user) return O.none;
return O.some(user);
});
return O.some(user);
} catch (error) {
return O.none;
}
}
/**

View File

@@ -43,19 +43,12 @@
@click="invokeAction('modals.support.toggle')"
/>
</div>
<div
class="flex"
:class="{
'flex-row-reverse gap-2':
workspaceSelectorFlagEnabled && !currentUser,
}"
>
<div class="flex">
<div
v-if="currentUser === null"
class="inline-flex items-center space-x-2"
>
<HoppButtonSecondary
v-if="!workspaceSelectorFlagEnabled"
:icon="IconUploadCloud"
:label="t('header.save_workspace')"
class="!focus-visible:text-emerald-600 !hover:text-emerald-600 hidden h-8 border border-emerald-600/25 bg-emerald-500/10 !text-emerald-500 hover:border-emerald-600/20 hover:bg-emerald-600/20 focus-visible:border-emerald-600/20 focus-visible:bg-emerald-600/20 md:flex"
@@ -67,22 +60,18 @@
@click="invokeAction('modals.login.toggle')"
/>
</div>
<TeamsMemberStack
v-else-if="
currentUser !== null &&
workspace.type === 'team' &&
selectedTeam &&
selectedTeam.teamMembers.length > 1
"
:team-members="selectedTeam.teamMembers"
show-count
class="mx-2"
@handle-click="handleTeamEdit()"
/>
<div
v-if="workspaceSelectorFlagEnabled || currentUser"
class="inline-flex items-center space-x-2"
>
<div v-else class="inline-flex items-center space-x-2">
<TeamsMemberStack
v-if="
workspace.type === 'team' &&
selectedTeam &&
selectedTeam.teamMembers.length > 1
"
:team-members="selectedTeam.teamMembers"
show-count
class="mx-2"
@handle-click="handleTeamEdit()"
/>
<div
class="flex h-8 divide-x divide-emerald-600/25 rounded border border-emerald-600/25 bg-emerald-500/10 focus-within:divide-emerald-600/20 focus-within:border-emerald-600/20 focus-within:bg-emerald-600/20 hover:divide-emerald-600/20 hover:border-emerald-600/20 hover:bg-emerald-600/20"
>
@@ -95,7 +84,6 @@
/>
<HoppButtonSecondary
v-if="
currentUser &&
workspace.type === 'team' &&
selectedTeam &&
selectedTeam?.myRole === 'OWNER'
@@ -136,7 +124,7 @@
</div>
</template>
</tippy>
<span v-if="currentUser" class="px-2">
<span class="px-2">
<tippy
interactive
trigger="click"
@@ -271,13 +259,6 @@ import {
const t = useI18n()
const toast = useToast()
/**
* Feature flag to enable the workspace selector login conversion
*/
const workspaceSelectorFlagEnabled = computed(
() => !!platform.platformFeatureFlags.workspaceSwitcherLogin?.value
)
/**
* Once the PWA code is initialized, this holds a method
* that can be called to show the user the installation
@@ -399,8 +380,6 @@ const inviteTeam = (team: { name: string }, teamID: string) => {
// Show the workspace selected team invite modal if the user is an owner of the team else show the default invite modal
const handleInvite = () => {
if (!currentUser.value) return invokeAction("modals.login.toggle")
if (
workspace.value.type === "team" &&
workspace.value.teamID &&

View File

@@ -59,7 +59,7 @@
/>
</div>
<div
v-else-if="teamListAdapterError"
v-if="!loading && teamListAdapterError"
class="flex flex-col items-center py-4"
>
<icon-lucide-help-circle class="svg-icons mb-4" />
@@ -85,7 +85,7 @@ import { useColorMode } from "@composables/theming"
import { GetMyTeamsQuery } from "~/helpers/backend/graphql"
import IconDone from "~icons/lucide/check"
import { useLocalState } from "~/newstore/localstate"
import { defineActionHandler, invokeAction } from "~/helpers/actions"
import { defineActionHandler } from "~/helpers/actions"
import { WorkspaceService } from "~/services/workspace.service"
import { useService } from "dioc/vue"
import { useElementVisibility, useIntervalFn } from "@vueuse/core"
@@ -157,8 +157,8 @@ const switchToTeamWorkspace = (team: GetMyTeamsQuery["myTeams"][number]) => {
workspaceService.changeWorkspace({
teamID: team.id,
teamName: team.name,
type: "team",
role: team.myRole,
type: "team",
})
}
@@ -174,16 +174,12 @@ watch(
(user) => {
if (!user) {
switchToPersonalWorkspace()
teamListadapter.dispose()
}
}
)
const displayModalAdd = (shouldDisplay: boolean) => {
if (!currentUser.value) return invokeAction("modals.login.toggle")
showModalAdd.value = shouldDisplay
teamListadapter.fetchList()
}
defineActionHandler("modals.team.new", () => {

View File

@@ -50,7 +50,6 @@ export default class TeamListAdapter {
}
public dispose() {
this.teamList$.next([])
this.isDispose = true
clearTimeout(this.timeoutHandle as any)
this.timeoutHandle = null

View File

@@ -11,7 +11,6 @@ import { InspectorsPlatformDef } from "./inspectors"
import { ServiceClassInstance } from "dioc"
import { IOPlatformDef } from "./io"
import { SpotlightPlatformDef } from "./spotlight"
import { Ref } from "vue"
export type PlatformDef = {
ui?: UIPlatformDef
@@ -46,11 +45,6 @@ export type PlatformDef = {
* If a value is not given, then the value is assumed to be true
*/
promptAsUsingCookies?: boolean
/**
* Whether to show the A/B testing workspace switcher click login flow or not
*/
workspaceSwitcherLogin?: Ref<boolean>
}
}

View File

@@ -1260,7 +1260,7 @@ dependencies = [
[[package]]
name = "hoppscotch-desktop"
version = "24.3.3"
version = "24.3.2"
dependencies = [
"cocoa 0.25.0",
"hex_color",

View File

@@ -26,7 +26,7 @@ createHoppApp("#app", {
history: historyDef,
},
interceptors: {
default: "browser",
default: "proxy",
interceptors: [
{ type: "standalone", interceptor: browserInterceptor },
{ type: "standalone", interceptor: proxyInterceptor },