Skip to content

Commit

Permalink
DESENG-622 Add languages link in sidenav (#2520)
Browse files Browse the repository at this point in the history
* DESENG-622 Add languages link in sidenav

* DESENG-622 Fix unit tests

---------

Co-authored-by: Alex <[email protected]>
  • Loading branch information
Baelx and Alex authored May 23, 2024
1 parent 5563c53 commit 8b2a453
Show file tree
Hide file tree
Showing 8 changed files with 56 additions and 1 deletion.
3 changes: 3 additions & 0 deletions CHANGELOG.MD
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## May 22, 2024
- **Feature** Add languages side nav link [🎟️ DESENG-622](https://apps.itsm.gov.bc.ca/jira/browse/DESENG-622)

## May 21, 2024
- **Task** Clean up met-cron [🎟️ DESENG-602](https://apps.itsm.gov.bc.ca/jira/browse/DESENG-602)

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
"""
Add the view_languages role. Also adds it as an ADMIN role.
Revision ID: 5388f257abfb
Revises: 1407e0ad88f6
Create Date: 2024-05-22 14:55:55.334805
"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = '5388f257abfb'
down_revision = '1407e0ad88f6'
branch_labels = None
depends_on = None


def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.execute("INSERT INTO user_role (created_date, updated_date, id, name, description) VALUES ('{0}', '{0}', 39, 'view_languages', 'Role to view languages')".format(sa.func.now()))
op.execute("INSERT INTO group_role_mapping (created_date, updated_date, id, role_id, group_id) VALUES ('{0}', '{0}', 61, 39, 1)".format(sa.func.now()))
# ### end Alembic commands ###


def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.execute("DELETE FROM group_role_mapping WHERE id = 61")
op.execute("DELETE FROM user_role WHERE id = 39")
# ### end Alembic commands ###
1 change: 1 addition & 0 deletions met-api/src/met_api/utils/roles.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,4 @@ class Role(Enum):
EXPORT_PROPONENT_COMMENT_SHEET = 'export_proponent_comment_sheet'
SUPER_ADMIN = 'super_admin'
MANAGE_METADATA = 'manage_metadata'
VIEW_LANGUAGES = 'view_languages'
7 changes: 7 additions & 0 deletions met-web/src/components/language/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import React from 'react';

const Language = () => {
return <div></div>;
};

export default Language;
7 changes: 7 additions & 0 deletions met-web/src/components/layout/SideNav/SideNavElements.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,13 @@ export const Routes: Route[] = [
authenticated: true,
allowedRoles: [USER_ROLES.VIEW_FEEDBACKS],
},
{
name: 'Languages',
path: '/languages',
base: 'languages',
authenticated: true,
allowedRoles: [USER_ROLES.VIEW_LANGUAGES],
},
{
name: 'Tenant Admin',
path: '/tenantadmin',
Expand Down
4 changes: 4 additions & 0 deletions met-web/src/routes/AuthenticatedRoutes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import ScrollToTop from 'components/scrollToTop';
import ReportSettings from 'components/survey/report';
import FormioListener from 'components/FormioListener';
import TenantListing from 'components/tenantManagement/Listing';
import Language from 'components/language';

const AuthenticatedRoutes = () => {
return (
Expand Down Expand Up @@ -64,6 +65,9 @@ const AuthenticatedRoutes = () => {
<Route element={<AuthGate allowedRoles={[USER_ROLES.MANAGE_METADATA]} />}>
<Route path="/metadatamanagement" element={<MetadataManagement />} />
</Route>
<Route element={<AuthGate allowedRoles={[USER_ROLES.VIEW_LANGUAGES]} />}>
<Route path="/languages" element={<Language />} />
</Route>
<Route element={<AuthGate allowedRoles={[USER_ROLES.SUPER_ADMIN]} />}>
<Route path="/tenantadmin" element={<TenantListing />} />
</Route>
Expand Down
2 changes: 1 addition & 1 deletion met-web/src/services/userService/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ export const USER_ROLES = {
EDIT_CLOSED_ENGAGEMENT: 'edit_closed_engagement',
VIEW_ASSIGNED_ENGAGEMENTS: 'view_assigned_engagements',
VIEW_APPROVED_COMMENTS: 'view_approved_comments',
APP_ADMIN: 'app-admin',
VIEW_SURVEYS: 'view_surveys',
VIEW_FEEDBACKS: 'view_feedbacks',
SHOW_ALL_COMMENT_STATUS: 'show_all_comment_status',
Expand All @@ -39,6 +38,7 @@ export const USER_ROLES = {
EXPORT_INTERNAL_COMMENT_SHEET: 'export_internal_comment_sheet',
EXPORT_PROPONENT_COMMENT_SHEET: 'export_proponent_comment_sheet',
MANAGE_METADATA: 'manage_metadata',
VIEW_LANGUAGES: 'view_languages',
};

export type UserStatusName = 'ACTIVE' | 'INACTIVE';
Expand Down
1 change: 1 addition & 0 deletions met-web/tests/unit/components/sidenav.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ jest.mock('react-redux', () => ({
USER_ROLES.VIEW_FEEDBACKS,
USER_ROLES.SUPER_ADMIN,
USER_ROLES.MANAGE_METADATA,
USER_ROLES.VIEW_LANGUAGES,
];
}),
}));
Expand Down

0 comments on commit 8b2a453

Please sign in to comment.