-
-
Notifications
You must be signed in to change notification settings - Fork 6.6k
Workflow Artifact Info Hover #37100
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
base: main
Are you sure you want to change the base?
Workflow Artifact Info Hover #37100
Changes from all commits
5d9a44e
7759b8d
96d62cf
415044d
ecc8429
06ba537
53a4c79
83f0d17
322023f
3887aaf
840ca21
6cc7c34
65ac91d
f822379
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| import {createArtifactTooltipElement} from './ActionRunArtifacts.ts'; | ||
|
|
||
| test('createArtifactTooltipElement for active artifact', () => { | ||
| const el = createArtifactTooltipElement({ | ||
| name: 'artifact.zip', | ||
| size: 1024 * 1024, | ||
| status: 'completed', | ||
| expiresUnix: Date.UTC(2026, 2, 20, 12, 0, 0) / 1000, | ||
| }, 'Expires at %s'); | ||
|
|
||
| const rt = el.querySelector('relative-time')!; | ||
| expect(rt).not.toBeNull(); | ||
| expect(rt.getAttribute('datetime')).toBe('2026-03-20T12:00:00.000Z'); | ||
| expect(rt.getAttribute('threshold')).toBe('P0Y'); | ||
| expect(rt.getAttribute('month')).toBe('short'); | ||
| expect(rt.getAttribute('hour')).toBe('numeric'); | ||
| expect(rt.getAttribute('minute')).toBe('2-digit'); | ||
| expect(el.textContent).toContain('Expires at'); | ||
| expect(el.textContent).toContain('1.0 MiB'); | ||
| expect(el.querySelector('.artifact-size')).not.toBeNull(); | ||
| }); | ||
|
|
||
| test('createArtifactTooltipElement with no expiry', () => { | ||
| const el = createArtifactTooltipElement({ | ||
| name: 'artifact.zip', | ||
| size: 512, | ||
| status: 'completed', | ||
| expiresUnix: 0, | ||
| }, 'Expires at %s'); | ||
|
|
||
| expect(el.querySelector('relative-time')).toBeNull(); | ||
| expect(el.textContent).toBe('512 B'); | ||
| }); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| import {createElementFromAttrs} from '../utils/dom.ts'; | ||
| import {formatBytes} from '../utils.ts'; | ||
| import type {ActionsArtifact} from '../modules/gitea-actions.ts'; | ||
|
|
||
| export function createArtifactTooltipElement(artifact: ActionsArtifact, expiresAtLocale: string): HTMLElement { | ||
| const sizeText = formatBytes(artifact.size); | ||
|
|
||
| if (artifact.expiresUnix <= 0) { | ||
| return createElementFromAttrs('span', null, sizeText); | ||
| } | ||
|
|
||
| const datetime = new Date(artifact.expiresUnix * 1000).toISOString(); | ||
| const parts = expiresAtLocale.split('%s'); | ||
| const relativeTime = createElementFromAttrs('relative-time', { | ||
| datetime, threshold: 'P0Y', prefix: '', weekday: '', | ||
| year: 'numeric', month: 'short', hour: 'numeric', minute: '2-digit', | ||
| }); | ||
| const sizeSpan = createElementFromAttrs('span', {class: 'artifact-size tw-border-l tw-border-current tw-ml-2 tw-pl-2'}, sizeText); | ||
| return createElementFromAttrs('span', null, parts[0] ?? '', relativeTime, parts[1] ?? '', sizeSpan); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,7 +5,9 @@ import {toRefs} from 'vue'; | |
| import {POST, DELETE} from '../modules/fetch.ts'; | ||
| import ActionRunSummaryView from './ActionRunSummaryView.vue'; | ||
| import ActionRunJobView from './ActionRunJobView.vue'; | ||
| import {createActionRunViewStore} from "./ActionRunView.ts"; | ||
| import {createActionRunViewStore} from './ActionRunView.ts'; | ||
| import {createArtifactTooltipElement} from './ActionRunArtifacts.ts'; | ||
| import {createTippy} from '../modules/tippy.ts'; | ||
|
|
||
| defineOptions({ | ||
| name: 'RepoActionView', | ||
|
|
@@ -20,7 +22,16 @@ const props = defineProps<{ | |
|
|
||
| const locale = props.locale; | ||
| const store = createActionRunViewStore(props.actionsUrl, props.runId); | ||
| const {currentRun: run , runArtifacts: artifacts} = toRefs(store.viewData); | ||
| const {currentRun: run, runArtifacts: artifacts} = toRefs(store.viewData); | ||
|
|
||
| function initSidebarTooltip(el: HTMLElement | null, content: string | HTMLElement) { | ||
| if (!el) return; | ||
| if (el._tippy) { | ||
| el._tippy.setContent(content); | ||
| } else { | ||
| createTippy(el, {content, role: 'tooltip', theme: 'tooltip', placement: 'top-end', arrow: false, offset: [0, 2]}); | ||
| } | ||
| } | ||
|
Comment on lines
+27
to
+34
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You need to improve the framework, instead of making future developers copy&paste such code. For example:
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess some generic way to specify all tippy props in HTML is needed. Should be done with a future migration to https://github.com/floating-ui/floating-ui in mind.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
No, don't do more than it needs. "tooltip" is "tooltip". Other tippy popups don't use "tooltip-content" for content. |
||
|
|
||
| function cancelRun() { | ||
| POST(`${run.value.link}/cancel`); | ||
|
|
@@ -118,20 +129,20 @@ async function deleteArtifact(name: string) { | |
| <div class="ui divider"/> | ||
| <div class="left-list-header">{{ locale.artifactsTitle }} ({{ artifacts.length }})</div> | ||
| <ul class="ui relaxed list flex-items-block"> | ||
| <li class="item" v-for="artifact in artifacts" :key="artifact.name"> | ||
| <li :ref="artifact.status !== 'expired' ? (el) => initSidebarTooltip(el as HTMLElement, createArtifactTooltipElement(artifact, locale.artifactExpiresAt)) : undefined" class="item" v-for="artifact in artifacts" :key="artifact.name"> | ||
| <template v-if="artifact.status !== 'expired'"> | ||
| <a class="tw-flex-1 flex-text-block" target="_blank" :href="run.link+'/artifacts/'+artifact.name"> | ||
| <SvgIcon name="octicon-file" class="tw-text-text"/> | ||
| <a class="tw-flex-1 flex-text-block muted" target="_blank" :href="run.link+'/artifacts/'+encodeURIComponent(artifact.name)"> | ||
| <SvgIcon name="octicon-file" class="tw-text-text-light"/> | ||
| <span class="tw-flex-1 gt-ellipsis">{{ artifact.name }}</span> | ||
| </a> | ||
| <a v-if="run.canDeleteArtifact" @click="deleteArtifact(artifact.name)"> | ||
| <SvgIcon name="octicon-trash" class="tw-text-text"/> | ||
| <a v-if="run.canDeleteArtifact" class="muted" @click="deleteArtifact(artifact.name)"> | ||
| <SvgIcon name="octicon-trash"/> | ||
| </a> | ||
bircni marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| </template> | ||
| <span v-else class="flex-text-block tw-flex-1 tw-text-grey-light"> | ||
| <span v-else class="flex-text-block tw-flex-1 tw-text-text-light-2"> | ||
| <SvgIcon name="octicon-file"/> | ||
| <span class="tw-flex-1 gt-ellipsis">{{ artifact.name }}</span> | ||
| <span class="ui label tw-text-grey-light tw-flex-shrink-0">{{ locale.artifactExpired }}</span> | ||
| <span class="ui label tw-flex-shrink-0">{{ locale.artifactExpired }}</span> | ||
| </span> | ||
| </li> | ||
| </ul> | ||
|
|
@@ -251,6 +262,7 @@ async function deleteArtifact(name: string) { | |
|
|
||
| .left-list-header { | ||
| font-size: 13px; | ||
| font-weight: var(--font-weight-semibold); | ||
| color: var(--color-text-light-2); | ||
| } | ||
|
|
||
|
|
@@ -259,6 +271,16 @@ async function deleteArtifact(name: string) { | |
| padding-left: 10px; | ||
| } | ||
|
|
||
| .action-view-left .ui.relaxed.list > .item { | ||
| padding-top: 0; | ||
| padding-bottom: 0; | ||
| } | ||
|
|
||
| .action-view-left .ui.relaxed.list > .item > :first-child { | ||
| padding-top: 0.42857143em; | ||
| padding-bottom: 0.42857143em; | ||
| } | ||
|
|
||
|
Comment on lines
+274
to
+283
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. By the way, don't use such trick. You can see it breaks the UI , makes the "job list" very narrow.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a minor fix to have the full vertical area hoverable (e.g. link turns blue on Will check. Likely refactor to |
||
| .job-brief-item { | ||
| padding: 6px 10px; | ||
| border-radius: var(--border-radius); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.