-
Notifications
You must be signed in to change notification settings - Fork 53
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
feat(3197): Table cell component for stages in pipeline list jobs view #1230
Open
tkyi
wants to merge
6
commits into
master
Choose a base branch
from
stageForJobsListView
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+191
−23
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
123e183
fix(3197): Add stage column to pipeline jobs list view for v1 and v2
tkyi 1a7de6c
fix: Add tests
tkyi 2b8b10e
Merge branch 'master' into stageForJobsListView
tkyi 1561875
fix: v1 tests
tkyi 1783cbe
Merge branch 'master' into stageForJobsListView
tkyi 5877714
fix: No existing builds bug
tkyi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import Component from '@ember/component'; | ||
import { computed } from '@ember/object'; | ||
|
||
export default Component.extend({ | ||
stageName: computed('record.stage.stageName', { | ||
get() { | ||
return this.record.stage?.stageName || 'N/A'; | ||
} | ||
}) | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<div class="stage-cell"> | ||
<div class="stage-name"> | ||
{{this.stageName}} | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
app/components/pipeline/jobs/table/cell/stage/component.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import Component from '@glimmer/component'; | ||
import getStageName from './util'; | ||
|
||
export default class PipelineJobsTableCellStageComponent extends Component { | ||
willDestroy() { | ||
super.willDestroy(); | ||
|
||
this.args.record.onDestroy(this.args.record.job); | ||
} | ||
|
||
get stageName() { | ||
return getStageName(this.args.record.job); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<div class="stage-cell"> | ||
{{this.stageName}} | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
/** | ||
* Get the stage name of the job. | ||
* @param job {Object} Job in the format returned by the API | ||
* @returns {string} | ||
*/ | ||
export default function getStageName(job) { | ||
return job?.permutations?.[0]?.stage?.name || 'N/A'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,6 +41,7 @@ | |
} | ||
|
||
&.coverage-column, | ||
&.stage-column, | ||
&.metrics-column, | ||
&.actions-column { | ||
width: 10rem; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
tests/integration/components/pipeline-list-stage-cell/component-test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { module, test } from 'qunit'; | ||
import { setupRenderingTest } from 'screwdriver-ui/tests/helpers'; | ||
import { render } from '@ember/test-helpers'; | ||
import hbs from 'htmlbars-inline-precompile'; | ||
|
||
module('Integration | Component | pipeline list stage cell', function (hooks) { | ||
setupRenderingTest(hooks); | ||
|
||
test('it renders', async function (assert) { | ||
this.set('record', { | ||
stage: { stageName: 'production' } | ||
}); | ||
|
||
await render(hbs`<PipelineListStageCell | ||
@record={{this.record}} | ||
/>`); | ||
|
||
assert.dom('.stage-name').hasText('production'); | ||
}); | ||
|
||
test('it renders default stage N/A if does not exist', async function (assert) { | ||
this.set('record', { | ||
stage: { stageName: 'N/A' } | ||
}); | ||
|
||
await render(hbs`<PipelineListStageCell | ||
@record={{this.record}} | ||
/>`); | ||
|
||
assert.dom('.stage-name').hasText('N/A'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
tests/unit/components/pipeline/jobs/table/cell/stage/util-test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { module, test } from 'qunit'; | ||
import getStageName from 'screwdriver-ui/components/pipeline/jobs/table/cell/stage/util'; | ||
|
||
module('Unit | Component | pipeline/jobs/table/cell/stage/util', function () { | ||
test('getStageName uses stage name', function (assert) { | ||
const job = { | ||
name: 'abc123', | ||
permutations: [ | ||
{ | ||
stage: { | ||
name: 'production' | ||
} | ||
} | ||
] | ||
}; | ||
|
||
assert.equal(getStageName(job), job.permutations[0].stage.name); | ||
}); | ||
|
||
test('getStageName uses default stage name when it does not exist', function (assert) { | ||
const job = { | ||
name: 'abc123', | ||
permutations: [{}] | ||
}; | ||
|
||
assert.equal(getStageName(job), 'N/A'); | ||
}); | ||
}); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Locally I got an error when viewing something without a stage.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Config for reference https://github.com/screwdriver-cd-test/functional-commands/blob/master/screwdriver.yaml
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After some investigation, this issue is caused when a pipeline has jobs that never run before, the change to the jobs list view to include the stages is not able to handle this at the moment.
To reproduce: create any new pipeline and don't run any builds, check into the jobs list view and console.