Skip to content

Commit

Permalink
Refactor codebase to improve code handling
Browse files Browse the repository at this point in the history
Signed-off-by: lucferbux <[email protected]>
  • Loading branch information
lucferbux committed Nov 8, 2024
1 parent 974c228 commit af44421
Show file tree
Hide file tree
Showing 121 changed files with 150 additions and 130 deletions.
4 changes: 2 additions & 2 deletions clients/ui/frontend/src/app/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ import {
StackItem,
} from '@patternfly/react-core';
import { BarsIcon } from '@patternfly/react-icons';
import ToastNotifications from '~/components/ToastNotifications';
import ToastNotifications from '~/shared/components/ToastNotifications';
import { useSettings } from '~/shared/hooks/useSettings';
import NavSidebar from './NavSidebar';
import AppRoutes from './AppRoutes';
import { AppContext } from './AppContext';
import { useSettings } from './useSettings';
import { ModelRegistrySelectorContextProvider } from './context/ModelRegistrySelectorContext';

const App: React.FC = () => {
Expand Down
2 changes: 1 addition & 1 deletion clients/ui/frontend/src/app/AppContext.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import { UserSettings, ConfigSettings } from '~/types';
import { UserSettings, ConfigSettings } from '~/shared/types';

type AppContextProps = {
config: ConfigSettings;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import { APIState } from '~/app/api/types';
import { APIState } from '~/shared/api/types';
import { ModelRegistryAPIs } from '~/app/types';
import {
createModelArtifact,
Expand All @@ -18,8 +18,8 @@ import {
patchModelArtifact,
patchModelVersion,
patchRegisteredModel,
} from '~/app/api/service';
import useAPIState from '~/app/api/useAPIState';
} from '~/shared/api/service';
import useAPIState from '~/shared/api/useAPIState';

export type ModelRegistryAPIState = APIState<ModelRegistryAPIs>;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import * as React from 'react';
import useFetchState, { FetchState, FetchStateCallbackPromise } from '~/utilities/useFetchState';
import useFetchState, {
FetchState,
FetchStateCallbackPromise,
} from '~/shared/utilities/useFetchState';
import { ModelArtifactList } from '~/app/types';
import { useModelRegistryAPI } from '~/app/hooks/useModelRegistryAPI';

Expand Down
7 changes: 5 additions & 2 deletions clients/ui/frontend/src/app/hooks/useModelRegistries.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import * as React from 'react';
import useFetchState, { FetchState, FetchStateCallbackPromise } from '~/utilities/useFetchState';
import useFetchState, {
FetchState,
FetchStateCallbackPromise,
} from '~/shared/utilities/useFetchState';
import { ModelRegistry } from '~/app/types';
import { getListModelRegistries } from '~/app/api/k8s';
import { getListModelRegistries } from '~/shared/api/k8s';

const useModelRegistries = (): FetchState<ModelRegistry[]> => {
const listModelRegistries = React.useMemo(() => getListModelRegistries(''), []);
Expand Down
5 changes: 4 additions & 1 deletion clients/ui/frontend/src/app/hooks/useModelVersionById.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import * as React from 'react';
import useFetchState, { FetchState, FetchStateCallbackPromise } from '~/utilities/useFetchState';
import useFetchState, {
FetchState,
FetchStateCallbackPromise,
} from '~/shared/utilities/useFetchState';
import { ModelVersion } from '~/app/types';
import { useModelRegistryAPI } from '~/app/hooks/useModelRegistryAPI';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import * as React from 'react';
import useFetchState, { FetchState, FetchStateCallbackPromise } from '~/utilities/useFetchState';
import useFetchState, {
FetchState,
FetchStateCallbackPromise,
} from '~/shared/utilities/useFetchState';
import { ModelVersionList } from '~/app/types';
import { useModelRegistryAPI } from '~/app/hooks/useModelRegistryAPI';

Expand Down
5 changes: 4 additions & 1 deletion clients/ui/frontend/src/app/hooks/useRegisteredModelById.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import * as React from 'react';
import useFetchState, { FetchState, FetchStateCallbackPromise } from '~/utilities/useFetchState';
import useFetchState, {
FetchState,
FetchStateCallbackPromise,
} from '~/shared/utilities/useFetchState';
import { RegisteredModel } from '~/app/types';
import { useModelRegistryAPI } from '~/app/hooks/useModelRegistryAPI';

Expand Down
5 changes: 4 additions & 1 deletion clients/ui/frontend/src/app/hooks/useRegisteredModels.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import * as React from 'react';
import useFetchState, { FetchState, FetchStateCallbackPromise } from '~/utilities/useFetchState';
import useFetchState, {
FetchState,
FetchStateCallbackPromise,
} from '~/shared/utilities/useFetchState';
import { RegisteredModelList } from '~/app/types';
import { useModelRegistryAPI } from '~/app/hooks/useModelRegistryAPI';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import * as React from 'react';
import { Navigate, Outlet, useParams } from 'react-router-dom';
import { Bullseye, Alert, Popover, List, ListItem, Button } from '@patternfly/react-core';
import { OutlinedQuestionCircleIcon } from '@patternfly/react-icons';
import ApplicationsPage from '~/app/components/ApplicationsPage';
import ApplicationsPage from '~/shared/components/ApplicationsPage';
import { ModelRegistrySelectorContext } from '~/app/context/ModelRegistrySelectorContext';
import { ProjectObjectType, typedEmptyImage } from '~/app/components/design/utils';
import { ProjectObjectType, typedEmptyImage } from '~/shared/components/design/utils';
import { ModelRegistryContextProvider } from '~/app/context/ModelRegistryContext';
import TitleWithIcon from '~/app/components/design/TitleWithIcon';
import TitleWithIcon from '~/shared/components/design/TitleWithIcon';
import EmptyModelRegistryState from './screens/components/EmptyModelRegistryState';
import InvalidModelRegistry from './screens/InvalidModelRegistry';
import ModelRegistrySelectorNavigator from './screens/ModelRegistrySelectorNavigator';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import ArchiveModelVersionDetails from './screens/ModelVersionsArchive/ArchiveMo
import RegisteredModelsArchiveDetails from './screens/RegisteredModelsArchive/RegisteredModelArchiveDetails';
import RegisterModel from './screens/RegisterModel/RegisterModel';
import RegisterVersion from './screens/RegisterModel/RegisterVersion';
import '~/style/MUI-theme.scss';
import '~/shared/style/MUI-theme.scss';

const ModelRegistryRoutes: React.FC = () => (
<Routes>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import EmptyStateErrorMessage from '~/app/components/EmptyStateErrorMessage';
import EmptyStateErrorMessage from '~/shared/components/EmptyStateErrorMessage';
import { modelRegistryUrl } from './routeUtils';
import ModelRegistrySelectorNavigator from './ModelRegistrySelectorNavigator';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Table, Tbody, Th, Thead, Tr } from '@patternfly/react-table';
import { PlusCircleIcon } from '@patternfly/react-icons';
import text from '@patternfly/react-styles/css/utilities/Text/text';
import spacing from '@patternfly/react-styles/css/utilities/Spacing/spacing';
import DashboardDescriptionListGroup from '~/components/DashboardDescriptionListGroup';
import DashboardDescriptionListGroup from '~/shared/components/DashboardDescriptionListGroup';
import { getProperties, mergeUpdatedProperty } from '~/app/pages/modelRegistry/screens/utils';
import { ModelRegistryCustomProperties } from '~/app/types';
import ModelPropertiesTableRow from '~/app/pages/modelRegistry/screens/ModelPropertiesTableRow';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import {
TextInput,
} from '@patternfly/react-core';
import { CheckIcon, TimesIcon } from '@patternfly/react-icons';
import { KeyValuePair } from '~/types';
import { EitherNotBoth } from '~/typeHelpers';
import { KeyValuePair } from '~/shared/types';
import { EitherNotBoth } from '~/shared/typeHelpers';
import FormFieldset from '~/app/pages/modelRegistry/screens/components/FormFieldset';

type ModelPropertiesTableRowProps = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import ApplicationsPage from '~/app/components/ApplicationsPage';
import TitleWithIcon from '~/app/components/design/TitleWithIcon';
import { ProjectObjectType } from '~/app/components/design/utils';
import ApplicationsPage from '~/shared/components/ApplicationsPage';
import TitleWithIcon from '~/shared/components/design/TitleWithIcon';
import { ProjectObjectType } from '~/shared/components/design/utils';
import useRegisteredModels from '~/app/hooks/useRegisteredModels';
import { filterLiveModels } from '~/app/pages/modelRegistry/screens/utils';
import ModelRegistrySelectorNavigator from './ModelRegistrySelectorNavigator';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import {
} from '@patternfly/react-core';
import truncateStyles from '@patternfly/react-styles/css/components/Truncate/truncate';
import { InfoCircleIcon, BlueprintIcon } from '@patternfly/react-icons';
import { useBrowserStorage } from '~/components/browserStorage';
import { useBrowserStorage } from '~/shared/components/browserStorage';
import { ModelRegistrySelectorContext } from '~/app/context/ModelRegistrySelectorContext';
import { ModelRegistry } from '~/app/types';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { useEffect } from 'react';
import { useNavigate, useParams } from 'react-router';
import { Breadcrumb, BreadcrumbItem, Flex, FlexItem, Truncate } from '@patternfly/react-core';
import { Link } from 'react-router-dom';
import ApplicationsPage from '~/app/components/ApplicationsPage';
import ApplicationsPage from '~/shared/components/ApplicationsPage';
import { ModelRegistrySelectorContext } from '~/app/context/ModelRegistrySelectorContext';
import useRegisteredModelById from '~/app/hooks/useRegisteredModelById';
import useModelVersionById from '~/app/hooks/useModelVersionById';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import * as React from 'react';
import { DescriptionList, Flex, FlexItem, ContentVariants, Title } from '@patternfly/react-core';
import DashboardDescriptionListGroup from '~/components/DashboardDescriptionListGroup';
import EditableTextDescriptionListGroup from '~/components/EditableTextDescriptionListGroup';
import EditableLabelsDescriptionListGroup from '~/components/EditableLabelsDescriptionListGroup';
import DashboardDescriptionListGroup from '~/shared/components/DashboardDescriptionListGroup';
import EditableTextDescriptionListGroup from '~/shared/components/EditableTextDescriptionListGroup';
import EditableLabelsDescriptionListGroup from '~/shared/components/EditableLabelsDescriptionListGroup';
import { ModelVersion } from '~/app/types';
import useModelArtifactsByVersionId from '~/app/hooks/useModelArtifactsByVersionId';
import { ModelRegistryContext } from '~/app/context/ModelRegistryContext';
import InlineTruncatedClipboardCopy from '~/components/InlineTruncatedClipboardCopy';
import DashboardHelpTooltip from '~/components/DashboardHelpTooltip';
import InlineTruncatedClipboardCopy from '~/shared/components/InlineTruncatedClipboardCopy';
import DashboardHelpTooltip from '~/shared/components/DashboardHelpTooltip';
import {
getLabels,
mergeUpdatedLabels,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import * as React from 'react';
import { ClipboardCopy, DescriptionList, Flex, FlexItem, Content } from '@patternfly/react-core';
import { RegisteredModel } from '~/app/types';
import { ModelRegistryContext } from '~/app/context/ModelRegistryContext';
import EditableTextDescriptionListGroup from '~/components/EditableTextDescriptionListGroup';
import EditableLabelsDescriptionListGroup from '~/components/EditableLabelsDescriptionListGroup';
import EditableTextDescriptionListGroup from '~/shared/components/EditableTextDescriptionListGroup';
import EditableLabelsDescriptionListGroup from '~/shared/components/EditableLabelsDescriptionListGroup';
import { getLabels, mergeUpdatedLabels } from '~/app/pages/modelRegistry/screens/utils';
import ModelPropertiesDescriptionListGroup from '~/app/pages/modelRegistry/screens/ModelPropertiesDescriptionListGroup';
import DashboardDescriptionListGroup from '~/components/DashboardDescriptionListGroup';
import DashboardDescriptionListGroup from '~/shared/components/DashboardDescriptionListGroup';
import ModelTimestamp from '~/app/pages/modelRegistry/screens/components/ModelTimestamp';

type ModelDetailsViewProps = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,20 @@ import { EllipsisVIcon, FilterIcon } from '@patternfly/react-icons';
import { useNavigate } from 'react-router';
import { ModelVersion, RegisteredModel } from '~/app/types';
import { ModelRegistrySelectorContext } from '~/app/context/ModelRegistrySelectorContext';
import { SearchType } from '~/app/components/DashboardSearchField';
import { SearchType } from '~/shared/components/DashboardSearchField';
import {
filterModelVersions,
sortModelVersionsByCreateTime,
} from '~/app/pages/modelRegistry/screens/utils';
import EmptyModelRegistryState from '~/app/pages/modelRegistry/screens/components/EmptyModelRegistryState';
import { ProjectObjectType, typedEmptyImage } from '~/app/components/design/utils';
import { ProjectObjectType, typedEmptyImage } from '~/shared/components/design/utils';
import {
modelVersionArchiveUrl,
registerVersionForModelUrl,
} from '~/app/pages/modelRegistry/screens/routeUtils';
import { asEnumMember } from '~/app/utils';
import ModelVersionsTable from '~/app/pages/modelRegistry/screens/ModelVersions/ModelVersionsTable';
import SimpleSelect from '~/app/components/SimpleSelect';
import SimpleSelect from '~/shared/components/SimpleSelect';
import FormFieldset from '~/app/pages/modelRegistry/screens/components/FormFieldset';

type ModelVersionListViewProps = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { useNavigate, useParams } from 'react-router';
import { Breadcrumb, BreadcrumbItem, Truncate } from '@patternfly/react-core';
import { Link } from 'react-router-dom';
import { ModelVersionsTab } from '~/app/pages/modelRegistry/screens/ModelVersions/const';
import ApplicationsPage from '~/app/components/ApplicationsPage';
import ApplicationsPage from '~/shared/components/ApplicationsPage';
import useModelVersionsByRegisteredModel from '~/app/hooks/useModelVersionsByRegisteredModel';
import useRegisteredModelById from '~/app/hooks/useRegisteredModelById';
import { ModelRegistrySelectorContext } from '~/app/context/ModelRegistrySelectorContext';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import * as React from 'react';
import { Table } from '~/app/components/table';
import { Table } from '~/shared/components/table';
import { ModelVersion } from '~/app/types';
import { mvColumns } from '~/app/pages/modelRegistry/screens/ModelVersions/ModelVersionsTableColumns';
import DashboardEmptyTableView from '~/app/components/DashboardEmptyTableView';
import DashboardEmptyTableView from '~/shared/components/DashboardEmptyTableView';
import ModelVersionsTableRow from '~/app/pages/modelRegistry/screens/ModelVersions/ModelVersionsTableRow';

type ModelVersionsTableProps = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { SortableData } from '~/app/components/table';
import { SortableData } from '~/shared/components/table';
import { ModelVersion } from '~/app/types';

export const mvColumns: SortableData<ModelVersion>[] = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { useEffect } from 'react';
import { useNavigate, useParams } from 'react-router';
import { Button, Flex, FlexItem, Label, Content, Tooltip, Truncate } from '@patternfly/react-core';

import ApplicationsPage from '~/app/components/ApplicationsPage';
import ApplicationsPage from '~/shared/components/ApplicationsPage';
import { ModelRegistrySelectorContext } from '~/app/context/ModelRegistrySelectorContext';
import useRegisteredModelById from '~/app/hooks/useRegisteredModelById';
import useModelVersionById from '~/app/hooks/useModelVersionById';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { useEffect } from 'react';
import { useNavigate, useParams } from 'react-router';
import { Button, Flex, FlexItem, Label, Content, Truncate } from '@patternfly/react-core';
import ApplicationsPage from '~/app/components/ApplicationsPage';
import ApplicationsPage from '~/shared/components/ApplicationsPage';
import { ModelRegistrySelectorContext } from '~/app/context/ModelRegistrySelectorContext';
import { ModelRegistryContext } from '~/app/context/ModelRegistryContext';
import useRegisteredModelById from '~/app/hooks/useRegisteredModelById';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react';
import { useParams } from 'react-router';
import { Breadcrumb, BreadcrumbItem } from '@patternfly/react-core';
import { Link } from 'react-router-dom';
import ApplicationsPage from '~/app/components/ApplicationsPage';
import ApplicationsPage from '~/shared/components/ApplicationsPage';
import { ModelRegistrySelectorContext } from '~/app/context/ModelRegistrySelectorContext';
import useRegisteredModelById from '~/app/hooks/useRegisteredModelById';
import useModelVersionsByRegisteredModel from '~/app/hooks/useModelVersionsByRegisteredModel';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import {
} from '@patternfly/react-core';
import { FilterIcon } from '@patternfly/react-icons';
import { ModelVersion } from '~/app/types';
import { SearchType } from '~/app/components/DashboardSearchField';
import SimpleSelect from '~/app/components/SimpleSelect';
import { SearchType } from '~/shared/components/DashboardSearchField';
import SimpleSelect from '~/shared/components/SimpleSelect';
import { asEnumMember } from '~/app/utils';
import { filterModelVersions } from '~/app/pages/modelRegistry/screens/utils';
import EmptyModelRegistryState from '~/app/pages/modelRegistry/screens/components/EmptyModelRegistryState';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as React from 'react';
import { Table } from '~/app/components/table';
import { Table } from '~/shared/components/table';
import { ModelVersion } from '~/app/types';
import DashboardEmptyTableView from '~/app/components/DashboardEmptyTableView';
import DashboardEmptyTableView from '~/shared/components/DashboardEmptyTableView';
import ModelVersionsTableRow from '~/app/pages/modelRegistry/screens/ModelVersions/ModelVersionsTableRow';
import { mvColumns } from '~/app/pages/modelRegistry/screens/ModelVersions/ModelVersionsTableColumns';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ import spacing from '@patternfly/react-styles/css/utilities/Spacing/spacing';
import { useParams, useNavigate } from 'react-router';
import { Link } from 'react-router-dom';
import FormFieldset from '~/app/pages/modelRegistry/screens/components/FormFieldset';
import FormSection from '~/app/components/pf-overrides/FormSection';
import ApplicationsPage from '~/app/components/ApplicationsPage';
import FormSection from '~/shared/components/pf-overrides/FormSection';
import ApplicationsPage from '~/shared/components/ApplicationsPage';
import { modelRegistryUrl, registeredModelUrl } from '~/app/pages/modelRegistry/screens/routeUtils';
import { ValueOf } from '~/typeHelpers';
import { ValueOf } from '~/shared/typeHelpers';
import { useRegisterModelData, RegistrationCommonFormData } from './useRegisterModelData';
import { isRegisterModelSubmitDisabled, registerModel } from './utils';
import { useRegistrationCommonState } from './useRegistrationCommonState';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ import {
import spacing from '@patternfly/react-styles/css/utilities/Spacing/spacing';
import { useParams, useNavigate } from 'react-router';
import { Link } from 'react-router-dom';
import ApplicationsPage from '~/app/components/ApplicationsPage';
import ApplicationsPage from '~/shared/components/ApplicationsPage';
import { modelRegistryUrl, registeredModelUrl } from '~/app/pages/modelRegistry/screens/routeUtils';
import useRegisteredModels from '~/app/hooks/useRegisteredModels';
import { ValueOf } from '~/typeHelpers';
import { ValueOf } from '~/shared/typeHelpers';
import { filterLiveModels } from '~/app/pages/modelRegistry/screens/utils';
import { RegistrationCommonFormData, useRegisterVersionData } from './useRegisterModelData';
import { isRegisterVersionSubmitDisabled, registerVersion } from './utils';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ import {
TextInputGroupMain,
} from '@patternfly/react-core';
import spacing from '@patternfly/react-styles/css/utilities/Spacing/spacing';
import { UpdateObjectAtPropAndValue } from '~/types';
import { UpdateObjectAtPropAndValue } from '~/shared/types';
// import { DataConnection, UpdateObjectAtPropAndValue } from '~/pages/projects/types';
// import { convertAWSSecretData } from '~/pages/projects/screens/detail/data-connections/utils';
import FormFieldset from '~/app/pages/modelRegistry/screens/components/FormFieldset';
import FormSection from '~/app/components/pf-overrides/FormSection';
import FormSection from '~/shared/components/pf-overrides/FormSection';
import { ModelVersion } from '~/app/types';
import { ModelLocationType, RegistrationCommonFormData } from './useRegisterModelData';
// import { ConnectionModal } from './ConnectionModal';
Expand Down
Loading

0 comments on commit af44421

Please sign in to comment.