fd5f316af0
* refactor(automate): logs api can get the projectId from the path * fix(automate): multiregion gql resolvers * fix(automate): multiregion event listeners * fix(automate): drop automationCount * fix(automate): multiregion run status * fix(automate): correctness * fix(automate): actually finish event listeners * chore(automate): fix tests fix tests * fix(automate): fix tests but make it multiregion flavor * fix(automate): logs endpoint * chore(automate): globalDb to db * fix(automate): inject projectid correctly * fix(automate): debug log fetch failure * chore(automate): fix tests for new message --------- Co-authored-by: Gergő Jedlicska <gergo@jedlicska.com>
158 lines
4.6 KiB
Vue
158 lines
4.6 KiB
Vue
<template>
|
|
<div class="flex flex-col gap-6">
|
|
<div class="grid gap-4 grid-cols-1 sm:grid-cols-2">
|
|
<AutomateFunctionPageInfoBlock title="Source">
|
|
<div class="space-y-1">
|
|
<CommonTextLink
|
|
v-tippy="license"
|
|
external
|
|
:to="repoUrl"
|
|
target="_blank"
|
|
class="max-w-full"
|
|
>
|
|
<span class="truncate">{{ repo }}</span>
|
|
</CommonTextLink>
|
|
<div v-if="githubDetails" class="flex items-center space-x-1">
|
|
<span>by</span>
|
|
<CommonTextLink
|
|
external
|
|
:to="githubDetails.owner.html_url"
|
|
target="_blank"
|
|
class="max-w-full"
|
|
>
|
|
<span class="truncate">
|
|
{{ githubDetails.owner.login }}
|
|
</span>
|
|
<img
|
|
:src="githubDetails.owner.avatar_url"
|
|
alt="Github account icon"
|
|
class="ml-1 w-6 h-6 rounded-full"
|
|
/>
|
|
</CommonTextLink>
|
|
</div>
|
|
</div>
|
|
</AutomateFunctionPageInfoBlock>
|
|
<AutomateFunctionPageInfoBlock title="Info">
|
|
<div class="gap-y-2 text-body-xs">
|
|
<div v-if="latestRelease">
|
|
<span class="font-medium">Last published: </span>
|
|
<CommonText :text="publishedAt" />
|
|
</div>
|
|
<CommonTextLink v-if="latestRelease?.inputSchema" @click="onViewParameters">
|
|
View parameters
|
|
</CommonTextLink>
|
|
</div>
|
|
</AutomateFunctionPageInfoBlock>
|
|
</div>
|
|
<AutomateFunctionPageInfoBlock title="Description">
|
|
<CommonProseMarkdownDescription :markdown="description" />
|
|
</AutomateFunctionPageInfoBlock>
|
|
<AutomateFunctionPageInfoBlock title="Readme">
|
|
<CommonProseGithubReadme
|
|
:readme-markdown="rawReadme || ''"
|
|
:repo="repo || ''"
|
|
:commit-id="selectedReleaseCommitId"
|
|
/>
|
|
</AutomateFunctionPageInfoBlock>
|
|
<div
|
|
class="mt-6 flex flex-col gap-2 sm:flex-row sm:justify-between sm:items-center"
|
|
>
|
|
<div>
|
|
<div class="text-heading-lg mb-2">Ready to go?</div>
|
|
<div class="label-light text-foreground-2 text-body-xs">
|
|
Use this function to create an automation on your project.
|
|
</div>
|
|
</div>
|
|
<div
|
|
v-tippy="
|
|
hasReleases ? undefined : 'Your function needs to have at least one release'
|
|
"
|
|
class="shrink-0"
|
|
>
|
|
<FormButton
|
|
class="shrink-0"
|
|
:disabled="!hasReleases"
|
|
@click="$emit('createAutomation')"
|
|
>
|
|
Use in automation
|
|
</FormButton>
|
|
</div>
|
|
</div>
|
|
<AutomateFunctionPageParametersDialog
|
|
v-if="latestRelease"
|
|
v-model:open="showParamsDialog"
|
|
:release="latestRelease"
|
|
/>
|
|
</div>
|
|
</template>
|
|
<script setup lang="ts">
|
|
import dayjs from 'dayjs'
|
|
import {
|
|
useGetGithubRepo,
|
|
useGetRawGithubReadme,
|
|
useResolveGitHubRepoFromUrl
|
|
} from '~/lib/automate/composables/github'
|
|
import { graphql } from '~/lib/common/generated/gql'
|
|
import type { AutomateFunctionPageInfo_AutomateFunctionFragment } from '~/lib/common/generated/gql/graphql'
|
|
|
|
// TODO: Responsivity everywhere
|
|
|
|
graphql(`
|
|
fragment AutomateFunctionPageInfo_AutomateFunction on AutomateFunction {
|
|
id
|
|
repo {
|
|
id
|
|
url
|
|
owner
|
|
name
|
|
}
|
|
description
|
|
releases(limit: 1) {
|
|
items {
|
|
id
|
|
inputSchema
|
|
createdAt
|
|
commitId
|
|
...AutomateFunctionPageParametersDialog_AutomateFunctionRelease
|
|
}
|
|
}
|
|
}
|
|
`)
|
|
|
|
defineEmits<{
|
|
createAutomation: []
|
|
}>()
|
|
|
|
const props = defineProps<{
|
|
fn: AutomateFunctionPageInfo_AutomateFunctionFragment
|
|
}>()
|
|
|
|
const repoUrl = computed(() => props.fn.repo.url)
|
|
const latestRelease = computed(() =>
|
|
props.fn.releases.items.length ? props.fn.releases.items[0] : undefined
|
|
)
|
|
const selectedReleaseCommitId = computed(() => latestRelease.value?.commitId)
|
|
|
|
const { repo } = useResolveGitHubRepoFromUrl(repoUrl)
|
|
const { data: githubDetails } = useGetGithubRepo(computed(() => repo.value || ''))
|
|
const { data: rawReadme } = useGetRawGithubReadme(
|
|
computed(() => repo.value || ''),
|
|
selectedReleaseCommitId
|
|
)
|
|
|
|
const showParamsDialog = ref(false)
|
|
|
|
const license = computed(() => githubDetails.value?.license?.name)
|
|
|
|
const publishedAt = computed(() => dayjs(latestRelease.value?.createdAt).from(dayjs()))
|
|
const description = computed(() =>
|
|
props.fn.description?.length ? props.fn.description : 'No description provided.'
|
|
)
|
|
const hasReleases = computed(() => !!latestRelease.value)
|
|
|
|
const onViewParameters = () => {
|
|
if (!latestRelease.value) return
|
|
showParamsDialog.value = true
|
|
}
|
|
</script>
|