Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CORE-259: add User to support page #5214

Merged
merged 2 commits into from
Jan 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/libs/ajax/User.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { authOpts } from 'src/auth/auth-session';
import { fetchOrchestration, fetchSam } from 'src/libs/ajax/ajax-common';
import { SamUserTermsOfServiceDetails } from 'src/libs/ajax/TermsOfService';
import { TerraUserProfile } from 'src/libs/state';
import { SupportSummary } from 'src/support/SupportResourceType';

export interface SamUserRegistrationStatusResponse {
userSubjectId: string;
Expand Down Expand Up @@ -342,6 +343,11 @@ export const User = (signal?: AbortSignal) => {
_.merge(authOpts(), { signal, method: 'POST' })
);
},

getSupportSummary: async (email: string): Promise<SupportSummary> => {
const res = await fetchSam(`api/admin/v1/user/email/${email}/supportSummary`, _.merge(authOpts(), { signal }));
return res.json();
},
};
};

Expand Down
11 changes: 8 additions & 3 deletions src/support/LookupSummaryAndPolicies.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { ButtonPrimary } from '@terra-ui-packages/components';
import React, { Fragment, useState } from 'react';
import _ from 'lodash/fp';
import React, { useState } from 'react';
import { TextInput } from 'src/components/input';
import colors from 'src/libs/colors';
import * as Nav from 'src/libs/nav';
import { ResourcePolicies } from 'src/support/ResourcePolicies';
import { ResourceTypeSummaryProps } from 'src/support/SupportResourceType';
import { ResourceTypeSummaryProps, supportResources } from 'src/support/SupportResourceType';
import { SupportSummary } from 'src/support/SupportSummary';

export const LookupSummaryAndPolicies = (props: ResourceTypeSummaryProps) => {
Expand All @@ -20,6 +21,10 @@ export const LookupSummaryAndPolicies = (props: ResourceTypeSummaryProps) => {
setResourceId('');
}, [props.fqResourceId.resourceTypeName]);

// the resourceType may be configured to skip policy retrieval/display
const displayPolicies = !_.find((res) => res.resourceType === props.fqResourceId.resourceTypeName, supportResources)
?.skipPolicies;

return (
<>
<div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between', marginBottom: '1rem' }}>
Expand Down Expand Up @@ -51,7 +56,7 @@ export const LookupSummaryAndPolicies = (props: ResourceTypeSummaryProps) => {
<ButtonPrimary onClick={() => submit()}>Load</ButtonPrimary>
</div>
{!!props.loadSupportSummaryFn && <SupportSummary {...props} />}
<ResourcePolicies {...props} />
{displayPolicies && <ResourcePolicies {...props} />}
</>
);
};
8 changes: 8 additions & 0 deletions src/support/SupportResourceType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Billing } from 'src/libs/ajax/billing/Billing';
import { DataRepo } from 'src/libs/ajax/DataRepo';
import { Groups } from 'src/libs/ajax/Groups';
import { FullyQualifiedResourceId } from 'src/libs/ajax/SamResources';
import { User } from 'src/libs/ajax/User';
import { Workspaces } from 'src/libs/ajax/workspaces/Workspaces';

export type SupportSummary = object;
Expand All @@ -16,6 +17,7 @@ export interface SupportResourceType {
displayName: string;
resourceType: string;
loadSupportSummaryFn: ((id: FullyQualifiedResourceId) => Promise<SupportSummary>) | undefined;
skipPolicies?: boolean;
}

// Define the supported resources, add your own here
Expand Down Expand Up @@ -45,4 +47,10 @@ export const supportResources: SupportResourceType[] = [
resourceType: 'datasnapshot',
loadSupportSummaryFn: (id: FullyQualifiedResourceId) => DataRepo().admin().adminRetrieveSnapshot(id.resourceId),
},
{
displayName: 'User',
resourceType: 'user',
skipPolicies: true,
loadSupportSummaryFn: (id: FullyQualifiedResourceId) => User().getSupportSummary(id.resourceId),
},
].sort((a, b) => a.displayName.localeCompare(b.displayName));
Loading