Skip to content

Commit

Permalink
review fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
OliwiaGowor committed Jul 29, 2024
1 parent 22b2cf8 commit 44641d9
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions src/components/KymaModules/KymaModulesCreate.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import { spacing } from '@ui5/webcomponents-react-base';

import { ResourceForm } from 'shared/ResourceForm';
import './KymaModulesCreate.scss';
import { Spinner } from 'shared/components/Spinner/Spinner';

export default function KymaModulesCreate({ resource, ...props }) {
const { t } = useTranslation();
Expand All @@ -37,7 +38,7 @@ export default function KymaModulesCreate({ resource, ...props }) {
const resourceName = kymaResource?.metadata.name;
const modulesResourceUrl = `/apis/operator.kyma-project.io/v1beta2/moduletemplates`;

const { data: modules } = useGet(modulesResourceUrl, {
const { data: modules, loading } = useGet(modulesResourceUrl, {
pollingInterval: 3000,
skip: !resourceName,
});
Expand All @@ -48,13 +49,23 @@ export default function KymaModulesCreate({ resource, ...props }) {

const getRequest = useSingleGet();
const patchRequest = useUpdate();
const [selectedModules] = useState(initialResource?.spec?.modules ?? []);
const [selectedModules] = useState(
cloneDeep(initialResource?.spec?.modules) ?? [],
);
const [isEdited, setIsEdited] = useState(false);
const [showMessageBox, setShowMessageBox] = useState({
isOpen: false,
hide: false,
});

if (loading) {
return (
<div style={{ height: 'calc(100vh - 14rem)' }}>
<Spinner />
</div>
);
}

const setChannel = (module, channel, index) => {
if (
selectedModules.find(
Expand Down Expand Up @@ -161,7 +172,7 @@ export default function KymaModulesCreate({ resource, ...props }) {
style={{ gap: '0.5rem' }}
key={module?.name}
>
<Label>{module.name}</Label>
<Label>{`${module.name}:`}</Label>
<Select
onChange={event => {
setChannel(module, event.detail.selectedOption.value, index);
Expand Down Expand Up @@ -310,7 +321,7 @@ export default function KymaModulesCreate({ resource, ...props }) {
actions={[
<Button
design="Emphasized"
key="discard"
key="change"
onClick={() => handleCreate()}
>
{t('kyma-modules.change')}
Expand Down

0 comments on commit 44641d9

Please sign in to comment.