mirror of
https://github.com/hanzoai/sentinel.git
synced 2026-09-29 22:34:33 +00:00
FSL-1.0-Apache-2.0 grants us the code, not the name. "Sentry" is Functional Software's trademark, so every place the running app says it to a user -- page titles, onboarding, empty states, toasts, settings copy, the self-hosted footer -- now says Sentinel. Attribution is the other half of the deal and stays untouched: upstream copyright headers, LICENSE, NOTICE. So does anything where the mark is a fact rather than a brand -- @sentry/* packages, sentry-cli, the wizard and bundler plugins, docs.sentry.io, the whole gettingStartedDocs tree. Renaming those would leave instructions that no longer work. Nothing structural moved. No import, identifier, route path, feature flag, API field or test id changed; the diff is 312 lines in and 312 out. Colocated specs were updated in lockstep with the copy they assert. Marketing and community links point at hanzo.ai, only where a real page exists to point at. Co-authored-by: Hanzo Dev <[email protected]>
134 lines
4.0 KiB
TypeScript
134 lines
4.0 KiB
TypeScript
import {
|
|
addErrorMessage,
|
|
addLoadingMessage,
|
|
addSuccessMessage,
|
|
} from 'sentry/actionCreators/indicator';
|
|
import AlertLink from 'sentry/components/alertLink';
|
|
import {Button} from 'sentry/components/button';
|
|
import EmptyMessage from 'sentry/components/emptyMessage';
|
|
import ExternalLink from 'sentry/components/links/externalLink';
|
|
import Panel from 'sentry/components/panels/panel';
|
|
import PanelBody from 'sentry/components/panels/panelBody';
|
|
import PanelHeader from 'sentry/components/panels/panelHeader';
|
|
import {t, tct} from 'sentry/locale';
|
|
import type {InternalAppApiToken, Organization} from 'sentry/types';
|
|
import withOrganization from 'sentry/utils/withOrganization';
|
|
import DeprecatedAsyncView from 'sentry/views/deprecatedAsyncView';
|
|
import ApiTokenRow from 'sentry/views/settings/account/apiTokenRow';
|
|
import SettingsPageHeader from 'sentry/views/settings/components/settingsPageHeader';
|
|
import TextBlock from 'sentry/views/settings/components/text/textBlock';
|
|
|
|
type Props = {
|
|
organization: Organization;
|
|
} & DeprecatedAsyncView['props'];
|
|
|
|
type State = {
|
|
tokenList: InternalAppApiToken[] | null;
|
|
} & DeprecatedAsyncView['state'];
|
|
|
|
export class ApiTokens extends DeprecatedAsyncView<Props, State> {
|
|
getTitle() {
|
|
return t('User Auth Tokens');
|
|
}
|
|
|
|
getDefaultState() {
|
|
return {
|
|
...super.getDefaultState(),
|
|
tokenList: [],
|
|
};
|
|
}
|
|
|
|
getEndpoints(): ReturnType<DeprecatedAsyncView['getEndpoints']> {
|
|
return [['tokenList', '/api-tokens/']];
|
|
}
|
|
|
|
handleRemoveToken = (token: InternalAppApiToken) => {
|
|
addLoadingMessage();
|
|
const oldTokenList = this.state.tokenList;
|
|
|
|
this.setState(
|
|
state => ({
|
|
tokenList: state.tokenList?.filter(tk => tk.id !== token.id) ?? [],
|
|
}),
|
|
async () => {
|
|
try {
|
|
await this.api.requestPromise('/api-tokens/', {
|
|
method: 'DELETE',
|
|
data: {tokenId: token.id},
|
|
});
|
|
|
|
addSuccessMessage(t('Removed token'));
|
|
} catch (_err) {
|
|
addErrorMessage(t('Unable to remove token. Please try again.'));
|
|
this.setState({
|
|
tokenList: oldTokenList,
|
|
});
|
|
}
|
|
}
|
|
);
|
|
};
|
|
|
|
renderBody() {
|
|
const {organization} = this.props;
|
|
const {tokenList} = this.state;
|
|
|
|
const isEmpty = !Array.isArray(tokenList) || tokenList.length === 0;
|
|
|
|
const action = (
|
|
<Button
|
|
priority="primary"
|
|
size="sm"
|
|
to="/settings/account/api/auth-tokens/new-token/"
|
|
data-test-id="create-token"
|
|
>
|
|
{t('Create New Token')}
|
|
</Button>
|
|
);
|
|
|
|
return (
|
|
<div>
|
|
<SettingsPageHeader title={this.getTitle()} action={action} />
|
|
<AlertLink to={`/settings/${organization?.slug ?? ''}/auth-tokens/`}>
|
|
{t(
|
|
"User Auth Tokens are tied to the logged in user, meaning they'll stop working if the user leaves the organization! We suggest using Organization Auth Tokens to create/manage tokens tied to the organization instead."
|
|
)}
|
|
</AlertLink>
|
|
<TextBlock>
|
|
{t(
|
|
"Authentication tokens allow you to perform actions against the Sentinel API on behalf of your account. They're the easiest way to get started using the API."
|
|
)}
|
|
</TextBlock>
|
|
<TextBlock>
|
|
{tct(
|
|
'For more information on how to use the web API, see our [link:documentation].',
|
|
{
|
|
link: <ExternalLink href="https://docs.sentry.io/api/" />,
|
|
}
|
|
)}
|
|
</TextBlock>
|
|
<Panel>
|
|
<PanelHeader>{t('Auth Token')}</PanelHeader>
|
|
|
|
<PanelBody>
|
|
{isEmpty && (
|
|
<EmptyMessage>
|
|
{t("You haven't created any authentication tokens yet.")}
|
|
</EmptyMessage>
|
|
)}
|
|
|
|
{tokenList?.map(token => (
|
|
<ApiTokenRow
|
|
key={token.id}
|
|
token={token}
|
|
onRemove={this.handleRemoveToken}
|
|
/>
|
|
))}
|
|
</PanelBody>
|
|
</Panel>
|
|
</div>
|
|
);
|
|
}
|
|
}
|
|
|
|
export default withOrganization(ApiTokens);
|