Skip to content

Commit

Permalink
fxi(FR-342): Unkown image error in Image list's control modal
Browse files Browse the repository at this point in the history
  • Loading branch information
yomybaby committed Jan 21, 2025
1 parent 5e36c40 commit 6e770cc
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 11 deletions.
6 changes: 4 additions & 2 deletions react/src/components/ImageList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ const ImageList: React.FC<{ style?: React.CSSProperties }> = ({ style }) => {
value
}
version @since(version: "24.12.0")
...ManageImageResourceLimitModal_image
...ManageAppsModal_image
}
}
`,
Expand Down Expand Up @@ -573,7 +575,7 @@ const ImageList: React.FC<{ style?: React.CSSProperties }> = ({ style }) => {
updateEnvironmentFetchKey();
});
}}
image={managingResourceLimit}
imageFrgmt={managingResourceLimit}
/>
<ManageAppsModal
open={!!managingApp}
Expand All @@ -584,7 +586,7 @@ const ImageList: React.FC<{ style?: React.CSSProperties }> = ({ style }) => {
updateEnvironmentFetchKey();
});
}}
image={managingApp}
imageFrgmt={managingApp}
/>
<ImageInstallModal
open={isOpenInstallModal}
Expand Down
28 changes: 23 additions & 5 deletions react/src/components/ManageAppsModal.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { useSuspendedBackendaiClient } from '../hooks';
import BAIModal, { BAIModalProps } from './BAIModal';
import Flex from './Flex';
import { EnvironmentImage } from './ImageList';
import { ManageAppsModalMutation } from './__generated__/ManageAppsModalMutation.graphql';
import { ManageAppsModal_image$key } from './__generated__/ManageAppsModal_image.graphql';
import { DeleteOutlined, PlusOutlined } from '@ant-design/icons';
import {
Input,
Expand All @@ -18,19 +18,19 @@ import graphql from 'babel-plugin-relay/macro';
import _ from 'lodash';
import React from 'react';
import { Trans, useTranslation } from 'react-i18next';
import { useMutation } from 'react-relay';
import { useFragment, useMutation } from 'react-relay';

interface ManageAppsModalProps extends BAIModalProps {
open: boolean;
image: EnvironmentImage | null;
imageFrgmt: ManageAppsModal_image$key | null;
onRequestClose: (success: boolean) => void;
}

type ServicePort = { app: string; protocol: string; port: number };

const ManageAppsModal: React.FC<ManageAppsModalProps> = ({
open,
image,
imageFrgmt,
onRequestClose,
...baiModalProps
}) => {
Expand All @@ -41,6 +41,24 @@ const ManageAppsModal: React.FC<ManageAppsModalProps> = ({

const { token } = theme.useToken();

const image = useFragment(
graphql`
fragment ManageAppsModal_image on Image {
labels {
key
value
}
registry
name @deprecatedSince(version: "24.12.0")
namespace @since(version: "24.12.0")
architecture
installed
tag
}
`,
imageFrgmt,
);

const [commitModifyImageInput, isInFlightModifyImageInput] =
useMutation<ManageAppsModalMutation>(graphql`
mutation ManageAppsModalMutation(
Expand Down Expand Up @@ -109,7 +127,7 @@ const ManageAppsModal: React.FC<ManageAppsModalProps> = ({
const commitRequest = () =>
commitModifyImageInput({
variables: {
target: `${image?.registry}/${image?.name}:${image?.tag}`,
target: `${image?.registry}/${image?.name ?? image.namespace}:${image?.tag}`,
architecture: image?.architecture,
props: {
labels: labels,
Expand Down
28 changes: 24 additions & 4 deletions react/src/components/ManageImageResourceLimitModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,22 @@ import {
ManageImageResourceLimitModalMutation,
ResourceLimitInput,
} from './__generated__/ManageImageResourceLimitModalMutation.graphql';
import { ManageImageResourceLimitModal_image$key } from './__generated__/ManageImageResourceLimitModal_image.graphql';
import { App, Form, FormInstance, message } from 'antd';
import graphql from 'babel-plugin-relay/macro';
import _ from 'lodash';
import React, { useRef } from 'react';
import { Trans, useTranslation } from 'react-i18next';
import { useMutation } from 'react-relay';
import { useFragment, useMutation } from 'react-relay';

interface ManageImageResourceLimitModalProps extends BAIModalProps {
image: EnvironmentImage | null;
imageFrgmt: ManageImageResourceLimitModal_image$key | null;
open: boolean;
onRequestClose: (success: boolean) => void;
}
const ManageImageResourceLimitModal: React.FC<
ManageImageResourceLimitModalProps
> = ({ image, open, onRequestClose, ...BAIModalProps }) => {
> = ({ imageFrgmt, open, onRequestClose, ...BAIModalProps }) => {
const baiClient = useSuspendedBackendaiClient();
// Differentiate default max value based on manager version.
// The difference between validating a variable type as undefined or none for an unsupplied field value.
Expand All @@ -30,6 +31,25 @@ const ManageImageResourceLimitModal: React.FC<
const formRef = useRef<FormInstance>(null);
const app = App.useApp();

const image = useFragment(
graphql`
fragment ManageImageResourceLimitModal_image on Image {
resource_limits {
key
min
max
}
registry
name @deprecatedSince(version: "24.12.0")
namespace @since(version: "24.12.0")
architecture
installed
tag
}
`,
imageFrgmt,
);

const [commitModifyImageInput, isInFlightModifyImageInput] =
useMutation<ManageImageResourceLimitModalMutation>(graphql`
mutation ManageImageResourceLimitModalMutation(
Expand Down Expand Up @@ -65,7 +85,7 @@ const ManageImageResourceLimitModal: React.FC<
const commitRequest = () =>
commitModifyImageInput({
variables: {
target: `${image?.registry}/${image?.name}:${image?.tag}`,
target: `${image?.registry}/${image?.name ?? image?.namespace}:${image?.tag}`,
architecture: image?.architecture,
props: {
resource_limits,
Expand Down

0 comments on commit 6e770cc

Please sign in to comment.