fix: team environments import (#2770)
Co-authored-by: Liyas Thomas <liyascthomas@gmail.com>
This commit is contained in:
@@ -25,7 +25,7 @@
|
|||||||
<span
|
<span
|
||||||
v-tippy="{ theme: 'tooltip' }"
|
v-tippy="{ theme: 'tooltip' }"
|
||||||
:title="`${t('collection.select_team')}`"
|
:title="`${t('collection.select_team')}`"
|
||||||
class="bg-transparent border-t border-dividerLight select-wrapper"
|
class="bg-transparent border-b border-dividerLight select-wrapper"
|
||||||
>
|
>
|
||||||
<ButtonSecondary
|
<ButtonSecondary
|
||||||
v-if="environmentType.selectedTeam"
|
v-if="environmentType.selectedTeam"
|
||||||
|
|||||||
@@ -116,7 +116,6 @@ import {
|
|||||||
environments$,
|
environments$,
|
||||||
replaceEnvironments,
|
replaceEnvironments,
|
||||||
appendEnvironments,
|
appendEnvironments,
|
||||||
getSelectedEnvironmentType,
|
|
||||||
} from "~/newstore/environments"
|
} from "~/newstore/environments"
|
||||||
import { TeamEnvironment } from "~/helpers/teams/TeamEnvironment"
|
import { TeamEnvironment } from "~/helpers/teams/TeamEnvironment"
|
||||||
import * as TE from "fp-ts/TaskEither"
|
import * as TE from "fp-ts/TaskEither"
|
||||||
@@ -129,6 +128,7 @@ const props = defineProps<{
|
|||||||
show: boolean
|
show: boolean
|
||||||
teamEnvironments?: TeamEnvironment[]
|
teamEnvironments?: TeamEnvironment[]
|
||||||
teamId?: string | undefined
|
teamId?: string | undefined
|
||||||
|
environmentType: "MY_ENV" | "TEAM_ENV"
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
const emit = defineEmits<{
|
const emit = defineEmits<{
|
||||||
@@ -143,23 +143,13 @@ const loading = ref(false)
|
|||||||
const myEnvironments = useReadonlyStream(environments$, [])
|
const myEnvironments = useReadonlyStream(environments$, [])
|
||||||
const currentUser = useReadonlyStream(currentUser$, null)
|
const currentUser = useReadonlyStream(currentUser$, null)
|
||||||
|
|
||||||
const selectedEnvType = getSelectedEnvironmentType()
|
|
||||||
|
|
||||||
const currentSelectedEnvionmentType = computed(() => {
|
|
||||||
if (selectedEnvType === "MY_ENV" || props.teamEnvironments === undefined) {
|
|
||||||
return "MY_ENV"
|
|
||||||
} else {
|
|
||||||
return "TEAM_ENV"
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
// Template refs
|
// Template refs
|
||||||
const tippyActions = ref<TippyComponent | null>(null)
|
const tippyActions = ref<TippyComponent | null>(null)
|
||||||
const inputChooseFileToImportFrom = ref<HTMLInputElement>()
|
const inputChooseFileToImportFrom = ref<HTMLInputElement>()
|
||||||
|
|
||||||
const environmentJson = computed(() => {
|
const environmentJson = computed(() => {
|
||||||
if (
|
if (
|
||||||
currentSelectedEnvionmentType.value === "TEAM_ENV" &&
|
props.environmentType === "TEAM_ENV" &&
|
||||||
props.teamEnvironments !== undefined
|
props.teamEnvironments !== undefined
|
||||||
) {
|
) {
|
||||||
const teamEnvironments = props.teamEnvironments.map(
|
const teamEnvironments = props.teamEnvironments.map(
|
||||||
@@ -233,7 +223,7 @@ const readEnvironmentGist = async () => {
|
|||||||
}
|
}
|
||||||
const environments = JSON.parse(Object.values(files)[0].content)
|
const environments = JSON.parse(Object.values(files)[0].content)
|
||||||
|
|
||||||
if (currentSelectedEnvionmentType.value === "MY_ENV") {
|
if (props.environmentType === "MY_ENV") {
|
||||||
replaceEnvironments(environments)
|
replaceEnvironments(environments)
|
||||||
fileImported()
|
fileImported()
|
||||||
} else {
|
} else {
|
||||||
@@ -258,9 +248,24 @@ const importToTeams = async (content: Environment[]) => {
|
|||||||
loading.value = true
|
loading.value = true
|
||||||
for (const [i, env] of content.entries()) {
|
for (const [i, env] of content.entries()) {
|
||||||
if (i === content.length - 1) {
|
if (i === content.length - 1) {
|
||||||
loading.value = false
|
await pipe(
|
||||||
hideModal()
|
createTeamEnvironment(
|
||||||
fileImported()
|
JSON.stringify(env.variables),
|
||||||
|
props.teamId as string,
|
||||||
|
env.name
|
||||||
|
),
|
||||||
|
TE.match(
|
||||||
|
(err: GQLError<string>) => {
|
||||||
|
console.error(err)
|
||||||
|
toast.error(`${getErrorMessage(err)}`)
|
||||||
|
},
|
||||||
|
() => {
|
||||||
|
loading.value = false
|
||||||
|
hideModal()
|
||||||
|
fileImported()
|
||||||
|
}
|
||||||
|
)
|
||||||
|
)()
|
||||||
} else {
|
} else {
|
||||||
await pipe(
|
await pipe(
|
||||||
createTeamEnvironment(
|
createTeamEnvironment(
|
||||||
@@ -326,7 +331,7 @@ const importFromJSON = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const importFromHoppscotch = (environments: Environment[]) => {
|
const importFromHoppscotch = (environments: Environment[]) => {
|
||||||
if (currentSelectedEnvionmentType.value === "MY_ENV") {
|
if (props.environmentType === "MY_ENV") {
|
||||||
appendEnvironments(environments)
|
appendEnvironments(environments)
|
||||||
fileImported()
|
fileImported()
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
<div class="flex justify-between flex-1 border-b border-dividerLight">
|
<div
|
||||||
|
class="sticky z-10 top-upperPrimaryStickyFold flex justify-between flex-1 border-b border-dividerLight bg-primary"
|
||||||
|
>
|
||||||
<ButtonSecondary
|
<ButtonSecondary
|
||||||
:icon="IconPlus"
|
:icon="IconPlus"
|
||||||
:label="`${t('action.new')}`"
|
:label="`${t('action.new')}`"
|
||||||
@@ -53,6 +55,7 @@
|
|||||||
<ButtonSecondary
|
<ButtonSecondary
|
||||||
:label="`${t('add.new')}`"
|
:label="`${t('add.new')}`"
|
||||||
filled
|
filled
|
||||||
|
outline
|
||||||
class="mb-4"
|
class="mb-4"
|
||||||
@click="displayModalAdd(true)"
|
@click="displayModalAdd(true)"
|
||||||
/>
|
/>
|
||||||
@@ -65,6 +68,7 @@
|
|||||||
/>
|
/>
|
||||||
<EnvironmentsImportExport
|
<EnvironmentsImportExport
|
||||||
:show="showModalImportExport"
|
:show="showModalImportExport"
|
||||||
|
environment-type="MY_ENV"
|
||||||
@hide-modal="displayModalImportExport(false)"
|
@hide-modal="displayModalImportExport(false)"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
<div class="flex justify-between flex-1 border-y border-dividerLight">
|
<div
|
||||||
|
class="sticky z-10 top-upperSecondaryStickyFold flex justify-between flex-1 border-b border-dividerLight bg-primary"
|
||||||
|
>
|
||||||
<ButtonSecondary
|
<ButtonSecondary
|
||||||
v-if="team === undefined || team.myRole === 'VIEWER'"
|
v-if="team === undefined || team.myRole === 'VIEWER'"
|
||||||
v-tippy="{ theme: 'tooltip' }"
|
v-tippy="{ theme: 'tooltip' }"
|
||||||
@@ -68,6 +70,7 @@
|
|||||||
v-else
|
v-else
|
||||||
:label="`${t('add.new')}`"
|
:label="`${t('add.new')}`"
|
||||||
filled
|
filled
|
||||||
|
outline
|
||||||
class="mb-4"
|
class="mb-4"
|
||||||
@click="displayModalAdd(true)"
|
@click="displayModalAdd(true)"
|
||||||
/>
|
/>
|
||||||
@@ -106,6 +109,7 @@
|
|||||||
:show="showModalImportExport"
|
:show="showModalImportExport"
|
||||||
:team-environments="teamEnvironments"
|
:team-environments="teamEnvironments"
|
||||||
:team-id="team?.id"
|
:team-id="team?.id"
|
||||||
|
environment-type="TEAM_ENV"
|
||||||
@hide-modal="displayModalImportExport(false)"
|
@hide-modal="displayModalImportExport(false)"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user