Skip to content

Commit

Permalink
fix some ts errors
Browse files Browse the repository at this point in the history
  • Loading branch information
mantis-toboggan-md committed Jan 25, 2024
1 parent 15c0856 commit 4b5610f
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 17 deletions.
21 changes: 12 additions & 9 deletions pkg/capi/edit/ClusterConfig.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import NameNsDescription from '@shell/components/form/NameNsDescription.vue';
import Loading from '@shell/components/Loading.vue';
import CruResource from '@shell/components/CruResource.vue';
import CreateEditView from '@shell/mixins/create-edit-view';
import { Translation } from '@rancher/shell/types/t';
import ClusterClassVariables from '../components/CCVariables/index.vue';
import { versionTest, versionValidator, nameValidator } from '../util/validators';
import {
Expand Down Expand Up @@ -71,19 +72,21 @@ export default defineComponent({
}
},
data() {
const store = this.$store as {[key: string]: any};
const t = store.getters['i18n/t'] as Translation;
const stepClusterClass = {
name: 'stepClusterClass',
title: this.t('capi.cluster.steps.clusterClass.title'),
label: this.t('capi.cluster.steps.clusterClass.label'),
title: t('capi.cluster.steps.clusterClass.title'),
label: t('capi.cluster.steps.clusterClass.label'),
subtext: '',
descriptionKey: 'capi.cluster.steps.clusterClass.description',
ready: false,
weight: 30
};
const stepConfiguration = {
name: 'stepConfiguration',
title: this.t('capi.cluster.steps.configuration.title'),
label: this.t('capi.cluster.steps.configuration.label'),
title: t('capi.cluster.steps.configuration.title'),
label: t('capi.cluster.steps.configuration.label'),
subtext: '',
descriptionKey: 'capi.cluster.steps.configuration.description',
ready: false,
Expand All @@ -92,8 +95,8 @@ export default defineComponent({
const stepVariables = {
name: 'stepVariables',
title: this.t('capi.cluster.steps.variables.title'),
label: this.t('capi.cluster.steps.variables.label'),
title: t('capi.cluster.steps.variables.title'),
label: t('capi.cluster.steps.variables.label'),
subtext: '',
descriptionKey: 'capi.cluster.steps.variables.description',
ready: false,
Expand Down Expand Up @@ -170,7 +173,7 @@ export default defineComponent({
return nameValidator(this.$store.getters['i18n/t']);
},
clusterClassOptions() {
const out: string[] = [];
const out: any[] = [];
const currentObject = this.clusterClassObj;
this.clusterClasses.forEach((obj: ClusterClass) => {
Expand All @@ -179,7 +182,7 @@ export default defineComponent({
return out;
function addType(obj: Object, disabled = false) {
function addType(obj: {[key: string]: any}, disabled = false) {
const id = obj?.metadata?.name;
const subtype = {
id,
Expand Down Expand Up @@ -298,7 +301,7 @@ export default defineComponent({
this.set(this.value.spec.controlPlaneEndpoint, 'port', val);
this.stepConfigurationReady();
},
clickedType(obj: Object) {
clickedType(obj: {[key:string]: any}) {
this.clusterClassObj = this.clusterClasses.find(x => x.metadata.name === obj.id);
this.setClass();
this.setNamespace();
Expand Down
4 changes: 2 additions & 2 deletions pkg/capi/edit/WorkerItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export default defineComponent({
},
},
data() {
const input = (this.value || []).slice();
const input = (this.value as any[] || []).slice();
const rows = [];
for ( const value of input ) {
Expand Down Expand Up @@ -112,7 +112,7 @@ export default defineComponent({
/**
* Remove item and emits removed row and its own index value
*/
remove(row: Object, index: Number) {
remove(row: {[key: string]: any}, index: number) {
this.$emit('remove', { row, index });
removeAt(this.rows, index);
this.queueUpdate();
Expand Down
10 changes: 6 additions & 4 deletions pkg/capi/edit/cluster.x-k8s.io.cluster.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { DEFAULT_WORKSPACE } from '@shell/config/types';
import CreateEditView from '@shell/mixins/create-edit-view';
import Loading from '@shell/components/Loading.vue';
import CruResource from '@shell/components/CruResource.vue';
import type { Route } from 'vue-router';
import ClusterConfig from './ClusterConfig.vue';
import { CAPI, QUERY_PARAMS, ClusterClass } from './../types/capi';
Expand Down Expand Up @@ -44,16 +45,17 @@ export default defineComponent({
}
},
data() {
const subType = this.$route.query[SUB_TYPE] || null;
const preselectedClass = this.$route.query[QUERY_PARAMS.CLASS] || null;
const route = this.$route as Route;
const subType = route.query[SUB_TYPE] || null;
const preselectedClass = route.query[QUERY_PARAMS.CLASS] || null;
return {
subType, preselectedClass, capiProviders: [], clusterClasses: null
};
},
computed: {
clusterClassOptions() {
const out: string[] = [];
const out: any[] = [];
const getters = this.$store.getters;
this.clusterClasses?.forEach((obj: ClusterClass) => {
Expand All @@ -62,7 +64,7 @@ export default defineComponent({
return out;
function addType(obj: Object, disabled = false) {
function addType(obj: {[key: string]: any}, disabled = false) {
const id = obj?.metadata?.name;
const label = getters['i18n/withFallback'](`cluster.clusterClass."${ id }"`, null, id);
const description = getters['i18n/withFallback'](`cluster.providerDescription."${ id }"`, null, '');
Expand Down
5 changes: 3 additions & 2 deletions pkg/capi/types/capi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,9 @@ export interface CAPIClusterNetwork {

export interface ClusterClass {
metadata: {
name: String,
annotations: Object
name: string,
namespace: string,
annotations?: {[key: string]: string}
},
spec: {
infrastructure: Object,
Expand Down

0 comments on commit 4b5610f

Please sign in to comment.