diff --git a/src/App.tsx b/src/App.tsx index e7d8b58..be99859 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -188,15 +188,43 @@ function App() { } /> - } /> - } /> + + + + } + /> + + + + } + /> } /> } /> - } /> - } /> + + + + } + /> + + + + } + /> } /> @@ -230,8 +258,22 @@ function App() { } /> - } /> - } /> + + + + } + /> + + + + } + /> } /> @@ -244,8 +286,22 @@ function App() { } /> - } /> - } /> + + + + } + /> + + + + } + /> } /> diff --git a/src/globals.css b/src/globals.css index 64496f2..aae62fc 100644 --- a/src/globals.css +++ b/src/globals.css @@ -1,4 +1,5 @@ @import './stylesheets/hidden-functionality.css'; +@import './stylesheets/roles-functionality.css'; .limited-text { overflow: hidden; diff --git a/src/pages/city/list.tsx b/src/pages/city/list.tsx index 063363f..95b7cf0 100644 --- a/src/pages/city/list.tsx +++ b/src/pages/city/list.tsx @@ -42,6 +42,7 @@ export const CityList = () => { { field: 'actions', headerName: 'Действия', + cellClassName: 'city-actions', minWidth: 120, display: 'flex', align: 'right', diff --git a/src/pages/country/list.tsx b/src/pages/country/list.tsx index c33f068..7bfe487 100644 --- a/src/pages/country/list.tsx +++ b/src/pages/country/list.tsx @@ -26,6 +26,7 @@ export const CountryList = () => { { field: 'actions', headerName: 'Действия', + cellClassName: 'country-actions', minWidth: 120, display: 'flex', align: 'right', diff --git a/src/pages/route/list.tsx b/src/pages/route/list.tsx index 411daa8..5fb1902 100644 --- a/src/pages/route/list.tsx +++ b/src/pages/route/list.tsx @@ -62,6 +62,7 @@ export const RouteList = () => { { field: 'actions', headerName: 'Действия', + cellClassName: 'route-actions', align: 'right', headerAlign: 'center', minWidth: 120, diff --git a/src/pages/station/list.tsx b/src/pages/station/list.tsx index beaacc8..3745890 100644 --- a/src/pages/station/list.tsx +++ b/src/pages/station/list.tsx @@ -67,6 +67,7 @@ export const StationList = () => { { field: 'actions', headerName: 'Действия', + cellClassName: 'station-actions', align: 'right', headerAlign: 'center', minWidth: 120, diff --git a/src/stylesheets/hidden-functionality.css b/src/stylesheets/hidden-functionality.css index 55a5dfc..5ddb1e5 100644 --- a/src/stylesheets/hidden-functionality.css +++ b/src/stylesheets/hidden-functionality.css @@ -37,13 +37,3 @@ .MuiBox-root div .css-1enbsbt-MuiButtonBase-root-MuiButton-root { display: none !important; } - -/* Hide users menu item by default */ -a[aria-label='Пользователи'] { - display: none !important; -} - -/* Show for admin users - this class will be added to body */ -body.is-admin a[aria-label='Пользователи'] { - display: flex !important; -} diff --git a/src/stylesheets/roles-functionality.css b/src/stylesheets/roles-functionality.css new file mode 100644 index 0000000..58ab681 --- /dev/null +++ b/src/stylesheets/roles-functionality.css @@ -0,0 +1,40 @@ +/* Прячем секцию Пользователи из сайдбара по умолчанию */ +a[aria-label='Пользователи'] { + display: none !important; +} +/* показываем только если админ */ +body.is-admin a[aria-label='Пользователи'] { + display: flex !important; +} + +/* Скрываем кнопки "Редактировать", "Удалить" и "Просмотр" в таблицах городов, стран, маршрутов и станций + для пользователей, у которых нет класса is-admin на . + Работает только в колонке с действиями (например, .city-actions), не затрагивая другие кнопки на странице. */ + +body:not(.is-admin) .city-actions .refine-edit-button, +body:not(.is-admin) .city-actions .refine-delete-button, +body:not(.is-admin) .country-actions .refine-edit-button, +body:not(.is-admin) .country-actions .refine-delete-button, +body:not(.is-admin) .route-actions .refine-edit-button, +body:not(.is-admin) .route-actions .refine-delete-button, +body:not(.is-admin) .station-actions .refine-edit-button, +body:not(.is-admin) .station-actions .refine-delete-button { + display: none !important; +} + +/* Скрываем "Редактировать" на show-странице, если нет класса is-admin */ +body:not(.is-admin) a[href^='/country/edit'] .refine-edit-button, +body:not(.is-admin) a[href^='/city/edit'] .refine-edit-button, +body:not(.is-admin) a[href^='/route/edit'] .refine-edit-button, +body:not(.is-admin) a[href^='/station/edit'] .refine-edit-button { + display: none !important; +} + +/* Скрываем "Создать" на list-странице, если нет класса is-admin */ + +body:not(.is-admin) a[href^='/country/create'] .refine-create-button, +body:not(.is-admin) a[href^='/city/create'] .refine-create-button, +body:not(.is-admin) a[href^='/route/create'] .refine-create-button, +body:not(.is-admin) a[href^='/station/create'] .refine-create-button { + display: none !important; +}