BigW Consortium Gitlab

Commit 660ba032 by Filipa Lacerda

Move callout to vue file and remove svg from data function to improve performance

parent 12cdc461
import Vue from 'vue'; <script>
import Cookies from 'js-cookie'; import Vue from 'vue';
import Translate from '../../vue_shared/translate'; import Cookies from 'js-cookie';
import illustrationSvg from '../icons/intro_illustration.svg'; import Translate from '../../vue_shared/translate';
import illustrationSvg from '../icons/intro_illustration.svg';
Vue.use(Translate); Vue.use(Translate);
const cookieKey = 'pipeline_schedules_callout_dismissed'; const cookieKey = 'pipeline_schedules_callout_dismissed';
export default { export default {
name: 'PipelineSchedulesCallout', name: 'PipelineSchedulesCallout',
data() { data() {
return { return {
docsUrl: document.getElementById('pipeline-schedules-callout').dataset.docsUrl, docsUrl: document.getElementById('pipeline-schedules-callout').dataset.docsUrl,
illustrationSvg, calloutDismissed: Cookies.get(cookieKey) === 'true',
calloutDismissed: Cookies.get(cookieKey) === 'true', };
};
},
methods: {
dismissCallout() {
this.calloutDismissed = true;
Cookies.set(cookieKey, this.calloutDismissed, { expires: 365 });
}, },
}, methods: {
template: ` dismissCallout() {
<div v-if="!calloutDismissed" class="pipeline-schedules-user-callout user-callout"> this.calloutDismissed = true;
<div class="bordered-box landing content-block"> Cookies.set(cookieKey, this.calloutDismissed, { expires: 365 });
<button },
id="dismiss-callout-btn" },
class="btn btn-default close" created() {
@click="dismissCallout"> this.illustrationSvg = illustrationSvg;
<i class="fa fa-times"></i> },
</button> };
<div class="svg-container" v-html="illustrationSvg"></div> </script>
<div class="user-callout-copy"> <template>
<h4>{{ __('Scheduling Pipelines') }}</h4> <div
<p> v-if="!calloutDismissed"
{{ __('The pipelines schedule runs pipelines in the future, repeatedly, for specific branches or tags. Those scheduled pipelines will inherit limited project access based on their associated user.') }} class="pipeline-schedules-user-callout user-callout">
</p> <div class="bordered-box landing content-block">
<p> {{ __('Learn more in the') }} <button
<a id="dismiss-callout-btn"
:href="docsUrl" class="btn btn-default close"
target="_blank" @click="dismissCallout">
rel="nofollow">{{ s__('Learn more in the|pipeline schedules documentation') }}</a>. <!-- oneline to prevent extra space before period --> <i
</p> aria-hidden="true"
</div> class="fa fa-times">
</i>
</button>
<div class="svg-container" v-html="illustrationSvg"></div>
<div class="user-callout-copy">
<h4>{{ __('Scheduling Pipelines') }}</h4>
<p>
{{ __('The pipelines schedule runs pipelines in the future, repeatedly, for specific branches or tags. Those scheduled pipelines will inherit limited project access based on their associated user.') }}
</p>
<p> {{ __('Learn more in the') }}
<a
:href="docsUrl"
target="_blank"
rel="nofollow">{{ s__('Learn more in the|pipeline schedules documentation') }}</a>. <!-- oneline to prevent extra space before period -->
</p>
</div> </div>
</div> </div>
`, </div>
}; </template>
\ No newline at end of file
import Vue from 'vue'; import Vue from 'vue';
import PipelineSchedulesCallout from './components/pipeline_schedules_callout'; import PipelineSchedulesCallout from './components/pipeline_schedules_callout.vue';
document.addEventListener('DOMContentLoaded', () => new Vue({ document.addEventListener('DOMContentLoaded', () => new Vue({
el: '#pipeline-schedules-callout', el: '#pipeline-schedules-callout',
......
---
title: Improves performance of vue code by using vue files and moving svg out of data
function in pipeline schedule callout
merge_request:
author:
type: other
import Vue from 'vue'; import Vue from 'vue';
import Cookies from 'js-cookie'; import Cookies from 'js-cookie';
import PipelineSchedulesCallout from '~/pipeline_schedules/components/pipeline_schedules_callout'; import PipelineSchedulesCallout from '~/pipeline_schedules/components/pipeline_schedules_callout.vue';
const PipelineSchedulesCalloutComponent = Vue.extend(PipelineSchedulesCallout); const PipelineSchedulesCalloutComponent = Vue.extend(PipelineSchedulesCallout);
const cookieKey = 'pipeline_schedules_callout_dismissed'; const cookieKey = 'pipeline_schedules_callout_dismissed';
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment