Skip to content

Commit 048e72e

Browse files
authored
Merge pull request #5384 from taskcluster/feature/ui-artifacts-list
UI artifacts list improvements
2 parents 6b10d28 + a04d0c5 commit 048e72e

File tree

9 files changed

+141
-13
lines changed

9 files changed

+141
-13
lines changed

changelog/issue-5348.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
audience: general
2+
level: patch
3+
reference: issue 5348
4+
---
5+
6+
Fix artifact copy functionality.

changelog/issue-5362.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
audience: general
2+
level: patch
3+
reference: issue 5362
4+
---
5+
6+
Display task artifacts sorted by importance

changelog/issue-5373.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
audience: general
2+
level: patch
3+
reference: issue 5373
4+
---
5+
6+
Allow local UI to run against existing taskcluster installation using `TASKCLUSTER_ROOT_URL`.

ui/.neutrinorc.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ const DEFAULT_PORT = 5080;
1111
const STATIC_DIR = join(__dirname, 'src/static');
1212
const port = process.env.PORT || DEFAULT_PORT;
1313

14+
const proxyTarget = process.env.TASKCLUSTER_ROOT_URL || 'http://localhost:3050';
15+
1416
require('@babel/register')({
1517
presets: [require.resolve('@babel/preset-env')],
1618
cache: false,
@@ -60,20 +62,20 @@ module.exports = {
6062
},
6163
proxy: {
6264
'/login': {
63-
target: 'http://localhost:3050',
65+
target: proxyTarget,
6466
changeOrigin: true,
6567
},
6668
'/graphql': {
67-
target: 'http://localhost:3050',
69+
target: proxyTarget,
6870
changeOrigin: true,
6971
},
7072
'/subscription': {
7173
ws: true,
7274
changeOrigin: true,
73-
target: 'ws://localhost:3050',
75+
target: proxyTarget.replace(/^http(s)?:/, 'ws$1:'),
7476
},
7577
'/api/web-server': {
76-
target: 'http://localhost:3050',
78+
target: proxyTarget,
7779
changeOrigin: true,
7880
},
7981
},

ui/README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,15 @@ http://localhost:3050, but otherwise need not be publicly accessible. The
1919
development server for this repo will proxy requests as necessary to
2020
http://localhost:3050.
2121

22+
### Using existing Taskcluster server
23+
24+
Instead of running web-server locally you can use existing Taskcluster installation.
25+
To point proxy endpoints, you need to set `TASKCLUSTER_ROOT_URL` environment variable:
26+
27+
```bash
28+
TASKCLUSTER_ROOT_URL=https://community-tc.services.mozilla.com/ yarn start
29+
```
30+
2231
## Development
2332

2433
To get started local development, just:

ui/src/components/TaskRunsCard/index.jsx

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ import { withAuth } from '../../utils/Auth';
3737
import { getArtifactUrl } from '../../utils/getArtifactUrl';
3838
import splitTaskQueueId from '../../utils/splitTaskQueueId';
3939
import Link from '../../utils/Link';
40+
import { sortArtifacts } from './sort';
4041

4142
const DOTS_VARIANT_LIMIT = 5;
4243

@@ -252,13 +253,7 @@ export default class TaskRunsCard extends Component {
252253

253254
return {
254255
...artifacts,
255-
edges: [...artifacts.edges].sort((a, b) => {
256-
if (a.node.isPublic === b.node.isPublic) {
257-
return 0;
258-
}
259-
260-
return a.node.isPublic ? -1 : 1;
261-
}),
256+
edges: sortArtifacts([...artifacts.edges]),
262257
};
263258
}
264259

@@ -288,7 +283,9 @@ export default class TaskRunsCard extends Component {
288283
handleArtifactClick,
289284
} = this.getArtifactInfo(artifact);
290285
// Remove authentication parameter
291-
const artifactUrl = new URL(`${window.location.origin}${url}`);
286+
const artifactUrl = new URL(
287+
`${url.startsWith('http') ? '' : window.location.origin}${url}`
288+
);
292289

293290
artifactUrl.searchParams.delete('bewit');
294291

ui/src/components/TaskRunsCard/index.test.jsx

Lines changed: 53 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,59 @@ it('should render TaskRunsCard', () => {
3838
extra: {},
3939
}}
4040
selectedRunId=""
41-
runs={{}}
41+
runs={[
42+
{
43+
taskId: 'eR1kMya2SruyMaRMZguROg',
44+
runId: 0,
45+
state: 'COMPLETED',
46+
reasonCreated: 'SCHEDULED',
47+
reasonResolved: 'COMPLETED',
48+
scheduled: '2022-02-03T14:41:19.706Z',
49+
started: '2022-02-03T14:43:54.086Z',
50+
resolved: '2022-02-03T14:45:28.396Z',
51+
workerGroup: 'us-east1',
52+
workerId: '7421215367664916236',
53+
takenUntil: '2022-02-03T15:03:54.082Z',
54+
artifacts: {
55+
pageInfo: {
56+
hasNextPage: false,
57+
hasPreviousPage: false,
58+
cursor: '$$FIRST$$',
59+
previousCursor: null,
60+
nextCursor: null,
61+
__typename: 'PageInfo',
62+
},
63+
edges: [
64+
{
65+
node: {
66+
name: 'public/coverage-final.json',
67+
contentType: 'application/json',
68+
__typename: 'Artifact',
69+
},
70+
__typename: 'ArtifactsEdge',
71+
},
72+
{
73+
node: {
74+
name: 'public/logs/live_backing.log',
75+
contentType: 'text/plain; charset=utf-8',
76+
__typename: 'Artifact',
77+
},
78+
__typename: 'ArtifactsEdge',
79+
},
80+
{
81+
node: {
82+
name: 'public/logs/live.log',
83+
contentType: 'text/plain; charset=utf-8',
84+
__typename: 'Artifact',
85+
},
86+
__typename: 'ArtifactsEdge',
87+
},
88+
],
89+
__typename: 'ArtifactsConnection',
90+
},
91+
__typename: 'TaskRun',
92+
},
93+
]}
4294
/>
4395
</MemoryRouter>
4496
);
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
export const getPriority = a => {
2+
if (a?.node?.name?.includes('live.log')) {
3+
return 1;
4+
}
5+
6+
if (a?.node?.name?.includes('live_backing.log')) {
7+
return 2;
8+
}
9+
10+
return a?.node?.name?.startsWith('public/') ? 3 : 4;
11+
};
12+
13+
export const sortArtifacts = artifacts => {
14+
return artifacts
15+
.map(a => ({ ...a, priority: getPriority(a) }))
16+
.sort((a, b) => {
17+
if (a.priority === b.priority) {
18+
return a.node?.name?.localeCompare(b.node?.name);
19+
}
20+
21+
return a.priority - b.priority;
22+
});
23+
};
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
const { sortArtifacts, getPriority } = require('./sort');
2+
3+
it('should define priority based on name', () => {
4+
expect(getPriority({})).toBe(4);
5+
expect(getPriority({ node: { name: 'private/file.log' } })).toBe(4);
6+
expect(getPriority({ node: { name: 'public/file.log' } })).toBe(3);
7+
expect(getPriority({ node: { name: 'public/live_backing.log' } })).toBe(2);
8+
expect(getPriority({ node: { name: 'public/live.log' } })).toBe(1);
9+
});
10+
11+
it('should sort by node name with priority', () => {
12+
const unsortedArtifacts = [
13+
{ node: { name: 'private/b.out' } },
14+
{ node: { name: 'private/a.out' } },
15+
{ node: { name: 'public/live.log' } },
16+
{ node: { name: 'private/coverage.json' } },
17+
{ node: { name: 'public/live_backing.log' } },
18+
];
19+
const sorted = sortArtifacts(unsortedArtifacts);
20+
21+
expect(sorted).toHaveLength(5);
22+
expect(sorted[0].node.name).toBe('public/live.log');
23+
expect(sorted[1].node.name).toBe('public/live_backing.log');
24+
expect(sorted[2].node.name).toBe('private/a.out');
25+
expect(sorted[3].node.name).toBe('private/b.out');
26+
expect(sorted[4].node.name).toBe('private/coverage.json');
27+
});

0 commit comments

Comments
 (0)