Skip to content

Commit 46fce2e

Browse files
authored
MMT-4010: As a user, I can navigate to a landing page for Keyword Manager. (#1349)
* MMT-4010: Creating Keyword Manager Navigation * MMT-4010: npm audit fix and added test * MMT-4010: Bamboo Variable and sharedUtils/ * MMT-4010: Changing to real ACL
1 parent 069d709 commit 46fce2e

File tree

15 files changed

+460
-37
lines changed

15 files changed

+460
-37
lines changed

.eslintrc

+2-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@
2828
"alias": {
2929
"map": [
3030
[ "@", "./static/src" ],
31-
[ "sharedConstants", "./sharedConstants"]
31+
[ "sharedConstants", "./sharedConstants"],
32+
[ "sharedUtils", "./sharedUtils"]
3233
],
3334
"extensions": [
3435
".js",

bin/deploy-bamboo.sh

+2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ config="`jq '.application.apiHost = $newValue' --arg newValue $bamboo_API_HOST <
1818
config="`jq '.application.cmrHost = $newValue' --arg newValue $bamboo_CMR_HOST <<< $config`"
1919
config="`jq '.application.edscHost = $newValue' --arg newValue $bamboo_EDSC_HOST <<< $config`"
2020
config="`jq '.application.gkrHost = $newValue' --arg newValue $bamboo_GKR_HOST <<< $config`"
21+
# Remove after CMR-10452 has been completed
22+
config="`jq '.application.showKeywordManager = $newValue' --arg newValue $bamboo_SHOW_KEYWORD_MANAGER <<< $config`"
2123
config="`jq '.application.cookieDomain = $newValue' --arg newValue $bamboo_COOKIE_DOMAIN <<< $config`"
2224
config="`jq '.application.displayProdWarning = $newValue' --arg newValue $bamboo_DISPLAY_PROD_WARNING <<< $config`"
2325
config="`jq '.application.tokenValidTime = $newValue' --arg newValue $bamboo_JWT_VALID_TIME <<< $config`"

jsconfig.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33
"baseUrl": ".",
44
"paths": {
55
"@/*": ["static/src/*"],
6-
"sharedConstants/*": ["sharedConstants/*"]
6+
"sharedConstants/*": ["sharedConstants/*"],
7+
"sharedUtils/*": ["sharedUtils/*"]
78
}
89
},
9-
"include": ["static/src/**/*", "sharedConstants/*"]
10+
"include": ["static/src/**/*", "sharedConstants/*", "sharedUtils/*"]
1011
}

package-lock.json

+12-12
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

static.config.json

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
"Access-Control-Allow-Headers": "*",
1414
"Access-Control-Allow-Credentials": true
1515
},
16+
"showKeywordManager": true,
1617
"cookieDomain": ".localhost",
1718
"tokenValidTime": "900",
1819
"displayProdWarning": "true",

static/src/js/App.jsx

+10-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import GroupFormPage from '@/js/pages/GroupFormPage/GroupFormPage'
99
import GroupListPage from '@/js/pages/GroupListPage/GroupListPage'
1010
import GroupPage from '@/js/pages/GroupPage/GroupPage'
1111
import HomePage from '@/js/pages/HomePage/HomePage'
12+
import KeywordManagerPage from '@/js/pages/KeywordManagerPage/KeywordManagerPage'
1213
import LogoutPage from '@/js/pages/LogoutPage/LogoutPage'
1314
import ManageCollectionAssociationPage from '@/js/pages/ManageCollectionAssociationPage/ManageCollectionAssociationPage'
1415
import ManageServiceAssociationsPage from '@/js/pages/ManageServiceAssociationsPage/ManageServiceAssociationsPage'
@@ -17,6 +18,7 @@ import OrderOptionFormPage from '@/js/pages/OrderOptionFormPage/OrderOptionFormP
1718
import OrderOptionListPage from '@/js/pages/OrderOptionListPage/OrderOptionListPage'
1819
import OrderOptionPage from '@/js/pages/OrderOptionPage/OrderOptionPage'
1920
import PermissionListPage from '@/js/pages/PermissionListPage/PermissionListPage'
21+
import PermissionFormPage from '@/js/pages/PermissionFormPage/PermissionFormPage'
2022
import PermissionPage from '@/js/pages/PermissionPage/PermissionPage'
2123
import ProviderPermissionsPage from '@/js/pages/ProviderPermissionsPage/ProviderPermissionsPage'
2224
import ProvidersPage from '@/js/pages/ProvidersPage/ProvidersPage'
@@ -39,7 +41,6 @@ import TemplatePreview from '@/js/components/TemplatePreview/TemplatePreview'
3941
import REDIRECTS from '@/js/constants/redirectsMap/redirectsMap'
4042

4143
import withProviders from '@/js/providers/withProviders/withProviders'
42-
import PermissionFormPage from './pages/PermissionFormPage/PermissionFormPage'
4344

4445
import '../css/index.scss'
4546

@@ -221,6 +222,10 @@ export const App = () => {
221222
path: '/admin/groups',
222223
element: <GroupListPage isAdminPage />
223224
},
225+
{
226+
path: '/admin/keywordmanager',
227+
element: <KeywordManagerPage isAdminPage />
228+
},
224229
{
225230
path: '/admin/groups/:id',
226231
element: <GroupPage isAdminPage />
@@ -241,6 +246,10 @@ export const App = () => {
241246
{
242247
path: '/admin/groups/:id/edit',
243248
element: <GroupFormPage isAdminPage />
249+
},
250+
{
251+
path: '/admin/keywordmanager',
252+
element: <KeywordManagerPage isAdminPage />
244253
}
245254
]
246255
}

static/src/js/__tests__/App.test.jsx

+34
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,22 @@ import App from '@/js/App'
77
vi.mock('@/js/components/ErrorBanner/ErrorBanner')
88
vi.mock('@/js/utils/errorLogger')
99

10+
vi.mock('@/js/hooks/useAuthContext', () => ({
11+
default: vi.fn(() => ({
12+
user: {
13+
uid: 'testuser'
14+
}
15+
}))
16+
}))
17+
18+
vi.mock('@/js/hooks/usePermissions', () => ({
19+
default: vi.fn(() => ({
20+
hasSystemGroup: true,
21+
hasSystemKeywords: true,
22+
loading: false
23+
}))
24+
}))
25+
1026
vi.mock('@/js/pages/SearchPage/SearchPage', () => ({
1127
default: vi.fn(() => {
1228
const { type } = useParams()
@@ -59,6 +75,12 @@ vi.mock('@/js/components/LayoutUnauthenticated/LayoutUnauthenticated', () => ({
5975
))
6076
}))
6177

78+
vi.mock('@/js/pages/KeywordManagerPage/KeywordManagerPage', () => ({
79+
default: vi.fn(({ isAdminPage }) => (
80+
<div data-testid={`mock-keyword-manager-page${isAdminPage ? '-admin' : ''}`}>Keyword Manager Page</div>
81+
))
82+
}))
83+
6284
const setup = () => {
6385
render(
6486
<App />
@@ -195,4 +217,16 @@ describe('App component', () => {
195217
window.history.pushState({}, '', '/')
196218
})
197219
})
220+
221+
describe('when rendering the "/admin/keywordmanager" route', () => {
222+
test('renders the admin keyword manager page', async () => {
223+
window.history.pushState({}, '', '/admin/keywordmanager')
224+
225+
setup()
226+
227+
expect(await screen.findByTestId('mock-keyword-manager-page-admin')).toBeInTheDocument()
228+
229+
window.history.pushState({}, '', '/')
230+
})
231+
})
198232
})

static/src/js/components/Layout/Layout.jsx

+9-2
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,17 @@ const Layout = ({ className, displayNav }) => {
5151

5252
const { user } = useAuthContext()
5353

54-
const { hasSystemGroup, loading } = usePermissions({
55-
systemGroup: ['read']
54+
const { hasSystemGroup, hasSystemKeywords, loading } = usePermissions({
55+
systemGroup: ['read'],
56+
systemKeywords: ['read']
5657
})
5758

5859
const [showAboutModal, setShowAboutModal] = useState(false)
5960

6061
if (loading) return null
6162

6263
const canViewGroups = hasSystemGroup
64+
const canViewKeywords = hasSystemKeywords
6365
const canViewAdmin = canViewGroups // || canView* other permission if needed
6466

6567
return (
@@ -215,6 +217,11 @@ const Layout = ({ className, displayNav }) => {
215217
to: '/admin/groups',
216218
title: 'System Groups',
217219
visible: canViewGroups
220+
},
221+
{
222+
to: '/admin/keywordmanager',
223+
title: 'Keyword Manager',
224+
visible: canViewKeywords
218225
}
219226
]
220227
}

static/src/js/components/Layout/__tests__/Layout.test.jsx

+21-4
Original file line numberDiff line numberDiff line change
@@ -73,15 +73,19 @@ const setup = (loggedIn) => {
7373

7474
describe('Layout component', () => {
7575
test('renders the content to the React Router Outlet', async () => {
76-
usePermissions.mockReturnValue({ hasSystemGroup: true })
76+
usePermissions.mockReturnValue({
77+
hasSystemGroup: true,
78+
hasSystemKeywords: true
79+
})
7780

7881
setup()
7982

8083
expect(screen.getByText('This is some content')).toBeInTheDocument()
8184

8285
expect(usePermissions).toHaveBeenCalledTimes(1)
8386
expect(usePermissions).toHaveBeenCalledWith({
84-
systemGroup: ['read']
87+
systemGroup: ['read'],
88+
systemKeywords: ['read']
8589
})
8690

8791
expect(PrimaryNavigation).toHaveBeenCalledTimes(1)
@@ -180,6 +184,11 @@ describe('Layout component', () => {
180184
to: '/admin/groups',
181185
title: 'System Groups',
182186
visible: true
187+
},
188+
{
189+
to: '/admin/keywordmanager',
190+
title: 'Keyword Manager',
191+
visible: true
183192
}
184193
]
185194
}
@@ -188,9 +197,12 @@ describe('Layout component', () => {
188197
}, {})
189198
})
190199

191-
describe('when the user does not have system group permissions', () => {
200+
describe('when the user does not have system group or system keywords permissions', () => {
192201
test('does not render the admin links', async () => {
193-
usePermissions.mockReturnValue({ hasSystemGroup: false })
202+
usePermissions.mockReturnValue({
203+
hasSystemGroup: false,
204+
hasSystemKeywords: false
205+
})
194206

195207
setup()
196208

@@ -292,6 +304,11 @@ describe('Layout component', () => {
292304
to: '/admin/groups',
293305
title: 'System Groups',
294306
visible: false
307+
},
308+
{
309+
to: '/admin/keywordmanager',
310+
title: 'Keyword Manager',
311+
visible: false
295312
}
296313
]
297314
}

0 commit comments

Comments
 (0)