Skip to content

Commit

Permalink
HARVESTER: Add hideNamespaceLocation for product config (#7702)
Browse files Browse the repository at this point in the history
  • Loading branch information
n313893254 authored Jan 13, 2023
1 parent 4ccb724 commit 17f784c
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 7 deletions.
3 changes: 2 additions & 1 deletion pkg/harvester/config/harvester.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ export function init($plugin, store) {
product: PRODUCT_NAME,
resource: HCI.DASHBOARD
}
}
},
hideNamespaceLocation: true,
});

basicType([HCI.DASHBOARD]);
Expand Down
18 changes: 17 additions & 1 deletion pkg/harvester/models/harvesterhci.io.virtualmachineimage.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,26 @@ import { formatSi } from '@shell/utils/units';
import { ucFirst } from '@shell/utils/string';
import { stateDisplay, colorForState } from '@shell/plugins/dashboard-store/resource-class';
import { _CLONE } from '@shell/config/query-params';
import { isReady } from '@shell/machine-config/harvester';
import HarvesterResource from './harvester';
import { PRODUCT_NAME as HARVESTER_PRODUCT } from '../config/harvester';

function isReady() {
function getStatusConditionOfType(type, defaultValue = []) {
const conditions = Array.isArray(get(this, 'status.conditions')) ? this.status.conditions : defaultValue;

return conditions.find( cond => cond.type === type);
}

const initialized = getStatusConditionOfType.call(this, 'Initialized');
const imported = getStatusConditionOfType.call(this, 'Imported');
const isCompleted = this.status?.progress === 100;

if ([initialized?.status, imported?.status].includes('False')) {
return false;
} else {
return isCompleted && true;
}
}
export default class HciVmImage extends HarvesterResource {
get availableActions() {
let out = super._availableActions;
Expand Down
4 changes: 4 additions & 0 deletions shell/components/ExplorerProjectsNamespaces.vue
Original file line number Diff line number Diff line change
Expand Up @@ -399,10 +399,14 @@ export default {
<template #cell:name="{row}">
<div class="namespace-name">
<n-link
v-if="row.detailLocation"
:to="row.detailLocation"
>
{{ row.name }}
</n-link>
<span v-else>
{{ row.name }}
</span>
<i
v-if="row.hasSystemLabels"
v-tooltip="getPSA(row)"
Expand Down
17 changes: 16 additions & 1 deletion shell/components/ResourceDetail/Masthead.vue
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,10 @@ export default {
return parent?.location;
},
hideNamespaceLocation() {
return this.$store.getters['currentProduct'].hideNamespaceLocation;
},
},
methods: {
Expand Down Expand Up @@ -427,7 +431,18 @@ export default {
>
<span v-if="isNamespace && project">{{ t("resourceDetail.masthead.project") }}: <nuxt-link :to="project.detailLocation">{{ project.nameDisplay }}</nuxt-link></span>
<span v-else-if="isWorkspace">{{ t("resourceDetail.masthead.workspace") }}: <nuxt-link :to="workspaceLocation">{{ namespace }}</nuxt-link></span>
<span v-else-if="namespace && !hasMultipleNamespaces">{{ t("resourceDetail.masthead.namespace") }}: <nuxt-link :to="namespaceLocation">{{ namespace }}</nuxt-link></span>
<span v-else-if="namespace && !hasMultipleNamespaces">
{{ t("resourceDetail.masthead.namespace") }}:
<nuxt-link
v-if="!hideNamespaceLocation"
:to="namespaceLocation"
>
{{ namespace }}
</nuxt-link>
<span v-else>
{{ namespace }}
</span>
</span>
<span v-if="parent.showAge">{{ t("resourceDetail.masthead.age") }}: <LiveDate
class="live-date"
:value="value.creationTimestamp"
Expand Down
7 changes: 3 additions & 4 deletions shell/models/namespace.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,11 +187,10 @@ export default class Namespace extends SteveModel {
}

get _detailLocation() {
const _detailLocation = super._detailLocation;
let _detailLocation = super._detailLocation;

// Harvester uses these resource directly... but has different routes. detailLocation covers routes leading to resource (like edit)
if (this.$rootGetters['currentProduct'].inStore === HARVESTER) {
_detailLocation.name = `${ HARVESTER }-${ _detailLocation.name }`.replace('-product', '');
if (this.$rootGetters['currentProduct'].hideNamespaceLocation) {
_detailLocation = false;
}

return _detailLocation;
Expand Down
1 change: 1 addition & 0 deletions shell/store/type-map.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
// category, -- Group to show the product in for the nav hamburger menu
// typeStoreMap, -- An object mapping types to the store that should be used to retrieve information about the type
// hideSystemResources -- Hide resources in namespaces where namespace.isSystem === true, or a namespace managed by fleet (per its annotation) and hide those namespaces from ns/project list and nsfilter (default false)
// hideNamespaceLocation -- Hide the namespace link in the ResourceDetail masthead of namespaced resources and hide the ExplorerProjectsNamespaces namespace link (default false)
// })
//
// externalLink(stringOrFn) The product has an external page (function gets context object
Expand Down

0 comments on commit 17f784c

Please sign in to comment.