mirror of
https://github.com/harvester/harvester-ui-extension.git
synced 2026-10-01 11:46:06 +08:00
Compare commits
3
Commits
v1.8.0-rc6
...
v1.8.0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1dcb528717 | ||
|
|
36fc21ccbc | ||
|
|
8803b79524 |
@@ -43,7 +43,7 @@ jobs:
|
||||
needs:
|
||||
- setup-release-tag
|
||||
- check-version
|
||||
uses: rancher/dashboard/.github/workflows/build-extension-charts.yml@9eb70a732e9be146722e1dbab431338366c2afc6 # creators-pkg-v3.0.10
|
||||
uses: rancher/dashboard/.github/workflows/build-extension-charts.yml@3b26a36bad555e5e2b8634b24823be29732f287c # master
|
||||
permissions:
|
||||
actions: write
|
||||
contents: write
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "harvester-ui-extension",
|
||||
"version": "1.8.0-rc6",
|
||||
"version": "1.8.0",
|
||||
"private": false,
|
||||
"engines": {
|
||||
"node": ">=20.0.0"
|
||||
|
||||
@@ -4,6 +4,7 @@ import { Card } from '@components/Card';
|
||||
import AsyncButton from '@shell/components/AsyncButton';
|
||||
import { escapeHtml } from '@shell/utils/string';
|
||||
import { HCI } from '../types';
|
||||
import { getHarvesterUserName } from '../utils/auth';
|
||||
|
||||
export default {
|
||||
name: 'HarvesterEnablePciPassthrough',
|
||||
@@ -34,16 +35,7 @@ export default {
|
||||
},
|
||||
|
||||
async save(buttonCb) {
|
||||
// isSingleProduct == this is a standalone Harvester cluster
|
||||
const isSingleProduct = this.$store.getters['isSingleProduct'];
|
||||
let userName = 'admin';
|
||||
|
||||
// if this is imported Harvester, there may be users other than 'admin
|
||||
if (!isSingleProduct) {
|
||||
const user = this.$store.getters['auth/v3User'];
|
||||
|
||||
userName = user?.username || user?.id;
|
||||
}
|
||||
const userName = getHarvesterUserName(this.$store.getters);
|
||||
|
||||
for (let i = 0; i < this.resources.length; i++) {
|
||||
const actionResource = this.resources[i];
|
||||
|
||||
@@ -4,6 +4,7 @@ import { Card } from '@components/Card';
|
||||
import AsyncButton from '@shell/components/AsyncButton';
|
||||
import { escapeHtml } from '@shell/utils/string';
|
||||
import { HCI } from '../types';
|
||||
import { getHarvesterUserName } from '../utils/auth';
|
||||
|
||||
export default {
|
||||
name: 'HarvesterEnableUSBPassthrough',
|
||||
@@ -34,16 +35,7 @@ export default {
|
||||
},
|
||||
|
||||
async save(buttonCb) {
|
||||
// isSingleProduct == this is a standalone Harvester cluster
|
||||
const isSingleProduct = this.$store.getters['isSingleProduct'];
|
||||
let userName = 'admin';
|
||||
|
||||
// if this is imported Harvester, there may be users other than 'admin
|
||||
if (!isSingleProduct) {
|
||||
const user = this.$store.getters['auth/v3User'];
|
||||
|
||||
userName = user?.username || user?.id;
|
||||
}
|
||||
const userName = getHarvesterUserName(this.$store.getters);
|
||||
|
||||
for (let i = 0; i < this.resources.length; i++) {
|
||||
const actionResource = this.resources[i];
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<script>
|
||||
import { NORMAN } from '@shell/config/types';
|
||||
import { HCI } from '../types';
|
||||
import { getHarvesterUser } from '../utils/auth';
|
||||
|
||||
export default {
|
||||
props: {
|
||||
@@ -25,7 +26,7 @@ export default {
|
||||
},
|
||||
|
||||
data() {
|
||||
const user = this.$store.getters['auth/v3User'];
|
||||
const user = getHarvesterUser(this.$store.getters);
|
||||
|
||||
return {
|
||||
harvesterSettings: [],
|
||||
|
||||
@@ -2,6 +2,7 @@ import SteveModel from '@shell/plugins/steve/steve-class';
|
||||
import { escapeHtml } from '@shell/utils/string';
|
||||
import { HCI } from '../types';
|
||||
import { HCI as HCI_ANNOTATIONS } from '@pkg/harvester/config/labels-annotations';
|
||||
import { getHarvesterUserName } from '../utils/auth';
|
||||
|
||||
const STATUS_DISPLAY = {
|
||||
enabled: {
|
||||
@@ -96,15 +97,8 @@ export default class PCIDevice extends SteveModel {
|
||||
if (!this.passthroughClaim) {
|
||||
return false;
|
||||
}
|
||||
const isSingleProduct = this.$rootGetters['isSingleProduct'];
|
||||
let userName = 'admin';
|
||||
|
||||
// if this is imported Harvester, there may be users other than admin
|
||||
if (!isSingleProduct) {
|
||||
const user = this.$rootGetters['auth/v3User'];
|
||||
|
||||
userName = user?.username || user?.id;
|
||||
}
|
||||
const userName = getHarvesterUserName(this.$rootGetters);
|
||||
|
||||
return this.claimedBy === userName;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import SteveModel from '@shell/plugins/steve/steve-class';
|
||||
import { escapeHtml } from '@shell/utils/string';
|
||||
import { HCI } from '../types';
|
||||
import { getHarvesterUserName } from '../utils/auth';
|
||||
|
||||
const STATUS_DISPLAY = {
|
||||
enabled: {
|
||||
@@ -87,15 +88,8 @@ export default class USBDevice extends SteveModel {
|
||||
if (!this.passthroughClaim) {
|
||||
return false;
|
||||
}
|
||||
const isSingleProduct = this.$rootGetters['isSingleProduct'];
|
||||
let userName = 'admin';
|
||||
|
||||
// if this is imported Harvester, there may be users other than admin
|
||||
if (!isSingleProduct) {
|
||||
const user = this.$rootGetters['auth/v3User'];
|
||||
|
||||
userName = user?.username || user?.id;
|
||||
}
|
||||
const userName = getHarvesterUserName(this.$rootGetters);
|
||||
|
||||
return this.claimedBy === userName;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "harvester",
|
||||
"description": "Rancher UI Extension for Harvester",
|
||||
"version": "1.8.0-rc6",
|
||||
"version": "1.8.0",
|
||||
"private": false,
|
||||
"rancher": {
|
||||
"annotations": {
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
/**
|
||||
* Resolve the Harvester username from Vuex getters.
|
||||
*
|
||||
* Works with both `this.$store.getters` (in components) and
|
||||
* `this.$rootGetters` (in Steve models).
|
||||
*
|
||||
* - In single-product (standalone Harvester) mode, always returns the
|
||||
* default username (`admin`).
|
||||
* - Otherwise, falls back to the authenticated user's `username` or `id`.
|
||||
*/
|
||||
export function getHarvesterUserName(getters, defaultUserName = 'admin') {
|
||||
const isSingleProduct = getters?.['isSingleProduct'];
|
||||
|
||||
if (isSingleProduct) {
|
||||
return defaultUserName;
|
||||
}
|
||||
|
||||
const user = getHarvesterUser(getters);
|
||||
|
||||
return user?.username || user?.id || defaultUserName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the authenticated user object from Vuex getters.
|
||||
*
|
||||
* Works with both `this.$store.getters` (in components) and
|
||||
* `this.$rootGetters` (in Steve models).
|
||||
*/
|
||||
export function getHarvesterUser(getters) {
|
||||
return getters?.['auth/user'];
|
||||
}
|
||||
Reference in New Issue
Block a user