-
Notifications
You must be signed in to change notification settings - Fork 208
[UI] Default fleet in project wizard #3464
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
Open
olgenn
wants to merge
3
commits into
master
Choose a base branch
from
373_project_default_fleet
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| import type { RootState } from 'store'; | ||
| import { createSlice, PayloadAction } from '@reduxjs/toolkit'; | ||
|
|
||
| import { IProps as ConfirmationDialogProps } from './types'; | ||
|
|
||
| type ConfirmationDialogPropsWithUuid = ConfirmationDialogProps & { uuid: string }; | ||
|
|
||
| type ConfirmationDialogsStata = { | ||
| dialogs: Array<ConfirmationDialogPropsWithUuid>; | ||
| }; | ||
|
|
||
| const initialState: ConfirmationDialogsStata = { | ||
| dialogs: [], | ||
| }; | ||
|
|
||
| export const confirmationSlice = createSlice({ | ||
| name: 'confirmation', | ||
| initialState, | ||
|
|
||
| reducers: { | ||
| open: (state, action: PayloadAction<ConfirmationDialogPropsWithUuid>) => { | ||
| state.dialogs = [...state.dialogs, action.payload]; | ||
| }, | ||
| close: (state, action: PayloadAction<ConfirmationDialogPropsWithUuid['uuid']>) => { | ||
| state.dialogs = state.dialogs.filter((i) => i.uuid !== action.payload); | ||
| }, | ||
| }, | ||
| }); | ||
|
|
||
| export const { open, close } = confirmationSlice.actions; | ||
|
|
||
| export const selectConfirmationDialogs = (state: RootState) => state.confirmation.dialogs; | ||
|
|
||
| export default confirmationSlice.reducer; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| import React from 'react'; | ||
| import { Controller, FieldValues } from 'react-hook-form'; | ||
| import FormField from '@cloudscape-design/components/form-field'; | ||
| import ToggleCSD from '@cloudscape-design/components/toggle'; | ||
|
|
||
| import { FormToggleProps } from './types'; | ||
|
|
||
| export const FormToggle = <T extends FieldValues>({ | ||
| name, | ||
| control, | ||
| rules, | ||
| label, | ||
| info, | ||
| constraintText, | ||
| description, | ||
| secondaryControl, | ||
| stretch, | ||
| leftContent, | ||
| toggleLabel, | ||
| onChange: onChangeProp, | ||
| toggleDescription, | ||
| ...props | ||
| }: FormToggleProps<T>) => { | ||
| return ( | ||
| <Controller | ||
| name={name} | ||
| control={control} | ||
| rules={rules} | ||
| render={({ field: { onChange, value, ...fieldRest }, fieldState: { error } }) => { | ||
| return ( | ||
| <FormField | ||
| description={description} | ||
| label={label} | ||
| info={info} | ||
| stretch={stretch} | ||
| constraintText={constraintText} | ||
| secondaryControl={secondaryControl} | ||
| errorText={error?.message} | ||
| > | ||
| {leftContent} | ||
|
|
||
| <ToggleCSD | ||
| {...fieldRest} | ||
| {...props} | ||
| checked={value} | ||
| onChange={(event) => { | ||
| onChange(event.detail.checked); | ||
| onChangeProp?.(event); | ||
| }} | ||
| description={toggleDescription} | ||
| > | ||
| {toggleLabel} | ||
| </ToggleCSD> | ||
| </FormField> | ||
| ); | ||
| }} | ||
| /> | ||
| ); | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| import { ReactNode } from 'react'; | ||
| import { ControllerProps, FieldValues } from 'react-hook-form'; | ||
| import { FormFieldProps } from '@cloudscape-design/components/form-field'; | ||
| import { ToggleProps } from '@cloudscape-design/components/toggle'; | ||
|
|
||
| export type FormToggleProps<T extends FieldValues> = Omit<ToggleProps, 'value' | 'checked' | 'name'> & | ||
| Omit<FormFieldProps, 'errorText'> & | ||
| Pick<ControllerProps<T>, 'control' | 'name' | 'rules'> & { | ||
| toggleDescription?: ReactNode; | ||
| leftContent?: ReactNode; | ||
| toggleLabel?: ReactNode | string; | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| import { close, open } from 'components/ConfirmationDialog/slice'; | ||
| import { IProps as ConfirmationDialogProps } from 'components/ConfirmationDialog/types'; | ||
|
|
||
| import { getUid } from '../libs'; | ||
| import useAppDispatch from './useAppDispatch'; | ||
|
|
||
| export const useConfirmationDialog = () => { | ||
| const dispatch = useAppDispatch(); | ||
|
|
||
| const onDiscard = (uuid: string) => { | ||
| dispatch(close(uuid)); | ||
| }; | ||
|
|
||
| const openConfirmationDialog = (props: Omit<ConfirmationDialogProps, 'onDiscard'>) => { | ||
| const uuid = getUid(); | ||
|
|
||
| dispatch( | ||
| open({ | ||
| uuid, | ||
| ...props, | ||
| onDiscard: () => onDiscard(uuid), | ||
| }), | ||
| ); | ||
| }; | ||
|
|
||
| return [openConfirmationDialog]; | ||
| }; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| import React from 'react'; | ||
|
|
||
| export const projectTypeOptions = [ | ||
| { | ||
| label: 'GPU marketplace', | ||
| description: | ||
| 'Find the cheapest GPUs available in our marketplace. Enjoy $5 in free credits, and easily top up your balance with a credit card.', | ||
| value: 'gpu_marketplace', | ||
| }, | ||
| { | ||
| label: 'Your cloud accounts', | ||
| description: 'Connect and manage your cloud accounts. dstack supports all major GPU cloud providers.', | ||
| value: 'own_cloud', | ||
| }, | ||
| ]; | ||
|
|
||
| export const FLEET_MIN_INSTANCES_INFO = { | ||
| header: <h2>Min number of instances</h2>, | ||
| body: ( | ||
| <> | ||
| <p>Some text</p> | ||
| </> | ||
| ), | ||
| }; | ||
|
|
||
| export const FLEET_MAX_INSTANCES_INFO = { | ||
| header: <h2>Max number of instances</h2>, | ||
| body: ( | ||
| <> | ||
| <p>Some text</p> | ||
| </> | ||
| ), | ||
| }; | ||
|
|
||
| export const FLEET_IDLE_DURATION_INFO = { | ||
| header: <h2>Idle duration</h2>, | ||
| body: ( | ||
| <> | ||
| <p>Some text</p> | ||
| </> | ||
| ), | ||
| }; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Confirmation dialog doesn't close after user confirms
High Severity
The
useConfirmationDialoghook wrapsonDiscardto close the dialog but doesn't wraponConfirm. When the user clicks confirm, the originalonConfirmcallback runs but the dialog remains visible becauseclose(uuid)is never dispatched. The dialog will stay open until the user clicks Cancel or dismisses it manually.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.
onConfirm was implemented in ConfirmationDialof componentd