-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Resolves #1. Use same lint of rancher/dashboard/pkg/rancher-components/package.json. Signed-off-by: Masashi Honma <masashi.honma@gmail.com>
- Loading branch information
Showing
14 changed files
with
629 additions
and
189 deletions.
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,36 @@ | ||
name: CI Workflow | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
- dev | ||
pull_request: | ||
branches: | ||
- main | ||
- dev | ||
|
||
jobs: | ||
lint: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Setup Nodejs with yarn caching | ||
uses: actions/setup-node@v4 | ||
with: | ||
cache: yarn | ||
node-version-file: ".nvmrc" | ||
|
||
- name: Install dependencies | ||
run: | | ||
yarn install | ||
- name: Run lint | ||
run: | | ||
yarn lint | ||
- name: Build Rancher Extension | ||
run: | | ||
yarn build-pkg supportability-review-app |
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 |
---|---|---|
@@ -1,21 +1,19 @@ | ||
export const SUPPORTABILITY_REVIEW_STORE = 'sr' | ||
export const SUPPORTABILITY_REVIEW_STORE = 'sr'; | ||
|
||
// If this is changed, then the same should reflect in en-us.yaml | ||
export const SUPPORTABILITY_REVIEW_PRODUCT_NAME = 'sr' | ||
export const SUPPORTABILITY_REVIEW_PRODUCT_NAME = 'sr'; | ||
|
||
export const SUPPORTABILITY_REVIEW_CRD_IDS = { | ||
REVIEW_BUNDLE: 'sr.cattle.io.reviewbundle' | ||
} | ||
export const SUPPORTABILITY_REVIEW_CRD_IDS = { REVIEW_BUNDLE: 'sr.cattle.io.reviewbundle' }; | ||
|
||
export const SR_APP_PAGES = { | ||
DASHBOARD: 'dashboard', | ||
VIEW_REPORT: 'view-report', | ||
DASHBOARD: 'dashboard', | ||
VIEW_REPORT: 'view-report', | ||
REVIEW_BUNDLE: 'review-bundle' | ||
} | ||
}; | ||
|
||
export const SR_CHARTS = { | ||
OPERATOR: 'rancher-supportability-review', | ||
CRD: 'rancher-supportability-review-crd' | ||
} | ||
CRD: 'rancher-supportability-review-crd' | ||
}; | ||
|
||
export const BLANK_CLUSTER = '_' | ||
export const BLANK_CLUSTER = '_'; |
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
83 changes: 44 additions & 39 deletions
83
pkg/supportability-review-app/models/sr.cattle.io.reviewbundle.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 |
---|---|---|
@@ -1,83 +1,88 @@ | ||
import SteveModel from '@shell/plugins/steve/steve-class' | ||
import { createRoute } from '../utils/custom-routing' | ||
import SteveModel from '@shell/plugins/steve/steve-class'; | ||
import { createRoute } from '../utils/custom-routing'; | ||
|
||
export default class ReviewBundle extends SteveModel { | ||
get _availableActions() { | ||
let out = super._availableActions | ||
let out = super._availableActions; | ||
|
||
// Remove unused menus | ||
const toFilter = ['goToViewConfig', 'goToClone', 'download'] | ||
const toFilter = ['goToViewConfig', 'goToClone', 'download']; | ||
|
||
out = out.filter((action) => { | ||
if (!toFilter.includes(action.action)) { | ||
return action | ||
return action; | ||
} | ||
}) | ||
}); | ||
|
||
// Add custom menus | ||
const t = this.$rootGetters['i18n/t'] | ||
const t = this.$rootGetters['i18n/t']; | ||
|
||
const downloadBundle = { | ||
action: 'downloadThisBundle', | ||
action: 'downloadThisBundle', | ||
enabled: this.hasBundle, | ||
icon: 'icon icon-fw icon-download', | ||
label: t('sr.menuLabels.downloadBundle'), | ||
total: 1 | ||
} | ||
icon: 'icon icon-fw icon-download', | ||
label: t('sr.menuLabels.downloadBundle'), | ||
total: 1 | ||
}; | ||
|
||
const viewReport = { | ||
action: 'viewReport', | ||
action: 'viewReport', | ||
enabled: this.hasBundle, | ||
icon: 'icon icon-fw icon-info', | ||
label: t('sr.menuLabels.viewReport'), | ||
total: 1 | ||
} | ||
icon: 'icon icon-fw icon-info', | ||
label: t('sr.menuLabels.viewReport'), | ||
total: 1 | ||
}; | ||
|
||
out.unshift(viewReport) | ||
out.unshift(downloadBundle) | ||
out.unshift(viewReport); | ||
out.unshift(downloadBundle); | ||
|
||
return out | ||
return out; | ||
} | ||
|
||
viewReport() { | ||
const route = createRoute('report', {}, {}) | ||
window.location.href = `../${route.params.product}/view-report/${this.id}/?bundlename=${this.metadata.name}` | ||
const route = createRoute('report', {}, {}); | ||
|
||
window.location.href = `../${ route.params.product }/view-report/${ this.id }/?bundlename=${ this.metadata.name }`; | ||
} | ||
|
||
downloadFromUrl(url, filename) { | ||
fetch(url) | ||
.then((response) => response.blob()) | ||
.then((blob) => { | ||
const link = document.createElement('a') | ||
link.href = URL.createObjectURL(blob) | ||
link.download = filename | ||
link.click() | ||
const link = document.createElement('a'); | ||
|
||
link.href = URL.createObjectURL(blob); | ||
link.download = filename; | ||
link.click(); | ||
}) | ||
.catch(console.error) | ||
.catch(console.error); | ||
} | ||
|
||
async downloadThisBundle() { | ||
const hostname = window.location.host | ||
const hostname = window.location.host; | ||
|
||
try { | ||
this.downloadFromUrl( | ||
'https://' + | ||
hostname + | ||
'/k8s/clusters/local/api/v1/namespaces/sr-operator-system/services/http:sr-bundle-app-frontend-service:80/proxy/' + | ||
'?key=' + | ||
this.metadata.name + | ||
'&type=file', | ||
`https://${ | ||
hostname | ||
}/k8s/clusters/local/api/v1/namespaces/sr-operator-system/services/http:sr-bundle-app-frontend-service:80/proxy/` + | ||
`?key=${ | ||
this.metadata.name | ||
}&type=file`, | ||
this.status?.fileName | ||
) | ||
); | ||
} catch (err) { | ||
this.$dispatch('growl/fromError', { title: 'Error downloading file', err }, { root: true }) | ||
this.$dispatch('growl/fromError', { title: 'Error downloading file', err }, { root: true }); | ||
} | ||
} | ||
|
||
get hasBundle() { | ||
const fileName = this.status?.fileName | ||
const fileName = this.status?.fileName; | ||
|
||
if (fileName === undefined || fileName === '') { | ||
return false | ||
return false; | ||
} else { | ||
return true | ||
return true; | ||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -1,91 +1,93 @@ | ||
import { STATE, NAME as NAME_COL, AGE, NAMESPACE as NAMESPACE_COL } from '@shell/config/table-headers' | ||
import { SUPPORTABILITY_REVIEW_PRODUCT_NAME, SUPPORTABILITY_REVIEW_CRD_IDS, SR_APP_PAGES } from './config/types' | ||
import { rootRoute, createRoute } from './utils/custom-routing' | ||
import { STATE, NAME as NAME_COL, AGE } from '@shell/config/table-headers'; | ||
import { SUPPORTABILITY_REVIEW_PRODUCT_NAME, SUPPORTABILITY_REVIEW_CRD_IDS, SR_APP_PAGES } from './config/types'; | ||
import { rootRoute, createRoute } from './utils/custom-routing'; | ||
|
||
export function init($plugin, store) { | ||
const { product, configureType, virtualType, basicType, headers } = $plugin.DSL( | ||
const { | ||
product, configureType, virtualType, basicType, headers | ||
} = $plugin.DSL( | ||
store, | ||
SUPPORTABILITY_REVIEW_PRODUCT_NAME | ||
// SUPPORTABILITY_REVIEW_PRODUCT_FULL_NAME, | ||
) | ||
); | ||
|
||
function getBundleSizeString(row) { | ||
if (row.status === undefined || row.status.fileSize === undefined) return '---' | ||
if (row.status === undefined || row.status.fileSize === undefined) return '---'; | ||
|
||
const one_kilo = 1024 | ||
const one_mega = one_kilo * 1024 | ||
const one_giga = one_mega * 1024 | ||
const size = row.status.fileSize | ||
const oneKilo = 1024; | ||
const oneMega = oneKilo * 1024; | ||
const oneGiga = oneMega * 1024; | ||
const size = row.status.fileSize; | ||
|
||
if (size < one_kilo) { | ||
return size + ' B' | ||
} else if (size < one_mega) { | ||
return (size / one_kilo).toFixed(2) + ' KiB' | ||
} else if (size < one_giga) { | ||
return (size / one_mega).toFixed(2) + ' MiB' | ||
if (size < oneKilo) { | ||
return `${ size } B`; | ||
} else if (size < oneMega) { | ||
return `${ (size / oneKilo).toFixed(2) } KiB`; | ||
} else if (size < oneGiga) { | ||
return `${ (size / oneMega).toFixed(2) } MiB`; | ||
} else { | ||
return size + ' B' | ||
return `${ size } B`; | ||
} | ||
} | ||
|
||
// app in sidebar | ||
product({ | ||
icon: 'service', | ||
inStore: 'management', | ||
icon: 'service', | ||
inStore: 'management', | ||
showClusterSwitcher: false, | ||
weight: 100, | ||
to: rootRoute() | ||
}) | ||
weight: 100, | ||
to: rootRoute() | ||
}); | ||
|
||
// dashboard menu entry in SR App | ||
virtualType({ | ||
labelKey: 'sr.menuLabels.dashboard', | ||
// label: store.getters["i18n/t"]("sr.menuLabels.dashboard"), | ||
name: SR_APP_PAGES.DASHBOARD, | ||
route: rootRoute() | ||
}) | ||
name: SR_APP_PAGES.DASHBOARD, | ||
route: rootRoute() | ||
}); | ||
|
||
// defining a k8s resource as page | ||
configureType(SUPPORTABILITY_REVIEW_CRD_IDS.REVIEW_BUNDLE, { | ||
displayName: store.getters['i18n/t'](`typeLabel."${SUPPORTABILITY_REVIEW_CRD_IDS.REVIEW_BUNDLE}"`), | ||
displayName: store.getters['i18n/t'](`typeLabel."${ SUPPORTABILITY_REVIEW_CRD_IDS.REVIEW_BUNDLE }"`), | ||
isCreatable: true, | ||
isEditable: false, | ||
isEditable: false, | ||
isRemovable: true | ||
}) | ||
}); | ||
headers(SUPPORTABILITY_REVIEW_CRD_IDS.REVIEW_BUNDLE, [ | ||
STATE, | ||
NAME_COL, | ||
{ | ||
name: 'Cluster', | ||
name: 'Cluster', | ||
labelKey: 'tableHeaders.clusterCount', | ||
getValue: (row) => row.status?.clusterCount || '---', | ||
sort: ['status.clusterCount'] | ||
sort: ['status.clusterCount'] | ||
}, | ||
{ | ||
name: 'Pass', | ||
name: 'Pass', | ||
labelKey: 'tableHeaders.pass', | ||
getValue: (row) => row.status?.checkResult || '---', | ||
sort: ['status.checkResult'] | ||
sort: ['status.checkResult'] | ||
}, | ||
{ | ||
name: 'Size', | ||
name: 'Size', | ||
labelKey: 'tableHeaders.bundleSize', | ||
getValue: (row) => getBundleSizeString(row), | ||
sort: ['status.fileSize'] | ||
sort: ['status.fileSize'] | ||
}, | ||
AGE | ||
]) | ||
]); | ||
|
||
virtualType({ | ||
label: store.getters['i18n/t']('sr.menuLabels.viewReport'), | ||
name: SR_APP_PAGES.VIEW_REPORT, | ||
name: SR_APP_PAGES.VIEW_REPORT, | ||
route: createRoute('view-report') | ||
}) | ||
}); | ||
|
||
// registering the defined pages as side-menu entries | ||
basicType([ | ||
SR_APP_PAGES.DASHBOARD, | ||
SUPPORTABILITY_REVIEW_CRD_IDS.REVIEW_BUNDLE | ||
// SR_APP_PAGES.VIEW_REPORT, | ||
]) | ||
]); | ||
} |
Oops, something went wrong.