Skip to content

Commit

Permalink
MWB-465: update name to assets
Browse files Browse the repository at this point in the history
  • Loading branch information
SilverBerserk committed Dec 20, 2024
1 parent b33e5ca commit fe4ecc7
Show file tree
Hide file tree
Showing 14 changed files with 80 additions and 182 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export const ListFileCollectionActions = (props) => {
<MenuActionButton
id="resources_button"
onClick={handleResourceManagerAction}
title='Resources'
title='Assets'
icon={<DescriptionOutlinedIcon/>}
/>
<MenuActionButton
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {RouterLink} from 'src/components/router-link';
import {mappingPackagesApi as sectionApi} from 'src/api/mapping-packages';
import MappingPackageDetails from "src/sections/app/mapping-package/details";

const Resources =
const Assets =
dynamic(() => import("src/sections/app/mapping-package/resources"));
const MappingPackageRulesView =
dynamic(() => import("src/sections/app/mapping-package/mapping-package-rules-view"));
Expand All @@ -31,7 +31,7 @@ const StatesView =

const tabs = [
{label: 'Details', value: 'details'},
{label: 'Resources', value: 'resources'},
{label: 'Assets', value: 'assets'},
{label: 'Mapping Rules', value: 'mappingRules'},
{label: 'Triple Map Fragments', value: 'tripleMapFragments'},
{label: 'States', value: 'states'}
Expand Down Expand Up @@ -127,8 +127,8 @@ const Page = () => {
{currentTab === 'details' && (
<MappingPackageDetails item={item}/>
)}
{currentTab === 'resources' && (
<Resources item={item}/>
{currentTab === 'assets' && (
<Assets item={item}/>
)}
{currentTab === "mappingRules" && (
<MappingPackageRulesView id={id}/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import {Box} from "@mui/system";
import Stack from '@mui/material/Stack';
import Button from '@mui/material/Button';
import Dialog from "@mui/material/Dialog";
import SvgIcon from '@mui/material/SvgIcon';
import {useTheme} from "@mui/material/styles";
import Grid from '@mui/material/Unstable_Grid2';
import DialogTitle from "@mui/material/DialogTitle";
Expand Down Expand Up @@ -51,9 +50,7 @@ const Page = () => {
const handleDiscover = () => {
const toastId = toastLoad('Discovering terms ...')
ontologyTermsApi.discoverTerms()
.then(res => {
toastSuccess(`${res.task_name} successfully started.`, toastId)
})
.then(res => toastSuccess(`${res.task_name} successfully started.`, toastId))
.catch(err => toastError(`Discovering terms failed: ${err.message}.`, toastId))
};

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import * as React from 'react';
import {useCallback, useEffect, useState} from "react";
import {useFormik} from "formik";

import ArrowLeftIcon from '@untitled-ui/icons-react/build/esm/ArrowLeft';
import ArrowBackIcon from '@mui/icons-material/ArrowBack';

import Chip from '@mui/material/Chip';
import Link from '@mui/material/Link';
import Stack from '@mui/material/Stack';
import Paper from "@mui/material/Paper";
import SvgIcon from '@mui/material/SvgIcon';
import Divider from "@mui/material/Divider";
import Checkbox from "@mui/material/Checkbox";
import Grid from "@mui/material/Unstable_Grid2";
import Typography from '@mui/material/Typography';
Expand All @@ -25,10 +26,7 @@ import CodeMirrorDefault from "src/components/app/form/codeMirrorDefault";
import {ForItemDataState} from "src/contexts/app/section/for-item-data-state";
import {FileResourceEditForm} from 'src/sections/app/file-manager/file-resource-edit-form';
import {testDataFileResourcesApi as sectionApi} from 'src/api/test-data-suites/file-resources';
import {
MappingPackageFormSelect
} from '../../../../../../sections/app/mapping-package/components/mapping-package-form-select';
import Divider from "@mui/material/Divider";
import {MappingPackageFormSelect} from 'src/sections/app/mapping-package/components/mapping-package-form-select';


const useItem = (sectionApi, id) => {
Expand Down Expand Up @@ -158,7 +156,7 @@ const Page = () => {
underline="hover"
>
<SvgIcon sx={{mr: 1}}>
<ArrowLeftIcon/>
<ArrowBackIcon/>
</SvgIcon>
<Typography variant="subtitle2">
{sectionApi.SECTION_TITLE}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import ArrowLeftIcon from '@untitled-ui/icons-react/build/esm/ArrowLeft';
import ArrowBackIcon from '@mui/icons-material/ArrowBack';

import Link from '@mui/material/Link';
import Stack from '@mui/material/Stack';
import SvgIcon from '@mui/material/SvgIcon';
import Grid from "@mui/material/Unstable_Grid2";
import Typography from '@mui/material/Typography';

import {paths} from 'src/paths';
Expand All @@ -10,12 +12,10 @@ import {useRouter} from "src/hooks/use-router";
import {Layout as AppLayout} from 'src/layouts/app';
import {usePageView} from 'src/hooks/use-page-view';
import {RouterLink} from 'src/components/router-link';
import {FormTextField} from "src/components/app/form/text-field";
import {ForItemCreateForm} from "src/contexts/app/section/for-item-form";
import {FileResourceEditForm} from 'src/sections/app/file-manager/file-resource-edit-form';
import {testDataFileResourcesApi as sectionApi} from 'src/api/test-data-suites/file-resources';
import * as React from "react";
import Grid from "@mui/material/Unstable_Grid2";
import {FormTextField} from "../../../../../components/app/form/text-field";

const ExtraForm = (props) => {
const {
Expand Down Expand Up @@ -72,7 +72,7 @@ const Page = () => {
underline="hover"
>
<SvgIcon sx={{mr: 1}}>
<ArrowLeftIcon/>
<ArrowBackIcon/>
</SvgIcon>
<Typography variant="subtitle2">
{sectionApi.SECTION_TITLE}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import {useEffect, useMemo, useState} from 'react';
import {useEffect, useState} from 'react';

import Plus from '@untitled-ui/icons-react/build/esm/Plus';
import Upload01Icon from '@untitled-ui/icons-react/build/esm/Upload01';
import AddIcon from '@mui/icons-material/Add';
import UploadIcon from '@mui/icons-material/Upload';

import Link from "@mui/material/Link";
import Stack from '@mui/material/Stack';
import Button from '@mui/material/Button';
import SvgIcon from '@mui/material/SvgIcon';
import Typography from '@mui/material/Typography';
import Breadcrumbs from "@mui/material/Breadcrumbs";

Expand All @@ -17,72 +16,14 @@ import {useRouter} from "src/hooks/use-router";
import {Layout as AppLayout} from 'src/layouts/app';
import {usePageView} from 'src/hooks/use-page-view';
import {RouterLink} from "src/components/router-link";
import useItemsSearch from 'src/hooks/use-items-search';
import {ItemList} from 'src/sections/app/file-manager/item-list';
import {ItemDrawer} from 'src/sections/app/file-manager/item-drawer';
import {ItemSearch} from 'src/sections/app/file-manager/item-search';
import {ItemSearch} from 'src/sections/app/files-form/item-search';
import {testDataSuitesApi as sectionApi} from 'src/api/test-data-suites';
import {FileUploader} from 'src/sections/app/file-manager/file-uploader';
import {BreadcrumbsSeparator} from "src/components/breadcrumbs-separator";
import {testDataFileResourcesApi as fileResourcesApi} from 'src/api/test-data-suites/file-resources';

const useItemsSearch = () => {
const [state, setState] = useState({
filters: {
query: undefined
},
page: sectionApi.DEFAULT_PAGE,
rowsPerPage: sectionApi.DEFAULT_ROWS_PER_PAGE,
sortBy: 'createdAt',
sortDir: 'desc'
});

const handleFiltersChange = filters => {
setState(prevState => ({
...prevState,
filters
}));
}

const handleSortChange = sortDir => {
setState(prevState => ({
...prevState,
sortDir
}));
}

const handlePageChange = (event, page) => {
setState(prevState => ({
...prevState,
page
}));
}

const handleRowsPerPageChange = event => {
setState(prevState => ({
...prevState,
rowsPerPage: parseInt(event.target.value, 10)
}));
}

return {
handleFiltersChange,
handleSortChange,
handlePageChange,
handleRowsPerPageChange,
state
};
};

const useCurrentItem = (items, itemId) => {
return useMemo(() => {
if (!itemId) {
return undefined;
}

return items.find((item) => item.id === itemId);
}, [items, itemId]);
};

const Page = () => {
const [view, setView] = useState('grid');
const [state, setState] = useState({
Expand All @@ -92,10 +33,8 @@ const Page = () => {
});

const uploadDialog = useDialog();
const detailsDialog = useDialog();
const itemsSearch = useItemsSearch();
const itemsSearch = useItemsSearch(state.items, sectionApi, ['title']);

const currentItem = useCurrentItem(state.items, detailsDialog.data);

const router = useRouter();
const {id} = router.query;
Expand All @@ -105,7 +44,7 @@ const Page = () => {
useEffect(() => {
id && handleItemsGet();
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [itemsSearch.state, id]);
}, [id]);

const handleItemsGet = async () => {
try {
Expand Down Expand Up @@ -133,7 +72,7 @@ const Page = () => {
>
<Stack spacing={1}>
<Typography variant="h4">
{`Resource Manager: ${state.collection.title}`}
{`Assets Manager: ${state.collection.title}`}
</Typography>

<Breadcrumbs separator={<BreadcrumbsSeparator/>}>
Expand All @@ -157,7 +96,7 @@ const Page = () => {
color="text.secondary"
variant="subtitle2"
>
Resource Manager
Assets Manager
</Typography>
</Breadcrumbs>
</Stack>
Expand All @@ -168,23 +107,14 @@ const Page = () => {
>
<Button
onClick={uploadDialog.handleOpen}
startIcon={(
<SvgIcon>
<Upload01Icon/>
</SvgIcon>
)}
variant="contained"
startIcon={<UploadIcon/>}
>
Upload
</Button>
<Button
component={Link}
href={paths.app[sectionApi.section].resource_manager.create.replace('[id]', id)}
startIcon={(
<SvgIcon>
<Plus/>
</SvgIcon>
)}
startIcon={<AddIcon/>}
variant="contained"
>
Add
Expand All @@ -193,16 +123,16 @@ const Page = () => {
</Stack>
<Stack spacing={{xs: 3, lg: 4}}>
<ItemSearch
onFiltersChange={itemsSearch.handleFiltersChange}
onFiltersChange={e => itemsSearch.handleSearchItems([e])}
onSortChange={itemsSearch.handleSortChange}
onViewChange={setView}
sortBy={itemsSearch.state.sortBy}
sortDir={itemsSearch.state.sortDir}
view={view}
/>
<ItemList
count={state.itemsCount}
items={state.items}
count={itemsSearch.count}
items={itemsSearch.pagedItems}
collection={state.collection}
onPageChange={itemsSearch.handlePageChange}
onRowsPerPageChange={itemsSearch.handleRowsPerPageChange}
Expand All @@ -216,11 +146,6 @@ const Page = () => {
</Stack>
</Stack>

<ItemDrawer
item={currentItem}
onClose={detailsDialog.handleClose}
open={detailsDialog.open}
/>
<FileUploader
onClose={uploadDialog.handleClose}
open={uploadDialog.open}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,11 @@
import PropTypes from 'prop-types';
import CheckVerified01 from '@untitled-ui/icons-react/build/esm/CheckVerified01';
import Star01Icon from '@untitled-ui/icons-react/build/esm/Star01';
import Users01Icon from '@untitled-ui/icons-react/build/esm/Users01';
import Avatar from '@mui/material/Avatar';
import Box from '@mui/material/Box';
import Card from '@mui/material/Card';
import CardContent from '@mui/material/CardContent';
import Link from '@mui/material/Link';
import Stack from '@mui/material/Stack';
import SvgIcon from '@mui/material/SvgIcon';
import Typography from '@mui/material/Typography';
import CardContent from '@mui/material/CardContent';

import {RouterLink} from 'src/components/router-link';
import {paths} from 'src/paths';
import {getInitials} from 'src/utils/get-initials';

import {FileResourceCollectionsList} from './file-resource-collections-list';
import {useTranslation} from "react-i18next";
Expand Down Expand Up @@ -54,11 +46,12 @@ export const FileResourceCollectionsCard = (props) => {
>
{collectionTitle}
</Link>
<Typography variant="body2">{}</Typography>
</div>
</Stack>
<Box sx={{mt: 2}}>
<FileResourceCollectionsList collectionApi={collectionApi} filters={filters} request={requestBase}/>
<FileResourceCollectionsList collectionApi={collectionApi}
filters={filters}
request={requestBase}/>
</Box>
</CardContent>
</Card>
Expand Down
Loading

0 comments on commit fe4ecc7

Please sign in to comment.