-
Notifications
You must be signed in to change notification settings - Fork 263
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
Add formatting to cluster repos branch names #12497
base: master
Are you sure you want to change the base?
Changes from 1 commit
dce0e8e
b887371
a7d09a2
8bb3315
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,29 @@ | ||
<script> | ||
export default { | ||
props: { | ||
value: { // row | ||
type: Object, | ||
default: () => {} | ||
}, | ||
col: { | ||
type: Object, | ||
default: () => {} | ||
} | ||
}, | ||
|
||
computed: { | ||
clusterRepoBranch() { | ||
return this.value?.isOciType ? this.t('generic.na') : this.value?.spec?.gitBranch ? this.value.spec.gitBranch : undefined; | ||
} | ||
} | ||
}; | ||
</script> | ||
|
||
<template> | ||
<span> | ||
{{ clusterRepoBranch }} | ||
<template v-if="!clusterRepoBranch && col.dashIfEmpty"> | ||
<span class="text-muted">—</span> | ||
</template> | ||
</span> | ||
</template> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { mount } from '@vue/test-utils'; | ||
import ClusterRepoBranch from '@shell/components/formatter/ClusterRepoBranch.vue'; | ||
|
||
const notApplicableTranslationKey = '%generic.na%'; | ||
|
||
describe('component: ClusterRepoBranch', () => { | ||
it.each([ | ||
[{ isOciType: false, spec: { url: 'https://git.rancher.io/charts', gitBranch: 'dev-v2.10' } }, 'dev-v2.10'], | ||
[{ isOciType: false, spec: { url: 'https://git.rancher.io/charts', gitBranch: 'main' } }, 'main'], | ||
[{ isOciType: false, spec: { url: '', gitBranch: 'main' } }, 'main'], | ||
[{ isOciType: false, spec: { url: '', gitBranch: '' } }, '—'], | ||
[{ isOciType: false, spec: { url: '' } }, '—'], | ||
[{ isOciType: true, spec: { url: 'oci://' } }, notApplicableTranslationKey], | ||
[{ isOciType: true, spec: { url: 'oci://', gitBranch: 'main' } }, notApplicableTranslationKey], | ||
[{ isOciType: true, spec: { url: '' } }, notApplicableTranslationKey], | ||
[{ }, '—'], | ||
[undefined, '—'], | ||
])('should display correct branch', async(clusterRepo, expectedBranchTextToShow) => { | ||
const wrapper = await mount(ClusterRepoBranch, { props: { value: clusterRepo, col: { dashIfEmpty: true } } }); | ||
const element = wrapper.find('span'); | ||
|
||
expect(element.text()).toBe(expectedBranchTextToShow); | ||
}); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -75,9 +75,18 @@ export function init(store) { | |
dashIfEmpty: true, | ||
}; | ||
|
||
const clusterRepoBranch = { | ||
name: 'branch', | ||
labelKey: 'tableHeaders.branch', | ||
sort: 'spec.gitBranch', | ||
getValue: (row) => row, | ||
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. doesn't this break local sorting / searching? 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. it doesn't search.movThere 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 breaks search (n/a provides no hits). Would suggest this, which means the formatter might not be neeed
would just need to resolve access to 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.
|
||
formatter: 'ClusterRepoBranch', | ||
dashIfEmpty: true, | ||
}; | ||
|
||
headers(CATALOG.APP, [STATE, NAME_COL, NAMESPACE, CHART, CHART_UPGRADE, APP_SUMMARY, AGE]); | ||
headers(CATALOG.REPO, [STATE, NAME_COL, NAMESPACE, repoType, repoUrl, repoBranch, AGE]); | ||
headers(CATALOG.CLUSTER_REPO, [STATE, NAME_COL, repoType, repoUrl, repoBranch, AGE]); | ||
headers(CATALOG.CLUSTER_REPO, [STATE, NAME_COL, repoType, repoUrl, clusterRepoBranch, AGE]); | ||
headers(CATALOG.OPERATION, [ | ||
STATE, | ||
NAME_COL, | ||
|
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.
We might want to pause on this.
When the list is updated to use server-side pagination the sort and search will be broken (given both will still be on value.spec.gitBranch).
The alternative is to not use server-side pagination for this list, given it's small
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.
Even without this change we can have missing gitBranch in the
spec
object. In those cases we currently show–
for all types of cluster repos, but here we shown/a
for just the oci type, is there a way to test the server-side pagination now?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.
Server side sort and filtering can only be done on values that natively exist in the resource server side.
Here we would be showing
n/a
but still sorting and filtering onspec.gitBranch
's undefined value. Sorting might seem ok UX wise but wouldn't strictly be true (aaa1, na1, na2, x1, n/a, n/a, n/a, n/a). The user wouldn't wouldn't get any results if they filtered on n/a.Maybe it's just not worth converting this list. Maybe one for UX