Skip to content

Commit

Permalink
Merge branch 'f/byon' into incubation
Browse files Browse the repository at this point in the history
  • Loading branch information
lucferbux committed Aug 10, 2023
2 parents 41a14f5 + 74092d3 commit 57e8b65
Show file tree
Hide file tree
Showing 74 changed files with 231 additions and 257 deletions.
5 changes: 4 additions & 1 deletion .github/ISSUE_TEMPLATE/bug_report.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@ body:
id: version
attributes:
label: Version
description: What was the version this was found on?
description: |
What was the version this was found on?
eg. a branch name, a commit id, or a version number
validations:
required: true
- type: textarea
Expand Down
5 changes: 1 addition & 4 deletions frontend/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,8 @@ module.exports = {
testEnvironment: 'jest-environment-jsdom',

// include projects from node_modules as required
transformIgnorePatterns: [
'node_modules/(?!yaml)',
],
transformIgnorePatterns: ['node_modules/(?!yaml)'],

// A list of paths to snapshot serializer modules Jest should use for snapshot testing
snapshotSerializers: [],

};
26 changes: 26 additions & 0 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@
},
"devDependencies": {
"@babel/core": "^7.21.0",
"@types/dompurify": "^2.2.6",
"@types/lodash-es": "^4.17.8",
"@types/node": "^17.0.29",
"@types/react": "^18.0.24",
"@types/react-dom": "^18.0.8",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import { Meta, StoryFn } from '@storybook/react';
import { Meta, StoryFn, StoryObj } from '@storybook/react';
import { rest } from 'msw';
import { within } from '@storybook/testing-library';
import { mockClusterSettings } from '~/__mocks__/mockClusterSettings';
Expand All @@ -20,7 +20,7 @@ export default {

const Template: StoryFn<typeof ClusterSettings> = (args) => <ClusterSettings {...args} />;

export const Default = {
export const Default: StoryObj = {
render: Template,

play: async ({ canvasElement }) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';

import { StoryFn, Meta } from '@storybook/react';
import { StoryFn, Meta, StoryObj } from '@storybook/react';
import { rest } from 'msw';
import { within, userEvent } from '@storybook/testing-library';
import { expect } from '@storybook/jest';
Expand Down Expand Up @@ -51,7 +51,7 @@ const Template: StoryFn<typeof ModelServingGlobal> = (args) => (
</Routes>
);

export const EditModel = {
export const EditModel: StoryObj = {
render: Template,

parameters: {
Expand All @@ -72,7 +72,7 @@ export const EditModel = {
},
};

export const DeleteModel = {
export const DeleteModel: StoryObj = {
render: Template,

parameters: {
Expand All @@ -92,7 +92,7 @@ export const DeleteModel = {
},
};

export const DeployModel = {
export const DeployModel: StoryObj = {
render: Template,

parameters: {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';

import { StoryFn, Meta } from '@storybook/react';
import { StoryFn, Meta, StoryObj } from '@storybook/react';
import { rest } from 'msw';
import { userEvent, within } from '@storybook/testing-library';
import { Route } from 'react-router-dom';
Expand Down Expand Up @@ -130,7 +130,7 @@ const Template: StoryFn<typeof ServingRuntimeList> = (args) => {
);
};

export const ListAvailableModels = {
export const ListAvailableModels: StoryObj = {
render: Template,

play: async ({ canvasElement }) => {
Expand All @@ -141,7 +141,7 @@ export const ListAvailableModels = {
},
};

export const DeployModel = {
export const DeployModel: StoryObj = {
render: Template,

play: async ({ canvasElement }) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import { StoryFn, Meta } from '@storybook/react';
import { StoryFn, Meta, StoryObj } from '@storybook/react';
import { DefaultBodyType, MockedRequest, rest, RestHandler } from 'msw';
import { within } from '@storybook/testing-library';
import { Route } from 'react-router-dom';
Expand Down Expand Up @@ -151,7 +151,7 @@ const Template: StoryFn<typeof ProjectDetails> = (args) => {
);
};

export const Default = {
export const Default: StoryObj = {
render: Template,
play: async ({ canvasElement }) => {
// load page and wait until settled
Expand All @@ -160,7 +160,7 @@ export const Default = {
},
};

export const EmptyDetailsPage = {
export const EmptyDetailsPage: StoryObj = {
render: Template,

parameters: {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Meta } from '@storybook/react';
import { Meta, StoryObj } from '@storybook/react';
import { rest } from 'msw';
import { within, userEvent } from '@storybook/testing-library';
import { mockProjectK8sResource } from '~/__mocks__/mockProjectK8sResource';
Expand Down Expand Up @@ -45,7 +45,7 @@ export default {
},
} as Meta<typeof ProjectView>;

export const EditProject = {
export const EditProject: StoryObj = {
parameters: {
a11y: {
// need to select modal as root
Expand All @@ -64,7 +64,7 @@ export const EditProject = {
},
};

export const DeleteProject = {
export const DeleteProject: StoryObj = {
parameters: {
a11y: {
element: '.pf-c-backdrop',
Expand All @@ -82,7 +82,7 @@ export const DeleteProject = {
},
};

export const CreateProject = {
export const CreateProject: StoryObj = {
parameters: {
a11y: {
element: '.pf-c-backdrop',
Expand Down
9 changes: 5 additions & 4 deletions frontend/src/api/k8s/projects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,16 +95,17 @@ export const createProject = (
export const getModelServingProjects = (): Promise<ProjectKind[]> =>
getProjects(`${LABEL_SELECTOR_DASHBOARD_RESOURCE},${LABEL_SELECTOR_MODEL_SERVING_PROJECT}`);

async function filter(arr, callback) {
const filter = async (arr: ProjectKind[], callback: (project: ProjectKind) => Promise<boolean>) => {
const fail = Symbol();
const isProject = (i: ProjectKind | typeof fail): i is ProjectKind => i !== fail;
return (
await Promise.all(arr.map(async (item) => ((await callback(item)) ? item : fail)))
).filter((i) => i !== fail);
}
).filter(isProject);
};

export const getModelServingProjectsAvailable = async (): Promise<ProjectKind[]> =>
getModelServingProjects().then((projects) =>
filter(projects, async (project) => {
filter(projects, async (project: ProjectKind) => {
const projectServing = await listServingRuntimes(project.metadata.name);
return projectServing.length !== 0;
}),
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/api/k8s/secrets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ export const assembleSecret = (
type: 'aws' | 'generic' = 'generic',
secretName?: string,
): SecretKind => {
const labels = {
const labels: Record<string, string> = {
[KnownLabels.DASHBOARD_RESOURCE]: 'true',
};
const annotations = {};
const annotations: Record<string, string> = {};

let stringData = data;
let name = `secret-${genRandomChars()}`;
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/app/useApplicationSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export const useApplicationSettings = (): {
const setRefreshMarker = useTimeBasedRefresh();

React.useEffect(() => {
let watchHandle;
let watchHandle: ReturnType<typeof setTimeout>;
let cancelled = false;
const watchDashboardConfig = () => {
fetchDashboardConfig()
Expand Down
6 changes: 3 additions & 3 deletions frontend/src/components/OdhAppCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,15 @@ const OdhAppCard: React.FC<OdhAppCardProps> = ({ odhApp }) => {
const { dashboardConfig } = useAppContext();
const dispatch = useAppDispatch();

const onToggle = (value) => {
const onToggle = (value: boolean) => {
setIsOpen(value);
};

const onOpenKebab = () => {
setIsOpen(!isOpen);
};

const onQuickStart = (e) => {
const onQuickStart = (e: React.SyntheticEvent | Event) => {
e.preventDefault();
launchQuickStart(odhApp.spec.quickStart, qsContext);
};
Expand Down Expand Up @@ -130,7 +130,7 @@ const OdhAppCard: React.FC<OdhAppCardProps> = ({ odhApp }) => {
'm-disabled': disabled,
});

const popoverBodyContent = (hide) => (
const popoverBodyContent = (hide: () => void) => (
<div>
Subscription is no longer valid. To validate click&nbsp;
<Button
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/OdhDocCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ const OdhDocCard: React.FC<OdhDocCardProps> = ({ odhDoc, favorite, updateFavorit
});
}, [odhDoc.metadata.name, odhDoc.spec.type, qsContext]);

const onQuickStart = (e) => {
const onQuickStart = (e: React.SyntheticEvent) => {
e.preventDefault();
launchQuickStart(odhDoc.metadata.name, qsContext);
fireResourceAccessedEvent(odhDoc.metadata.name, odhDoc.spec.type, qsContext)();
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/OdhDocListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ type OdhDocCardProps = {
const OdhDocListItem: React.FC<OdhDocCardProps> = ({ odhDoc, favorite, updateFavorite }) => {
const [qsContext] = useQuickStartCardSelected(odhDoc.metadata.name, odhDoc.metadata.name);

const onQuickStart = (e) => {
const onQuickStart = (e: React.SyntheticEvent) => {
e.preventDefault();
launchQuickStart(odhDoc.metadata.name, qsContext);
};
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/components/error/ErrorBoundary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ type ErrorBoundaryState =
};

class ErrorBoundary extends React.Component<ErrorBoundaryProps, ErrorBoundaryState> {
constructor(props) {
constructor(props: ErrorBoundaryProps) {
super(props);
this.state = {
hasError: false,
};
}

componentDidCatch(error, errorInfo) {
componentDidCatch(error: Error, errorInfo: React.ErrorInfo) {
this.setState({
hasError: true,
error,
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/components/table/useTableColumnSort.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ const useTableColumnSort = <T>(
return 0;
}

const dataValueA = a[columnField.field];
const dataValueB = b[columnField.field];
const dataValueA = a[columnField.field as keyof T];
const dataValueB = b[columnField.field as keyof T];
if (typeof dataValueA === 'string' && typeof dataValueB === 'string') {
return dataValueA.localeCompare(dataValueB);
}
Expand Down
6 changes: 3 additions & 3 deletions frontend/src/concepts/dashboard/DashboardSearchField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export enum SearchType {
}

type DashboardSearchFieldProps = {
types: string[];
types: SearchType[];
searchType: SearchType;
onSearchTypeChange: (searchType: SearchType) => void;
searchValue: string;
Expand All @@ -42,14 +42,14 @@ const DashboardSearchField: React.FC<DashboardSearchFieldProps> = ({
selections={searchType}
onSelect={(e, key) => {
if (typeof key === 'string') {
onSearchTypeChange(SearchType[key]);
onSearchTypeChange(key as SearchType);
setTypeOpen(false);
}
}}
>
{types.map((key) => (
<SelectOption key={key} value={key}>
{SearchType[key]}
{key}
</SelectOption>
))}
</Select>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ const createObjectStorageSecret = (
});
};

const createSecrets = (config: PipelineServerConfigType, projectName) =>
const createSecrets = (config: PipelineServerConfigType, projectName: string) =>
new Promise<SecretsResponse>((resolve, reject) => {
Promise.all([
createDatabaseSecret(config.database, projectName, true),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ const RunTypeSectionScheduled: React.FC<RunTypeSectionScheduledProps> = ({ data,
<b>Run every</b>
</Text>
<SimpleDropdownSelect
options={Object.keys(PeriodicOptions).map((key) => ({
key: PeriodicOptions[key],
label: PeriodicOptions[key],
options={Object.values(PeriodicOptions).map((v) => ({
key: v,
label: v,
}))}
value={data.value}
onChange={(value) => onChange({ ...data, value })}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,10 @@ const createJob = async (
periodic_schedule:
formData.runType.data.triggerType === ScheduledType.PERIODIC
? {
interval_second: periodicOptionAsSeconds[formData.runType.data.value].toString(),
interval_second:
periodicOptionAsSeconds[
formData.runType.data.value as keyof typeof periodicOptionAsSeconds
].toString(),
start_time: startDate,
end_time: endDate,
}
Expand Down
Loading

0 comments on commit 57e8b65

Please sign in to comment.