Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: error on pill variables item copy to clipboard #313

Merged
merged 1 commit into from
Nov 14, 2024
Merged
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
2 changes: 0 additions & 2 deletions apps/shelve/app/components/form/Group.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
<script setup lang="ts">
import type { PropType } from 'vue'

type GroupProps = {
label?: string
required?: boolean
Expand Down
13 changes: 6 additions & 7 deletions apps/shelve/app/components/project/CreateVariables.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<script setup lang="ts">
import type { Variable } from '@shelve/types'
import type { PropType } from 'vue'

type CreateVariablesProps = {
refresh: () => Promise<void>
Expand Down Expand Up @@ -32,17 +31,17 @@ const items = [
{
label: 'For production',
icon: 'lucide:clipboard',
onSelect: () => copyEnv(variables!, 'production')
onSelect: () => copyEnv(variables, 'production')
},
{
label: 'For preview',
icon: 'lucide:clipboard',
onSelect: () => copyEnv(variables!, 'preview')
onSelect: () => copyEnv(variables, 'preview')
},
{
label: 'For development',
icon: 'lucide:clipboard',
onSelect: () => copyEnv(variables!, 'development')
onSelect: () => copyEnv(variables, 'development')
}
],
[
Expand All @@ -55,17 +54,17 @@ const items = [
{
label: 'For production',
icon: 'lucide:download',
onSelect: () => downloadEnv(variables!, 'production')
onSelect: () => downloadEnv(variables, 'production')
},
{
label: 'For preview',
icon: 'lucide:download',
onSelect: () => downloadEnv(variables!, 'preview')
onSelect: () => downloadEnv(variables, 'preview')
},
{
label: 'For development',
icon: 'lucide:download',
onSelect: () => downloadEnv(variables!, 'development')
onSelect: () => downloadEnv(variables, 'development')
}
],
]
Expand Down
2 changes: 1 addition & 1 deletion apps/shelve/app/components/project/MainSection.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script setup lang="ts">
import type { Project } from '@shelve/types'
import type { PropType, Ref } from 'vue'
import type { Ref } from 'vue'

type ProjectProps = {
project: Project
Expand Down
31 changes: 9 additions & 22 deletions apps/shelve/app/components/project/VariableItem.vue
Original file line number Diff line number Diff line change
@@ -1,28 +1,15 @@
<script setup lang="ts">
import type { Variable } from '@shelve/types'
import type { PropType } from 'vue'

const { refresh, variable, projectId } = defineProps({
refresh: {
type: Function,
required: true,
},
variables: {
type: Array as PropType<Variable[]>,
},
variable: {
type: Object as PropType<Variable>,
required: true
},
projectId: {
type: String,
required: true,
},
isSelected: {
type: Boolean,
required: true
}
})
type ProjectVariableProps = {
refresh: () => Promise<void>
variables: Variable[]
variable: Variable
projectId: string
isSelected: boolean
}

const { refresh, variable, projectId } = defineProps<ProjectVariableProps>()

const {
updateLoading,
Expand Down
12 changes: 5 additions & 7 deletions apps/shelve/app/components/team/Member.vue
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
<script setup lang="ts">
import type { Member } from '@shelve/types'
import type { PropType } from 'vue'

defineProps({
member: {
type: Object as PropType<Member>,
required: true
}
})
type TeamMemberProps = {
member: Member
}

defineProps<TeamMemberProps>()
</script>

<template>
Expand Down
11 changes: 8 additions & 3 deletions apps/shelve/app/utils/env.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
import type { Variable } from '@shelve/types'

export function copyEnv(variables: Variable[], env: 'production' | 'preview' | 'development') {
export function copyEnv(variables: Variable[], env?: 'production' | 'preview' | 'development') {
if (variables.length === 0) return
const envVariables = variables.filter((variable) => variable.environment.includes(env))
const envString = envVariables.map((variable) => `${variable.key}=${variable.value}`).join('\n')
if (env) {
const envVariables = variables.filter((variable) => variable.environment.includes(env))
const envString = envVariables.map((variable) => `${ variable.key }=${ variable.value }`).join('\n')
copyToClipboard(envString, 'Copied to clipboard')
return
}
const envString = variables.map((variable) => `${ variable.key }=${ variable.value }`).join('\n')
copyToClipboard(envString, 'Copied to clipboard')
}

Expand Down