Commit 721f251f authored by Phil Hughes's avatar Phil Hughes

Merge branch 'add-forked-pipeline-indicator' into 'master'

Show if a Pipeline was Run in a Fork

See merge request gitlab-org/gitlab!48517
parents 4550c443 2a626db0
...@@ -369,6 +369,9 @@ export default class MergeRequestTabs { ...@@ -369,6 +369,9 @@ export default class MergeRequestTabs {
projectId: pipelineTableViewEl.dataset.projectId, projectId: pipelineTableViewEl.dataset.projectId,
mergeRequestId: mrWidgetData ? mrWidgetData.iid : null, mergeRequestId: mrWidgetData ? mrWidgetData.iid : null,
}, },
provide: {
targetProjectFullPath: mrWidgetData?.target_project_full_path || '',
},
}).$mount(); }).$mount();
// $mount(el) replaces the el with the new rendered component. We need it in order to mount // $mount(el) replaces the el with the new rendered component. We need it in order to mount
......
...@@ -25,6 +25,11 @@ export default { ...@@ -25,6 +25,11 @@ export default {
required: true, required: true,
}, },
}, },
inject: {
targetProjectFullPath: {
default: '',
},
},
computed: { computed: {
user() { user() {
return this.pipeline.user; return this.pipeline.user;
...@@ -32,6 +37,12 @@ export default { ...@@ -32,6 +37,12 @@ export default {
isScheduled() { isScheduled() {
return this.pipeline.source === SCHEDULE_ORIGIN; return this.pipeline.source === SCHEDULE_ORIGIN;
}, },
isInFork() {
return Boolean(
this.targetProjectFullPath &&
this.pipeline?.project?.full_path !== `/${this.targetProjectFullPath}`,
);
},
}, },
}; };
</script> </script>
...@@ -52,9 +63,8 @@ export default { ...@@ -52,9 +63,8 @@ export default {
:title="__('This pipeline was triggered by a schedule.')" :title="__('This pipeline was triggered by a schedule.')"
class="badge badge-info" class="badge badge-info"
data-testid="pipeline-url-scheduled" data-testid="pipeline-url-scheduled"
>{{ __('Scheduled') }}</span
> >
{{ __('Scheduled') }}
</span>
</gl-link> </gl-link>
<span <span
v-if="pipeline.flags.latest" v-if="pipeline.flags.latest"
...@@ -62,27 +72,24 @@ export default { ...@@ -62,27 +72,24 @@ export default {
:title="__('Latest pipeline for the most recent commit on this branch')" :title="__('Latest pipeline for the most recent commit on this branch')"
class="js-pipeline-url-latest badge badge-success" class="js-pipeline-url-latest badge badge-success"
data-testid="pipeline-url-latest" data-testid="pipeline-url-latest"
>{{ __('latest') }}</span
> >
{{ __('latest') }}
</span>
<span <span
v-if="pipeline.flags.yaml_errors" v-if="pipeline.flags.yaml_errors"
v-gl-tooltip v-gl-tooltip
:title="pipeline.yaml_errors" :title="pipeline.yaml_errors"
class="js-pipeline-url-yaml badge badge-danger" class="js-pipeline-url-yaml badge badge-danger"
data-testid="pipeline-url-yaml" data-testid="pipeline-url-yaml"
>{{ __('yaml invalid') }}</span
> >
{{ __('yaml invalid') }}
</span>
<span <span
v-if="pipeline.flags.failure_reason" v-if="pipeline.flags.failure_reason"
v-gl-tooltip v-gl-tooltip
:title="pipeline.failure_reason" :title="pipeline.failure_reason"
class="js-pipeline-url-failure badge badge-danger" class="js-pipeline-url-failure badge badge-danger"
data-testid="pipeline-url-failure" data-testid="pipeline-url-failure"
>{{ __('error') }}</span
> >
{{ __('error') }}
</span>
<gl-link <gl-link
v-if="pipeline.flags.auto_devops" v-if="pipeline.flags.auto_devops"
:id="`pipeline-url-autodevops-${pipeline.id}`" :id="`pipeline-url-autodevops-${pipeline.id}`"
...@@ -112,17 +119,16 @@ export default { ...@@ -112,17 +119,16 @@ export default {
</gl-sprintf> </gl-sprintf>
</div> </div>
</template> </template>
<gl-link :href="autoDevopsHelpPath" target="_blank" rel="noopener noreferrer nofollow"> <gl-link :href="autoDevopsHelpPath" target="_blank" rel="noopener noreferrer nofollow">{{
{{ __('Learn more about Auto DevOps') }} __('Learn more about Auto DevOps')
</gl-link> }}</gl-link>
</gl-popover> </gl-popover>
<span <span
v-if="pipeline.flags.stuck" v-if="pipeline.flags.stuck"
class="js-pipeline-url-stuck badge badge-warning" class="js-pipeline-url-stuck badge badge-warning"
data-testid="pipeline-url-stuck" data-testid="pipeline-url-stuck"
>{{ __('stuck') }}</span
> >
{{ __('stuck') }}
</span>
<span <span
v-if="pipeline.flags.detached_merge_request_pipeline" v-if="pipeline.flags.detached_merge_request_pipeline"
v-gl-tooltip v-gl-tooltip
...@@ -133,9 +139,16 @@ export default { ...@@ -133,9 +139,16 @@ export default {
" "
class="js-pipeline-url-detached badge badge-info" class="js-pipeline-url-detached badge badge-info"
data-testid="pipeline-url-detached" data-testid="pipeline-url-detached"
>{{ __('detached') }}</span
>
<span
v-if="isInFork"
v-gl-tooltip
:title="__('Pipeline ran in fork of project')"
class="badge badge-info"
data-testid="pipeline-url-fork"
>{{ __('fork') }}</span
> >
{{ __('detached') }}
</span>
</div> </div>
</div> </div>
</template> </template>
---
title: Show if a Pipeline was Ran in a Fork
merge_request: 48517
author:
type: added
...@@ -19800,6 +19800,9 @@ msgstr "" ...@@ -19800,6 +19800,9 @@ msgstr ""
msgid "Pipeline minutes quota" msgid "Pipeline minutes quota"
msgstr "" msgstr ""
msgid "Pipeline ran in fork of project"
msgstr ""
msgid "Pipeline subscriptions" msgid "Pipeline subscriptions"
msgstr "" msgstr ""
...@@ -32146,6 +32149,9 @@ msgstr "" ...@@ -32146,6 +32149,9 @@ msgstr ""
msgid "for this project" msgid "for this project"
msgstr "" msgstr ""
msgid "fork"
msgstr ""
msgid "fork this project" msgid "fork this project"
msgstr "" msgstr ""
......
...@@ -16,6 +16,7 @@ describe('Pipeline Url Component', () => { ...@@ -16,6 +16,7 @@ describe('Pipeline Url Component', () => {
const findAutoDevopsTag = () => wrapper.find('[data-testid="pipeline-url-autodevops"]'); const findAutoDevopsTag = () => wrapper.find('[data-testid="pipeline-url-autodevops"]');
const findStuckTag = () => wrapper.find('[data-testid="pipeline-url-stuck"]'); const findStuckTag = () => wrapper.find('[data-testid="pipeline-url-stuck"]');
const findDetachedTag = () => wrapper.find('[data-testid="pipeline-url-detached"]'); const findDetachedTag = () => wrapper.find('[data-testid="pipeline-url-detached"]');
const findForkTag = () => wrapper.find('[data-testid="pipeline-url-fork"]');
const defaultProps = { const defaultProps = {
pipeline: { pipeline: {
...@@ -30,6 +31,9 @@ describe('Pipeline Url Component', () => { ...@@ -30,6 +31,9 @@ describe('Pipeline Url Component', () => {
const createComponent = props => { const createComponent = props => {
wrapper = shallowMount(PipelineUrlComponent, { wrapper = shallowMount(PipelineUrlComponent, {
propsData: { ...defaultProps, ...props }, propsData: { ...defaultProps, ...props },
provide: {
targetProjectFullPath: 'test/test',
},
}); });
}; };
...@@ -137,4 +141,15 @@ describe('Pipeline Url Component', () => { ...@@ -137,4 +141,15 @@ describe('Pipeline Url Component', () => {
expect(findScheduledTag().exists()).toBe(true); expect(findScheduledTag().exists()).toBe(true);
expect(findScheduledTag().text()).toContain('Scheduled'); expect(findScheduledTag().text()).toContain('Scheduled');
}); });
it('should render the fork badge when the pipeline was run in a fork', () => {
createComponent({
pipeline: {
flags: {},
project: { fullPath: 'test/forked' },
},
});
expect(findForkTag().exists()).toBe(true);
expect(findForkTag().text()).toBe('fork');
});
}); });
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