Skip to content

Commit

Permalink
Helm related fixes (#338)
Browse files Browse the repository at this point in the history
* fixed helm manual url input issue

* fixed ts issues

* added managed by helm in secret
  • Loading branch information
tulsiojha authored Dec 10, 2024
1 parent c3b3d9b commit be645db
Show file tree
Hide file tree
Showing 20 changed files with 459 additions and 270 deletions.
22 changes: 5 additions & 17 deletions gql-queries-generator/doc/queries.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -1033,6 +1033,7 @@ query consoleGetApp($envName: String!, $name: String!) {
portMappings {
devicePort
appPort
protocol
}
}
nodeSelector
Expand Down Expand Up @@ -1215,6 +1216,7 @@ query consoleListApps($envName: String!, $pq: CursorPaginationIn, $search: Searc
portMappings {
appPort
devicePort
protocol
}
toDevice
}
Expand Down Expand Up @@ -1668,6 +1670,7 @@ query consoleListSecrets($envName: String!, $search: SearchSecrets, $pq: CursorP
}
creationTime
displayName
createdByHelm
stringData
environmentName
isReadyOnly
Expand Down Expand Up @@ -1714,6 +1717,7 @@ query consoleGetSecret($envName: String!, $name: String!) {
environmentName
immutable
markedForDeletion
createdByHelm
metadata {
annotations
creationTimestamp
Expand Down Expand Up @@ -3037,19 +3041,11 @@ query consoleGetClusterMSv($name: String!) {
recordVersion
spec {
msvcSpec {
nodeSelector
serviceTemplate {
apiVersion
kind
spec
}
tolerations {
effect
key
operator
tolerationSeconds
value
}
}
targetNamespace
}
Expand Down Expand Up @@ -3116,19 +3112,11 @@ query consoleListClusterMSvs($pagination: CursorPaginationIn, $search: SearchClu
recordVersion
spec {
msvcSpec {
nodeSelector
serviceTemplate {
apiVersion
kind
spec
}
tolerations {
effect
key
operator
tolerationSeconds
value
}
}
targetNamespace
}
Expand Down Expand Up @@ -4525,7 +4513,7 @@ query consoleListServiceBinding($envName: String!, $pagination: CursorPagination
interceptStatus {
intercepted
portMappings {
containerPort
devicePort
servicePort
}
toAddr
Expand Down
35 changes: 29 additions & 6 deletions src/apps/console/page-components/secret-resource-v2.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import ListV2 from '../components/listV2';
import ResourceExtraAction from '../components/resource-extra-action';
import { useConsoleApi } from '../server/gql/api-provider';
import { ISecrets } from '../server/gql/queries/secret-queries';
import { Chip } from '@kloudlite/design-system/atoms/chips';

const RESOURCE_NAME = 'secret';
type BaseType = ExtractNodeType<ISecrets>;
Expand All @@ -48,12 +49,21 @@ const parseItem = (item: BaseType) => {
author: `Updated by ${titleCase(parseUpdateOrCreatedBy(item))}`,
time: parseUpdateOrCreatedOn(item),
},
createdByHelm: item.createdByHelm,
};
};

const ExtraButton = ({ onDelete }: { onDelete: () => void }) => {
const ExtraButton = ({
onDelete,
item,
}: {
onDelete: () => void;
item: BaseType;
}) => {
console.log(item);
return (
<ResourceExtraAction
disabled={!!item.createdByHelm}
options={[
{
label: 'Delete',
Expand Down Expand Up @@ -111,6 +121,7 @@ const GridView = ({
onDelete={() => {
onDelete(item);
}}
item={item}
/>
)
}
Expand Down Expand Up @@ -165,11 +176,17 @@ const ListView = ({
name: 'name',
className: listClass.title,
},
{
render: () => 'Managed by',
name: 'managedBy',
className: 'flex-1 min-w-[30px] flex items-center justify-center',
},
{
render: () => 'Entries',
name: 'entries',
className: 'flex-1 min-w-[30px] flex items-center justify-center',
},

{
render: () => 'Updated',
name: 'updated',
Expand All @@ -182,7 +199,7 @@ const ListView = ({
},
],
rows: items.map((i) => {
const { name, id, entries, updateInfo } = parseItem(i);
const { name, id, entries, updateInfo, createdByHelm } = parseItem(i);
return {
onClick: () => {
onClick(i);
Expand All @@ -193,6 +210,12 @@ const ListView = ({
name: {
render: () => <ListTitleV2 title={name} />,
},
managedBy: {
render: () =>
createdByHelm ? (
<Chip item={'helm-chart'} label="Helm chart" />
) : null,
},
entries: {
render: () => <ListItemV2 data={entries} />,
},
Expand All @@ -209,7 +232,7 @@ const ListView = ({
? {
action: {
render: () => (
<ExtraButton onDelete={() => onDelete(i)} />
<ExtraButton onDelete={() => onDelete(i)} item={i} />
),
},
}
Expand All @@ -233,7 +256,7 @@ const SecretResourcesV2 = ({
linkComponent = null,
}: Omit<IResource, 'onDelete'>) => {
const [showDeleteDialog, setShowDeleteDialog] = useState<BaseType | null>(
null
null,
);

const api = useConsoleApi();
Expand All @@ -245,9 +268,9 @@ const SecretResourcesV2 = ({
useWatchReload(
items.map((i) => {
return `account:${account}.environment:${environment}.secret:${parseName(
i
i,
)}`;
})
}),
);

const props: IResource = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ import {
IShowDialog,
} from '~/console/components/types.d';
import Handle from './handle';
import { ISecret, ISecrets } from '~/console/server/gql/queries/secret-queries';
import { ExtractNodeType } from '~/console/server/r-utils/common';
import { NN } from '~/root/lib/types/common';

// const RESOURCE_NAME = 'secret';

Expand All @@ -26,6 +29,7 @@ interface IResourceBase {
deleteItem: (item: ICSBase) => void;
restoreItem: (item: ICSBase) => void;
searchText: string;
orgItem: ISecret;
}

interface IShowSecretDialog extends Omit<IAlertModal, 'setShow'> {
Expand All @@ -51,13 +55,15 @@ type OnAction = ({
type IExtraButton = {
onAction: OnAction;
item: [string, ICSValueExtended];
orgItem: ISecret;
};

const ExtraButton = ({ onAction, item }: IExtraButton) => {
const ExtraButton = ({ onAction, item, orgItem }: IExtraButton) => {
const iconSize = 16;

return item[1].newvalue || item[1].delete ? (
<ResourceExtraAction
disabled={!!orgItem.createdByHelm}
options={[
{
label: 'Restore',
Expand Down Expand Up @@ -85,6 +91,7 @@ const ExtraButton = ({ onAction, item }: IExtraButton) => {
/>
) : (
<ResourceExtraAction
disabled={!!orgItem.createdByHelm}
options={[
{
label: 'Edit',
Expand Down Expand Up @@ -184,7 +191,7 @@ const ValueComponent = ({
// );
// };

const ListView = ({ items, onAction, onShow }: IResource) => {
const ListView = ({ items, onAction, onShow, orgItem }: IResource) => {
return (
<ListV2.Root
data={{
Expand Down Expand Up @@ -222,7 +229,13 @@ const ListView = ({ items, onAction, onShow }: IResource) => {
),
},
action: {
render: () => <ExtraButton onAction={onAction} item={item} />,
render: () => (
<ExtraButton
onAction={onAction}
item={item}
orgItem={orgItem}
/>
),
},
},
};
Expand All @@ -238,6 +251,7 @@ const SecretItemResources = ({
deleteItem,
editItem,
restoreItem,
orgItem,
}: IResourceBase) => {
const [showSecret, setShowSecret] = useState<IShowSecretDialog>({
show: false,
Expand All @@ -259,7 +273,7 @@ const SecretItemResources = ({
return true;
}
return false;
})
}),
);
}, [searchText, modifiedItems]);

Expand All @@ -281,6 +295,7 @@ const SecretItemResources = ({
deleteItem,
editItem,
restoreItem,
orgItem,
onShow,
onAction: ({ action, item }) => {
const data = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ const ConfigBody = ({ secret }: { secret: ISecret }) => {
newvalue: null,
},
};
}, {})
}, {}),
);
} catch {
//
Expand All @@ -97,7 +97,7 @@ const ConfigBody = ({ secret }: { secret: ISecret }) => {
(mi) =>
mi.delete ||
mi.insert ||
(mi.newvalue != null && mi.newvalue !== mi.value)
(mi.newvalue != null && mi.newvalue !== mi.value),
).length;
};

Expand All @@ -123,7 +123,7 @@ const ConfigBody = ({ secret }: { secret: ISecret }) => {
data: modifiedItems,
})
}
disabled={success}
disabled={success || !!secret.createdByHelm}
/>
{changesCount() > 0 && !success && (
<Button
Expand Down Expand Up @@ -151,7 +151,7 @@ const ConfigBody = ({ secret }: { secret: ISecret }) => {
[key]: val.newvalue ? val.newvalue : val.value,
};
},
{}
{},
);
if (!environment) {
throw new Error('Project or Environment is required!.');
Expand Down Expand Up @@ -191,6 +191,7 @@ const ConfigBody = ({ secret }: { secret: ISecret }) => {
tools={<Tools searchText={searchText} setSearchText={setSearchText} />}
>
<Resources
orgItem={secret}
searchText={searchText.trim()}
modifiedItems={modifiedItems}
editItem={(item, value) => {
Expand Down
Loading

0 comments on commit be645db

Please sign in to comment.