Skip to content

Commit

Permalink
Merge branch 'main' into kyma-config
Browse files Browse the repository at this point in the history
  • Loading branch information
dbadura committed Sep 4, 2024
2 parents c32944e + 7c3fcb7 commit 9a39e52
Show file tree
Hide file tree
Showing 19 changed files with 505 additions and 60 deletions.
2 changes: 1 addition & 1 deletion CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Default owners of the repository
* @akucharska @mrCherry97 @valentinvieriu @chriskari @OliwiaGowor
* @akucharska @mrCherry97 @dbadura @chriskari @OliwiaGowor

# Owners of all translations in the repository
public/i18n/ @kyma-project/technical-writers
Expand Down
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Overview
# Contributing

To contribute to this project, follow the rules from the general [CONTRIBUTING.md](https://github.com/kyma-project/community/blob/main/CONTRIBUTING.md) document in the `community` repository.
To contribute to this project, follow the general [Contributing Rules](https://github.com/kyma-project/community/blob/main/docs/contributing/02-contributing.md) documented in the `community` repository.

## UX DoD Requirements

Expand Down
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -189,3 +189,15 @@ k3d cluster create kyma --k3s-arg '--tls-san=host.docker.internal@server:*'
```

A cluster created in such a way has the `host.docker.internal` set as Subject Alternative Name in the SSL Certificate of the API Server since the very beginning.

## Contributing

See the [Contributing Rules](CONTRIBUTING.md).

## Code of Conduct

See the [Code of Conduct](CODE_OF_CONDUCT.md) document.

## Licensing

See the [license](./LICENSE) file.
5 changes: 5 additions & 0 deletions public/i18n/en.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -992,11 +992,16 @@ legal:
privacy: Privacy
trademark: Trademark
limit-ranges:
description: <0> Limit Range </0> is a policy to constrain the resource allocations that you can specify for each applicable object kind in a namespace.
headers:
default: Default
default-request: Default Request
max: Max
max-ratio: Max Limit/Request Ratio
min: Min
limits: Limits
resource: Resource
type: Type
name_singular: LimitRange
title: Limit Ranges
machine-info:
Expand Down
10 changes: 5 additions & 5 deletions src/resources/LimitRanges/LimitRangeCreate.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
import React, { useState } from 'react';
import { useState } from 'react';
import { useTranslation } from 'react-i18next';
import { useRecoilValue } from 'recoil';

import { ResourceForm } from 'shared/ResourceForm';
import { activeNamespaceIdState } from 'state/activeNamespaceIdAtom';
import * as _ from 'lodash';

import { createLimitRangeTemplate } from './templates';

export function LimitRangeCreate({
export default function LimitRangeCreate({
formElementRef,
onChange,
setCustomValid,
Expand All @@ -29,20 +27,22 @@ export function LimitRangeCreate({
}),
);

const [initialUnchangedResource] = useState(initialLimitRange);

return (
<ResourceForm
{...props}
pluralKind="limitRanges"
singularName={t('limit-ranges.name_singular')}
resource={limitRange}
initialResource={initialResource}
initialUnchangedResource={initialUnchangedResource}
setResource={setLimitRange}
onChange={onChange}
formElementRef={formElementRef}
createUrl={resourceUrl}
setCustomValid={setCustomValid}
onlyYaml
afterCreatedFn={() => {}}
/>
);
}
45 changes: 45 additions & 0 deletions src/resources/LimitRanges/LimitRangeDetails.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import { ResourceDetails } from 'shared/components/ResourceDetails/ResourceDetails';
import LimitRangeCreate from './LimitRangeCreate';
import LimitRangeSpecification from './LimitRangeSpecification';
import { ResourceDescription } from '.';

type LimitResources = {
memory?: string;
cpu?: string;
storage?: string;
};

export type LimitProps = {
type: string;
max?: LimitResources;
min?: LimitResources;
default?: LimitResources;
defaultRequest?: LimitResources;
};

export type LimitRangeProps = {
metadata: {
name: string;
namespace: string;
};
spec: {
limits: [LimitProps];
};
};

export default function LimitRangeDetails(props: any) {
const customComponents = [
(resource: LimitRangeProps) => (
<LimitRangeSpecification resource={resource} />
),
];

return (
<ResourceDetails
description={ResourceDescription}
createResourceForm={LimitRangeCreate}
customComponents={customComponents}
{...props}
/>
);
}
48 changes: 0 additions & 48 deletions src/resources/LimitRanges/LimitRangeList.js

This file was deleted.

73 changes: 73 additions & 0 deletions src/resources/LimitRanges/LimitRangeList.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
import { useTranslation } from 'react-i18next';
import { ResourcesList } from 'shared/components/ResourcesList/ResourcesList';
import LimitRangeCreate from './LimitRangeCreate';
import { ResourceDescription, docsURL, i18nDescriptionKey } from '.';
import { LimitRangeProps } from './LimitRangeDetails';
import { EMPTY_TEXT_PLACEHOLDER } from 'shared/constants';

export default function LimitRangeList(props: any) {
const { t } = useTranslation();

const findTypeIndex = (obj: LimitRangeProps) => {
if (!obj || !obj.spec || !Array.isArray(obj.spec.limits)) {
return -1;
}

const typePriority = ['Pod', 'Container', 'PersistentVolumeClaim'];

for (const type of typePriority) {
const index = obj.spec.limits.findIndex(limit => limit.type === type);
if (index !== -1) {
return index;
}
}

return -1;
};
const customColumns = [
{
header: t('limit-ranges.headers.type'),
value: (limit: LimitRangeProps) =>
limit.spec.limits?.[findTypeIndex(limit)]?.type ||
EMPTY_TEXT_PLACEHOLDER,
},
{
header: t('limit-ranges.headers.max'),
value: (limit: LimitRangeProps) =>
limit.spec.limits?.[findTypeIndex(limit)]?.max?.memory ||
EMPTY_TEXT_PLACEHOLDER,
},
{
header: t('limit-ranges.headers.min'),
value: (limit: LimitRangeProps) =>
limit.spec.limits?.[findTypeIndex(limit)]?.min?.memory ||
EMPTY_TEXT_PLACEHOLDER,
},
{
header: t('limit-ranges.headers.default'),
value: (limit: LimitRangeProps) =>
limit.spec.limits?.[findTypeIndex(limit)]?.default?.memory ||
EMPTY_TEXT_PLACEHOLDER,
},
{
header: t('limit-ranges.headers.default-request'),
value: (limit: LimitRangeProps) =>
limit.spec.limits?.[findTypeIndex(limit)]?.defaultRequest?.memory ||
EMPTY_TEXT_PLACEHOLDER,
},
];

return (
<ResourcesList
resourceTitle={t('limit-ranges.title')}
description={ResourceDescription}
{...props}
createResourceForm={LimitRangeCreate}
emptyListProps={{
subtitleText: i18nDescriptionKey,
url: docsURL,
}}
customColumns={customColumns}
/>
);
}
11 changes: 11 additions & 0 deletions src/resources/LimitRanges/LimitRangeSpecification.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
.limit-range-spec {
&.compact {
margin: 0 0 1rem 0 !important;
padding-right: 0.5rem;
}
text-transform: capitalize;
}

ui5-table-cell:has(> ui5-panel.limit-range-spec.compact) {
display: inline !important;
}
Loading

0 comments on commit 9a39e52

Please sign in to comment.