Skip to content

Commit

Permalink
Update build layout (woodpecker-ci#678)
Browse files Browse the repository at this point in the history
* show yml config of build in UI

* fix after merge

* improve build configs

* fix approve & decline build

* improve build layout

* undo un-related changes

* fix type

* move icon back to right side

Co-authored-by: 6543 <[email protected]>
  • Loading branch information
anbraten and 6543 authored Jan 9, 2022
1 parent 77923ad commit 9d17e26
Show file tree
Hide file tree
Showing 15 changed files with 487 additions and 372 deletions.
8 changes: 4 additions & 4 deletions web/src/components/build-feed/BuildFeedItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
<span class="underline">{{ build.owner }} / {{ build.name }}</span>
<span class="whitespace-nowrap overflow-hidden overflow-ellipsis">{{ message }}</span>
<div class="flex flex-col mt-2">
<div class="flex space-x-2 items-center">
<Icon name="duration" />
<span>{{ duration }}</span>
</div>
<div class="flex space-x-2 items-center">
<Icon name="since" />
<span>{{ since }}</span>
</div>
<div class="flex space-x-2 items-center">
<Icon name="duration" />
<span>{{ duration }}</span>
</div>
</div>
</div>
</div>
Expand Down
14 changes: 10 additions & 4 deletions web/src/components/layout/Panel.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
<template>
<div class="rounded-md w-full p-4 shadow border bg-white dark:bg-dark-gray-700 dark:border-dark-200">
<slot />
<div class="rounded-md w-full shadow overflow-hidden text-gray-500 bg-gray-300 dark:bg-dark-gray-700">
<div v-if="title" class="font-bold bg-gray-400 dark:bg-dark-gray-800 p-2">{{ title }}</div>
<div class="w-full p-4 bg-gray-300 dark:bg-dark-gray-700">
<slot />
</div>
</div>
</template>

Expand All @@ -10,8 +13,11 @@ import { defineComponent } from 'vue';
export default defineComponent({
name: 'Panel',
setup() {
return {};
props: {
title: {
type: String,
default: '',
},
},
});
</script>
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import { Build, Repo } from '~/lib/api/types';
import { findProc } from '~/utils/helpers';
export default defineComponent({
name: 'BuildLogs',
name: 'BuildLog',
components: {},
Expand Down
112 changes: 112 additions & 0 deletions web/src/components/repo/build/BuildProcList.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
<template>
<div class="flex flex-col w-3/12 text-gray-200 dark:text-gray-400">
<div class="flex py-4 px-2 mx-2 justify-between flex-shrink-0 text-gray-500 border-b-1 dark:border-dark-gray-600">
<div class="flex space-x-1 items-center flex-shrink-0">
<div class="flex items-center"><img class="w-6" :src="build.author_avatar" /></div>
<span>{{ build.author }}</span>
</div>
<div class="flex space-x-1 items-center">
<Icon v-if="build.event === 'push'" name="push" />
<Icon v-if="build.event === 'deployment'" name="deployment" />
<Icon v-else-if="build.event === 'tag'" name="tag" />
<a
v-else-if="build.event === 'pull_request'"
class="flex items-center text-link"
:href="build.link_url"
target="_blank"
>
<Icon name="pull_request" />
<span>{{
`#${build.ref.replaceAll('refs/pull/', '').replaceAll('refs/merge-requests/', '').replaceAll('/head', '')}`
}}</span></a
>
<span v-if="build.event !== 'pull_request'">{{ build.branch }}</span>
</div>
<div class="flex items-center flex-shrink-0">
<template v-if="build.event === 'pull_request'">
<Icon name="commit" />
<span>{{ build.commit.slice(0, 10) }}</span>
</template>
<a v-else class="text-link flex items-center" :href="build.link_url" target="_blank">
<Icon name="commit" />
<span>{{ build.commit.slice(0, 10) }}</span>
</a>
</div>
</div>

<div v-for="proc in build.procs" :key="proc.id">
<div class="p-4 pb-1 flex flex-wrap items-center justify-between">
<span>{{ proc.name }}</span>
<div v-if="proc.environ" class="text-xs">
<div v-for="(value, key) in proc.environ" :key="key">
<span
class="
pl-2
pr-1
py-0.5
bg-gray-800
dark:bg-gray-600
border-2 border-gray-800
dark:border-gray-600
rounded-l-full
"
>{{ key }}</span
>
<span class="pl-1 pr-2 py-0.5 border-2 border-gray-800 dark:border-gray-600 rounded-r-full">{{
value
}}</span>
</div>
</div>
</div>
<div
v-for="job in proc.children"
:key="job.pid"
class="flex p-2 pl-6 cursor-pointer items-center hover:bg-gray-700 hover:dark:bg-dark-gray-900"
:class="{ 'bg-gray-700 !dark:bg-dark-gray-600': selectedProcId && selectedProcId === job.pid }"
@click="$emit('update:selected-proc-id', job.pid)"
>
<div v-if="['success'].includes(job.state)" class="w-2 h-2 bg-lime-400 rounded-full" />
<div v-if="['pending', 'skipped'].includes(job.state)" class="w-2 h-2 bg-gray-400 rounded-full" />
<div
v-if="['killed', 'error', 'failure', 'blocked', 'declined'].includes(job.state)"
class="w-2 h-2 bg-red-400 rounded-full"
/>
<div v-if="['started', 'running'].includes(job.state)" class="w-2 h-2 bg-blue-400 rounded-full" />
<span class="ml-2">{{ job.name }}</span>
<BuildProcDuration :proc="job" />
</div>
</div>
</div>
</template>

<script lang="ts">
import { defineComponent, PropType } from 'vue';
import BuildProcDuration from '~/components/repo/build/BuildProcDuration.vue';
import { Build } from '~/lib/api/types';
export default defineComponent({
name: 'BuildProcList',
components: {
BuildProcDuration,
},
props: {
build: {
type: Object as PropType<Build>,
required: true,
},
selectedProcId: {
type: Number as PropType<number | null>,
default: null,
},
},
emits: {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
'update:selected-proc-id': (selectedProcId: number) => true,
},
});
</script>
89 changes: 0 additions & 89 deletions web/src/components/repo/build/BuildProcs.vue

This file was deleted.

2 changes: 1 addition & 1 deletion web/src/components/tabs/Tab.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<div v-show="isActive" :aria-hidden="!isActive">
<div v-if="$slots.default" v-show="isActive" :aria-hidden="!isActive" class="mt-4">
<slot />
</div>
</template>
Expand Down
2 changes: 1 addition & 1 deletion web/src/components/tabs/Tabs.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template>
<div class="flex flex-col">
<div class="flex w-full pt-4 mb-4">
<div class="flex w-full pt-4">
<div
v-for="tab in tabs"
:key="tab.id"
Expand Down
6 changes: 1 addition & 5 deletions web/src/compositions/useBuild.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,7 @@ export default (build: Ref<Build | undefined>) => {
return undefined;
}

const start = build.value.started_at || 0;

if (start === 0) {
return 0;
}
const start = build.value.created_at || 0;

return start * 1000;
});
Expand Down
2 changes: 1 addition & 1 deletion web/src/lib/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export default class WoodpeckerClient extends ApiClient {
return this._get(`/api/repos/${owner}/${repo}/builds?${query}`) as Promise<Build[]>;
}

getBuild(owner: string, repo: string, number: string | 'latest'): Promise<Build> {
getBuild(owner: string, repo: string, number: number | 'latest'): Promise<Build> {
return this._get(`/api/repos/${owner}/${repo}/builds/${number}`) as Promise<Build>;
}

Expand Down
13 changes: 10 additions & 3 deletions web/src/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,17 @@ const routes: RouteRecordRaw[] = [
props: (route) => ({ branch: route.params.branch }),
},
{
path: 'build/:buildId/:procId?',
name: 'repo-build',
component: (): Component => import('~/views/repo/RepoBuild.vue'),
path: 'build/:buildId',
component: (): Component => import('~/views/repo/build/BuildWrapper.vue'),
props: true,
children: [
{
path: ':procId?',
name: 'repo-build',
component: (): Component => import('~/views/repo/build/Build.vue'),
props: true,
},
],
},
{
path: 'settings',
Expand Down
2 changes: 1 addition & 1 deletion web/src/store/builds.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export default defineStore({
});
},
async loadBuild(owner: string, repo: string, buildNumber: number) {
const build = await apiClient.getBuild(owner, repo, buildNumber.toString());
const build = await apiClient.getBuild(owner, repo, buildNumber);
this.setBuild(owner, repo, build);
},
async loadBuildFeed() {
Expand Down
Loading

0 comments on commit 9d17e26

Please sign in to comment.