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

chore: make git message warnings remain dismissable #26812

Merged
merged 17 commits into from
Jun 5, 2023
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
fix: update TrackedBanner to parse markdown message
  • Loading branch information
jordanpowell88 committed May 31, 2023
commit bba108d5c82598b964e54027191c136b59497121
22 changes: 21 additions & 1 deletion packages/app/src/specs/banners/TrackedBanner.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
v-model="isAlertDisplayed"
v-bind="$attrs"
>
<div
ref="markdownTarget"
class="warning-markdown"
v-html="markdown"
/>
<slot
:dismiss="dismiss"
:bannerInstanceId="bannerInstanceId"
Expand All @@ -12,9 +17,10 @@

<script setup lang="ts">
import Alert from '@packages/frontend-shared/src/components/Alert.vue'
import { onMounted, ref, watchEffect, watch } from 'vue'
import { onMounted, ref, watchEffect, watch, computed } from 'vue'
import { gql, useMutation, useQuery } from '@urql/vue'
import { TrackedBanner_ProjectStateDocument, TrackedBanner_RecordBannerSeenDocument, TrackedBanner_SetProjectStateDocument } from '../../generated/graphql'
import { useMarkdown } from '@packages/frontend-shared/src/composables/useMarkdown'
import { set } from 'lodash'
import { nanoid } from 'nanoid'

Expand All @@ -30,6 +36,8 @@ interface TrackedBannerComponentProps extends AlertComponentProps {
hasBannerBeenShown: boolean
eventData: EventData
recordBannerShown: boolean
message: string
details?: string | null
}

gql`
Expand Down Expand Up @@ -62,13 +70,25 @@ mutation TrackedBanner_recordBannerSeen($campaign: String!, $messageId: String!,

const props = withDefaults(defineProps<TrackedBannerComponentProps>(), {
recordBannerShown: true,
details: undefined,
})

const stateQuery = useQuery({ query: TrackedBanner_ProjectStateDocument })
const setStateMutation = useMutation(TrackedBanner_SetProjectStateDocument)
const reportSeenMutation = useMutation(TrackedBanner_RecordBannerSeenDocument)
const bannerInstanceId = ref(nanoid())
const isAlertDisplayed = ref(true)
const markdownTarget = ref()

let message = computed(() => {
if (props.details) {
return [props.message, ` ${ props.details }`].join('\n\n')
}

return props.message
})

const { markdown } = useMarkdown(markdownTarget, message.value, { classes: { code: ['bg-warning-200'] } })

watchEffect(() => {
if (!props.hasBannerBeenShown && props.eventData && props.recordBannerShown) {
Expand Down