-
Notifications
You must be signed in to change notification settings - Fork 163
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
Refactor BYON images table #1506
Merged
openshift-ci
merged 1 commit into
opendatahub-io:f/byon
from
DaoDaoNoCode:upstream-issue-1432
Jul 17, 2023
Merged
Changes from all commits
Commits
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 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 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
36 changes: 36 additions & 0 deletions
36
frontend/src/concepts/dashboard/DashboardEmptyTableView.tsx
This file contains 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,36 @@ | ||
import * as React from 'react'; | ||
import { | ||
Bullseye, | ||
Button, | ||
EmptyState, | ||
EmptyStateBody, | ||
EmptyStateIcon, | ||
EmptyStatePrimary, | ||
Title, | ||
} from '@patternfly/react-core'; | ||
import { SearchIcon } from '@patternfly/react-icons'; | ||
|
||
type DashboardEmptyTableViewProps = { | ||
onClearFilters: () => void; | ||
}; | ||
|
||
const DashboardEmptyTableView: React.FC<DashboardEmptyTableViewProps> = ({ onClearFilters }) => ( | ||
<Bullseye> | ||
<EmptyState> | ||
<EmptyStateIcon icon={SearchIcon} /> | ||
<Title size="lg" headingLevel="h2"> | ||
No results found | ||
</Title> | ||
<EmptyStateBody> | ||
No results match the filter criteria. Clear all filters and try again. | ||
</EmptyStateBody> | ||
<EmptyStatePrimary> | ||
<Button variant="link" onClick={() => onClearFilters()}> | ||
Clear all filters | ||
</Button> | ||
</EmptyStatePrimary> | ||
</EmptyState> | ||
</Bullseye> | ||
); | ||
|
||
export default DashboardEmptyTableView; |
This file contains 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,69 @@ | ||
import * as React from 'react'; | ||
import { InputGroup, SearchInput, Select, SelectOption } from '@patternfly/react-core'; | ||
|
||
// List all the possible search fields here | ||
export enum SearchType { | ||
NAME = 'Name', | ||
DESCRIPTION = 'Description', | ||
USER = 'User', | ||
PROJECT = 'Project', | ||
METRIC = 'Metric', | ||
PROTECTED_ATTRIBUTE = 'Protected attribute', | ||
PRIVILEGED_VALUE = 'Privileged value', | ||
UNPRIVILEGED_VALUE = 'Unprivileged value', | ||
OUTPUT = 'Output', | ||
OUTPUT_VALUE = 'Output value', | ||
PROVIDER = 'Provider', | ||
} | ||
|
||
type DashboardSearchFieldProps = { | ||
types: string[]; | ||
searchType: SearchType; | ||
onSearchTypeChange: (searchType: SearchType) => void; | ||
searchValue: string; | ||
onSearchValueChange: (searchValue: string) => void; | ||
}; | ||
|
||
const DashboardSearchField: React.FC<DashboardSearchFieldProps> = ({ | ||
types, | ||
searchValue, | ||
searchType, | ||
onSearchValueChange, | ||
onSearchTypeChange, | ||
}) => { | ||
const [typeOpen, setTypeOpen] = React.useState(false); | ||
|
||
return ( | ||
<InputGroup> | ||
<Select | ||
removeFindDomNode | ||
isOpen={typeOpen} | ||
onToggle={() => setTypeOpen(!typeOpen)} | ||
selections={searchType} | ||
onSelect={(e, key) => { | ||
if (typeof key === 'string') { | ||
onSearchTypeChange(SearchType[key]); | ||
setTypeOpen(false); | ||
} | ||
}} | ||
> | ||
{types.map((key) => ( | ||
<SelectOption key={key} value={key}> | ||
{SearchType[key]} | ||
</SelectOption> | ||
))} | ||
</Select> | ||
<SearchInput | ||
placeholder={`Find by ${searchType.toLowerCase()}`} | ||
value={searchValue} | ||
onChange={(_, newSearch) => { | ||
onSearchValueChange(newSearch); | ||
}} | ||
onClear={() => onSearchValueChange('')} | ||
style={{ minWidth: '200px' }} | ||
/> | ||
</InputGroup> | ||
); | ||
}; | ||
|
||
export default DashboardSearchField; |
This file contains 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,48 @@ | ||
import * as React from 'react'; | ||
import { Switch } from '@patternfly/react-core'; | ||
import { BYONImage } from '~/types'; | ||
import { updateBYONImage } from '~/services/imagesService'; | ||
import useNotification from '~/utilities/useNotification'; | ||
|
||
type BYONImageStatusToggleProps = { | ||
image: BYONImage; | ||
}; | ||
|
||
const BYONImageStatusToggle: React.FC<BYONImageStatusToggleProps> = ({ image }) => { | ||
const [isLoading, setLoading] = React.useState(false); | ||
const [isEnabled, setEnabled] = React.useState(image.visible); | ||
const notification = useNotification(); | ||
const handleChange = (checked: boolean) => { | ||
setLoading(true); | ||
updateBYONImage({ | ||
name: image.name, | ||
visible: checked, | ||
packages: image.packages, | ||
}) | ||
.then(() => { | ||
setEnabled(checked); | ||
}) | ||
.catch((e) => { | ||
notification.error( | ||
`Error ${checked ? 'enable' : 'disable'} the serving runtime`, | ||
e.message, | ||
); | ||
setEnabled(!checked); | ||
}) | ||
.finally(() => { | ||
setLoading(false); | ||
}); | ||
}; | ||
|
||
return ( | ||
<Switch | ||
aria-label={`Enable Switch ${image.name}`} | ||
data-id={`enabled-disable-${image.id}`} | ||
isChecked={isEnabled} | ||
onChange={handleChange} | ||
isDisabled={isLoading} | ||
/> | ||
); | ||
}; | ||
|
||
export default BYONImageStatusToggle; |
Oops, something went wrong.
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.
Is this taken care of already?
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.
Not yet, I believe this part will be taken care of after we support OOTB images
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.
Not sure if we should be removing this comment then. If we are, we should be tracking it somewhere. Are we already tracking this?
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.
No, i think we should just keep the comment here until we get to refactor the backend in phase 2.
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.
please keep the comment then, thanks
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.
Sorry my bad, I thought I didn't remove the comment 😞 I will add it back in the following PR, thanks!