Skip to content

Commit

Permalink
chore: fix notification (missing content) and remove useless field fr…
Browse files Browse the repository at this point in the history
…om importList array
  • Loading branch information
Luca Tagliabue committed Jun 21, 2024
1 parent 0d746da commit 368903b
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 39 deletions.
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
7 changes: 0 additions & 7 deletions ui/src/container/models/Details/current/imports/columns.jsx
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
10 changes: 2 additions & 8 deletions ui/src/container/models/Details/current/imports/index.jsx
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
2 changes: 1 addition & 1 deletion ui/src/container/models/Details/index.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import NotFound from '@Components/ErrorPage/not-found';
import { modelsApiSlice } from '@State/models/api';
import { useParams, useSearchParams } from 'react-router-dom';
import { MODEL_TABS_ENUM } from '@Src/constants';
import { MODEL_TABS_ENUM } from '@Container/models/Details/constants';
import Current from './current';
import Overview from './overview';
import ReferenceDashboard from './reference';
Expand Down
18 changes: 15 additions & 3 deletions ui/src/container/models/Details/overview/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
7 changes: 0 additions & 7 deletions ui/src/container/models/Details/reference/imports/columns.jsx
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
10 changes: 2 additions & 8 deletions ui/src/container/models/Details/reference/imports/index.jsx
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
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);
useEffect(() => {
if (notificationShowMessage) {
const { type, title } = notificationMessage;
Message[type](title);
const { type, title, content } = notificationMessage;
Message[type]({ title, content });

dispatch(resetNotificationMessage());
}
Expand Down

0 comments on commit 368903b

Please sign in to comment.