Skip to content

Commit

Permalink
Merge pull request #111 from bcgov/dev
Browse files Browse the repository at this point in the history
chore: release
  • Loading branch information
NithinKuruba authored Sep 12, 2023
2 parents d29fd55 + 5fd1dfc commit e85f38e
Show file tree
Hide file tree
Showing 38 changed files with 1,506 additions and 342 deletions.
7 changes: 0 additions & 7 deletions .github/workflows/publish-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,3 @@ jobs:
with:
bump_version_scheme: patch
tag_prefix: v

- name: Check Output Parameters
if: github.ref == 'refs/heads/main'
run: |
echo "Got tag name ${{ steps.release.outputs.tag_name }}"
echo "Got release version ${{ steps.release.outputs.version }}"
echo "Upload release artifacts to ${{ steps.release.outputs.upload_url }}"
2 changes: 1 addition & 1 deletion .tool-versions
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ nodejs 16.14.0
yarn 1.22.4
python 3.11.0
postgres 14.1
helm 3.2.4
helm 3.10.2
9 changes: 5 additions & 4 deletions app/.env.example
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
SSO_URL=https://dev.oidc.gov.bc.ca/auth/realms/onestopauth
SSO_URL=https://dev.loginproxy.gov.bc.ca/auth/realms/standard
SSO_CLIENT_ID=sso-requests
SSO_CLIENT_SECRET=sso-requests-secret
SSO_REDIRECT_URI=http://localhost:3000
SSO_LOGOUT_REDIRECT_URI=http://localhost:3000
SSO_AUTHORIZATION_RESPONSE_TYPE=code
SSO_AUTHORIZATION_SCOPE=openid
SSO_TOKEN_GRANT_TYPE=authorization_code
DEV_KC_URL=https://dev.oidc.gov.bc.ca
DEV_KC_URL=https://dev.loginproxy.gov.bc.ca
DEV_KC_CLIENT_ID=script-cli
DEV_KC_CLIENT_SECRET=
TEST_KC_URL=https://dev.oidc.gov.bc.ca
TEST_KC_URL=https://dev.loginproxy.gov.bc.ca
TEST_KC_CLIENT_ID=script-cli
TEST_KC_CLIENT_SECRET=
PROD_KC_URL=https://dev.oidc.gov.bc.ca
PROD_KC_URL=https://dev.loginproxy.gov.bc.ca
PROD_KC_CLIENT_ID=script-cli
PROD_KC_CLIENT_SECRET=
JWT_SECRET=verysecuresecret
Expand All @@ -33,3 +33,4 @@ BCEID_SERVICE_ID=
BCEID_SERVICE_BASIC_AUTH=
IDIR_JWKS_URI=
IDIR_ISSUER=
NEXTAUTH_URL=http://localhost:3000
36 changes: 36 additions & 0 deletions app/components/SearchBar.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import React from 'react';
import styled from 'styled-components';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { faMagnifyingGlass } from '@fortawesome/free-solid-svg-icons';

const Wrapper = styled.div`
width: 100%;
position: relative;
`;

const Icon = styled.i`
position: absolute;
right: 0.5em;
top: 0.5em;
color: grey;
`;

const Input = styled.input`
width: 100%;
border: 2px solid #606060;
padding: 0.3em 0.5em;
border-radius: 0.25em;
`;

function SearchBar(props: any) {
return (
<Wrapper>
<Input type="text" maxLength={100} {...props} />
<Icon>
<FontAwesomeIcon icon={faMagnifyingGlass} />
</Icon>
</Wrapper>
);
}

export default SearchBar;
165 changes: 165 additions & 0 deletions app/components/Table.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
import {
getCoreRowModel,
useReactTable,
flexRender,
getPaginationRowModel,
FilterFn,
getFilteredRowModel,
} from '@tanstack/react-table';
import type { ColumnDef } from '@tanstack/react-table';
import Pagination from 'react-bootstrap/Pagination';
import styled from 'styled-components';
import Select from 'react-select';
import Grid from '@button-inc/bcgov-theme/Grid';
import StyledTable from 'html-components/Table';
import { useState } from 'react';
import { rankItem } from '@tanstack/match-sorter-utils';
import SearchBar from './SearchBar';

const StyledPagination = styled(Pagination)`
margin: 0 !important;
& li {
margin: 0 !important;
}
`;

const PageInfo = styled.li`
padding-left: 5px;
line-height: 40px;
`;

const StyledSelect = styled(Select)`
width: 150px;
display: inline-block;
`;

const fuzzyFilter: FilterFn<any> = (row, columnId, value, addMeta) => {
// Rank the item
const itemRank = rankItem(row.getValue(columnId), value);

// Store the itemRank info
addMeta({
itemRank,
});

// Return if the item should be filtered in/out
return itemRank.passed;
};

interface ReactTableProps<T extends object> {
data: T[];
columns: ColumnDef<T>[];
noDataFoundMessage: string;
}
const Table = <T extends object>({ data, columns, noDataFoundMessage = 'no data found.' }: ReactTableProps<T>) => {
const numOfItemsPerPage = () => {
const options = [5, 10, 15, 20, 25, 30].map((val) => {
return { value: val, label: `${val} per page` };
});

return options;
};

const [globalFilter, setGlobalFilter] = useState('');

const table = useReactTable({
data,
columns,
initialState: {
pagination: {
pageSize: 5,
},
},
state: {
globalFilter,
},
onGlobalFilterChange: setGlobalFilter,
globalFilterFn: fuzzyFilter,
getCoreRowModel: getCoreRowModel(),
getPaginationRowModel: getPaginationRowModel(),
getFilteredRowModel: getFilteredRowModel(),
});

return (
<>
<SearchBar
type="text"
size="small"
maxLength="1000"
value={globalFilter ?? ''}
onChange={(v: any) => setGlobalFilter(String(v.target.value))}
placeholder="Search all columns..."
style={{ marginTop: '10px', maxWidth: '25%' }}
/>
<StyledTable>
<thead>
{table.getHeaderGroups().map((headerGroup) => (
<tr key={headerGroup.id}>
{headerGroup.headers.map((header) => (
<th key={header.id}>
{header.isPlaceholder ? null : flexRender(header.column.columnDef.header, header.getContext())}
</th>
))}
</tr>
))}
</thead>
<tbody>
{table.getRowModel().rows.length > 0 ? (
table.getRowModel().rows.map((row) => (
<tr key={row.id}>
{row.getVisibleCells().map((cell) => (
<td key={cell.id}>{flexRender(cell.column.columnDef.cell, cell.getContext())}</td>
))}
</tr>
))
) : (
<tr key={noDataFoundMessage}>
<td colSpan={10}>{noDataFoundMessage}</td>{' '}
</tr>
)}
</tbody>
</StyledTable>
<Grid cols={12}>
<Grid.Row collapse="992" gutter={[]} align="center">
<Grid.Col span={8}>
<StyledPagination>
<Pagination.Item
key="prev"
disabled={!table.getCanPreviousPage()}
onClick={() => {
table.previousPage();
}}
>
Previous
</Pagination.Item>
<Pagination.Item
key="next"
disabled={!table.getCanNextPage()}
onClick={() => {
table.nextPage();
}}
>
Next
</Pagination.Item>
<PageInfo>{`${table.getState().pagination.pageIndex + 1} of ${table.getPageCount()}`}</PageInfo>
</StyledPagination>
</Grid.Col>
<Grid.Col span={4}>
<div style={{ textAlign: 'right' }} data-testid="page-select">
<StyledSelect
menuPosition="fixed"
value={table.getState().pagination.pageSize}
options={numOfItemsPerPage()}
onChange={(e: any) => {
table.setPageSize(Number(e.value));
}}
></StyledSelect>
</div>
</Grid.Col>
</Grid.Row>
</Grid>
</>
);
};

export default Table;
31 changes: 12 additions & 19 deletions app/controllers/realm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { runQuery } from 'utils/db';
import KeycloakCore from 'utils/keycloak-core';

export async function getAllowedRealms(session: any) {
const username = session?.idir_username || '';
const roles = session?.client_roles || [];
const username = session?.user?.idir_username || '';
const roles = session?.user?.client_roles || [];
const isAdmin = roles.includes('sso-admin');
let result: any = null;

Expand All @@ -16,7 +16,6 @@ export async function getAllowedRealms(session: any) {
id,
realm,
product_name,
openshift_namespace,
product_owner_email,
product_owner_idir_userid,
technical_contact_email,
Expand All @@ -27,8 +26,10 @@ export async function getAllowedRealms(session: any) {
division,
branch,
created_at,
updated_at
FROM rosters WHERE LOWER(technical_contact_idir_userid)=LOWER($1) OR LOWER(product_owner_idir_userid)=LOWER($1) ORDER BY id ASC
updated_at,
rc_channel,
rc_channel_owned_by
FROM rosters WHERE LOWER(technical_contact_idir_userid)=LOWER($1) OR LOWER(second_technical_contact_idir_userid)=LOWER($1) OR LOWER(product_owner_idir_userid)=LOWER($1) ORDER BY id ASC
`,
[username],
);
Expand All @@ -41,18 +42,10 @@ export async function getAllowedRealms(session: any) {
if (kcAdminClient) {
for (let x = 0; x < result?.rows.length; x++) {
const realm = result?.rows[x];
const [realmData, poName, techName, secTechName] = await Promise.all([
kcCore.getRealm(realm.realm),
kcCore.getIdirUserName(realm.product_owner_idir_userid),
kcCore.getIdirUserName(realm.technical_contact_idir_userid),
kcCore.getIdirUserName(realm.second_technical_contact_idir_userid),
]);

realm.product_owner_name = poName;
realm.technical_contact_name = techName;
realm.second_technical_contact_name = secTechName;
realm.displayName = realmData?.displayName || '';
const [realmData] = await Promise.all([kcCore.getRealm(realm.realm)]);
realm.idps = realmData?.identityProviders?.map((v) => v.displayName || v.alias) || [];
const distinctProviders = new Set(realmData?.identityProviders?.map((v) => v.providerId) || []);
realm.protocol = Array.from(distinctProviders);
}
}
}
Expand All @@ -61,8 +54,8 @@ export async function getAllowedRealms(session: any) {
}

export async function getAllowedRealmNames(session: any) {
const username = session?.idir_username || '';
const roles = session?.client_roles || [];
const username = session?.user?.idir_username || '';
const roles = session?.user?.client_roles || [];
const isAdmin = roles.includes('sso-admin');
let result: any = null;

Expand All @@ -73,7 +66,7 @@ export async function getAllowedRealmNames(session: any) {
`
SELECT
realm,
FROM rosters WHERE LOWER(technical_contact_idir_userid)=LOWER($1) OR LOWER(product_owner_idir_userid)=LOWER($1) ORDER BY id ASC
FROM rosters WHERE LOWER(technical_contact_idir_userid)=LOWER($1) OR LOWER(second_technical_contact_idir_userid)=LOWER($1) OR LOWER(product_owner_idir_userid)=LOWER($1) ORDER BY id ASC
`,
[username],
);
Expand Down
4 changes: 3 additions & 1 deletion app/html-components/Table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ const Table = styled.table`
box-shadow: none;
text-align: left;
border-collapse: separate;
border-spacing: 0 5px;
border-spacing: 0;
table-layout: fixed;
& thead {
font-size: 12px;
Expand Down Expand Up @@ -38,6 +39,7 @@ const Table = styled.table`
& th,
& td {
border: none;
word-wrap: break-word;
}
`;

Expand Down
Loading

0 comments on commit e85f38e

Please sign in to comment.