Skip to content
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

chore: cleaning the code and filesystem and fixing antd message notification #12

Merged
merged 3 commits into from
Jun 24, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions ui/src/components/ImportButton/import-current-button.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ const { useImportCurrentDataMutation } = modelsApiSlice;
function ImportCurrentDatasetButton({ type = 'primary-light' }) {
const { uuid: modelUUID } = useParams();

const [triggerImportFeedback, { isLoading, isError }] = useImportCurrentDataMutation({ fixedCacheKey: `imports-reference-data-${modelUUID}` });
const isSubmitDisabled = isLoading || isError;
const [triggerImportFeedback, { isLoading }] = useImportCurrentDataMutation({ fixedCacheKey: `imports-reference-data-${modelUUID}` });
const isSubmitDisabled = isLoading;

const disableUploadAction = () => false;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { Tabs } from '@radicalbit/radicalbit-design-system';
import { useSearchParams } from 'react-router-dom';
import { METRICS_TABS } from '@Container/models/Details/constants';
import DataDriftMetrics from '../../data-drift-metrics';
import DataQualityMetrics from '../../data-quality-metrics';
import ModelQualityMetrics from '../../model-quality-metrics';
import DataQualityMetrics from '@Container/models/Details/reference/data-quality';
import ModelQualityMetrics from '@Container/models/Details/reference/model-quality';
import DataDriftMetrics from '@Container/models/Details/current/data-drift';

const tabs = [
{
Expand All @@ -23,7 +23,7 @@ const tabs = [
},
];

export default function CurrentDashboardModal() {
function Body() {
const [searchParams, setSearchParams] = useSearchParams();

const activeTab = searchParams.get('modal-tab-metrics') || METRICS_TABS.METRICS;
Expand All @@ -38,14 +38,17 @@ export default function CurrentDashboardModal() {
};

return (

<div className="px-4 pt-4 h-[99%]">
<Tabs
activeKey={activeTab}
fullHeight
items={tabs}
onChange={onChangeTab}
/>
<div className="flex flex-col gap-4 h-full">
<div className="px-4 pt-4 h-[99%]">
<Tabs
activeKey={activeTab}
fullHeight
items={tabs}
onChange={onChangeTab}
/>
</div>
</div>
);
}

export default Body;
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
import { memo } from 'react';
import { useParams } from 'react-router';
import { useSearchParams } from 'react-router-dom';
import CurrentDashboardModal from './current-dashboard-modal';
import Body from './body';

const { useGetModelByUUIDQuery } = modelsApiSlice;

Expand All @@ -38,9 +38,7 @@ function CurrentImportDetailModal() {
onCancel={handleOnCancel}
open
>
<div className="flex flex-col gap-4 h-full">
<CurrentDashboardModal />
</div>
<Body />
</RbitModal>
);
}
Expand Down
2 changes: 1 addition & 1 deletion ui/src/components/modals/modals-provider.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ModalsEnum } from '@Src/constants';
import useModals from '@Src/hooks/use-modals';
import AddNewModel from './add-new-model';
import CurrentImportsDetailModal from '../../container/models/Details/current-dashboard/imports/current-import-detail-modal';
import CurrentImportsDetailModal from './current-import-detail-modal';

export default function ModalsProvider() {
const { modalPayload: { modalName } } = useModals();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { numberFormatter } from '@Src/constants';
import moment from 'moment';
import { CHART_COLOR } from '../../constants';
import { CHART_COLOR } from '@Container/models/Details/constants';

export default function lineChartOptions(title, color, currentDataset, referenceDataset) {
const series = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { modelsApiSlice } from '@Src/store/state/models/api';
import { ModelTypeEnum } from '@State/models/constants';
import { memo } from 'react';
import { useParams } from 'react-router';
import BinaryClassificationMetrics from './binary-classification-metrics';
import BinaryClassificationMetrics from './binary-classification';

const { useGetModelByUUIDQuery } = modelsApiSlice;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { modelsApiSlice } from '@Src/store/state/models/api';
import { ModelTypeEnum } from '@State/models/constants';
import { memo } from 'react';
import { useParams } from 'react-router';
import BinaryClassificationMetrics from './binary-classification-metrics';
import BinaryClassificationMetrics from './binary-classification';

const { useGetModelByUUIDQuery } = modelsApiSlice;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,6 @@ import moment from 'moment';
import { DataTableAction, FontAwesomeIcon, Spinner } from '@radicalbit/radicalbit-design-system';

export const getColumns = (activeFilters, activeSorter) => [
columnFactory({
title: 'File name',
dataIndex: 'fileName',
key: 'fileName',
activeFilters,
activeSorter,
}),
columnFactory({
title: 'File path',
dataIndex: 'path',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,19 +59,13 @@ function FeedbackTable() {
const queryParams = useSelector((state) => contextConfigurationSelectors.selectQueryParamsSelector(state, NamespaceEnum.CURRENT_IMPORT));

const { data } = useGetCurrentImportsQuery({ uuid: modelUUID, queryParams });
const importList = data?.items.map((item) => ({
...item,
fileName: item.path.split('current/')[1],
path: `${item.path.split('current/')[0]}current/`,
errorEntries: 0,
entries: 100,
})) ?? [];
const items = data?.items || [];
const recordCount = data?.total;

return (
<SmartTable
columns={getColumns}
dataSource={importList}
dataSource={items}
modifier="w-full pt-4"
namespace={NamespaceEnum.CURRENT_IMPORT}
recordCount={recordCount}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ import { JOB_STATUS } from '@Src/constants';
import { modelsApiSlice } from '@Src/store/state/models/api';
import { Tabs } from '@radicalbit/radicalbit-design-system';
import { useParams, useSearchParams } from 'react-router-dom';
import { METRICS_TABS } from '../constants';
import DataDriftMetrics from './data-drift-metrics/binary-classification-metrics';
import DataQualityMetrics from './data-quality-metrics';
import { METRICS_TABS } from '@Container/models/Details/constants';
import DataDriftMetrics from './data-drift/binary-classification';
import DataQualityMetrics from './data-quality';
import Imports from './imports';
import ModelQualityMetrics from './model-quality-metrics';
import ModelQualityMetrics from './model-quality';

const { useGetReferenceDataQualityQuery } = modelsApiSlice;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { modelsApiSlice } from '@Src/store/state/models/api';
import { ModelTypeEnum } from '@State/models/constants';
import { memo } from 'react';
import { useParams } from 'react-router';
import BinaryClassificationMetrics from './binary-classification-metrics';
import BinaryClassificationMetrics from './binary-classification';

const { useGetModelByUUIDQuery } = modelsApiSlice;

Expand Down
12 changes: 6 additions & 6 deletions ui/src/container/models/Details/index.jsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { useParams, useSearchParams } from 'react-router-dom';
import { modelsApiSlice } from '@State/models/api';
import NotFound from '@Components/ErrorPage/not-found';
import { MODEL_TABS_ENUM } from './constants';
import CurrentDashboard from './current-dashboard';
import { modelsApiSlice } from '@State/models/api';
import { useParams, useSearchParams } from 'react-router-dom';
import { MODEL_TABS_ENUM } from '@Container/models/Details/constants';
import Current from './current';
import Overview from './overview';
import ReferenceDashboard from './reference-dashboard';
import ReferenceDashboard from './reference';

const { useGetModelByUUIDQuery } = modelsApiSlice;

Expand All @@ -30,6 +30,6 @@ export function ModelDetails() {
}

if (activeKey === MODEL_TABS_ENUM.CURRENT_DASHBOARD) {
return (<CurrentDashboard />);
return (<Current />);
}
}
20 changes: 16 additions & 4 deletions ui/src/container/models/Details/overview/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {
Tabs,
} from '@radicalbit/radicalbit-design-system';
import { useSearchParams } from 'react-router-dom';
import { MODEL_TABS_ENUM, OVERVIEW_TABS_ENUM } from '../constants';
import { MODEL_TABS_ENUM, OVERVIEW_TABS_ENUM } from '@Container/models/Details/constants';
import OutputsTab from './outputs-tab';
import SummaryTab from './summary-tab';
import VariablesTab from './variables-tab';
Expand All @@ -18,9 +18,21 @@ function Overview() {
};

const tabs = [
{ label: 'Summary', key: OVERVIEW_TABS_ENUM.SUMMARY, children: <SummaryTab /> },
{ label: 'Variables', key: OVERVIEW_TABS_ENUM.VARIABLES, children: <VariablesTab /> },
{ label: 'Outputs', key: OVERVIEW_TABS_ENUM.OUTPUTS, children: <OutputsTab /> },
{
label: 'Summary',
key: OVERVIEW_TABS_ENUM.SUMMARY,
children: <SummaryTab />,
},
{
label: 'Variables',
key: OVERVIEW_TABS_ENUM.VARIABLES,
children: <VariablesTab />,
},
{
label: 'Outputs',
key: OVERVIEW_TABS_ENUM.OUTPUTS,
children: <OutputsTab />,
},
];

return (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Tag } from '@radicalbit/radicalbit-design-system';
import { OVERVIEW_ROW_TYPE } from '../../constants';
import { OVERVIEW_ROW_TYPE } from '@Container/models/Details/constants';

const outputsColumns = (dataSource) => [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { DataTable } from '@radicalbit/radicalbit-design-system';
import { memo } from 'react';
import { useParams } from 'react-router';
import { modelsApiSlice } from '@Store/state/models/api';
import { OVERVIEW_ROW_TYPE } from '../../constants';
import { OVERVIEW_ROW_TYPE } from '@Container/models/Details/constants';
import outputsColumns from './columns';

const { useGetModelByUUIDQuery } = modelsApiSlice;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { DataTable } from '@radicalbit/radicalbit-design-system';
import { useParams } from 'react-router';
import { memo } from 'react';
import { modelsApiSlice } from '@Store/state/models/api';
import { OVERVIEW_ROW_TYPE } from '@Container/models/Details/constants';
import featuresColumns from './columns';
import { OVERVIEW_ROW_TYPE } from '../../constants';

const { useGetModelByUUIDQuery } = modelsApiSlice;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { modelsApiSlice } from '@Src/store/state/models/api';
import { ModelTypeEnum } from '@State/models/constants';
import { memo } from 'react';
import { useParams } from 'react-router';
import BinaryClassificationMetrics from './binary-classification-metrics';
import BinaryClassificationMetrics from './binary-classification';

const { useGetModelByUUIDQuery } = modelsApiSlice;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,6 @@ import moment from 'moment';
import { FontAwesomeIcon, Spinner } from '@radicalbit/radicalbit-design-system';

export const getColumns = (activeFilters, activeSorter) => [
columnFactory({
title: 'File name',
dataIndex: 'fileName',
key: 'fileName',
activeFilters,
activeSorter,
}),
columnFactory({
title: 'File path',
dataIndex: 'path',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,19 +43,13 @@ function FeedbackTable() {
const { uuid: modelUUID } = useParams();

const { data } = useGetReferenceImportsQuery({ uuid: modelUUID });
const importList = data?.items.map((item) => ({
...item,
fileName: item.path.split('reference/')[1],
path: `${item.path.split('reference/')[0]}reference/`,
errorEntries: 0,
entries: 100,
})) ?? [];
const items = data?.items || [];
const recordCount = data?.total;

return (
<SmartTable
columns={getColumns}
dataSource={importList}
dataSource={items}
modifier="w-full pt-4"
namespace={NamespaceEnum.REFERENCE_IMPORT}
recordCount={recordCount}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ import { JOB_STATUS } from '@Src/constants';
import { modelsApiSlice } from '@Src/store/state/models/api';
import { Tabs } from '@radicalbit/radicalbit-design-system';
import { useParams, useSearchParams } from 'react-router-dom';
import { METRICS_TABS } from '../constants';
import DataQualityMetrics from './data-quality-metrics';
import { METRICS_TABS } from '@Container/models/Details/constants';
import DataQualityMetrics from './data-quality';
import Imports from './imports';
import ModelQualityMetrics from './model-quality-metrics';
import ModelQualityMetrics from './model-quality';

const { useGetReferenceDataQualityQuery } = modelsApiSlice;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { modelsApiSlice } from '@Src/store/state/models/api';
import { ModelTypeEnum } from '@State/models/constants';
import { memo } from 'react';
import { useParams } from 'react-router';
import BinaryClassificationMetrics from './binary-classification-metrics';
import BinaryClassificationMetrics from './binary-classification';

const { useGetModelByUUIDQuery } = modelsApiSlice;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { useSelector } from 'react-redux';
import JobStatusPin from '@Components/JobStatus/job-status-pin';
import { selectors as contextConfigurationSelectors } from '@State/context-configuration';
import { NamespaceEnum } from '@Src/constants';
import { MODEL_TABS_ENUM } from '../constants';
import { MODEL_TABS_ENUM } from '@Container/models/Details/constants';

const { useGetModelsQuery } = modelsApiSlice;

Expand Down
2 changes: 1 addition & 1 deletion ui/src/store/middlewares.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export const rtkQueryErrorLogger = ({ dispatch }) => (next) => (action) => {
const error2 = action.payload?.data?.error?.message; // likes models-repo errors
const error3 = action.payload?.data;
const message = error1 || error2 || error3 || 'generic error';
const notificationMessage = notificationErrorJson({ status, statusText: message });
const notificationMessage = notificationErrorJson({ status, message });

dispatch(setNotificationMessage(notificationMessage));
}
Expand Down
5 changes: 3 additions & 2 deletions ui/src/store/state/notification/hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@ const useNotification = () => {
const notificationMessage = useSelector(selectNotificationMessage);
const notificationShowMessage = useSelector(selectNotificationShowMessage);

console.debug(notificationMessage);
dvalleri marked this conversation as resolved.
Show resolved Hide resolved
useEffect(() => {
if (notificationShowMessage) {
const { type, title } = notificationMessage;
Message[type](title);
const { type, title, content } = notificationMessage;
Message[type]({ title, content });

dispatch(resetNotificationMessage());
}
Expand Down
2 changes: 1 addition & 1 deletion ui/src/store/state/notification/slice.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { createSlice } from '@reduxjs/toolkit';
import { NotificationEnum } from './constants';
import { NotificationEnum } from '@State/notification/constants';

const initialState = {
showMessage: false,
Expand Down