-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[license-checks] Revoke license keys from UI (#53220)
## Description Add button to revoke license key from the UI directly. This is useful if we ever need to revoke a license key (and we do not need to go to the DB to do it). ## Screenshots ### Before ![Screenshot 2023-06-09 at 11 45 38](https://github.com/sourcegraph/sourcegraph/assets/9974711/e1240d3f-a580-4ecf-ae0a-e6d9a877ee4e) ![Screenshot 2023-06-09 at 11 46 21](https://github.com/sourcegraph/sourcegraph/assets/9974711/0d7468e6-f3ae-49fc-92e7-78b7e16ac606) ### After <img width="934" alt="Screenshot 2023-06-09 at 12 00 29" src="https://github.com/sourcegraph/sourcegraph/assets/9974711/ade7bc69-ffba-4845-af3a-4e260522412c"> <img width="925" alt="Screenshot 2023-06-09 at 12 00 42" src="https://github.com/sourcegraph/sourcegraph/assets/9974711/0e70577d-6564-409f-9a05-0c3f536eabab"> ## Test plan Tested locally + some unit tests
- Loading branch information
Showing
18 changed files
with
408 additions
and
216 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
106 changes: 106 additions & 0 deletions
106
...b/src/enterprise/site-admin/dotcom/productSubscriptions/SiteAdminLicenseKeyLookupPage.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
import React, { useEffect, useState } from 'react' | ||
|
||
import { useSearchParams } from 'react-router-dom' | ||
|
||
import { Container, H2, Text } from '@sourcegraph/wildcard' | ||
|
||
import { | ||
ConnectionContainer, | ||
ConnectionError, | ||
ConnectionLoading, | ||
ConnectionList, | ||
SummaryContainer, | ||
ConnectionSummary, | ||
ShowMoreButton, | ||
ConnectionForm, | ||
} from '../../../../components/FilteredConnection/ui' | ||
import { PageTitle } from '../../../../components/PageTitle' | ||
import { eventLogger } from '../../../../tracking/eventLogger' | ||
|
||
import { useQueryProductLicensesConnection } from './backend' | ||
import { SiteAdminProductLicenseNode } from './SiteAdminProductLicenseNode' | ||
|
||
interface Props {} | ||
|
||
const SEARCH_PARAM_KEY = 'query' | ||
|
||
/** | ||
* Displays the product licenses that have been created on Sourcegraph.com. | ||
*/ | ||
export const SiteAdminLicenseKeyLookupPage: React.FunctionComponent<React.PropsWithChildren<Props>> = () => { | ||
useEffect(() => eventLogger.logPageView('SiteAdminLicenseKeyLookup'), []) | ||
|
||
const [searchParams, setSearchParams] = useSearchParams() | ||
|
||
const [search, setSearch] = useState<string>(searchParams.get(SEARCH_PARAM_KEY) ?? '') | ||
|
||
const { loading, hasNextPage, fetchMore, refetchAll, connection, error } = useQueryProductLicensesConnection( | ||
search, | ||
20 | ||
) | ||
|
||
useEffect(() => { | ||
const query = search?.trim() ?? '' | ||
searchParams.set(SEARCH_PARAM_KEY, query) | ||
setSearchParams(searchParams) | ||
}, [search, searchParams, setSearchParams]) | ||
|
||
return ( | ||
<div className="site-admin-product-subscriptions-page"> | ||
<PageTitle title="Product subscriptions" /> | ||
<H2>License key lookup</H2> | ||
<Text>Find matching licenses and their associated product subscriptions.</Text> | ||
<ConnectionContainer> | ||
{error && <ConnectionError errors={[error.message]} />} | ||
{loading && !connection && <ConnectionLoading />} | ||
<ConnectionForm | ||
inputValue={search} | ||
onInputChange={event => { | ||
const search = event.target.value | ||
setSearch(search) | ||
}} | ||
inputPlaceholder="Search product licenses..." | ||
/> | ||
<div className="text-muted mb-2"> | ||
<small>Enter a partial license key to find matches.</small> | ||
</div> | ||
{search && ( | ||
<Container> | ||
<ConnectionList | ||
as="ul" | ||
className="list-group list-group-flush mb-0" | ||
aria-label="Subscription licenses" | ||
> | ||
{connection?.nodes?.length === 0 && ( | ||
<div className="text-center">No matching license key found.</div> | ||
)} | ||
|
||
{connection?.nodes?.map(node => ( | ||
<SiteAdminProductLicenseNode | ||
key={node.id} | ||
node={node} | ||
showSubscription={true} | ||
onRevokeCompleted={refetchAll} | ||
/> | ||
))} | ||
</ConnectionList> | ||
</Container> | ||
)} | ||
{connection && ( | ||
<SummaryContainer className="mt-2"> | ||
<ConnectionSummary | ||
first={15} | ||
centered={true} | ||
connection={connection} | ||
noun="product license" | ||
pluralNoun="product licenses" | ||
hasNextPage={hasNextPage} | ||
noSummaryIfAllNodesVisible={true} | ||
/> | ||
{hasNextPage && <ShowMoreButton centered={true} onClick={fetchMore} />} | ||
</SummaryContainer> | ||
)} | ||
</ConnectionContainer> | ||
</div> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.