feat: complete pre fill title and description
This commit is contained in:
@@ -29,6 +29,7 @@ class OpenAIAPI extends ApiClient {
|
||||
'summarize',
|
||||
'reply_suggestion',
|
||||
'label_suggestion',
|
||||
'summary_with_title',
|
||||
];
|
||||
|
||||
/**
|
||||
|
||||
@@ -12,20 +12,25 @@
|
||||
:error="nameError"
|
||||
@input="v$.title.$touch"
|
||||
/>
|
||||
<label>
|
||||
{{ $t('INTEGRATION_SETTINGS.LINEAR.ADD_OR_LINK.FORM.DESCRIPTION.LABEL') }}
|
||||
<textarea
|
||||
v-model="formState.description"
|
||||
:style="{ ...inputStyles, padding: '8px 12px' }"
|
||||
rows="3"
|
||||
class="text-sm"
|
||||
:placeholder="
|
||||
$t(
|
||||
'INTEGRATION_SETTINGS.LINEAR.ADD_OR_LINK.FORM.DESCRIPTION.PLACEHOLDER'
|
||||
)
|
||||
"
|
||||
/>
|
||||
</label>
|
||||
<div class="editor-wrap">
|
||||
<label>
|
||||
{{
|
||||
$t('INTEGRATION_SETTINGS.LINEAR.ADD_OR_LINK.FORM.DESCRIPTION.LABEL')
|
||||
}}
|
||||
</label>
|
||||
<div>
|
||||
<woot-message-editor
|
||||
v-model="formState.description"
|
||||
class="message-editor"
|
||||
:style="{ ...inputStyles, padding: '8px 12px' }"
|
||||
:placeholder="
|
||||
$t(
|
||||
'INTEGRATION_SETTINGS.LINEAR.ADD_OR_LINK.FORM.DESCRIPTION.PLACEHOLDER'
|
||||
)
|
||||
"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<label :class="{ error: v$.teamId.$error }">
|
||||
{{ $t('INTEGRATION_SETTINGS.LINEAR.ADD_OR_LINK.FORM.TEAM.LABEL') }}
|
||||
<select
|
||||
@@ -107,7 +112,9 @@ import { useI18n } from 'dashboard/composables/useI18n';
|
||||
import { useAlert } from 'dashboard/composables';
|
||||
import LinearAPI from 'dashboard/api/integrations/linear';
|
||||
import validations from './validations';
|
||||
import WootMessageEditor from 'dashboard/components/widgets/WootWriter/Editor.vue';
|
||||
import { parseLinearAPIErrorResponse } from 'dashboard/store/utils/api';
|
||||
import { inject } from 'vue';
|
||||
|
||||
const props = defineProps({
|
||||
accountId: {
|
||||
@@ -253,5 +260,13 @@ const createIssue = async () => {
|
||||
}
|
||||
};
|
||||
|
||||
onMounted(getTeams);
|
||||
onMounted(() => {
|
||||
getTeams();
|
||||
if (inject('suggestedTitle')) {
|
||||
formState.title = inject('suggestedTitle');
|
||||
}
|
||||
if (inject('suggestedSummary')) {
|
||||
formState.description = inject('suggestedSummary');
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
@@ -47,6 +47,7 @@ import { useI18n } from 'dashboard/composables/useI18n';
|
||||
import LinearAPI from 'dashboard/api/integrations/linear';
|
||||
import CreateOrLinkIssue from './CreateOrLinkIssue.vue';
|
||||
import Issue from './Issue.vue';
|
||||
import OpenAPI from 'dashboard/api/integrations/openapi';
|
||||
import { parseLinearAPIErrorResponse } from 'dashboard/store/utils/api';
|
||||
|
||||
defineComponent({
|
||||
@@ -63,6 +64,9 @@ const props = defineProps({
|
||||
const getters = useStoreGetters();
|
||||
const { t } = useI18n();
|
||||
|
||||
const suggestedTitle = ref('');
|
||||
const suggestedSummary = ref('');
|
||||
|
||||
const linkedIssue = ref(null);
|
||||
const shouldShow = ref(false);
|
||||
const shouldShowPopup = ref(false);
|
||||
@@ -70,18 +74,46 @@ const isUnlinking = ref(false);
|
||||
|
||||
provide('isUnlinking', isUnlinking);
|
||||
|
||||
provide('suggestedTitle', suggestedTitle);
|
||||
provide('suggestedSummary', suggestedSummary);
|
||||
|
||||
const currentAccountId = getters.getCurrentAccountId;
|
||||
|
||||
const conversation = computed(() =>
|
||||
getters.getConversationById.value(props.conversationId)
|
||||
);
|
||||
|
||||
const appIntegrations = getters['integrations/getAppIntegrations'];
|
||||
|
||||
const aiIntegration = computed(() => {
|
||||
return appIntegrations.value.find(
|
||||
integration => integration.id === 'openai' && !!integration.hooks.length
|
||||
)?.hooks[0];
|
||||
});
|
||||
const isAIIntegrationEnabled = computed(() => !!aiIntegration.value);
|
||||
|
||||
const tooltipText = computed(() => {
|
||||
return linkedIssue.value === null
|
||||
? t('INTEGRATION_SETTINGS.LINEAR.ADD_OR_LINK_BUTTON')
|
||||
: null;
|
||||
});
|
||||
|
||||
const suggestTitleAndSummary = async () => {
|
||||
try {
|
||||
const response = await OpenAPI.processEvent({
|
||||
type: 'summary_with_title',
|
||||
hookId: aiIntegration.value.id,
|
||||
conversationId: props.conversationId,
|
||||
});
|
||||
const { message } = response.data;
|
||||
const messageObject = JSON.parse(message);
|
||||
const { title = '', description = '' } = messageObject;
|
||||
suggestedTitle.value = title;
|
||||
suggestedSummary.value = description;
|
||||
} catch (error) {
|
||||
// Since this is a non-critical operation, we don't want to show an alert to the user
|
||||
}
|
||||
};
|
||||
const loadLinkedIssue = async () => {
|
||||
linkedIssue.value = null;
|
||||
try {
|
||||
@@ -137,5 +169,8 @@ watch(
|
||||
|
||||
onMounted(() => {
|
||||
loadLinkedIssue();
|
||||
if (isAIIntegrationEnabled.value) {
|
||||
suggestTitleAndSummary();
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user