-
Notifications
You must be signed in to change notification settings - Fork 1
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
WEB: Implement managed service cloning & notification ui & config/secrets ui #226
Conversation
Reviewer's Guide by SourceryThis pull request implements managed service cloning, notification UI, and configuration/secrets UI. The changes include refactoring existing components, adding new components for handling notifications, and updating GraphQL queries and mutations to support the new features. File-Level Changes
Tips
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @nxtcoder19 - I've reviewed your changes and they look great!
Here's what I looked at during the review
- 🟡 General issues: 10 issues found
- 🟢 Security: all looks good
- 🟢 Testing: all looks good
- 🟡 Complexity: 2 issues found
- 🟢 Documentation: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment to tell me if it was helpful.
@@ -1,51 +1,30 @@ | |||
import { | |||
DotsThreeVerticalFill, | |||
Eye, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion: Unused import 'generateKey' removed.
interface IResourceItemExtraOptions { | ||
onDelete: (() => void) | null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion: Removed unused interface IResourceItemExtraOptions.
const ResourceItemExtraOptions = ({ | ||
onDelete, | ||
onRestore, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion: Removed unused component ResourceItemExtraOptions.
const ResourceItemExtraOptions = ({ | |
onDelete, | |
onRestore, | |
const ResourceItemExtraOptions = () => { | |
return null; | |
} |
const RenderItem = ({ | ||
item, | ||
onDelete, | ||
onEdit, | ||
onRestore, | ||
onShow, | ||
edit, | ||
listMode = true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion: Removed unused component RenderItem.
import { useEffect, useState } from 'react'; | ||
import AnimateHide from '~/components/atoms/animate-hide'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion: Unused import 'generateKey' removed.
const RenderItem = ({ | ||
item, | ||
onDelete, | ||
onEdit, | ||
onRestore, | ||
edit, | ||
listMode = true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion: Removed unused component RenderItem.
imageUrl: Yup.string().matches( | ||
/^\w(\w|[-/])+?(?::(\w|[-])+)?\w$/, | ||
'Invalid image format' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion: Added validation for imageUrl format.
imageUrl: Yup.string().matches( | |
/^\w(\w|[-/])+?(?::(\w|[-])+)?\w$/, | |
'Invalid image format' | |
imageUrl: Yup.string().url('Invalid image format'), |
@@ -171,6 +174,8 @@ const ByokInstructionsPopup = ({ | |||
const ByokButton = ({ item }: { item: CombinedBaseType }) => { | |||
const [show, setShow] = useState(false); | |||
|
|||
console.log('item', item); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion: Remove console.log statement.
Consider removing the console.log statement before merging.
console.log('item', item); | |
return ( | |
<div> | |
{show ? ( |
@@ -5,9 +5,9 @@ import { parseName } from '~/console/server/r-utils/common'; | |||
import { FadeIn } from '~/console/page-components/util'; | |||
import { NameIdView } from '~/console/components/name-id-view'; | |||
import { BottomNavigation, GitDetailRaw } from '~/console/components/commons'; | |||
import { registryHost } from '~/lib/configs/base-url.cjs'; | |||
// import { registryHost } from '~/lib/configs/base-url.cjs'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
issue (complexity): Consider removing commented-out code and simplifying validation logic.
The new code introduces several complexities that could be avoided:
-
Commented Out Code: The presence of commented-out code (e.g.,
RepoSelector
) clutters the codebase and can be confusing for future developers. It's better to remove unused code entirely. -
Inline Validation: The inline validation for
imageUrl
usingYup.string().matches()
is harder to read, especially with complex regex patterns. Consider simplifying or documenting the regex for clarity. -
Redundant Code: The
TextInput
component forimageUrl
is added directly in the JSX, but the commented-outRepoSelector
code remains. This makes it unclear whetherRepoSelector
is intended to be removed or reused. -
Error Handling: Error handling for
imageUrl
is done directly in the JSX, which can be less clear than a more centralized approach.
Consider refactoring to remove unnecessary comments, simplify validation logic, and handle errors more clearly. This will make the code easier to read, understand, and maintain.
@@ -5,12 +5,12 @@ | |||
import { FadeIn } from '~/console/page-components/util'; | |||
import { NameIdView } from '~/console/components/name-id-view'; | |||
import { BottomNavigation, GitDetailRaw } from '~/console/components/commons'; | |||
import { registryHost } from '~/lib/configs/base-url.cjs'; | |||
// import { registryHost } from '~/lib/configs/base-url.cjs'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
issue (complexity): Consider removing commented-out code to improve readability and maintainability.
The new code introduces several complexities that could be avoided:
- Commented Out Code: The code has several lines commented out instead of being removed, which clutters the codebase and makes it harder to read and maintain.
- Inline Regex Duplication: The regex for validating
imageUrl
is duplicated, making future updates error-prone. Consider defining the regex once and reusing it. - Unnecessary Component Change: Replacing
RepoSelector
withTextInput
might lead to a loss of functionality or user experience thatRepoSelector
provided. - Error Handling: The new error handling within
TextInput
might not be as robust as the previous implementation.
Here is a suggested refactor to address these issues:
import { useAppState } from '~/console/page-components/app-states';
import useForm, { dummyEvent } from '~/root/lib/client/hooks/use-form';
import Yup from '~/root/lib/server/helpers/yup';
import { parseName } from '~/console/server/r-utils/common';
import { FadeIn } from '~/console/page-components/util';
import { NameIdView } from '~/console/components/name-id-view';
import { BottomNavigation, GitDetailRaw } from '~/console/components/commons';
import { useOutletContext } from '@remix-run/react';
import AppBuildIntegration from '~/console/page-components/app/app-build-integration';
import { keyconstants } from '~/console/server/r-utils/key-constants';
import { constants } from '~/console/server/utils/constants';
import { Button } from '~/components/atoms/button';
import { useEffect, useState } from 'react';
import { toast } from '~/components/molecule/toast';
import ResourceExtraAction from '~/console/components/resource-extra-action';
import { ArrowClockwise, GitMerge, PencilSimple } from '~/console/components/icons';
import { TextInput } from '~/components/atoms/input';
import { IEnvironmentContext } from '../_layout';
import { getImageTag } from './app-utils';
import BuildSelectionDialog from './app-build-selection-dialog';
const imageUrlRegex = /^\w(\w|[-/])+?(?::(\w|[-])+)?\w$/;
const ExtraButton = ({ onNew, onExisting }: { onNew: () => void; onExisting: () => void; }) => {
// ... rest of the component code
};
const validationSchema = Yup.object({
name: Yup.string().required(),
displayName: Yup.string().required(),
imageUrl: Yup.string().matches(imageUrlRegex, 'Invalid image format'),
manualRepo: Yup.string().when(['imageUrl', 'imageMode'], ([imageUrl, imageMode], schema) => {
if (imageMode === 'git') {
return schema;
}
if (!imageUrl) {
return schema.required().matches(imageUrlRegex, 'Invalid image format');
}
return schema;
}),
imageMode: Yup.string().required(),
});
// ... rest of the component code
<TextInput
size="lg"
label="Image name"
placeholder="Enter Image name"
value={values.imageUrl}
onChange={handleChange('imageUrl')}
error={!!errors.imageUrl}
message={errors.imageUrl}
/>
// ... rest of the component code
This refactor removes commented-out code, avoids regex duplication, and maintains the existing functionality.
- implement clone managed service - make ui changes in configs and secrets
d3f7b76
to
deea57c
Compare
WEB: Implement managed service cloning & notification ui & config/secrets ui
WEB: Implement managed service cloning & notification ui & config/secrets ui
WEB: Implement managed service cloning & notification ui & config/secrets ui
Resolves kloudlite/kloudlite#250
Summary by Sourcery
This pull request introduces several new features including managed service cloning, a notification UI, and enhanced configuration and secrets management UI. It also includes significant refactoring to improve code modularity and updates to the GraphQL schema to support these new features.