Skip to content
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

feat: Update genai codemie page #327

Merged
merged 1 commit into from
Aug 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/k8s/groups/EDP/Codemie/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export const EDP_CODEMIE_STATUS = {
CREATED: 'created',
ERROR: 'error',
} as const;
22 changes: 22 additions & 0 deletions src/k8s/groups/EDP/Codemie/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import { ApiProxy, K8s } from '@kinvolk/headlamp-plugin/lib';
import { STATUS_COLOR } from '../../../../constants/colors';
import { ICONS } from '../../../../icons/iconify-icons-mapping';
import { CodemieKubeObjectConfig } from './config';
import { EDP_CODEMIE_STATUS } from './constants';
import { CodemieKubeObjectInterface } from './types';

const {
Expand All @@ -20,4 +23,23 @@ export class CodemieKubeObject extends K8s.cluster.makeKubeObject<CodemieKubeObj
get spec(): CodemieKubeObjectInterface['spec'] {
return this.jsonData!.spec;
}

static getStatusIcon(status: string): [string, string, boolean?] {
if (status === undefined) {
return [ICONS.UNKNOWN, STATUS_COLOR.UNKNOWN];
}

const _status = status.toLowerCase();

switch (_status) {
case EDP_CODEMIE_STATUS.CREATED:
return [ICONS.CHECK_CIRCLE, STATUS_COLOR.SUCCESS];

case EDP_CODEMIE_STATUS.ERROR:
return [ICONS.CROSS_CIRCLE, STATUS_COLOR.ERROR];

default:
return [ICONS.UNKNOWN, STATUS_COLOR.UNKNOWN];
}
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
import { CODEMIE_SECRET_FORM_NAMES } from '../../../../../../widgets/ManageCodeMie/names';
import {
SECRET_LABEL_ASSOCIATED_KIND,
SECRET_LABEL_SECRET_TYPE,
} from '../../../../default/Secret/labels';
import { CodemieKubeObjectConfig } from '../../config';
import { SECRET_LABEL_SECRET_TYPE } from '../../../../default/Secret/labels';
import { createCodemieSecretInstance } from './index';

describe('testing createCodemieSecretInstance', () => {
Expand All @@ -21,7 +17,6 @@ describe('testing createCodemieSecretInstance', () => {
name: 'codemie',
labels: {
[SECRET_LABEL_SECRET_TYPE]: 'codemie',
[SECRET_LABEL_ASSOCIATED_KIND]: CodemieKubeObjectConfig.kind,
},
},
type: 'Opaque',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,7 @@ import { DeepPartial } from '../../../../../../types/global';
import { EDPKubeObjectInterface } from '../../../../../../types/k8s';
import { safeEncode } from '../../../../../../utils/decodeEncode';
import { CodemieSecretFormValues } from '../../../../../../widgets/ManageCodeMie/types';
import {
SECRET_LABEL_ASSOCIATED_KIND,
SECRET_LABEL_SECRET_TYPE,
} from '../../../../default/Secret/labels';
import { CodemieKubeObjectConfig } from '../../config';
import { SECRET_LABEL_SECRET_TYPE } from '../../../../default/Secret/labels';

export const createCodemieSecretInstance = (
names: {
Expand All @@ -25,7 +21,6 @@ export const createCodemieSecretInstance = (
name,
labels: {
[SECRET_LABEL_SECRET_TYPE]: 'codemie',
[SECRET_LABEL_ASSOCIATED_KIND]: CodemieKubeObjectConfig.kind,
},
},
data: {
Expand Down
4 changes: 4 additions & 0 deletions src/k8s/groups/EDP/CodemieProject/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,8 @@ export class CodemieProjectKubeObject extends K8s.cluster.makeKubeObject<Codemie
get spec(): CodemieProjectKubeObjectInterface['spec'] {
return this.jsonData!.spec;
}

get status(): CodemieProjectKubeObjectInterface['status'] {
return this.jsonData!.status;
}
}
4 changes: 4 additions & 0 deletions src/k8s/groups/EDP/CodemieProject/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,8 @@ export interface CodemieProjectKubeObjectInterface extends KubeObjectInterface {
};
name: string;
};
status: {
value: string;
error?: string;
};
}

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

1 change: 0 additions & 1 deletion src/k8s/groups/default/Secret/labels.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
export const SECRET_LABEL_SECRET_TYPE = 'app.edp.epam.com/secret-type';
export const SECRET_LABEL_INTEGRATION_SECRET = 'app.edp.epam.com/integration-secret';
export const SECRET_LABEL_ASSOCIATED_KIND = 'app.edp.epam.com/associated-kind';
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,5 @@ export const DynamicDataContext = React.createContext<DynamicDataContextProvider
codemieProject: initialData,
codemieProjectSettings: initialData,
codemieSecret: initialData,
codemieProjectSettingsSecret: initialData,
codemieQuickLink: initialData,
});
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
import React from 'react';
import { SecretKubeObject } from '../../../../../../k8s/groups/default/Secret';
import {
SECRET_LABEL_ASSOCIATED_KIND,
SECRET_LABEL_SECRET_TYPE,
} from '../../../../../../k8s/groups/default/Secret/labels';
import { SECRET_LABEL_SECRET_TYPE } from '../../../../../../k8s/groups/default/Secret/labels';
import { CodemieKubeObject } from '../../../../../../k8s/groups/EDP/Codemie';
import { CodemieKubeObjectConfig } from '../../../../../../k8s/groups/EDP/Codemie/config';
import { CodemieProjectKubeObject } from '../../../../../../k8s/groups/EDP/CodemieProject';
import { CodemieProjectSettingsKubeObject } from '../../../../../../k8s/groups/EDP/CodemieProjectSettings';
import { CodemieProjectSettingsKubeObjectConfig } from '../../../../../../k8s/groups/EDP/CodemieProjectSettings/config';
import { QuickLinkKubeObject } from '../../../../../../k8s/groups/EDP/QuickLink';
import { SYSTEM_QUICK_LINKS } from '../../../../../../k8s/groups/EDP/QuickLink/constants';
import { getDefaultNamespace } from '../../../../../../utils/getDefaultNamespace';
Expand All @@ -29,16 +24,7 @@ export const DynamicDataContextProvider: React.FC = ({ children }) => {
labelSelector: `${SECRET_LABEL_SECRET_TYPE}=codemie`,
});

const codemieSecret = codemieSecrets?.find(
(secret) =>
secret.metadata.labels?.[SECRET_LABEL_ASSOCIATED_KIND] === CodemieKubeObjectConfig.kind
);

const codemieProjectSettingsSecret = codemieSecrets?.find(
(secret) =>
secret.metadata.labels?.[SECRET_LABEL_ASSOCIATED_KIND] ===
CodemieProjectSettingsKubeObjectConfig.kind
);
const codemieSecret = codemieSecrets?.[0];

const DataContextValue = React.useMemo(
() => ({
Expand Down Expand Up @@ -67,11 +53,6 @@ export const DynamicDataContextProvider: React.FC = ({ children }) => {
isLoading: codemieSecrets === null,
error: codemieSecretsError,
},
codemieProjectSettingsSecret: {
data: codemieProjectSettingsSecret,
isLoading: codemieSecrets === null,
error: codemieSecretsError,
},
}),
[
codemie,
Expand All @@ -80,7 +61,6 @@ export const DynamicDataContextProvider: React.FC = ({ children }) => {
codemieProjectError,
codemieProjectSettings,
codemieProjectSettingsError,
codemieProjectSettingsSecret,
codemieQuickLink,
codemieQuickLinkError,
codemieSecret,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,5 @@ export interface DynamicDataContextProviderValue {
codemieProject: DataProviderValue<CodemieProjectKubeObjectInterface[]>;
codemieProjectSettings: DataProviderValue<CodemieProjectSettingsKubeObjectInterface[]>;
codemieSecret: DataProviderValue<SecretKubeObjectInterface>;
codemieProjectSettingsSecret: DataProviderValue<SecretKubeObjectInterface>;
codemieQuickLink: DataProviderValue<QuickLinkKubeObjectInterface>;
}
Loading
Loading