Skip to content

Commit

Permalink
Merge branch 'master' into DJ-universal-pull
Browse files Browse the repository at this point in the history
  • Loading branch information
DJensen94 authored Feb 29, 2024
2 parents 2be63ad + f8343b5 commit 528b678
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 36 deletions.
10 changes: 1 addition & 9 deletions backend/src/api/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,7 @@ app.use(express.json({ strict: false }));

app.use(
cors({
origin: [
'api.staging-cd.crossfeed.cyber.dhs.gov',
'api.crossfeed.cyber.dhs.gov',
'api.staging.crossfeed.cyber.dhs.gov',
'crossfeed.cyber.dhs.gov',
'staging.crossfeed.cyber.dhs.gov',
'staging-cd.crossfeed.cyber.dhs.gov',
/localhost$/
],
origin: [/.*crossfeed\.cyber\.dhs\.gov$/, /localhost$/],
methods: ['GET', 'POST', 'PUT', 'DELETE', 'OPTIONS']
})
);
Expand Down
6 changes: 6 additions & 0 deletions backend/src/api/organizations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,8 @@ export const create = wrapHandler(async (event) => {
* - Organizations
*/
export const list = wrapHandler(async (event) => {
console.log('list function called with event: ', event);

if (!isGlobalViewAdmin(event) && getOrgMemberships(event).length === 0) {
return {
//TODO: Should we return a 403?
Expand All @@ -375,6 +377,8 @@ export const list = wrapHandler(async (event) => {
};
}
await connectToDatabase();
console.log('Database connected');

let where: any = { parent: null };
if (!isGlobalViewAdmin(event)) {
where = { id: In(getOrgMemberships(event)), parent: null };
Expand All @@ -385,6 +389,8 @@ export const list = wrapHandler(async (event) => {
order: { name: 'ASC' }
});

console.log('Organization.find result: ', result);

return {
statusCode: 200,
body: JSON.stringify(result)
Expand Down
10 changes: 1 addition & 9 deletions frontend/scripts/constants.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
//CORS Options
export const ALLOW_ORIGIN = [
'api.staging-cd.crossfeed.cyber.dhs.gov',
'api.crossfeed.cyber.dhs.gov',
'api.staging.crossfeed.cyber.dhs.gov',
'crossfeed.cyber.dhs.gov',
'staging.crossfeed.cyber.dhs.gov',
'staging-cd.crossfeed.cyber.dhs.gov',
/localhost$/
];
export const ALLOW_ORIGIN = [/.*crossfeed\.cyber\.dhs\.gov$/, /localhost$/];
export const ALLOW_METHODS = ['GET', 'POST', 'PUT', 'DELETE', 'OPTIONS'];
20 changes: 10 additions & 10 deletions frontend/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ const App: React.FC = () => (
exact
path="/inventory"
component={SearchPage}
permissions={['globalView']}
permissions={['standard', 'globalView']}
/>
<RouteGuard
path="/inventory/domain/:domainId"
Expand All @@ -142,19 +142,19 @@ const App: React.FC = () => (
path="/inventory/vulnerabilities"
exact
component={Vulnerabilities}
permissions={['globalView']}
permissions={['standard', 'globalView']}
/>
<RouteGuard
path="/inventory/vulnerabilities/grouped"
component={(props) => (
<Vulnerabilities {...props} groupBy="title" />
)}
permissions={['globalView']}
permissions={['standard', 'globalView']}
/>
<RouteGuard
path="/inventory/vulnerability/:vulnerabilityId"
component={Vulnerability}
permissions={['globalView']}
permissions={['standard', 'globalView']}
/>
<RouteGuard
path="/feeds"
Expand All @@ -170,28 +170,28 @@ const App: React.FC = () => (
path="/scans"
exact
component={Scans}
permissions={['globalView']}
permissions={['standard', 'globalView']}
/>
<RouteGuard
path="/scans/history"
component={Scans}
exact
permissions={['globalView']}
permissions={['standard', 'globalView']}
/>
<RouteGuard
path="/scans/:scanId"
component={Scan}
permissions={['globalView']}
permissions={['standard', 'globalView']}
/>
<RouteGuard
path="/organizations/:organizationId"
component={Organization}
permissions={['standard', 'globalView']}
permissions={['globalView']}
/>
<RouteGuard
path="/organizations"
component={Organizations}
permissions={['globalView', 'regionalAdmin']}
permissions={['standard', 'globalView', 'regionalAdmin']}
/>
<RouteGuard
path="/users"
Expand All @@ -201,7 +201,7 @@ const App: React.FC = () => (
<RouteGuard
path="/settings"
component={Settings}
permissions={['globalView', 'regionalAdmin']}
permissions={['standard', 'globalView', 'regionalAdmin']}
/>
<RouteGuard
path="/region-admin-dashboard"
Expand Down
19 changes: 11 additions & 8 deletions frontend/src/components/OrganizationList/OrganizationList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,14 @@ export const OrganizationList: React.FC<{
const [organizations, setOrganizations] = useState<Organization[]>([]);
const [dialogOpen, setDialogOpen] = useState(false);
const history = useHistory();
const getOrgsURL = `/v2/organizations/`;

const orgCols: GridColDef[] = [
{ field: 'name', headerName: 'Organization', minWidth: 100, flex: 2 },
{ field: 'userCount', headerName: 'Members', minWidth: 100, flex: 1 },
// { field: 'userCount', headerName: 'Members', minWidth: 100, flex: 1 },
{ field: 'state', headerName: 'State', minWidth: 100, flex: 1 },
{ field: 'regionId', headerName: 'Region', minWidth: 100, flex: 1 },
{ field: 'tagNames', headerName: 'Tags', minWidth: 100, flex: 1 },
// { field: 'tagNames', headerName: 'Tags', minWidth: 100, flex: 1 },
{
field: 'view',
headerName: 'View/Edit',
Expand Down Expand Up @@ -61,16 +62,16 @@ export const OrganizationList: React.FC<{

const fetchOrganizations = useCallback(async () => {
try {
const rows = await apiGet<Organization[]>('/organizations/');
rows.forEach((obj) => {
obj.userCount = obj.userRoles.length;
obj.tagNames = obj.tags.map((tag) => tag.name);
});
const rows = await apiGet<Organization[]>(getOrgsURL);
// rows.forEach((obj) => {
// // obj.userCount = obj.userRoles.length;
// obj.tagNames = obj.tags.map((tag) => tag.name);
// });
setOrganizations(rows);
} catch (e) {
console.error(e);
}
}, [apiGet]);
}, [apiGet, getOrgsURL]);

React.useEffect(() => {
if (!parent) fetchOrganizations();
Expand All @@ -79,6 +80,8 @@ export const OrganizationList: React.FC<{
}
}, [fetchOrganizations, parent]);

console.log(JSON.stringify(organizations));

const addOrgButton = user?.userType === 'globalAdmin' && (
<Button
size="small"
Expand Down

0 comments on commit 528b678

Please sign in to comment.