Skip to content

Commit

Permalink
feat: rename access tokens to api keys (#6687)
Browse files Browse the repository at this point in the history
* feat: rename access tokens to api keys

* feat: update test cases

* feat: update delete token to delete key
  • Loading branch information
YounixM authored Dec 20, 2024
1 parent 04778b9 commit 2f62a9d
Show file tree
Hide file tree
Showing 10 changed files with 35 additions and 35 deletions.
2 changes: 1 addition & 1 deletion frontend/public/locales/en-GB/routes.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"alert_channels": "Alert Channels",
"organization_settings": "Organization Settings",
"ingestion_settings": "Ingestion Settings",
"api_keys": "Access Tokens",
"api_keys": "API Keys",
"my_settings": "My Settings",
"overview_metrics": "Overview Metrics",
"dbcall_metrics": "Database Calls",
Expand Down
2 changes: 1 addition & 1 deletion frontend/public/locales/en-GB/titles.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"MY_SETTINGS": "SigNoz | My Settings",
"ORG_SETTINGS": "SigNoz | Organization Settings",
"INGESTION_SETTINGS": "SigNoz | Ingestion Settings",
"API_KEYS": "SigNoz | Access Tokens",
"API_KEYS": "SigNoz | API Keys",
"SOMETHING_WENT_WRONG": "SigNoz | Something Went Wrong",
"UN_AUTHORIZED": "SigNoz | Unauthorized",
"NOT_FOUND": "SigNoz | Page Not Found",
Expand Down
2 changes: 1 addition & 1 deletion frontend/public/locales/en/apiKeys.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"delete_confirm_message": "Are you sure you want to delete {{keyName}} token? Deleting a token is irreversible and cannot be undone."
"delete_confirm_message": "Are you sure you want to delete {{keyName}} key? Deleting a key is irreversible and cannot be undone."
}
2 changes: 1 addition & 1 deletion frontend/public/locales/en/routes.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"alert_channels": "Alert Channels",
"organization_settings": "Organization Settings",
"ingestion_settings": "Ingestion Settings",
"api_keys": "Access Tokens",
"api_keys": "API Keys",
"my_settings": "My Settings",
"overview_metrics": "Overview Metrics",
"dbcall_metrics": "Database Calls",
Expand Down
2 changes: 1 addition & 1 deletion frontend/public/locales/en/titles.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"MY_SETTINGS": "SigNoz | My Settings",
"ORG_SETTINGS": "SigNoz | Organization Settings",
"INGESTION_SETTINGS": "SigNoz | Ingestion Settings",
"API_KEYS": "SigNoz | Access Tokens",
"API_KEYS": "SigNoz | API Keys",
"SOMETHING_WENT_WRONG": "SigNoz | Something Went Wrong",
"UN_AUTHORIZED": "SigNoz | Unauthorized",
"NOT_FOUND": "SigNoz | Page Not Found",
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/AppRoutes/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ export const oldRoutes = [
'/logs-explorer/live',
'/logs-save-views',
'/traces-save-views',
'/settings/api-keys',
'/settings/access-tokens',
];

export const oldNewRoutesMapping: Record<string, string> = {
Expand All @@ -442,7 +442,7 @@ export const oldNewRoutesMapping: Record<string, string> = {
'/logs-explorer/live': '/logs/logs-explorer/live',
'/logs-save-views': '/logs/saved-views',
'/traces-save-views': '/traces/saved-views',
'/settings/api-keys': '/settings/access-tokens',
'/settings/access-tokens': '/settings/api-keys',
};

export interface AppRoutes {
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/constants/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const ROUTES = {
MY_SETTINGS: '/my-settings',
SETTINGS: '/settings',
ORG_SETTINGS: '/settings/org-settings',
API_KEYS: '/settings/access-tokens',
API_KEYS: '/settings/api-keys',
INGESTION_SETTINGS: '/settings/ingestion-settings',
SOMETHING_WENT_WRONG: '/something-went-wrong',
UN_AUTHORIZED: '/un-authorized',
Expand Down
22 changes: 11 additions & 11 deletions frontend/src/container/APIKeys/APIKeys.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ describe('APIKeys component', () => {
});

it('renders APIKeys component without crashing', () => {
expect(screen.getByText('Access Tokens')).toBeInTheDocument();
expect(screen.getByText('API Keys')).toBeInTheDocument();
expect(
screen.getByText('Create and manage access tokens for the SigNoz API'),
screen.getByText('Create and manage API keys for the SigNoz API'),
).toBeInTheDocument();
});

Expand All @@ -40,27 +40,27 @@ describe('APIKeys component', () => {
);

await waitFor(() => {
expect(screen.getByText('No Expiry Token')).toBeInTheDocument();
expect(screen.getByText('1-5 of 18 tokens')).toBeInTheDocument();
expect(screen.getByText('No Expiry Key')).toBeInTheDocument();
expect(screen.getByText('1-5 of 18 keys')).toBeInTheDocument();
});
});

it('opens add new key modal on button click', async () => {
fireEvent.click(screen.getByText('New Token'));
fireEvent.click(screen.getByText('New Key'));
await waitFor(() => {
const createNewKeyBtn = screen.getByRole('button', {
name: /Create new token/i,
name: /Create new key/i,
});

expect(createNewKeyBtn).toBeInTheDocument();
});
});

it('closes add new key modal on cancel button click', async () => {
fireEvent.click(screen.getByText('New Token'));
fireEvent.click(screen.getByText('New Key'));

const createNewKeyBtn = screen.getByRole('button', {
name: /Create new token/i,
name: /Create new key/i,
});

await waitFor(() => {
Expand All @@ -79,18 +79,18 @@ describe('APIKeys component', () => {
),
);

fireEvent.click(screen.getByText('New Token'));
fireEvent.click(screen.getByText('New Key'));

const createNewKeyBtn = screen.getByRole('button', {
name: /Create new token/i,
name: /Create new key/i,
});

await waitFor(() => {
expect(createNewKeyBtn).toBeInTheDocument();
});

act(() => {
const inputElement = screen.getByPlaceholderText('Enter Token Name');
const inputElement = screen.getByPlaceholderText('Enter Key Name');
fireEvent.change(inputElement, { target: { value: 'Top Secret' } });
fireEvent.click(screen.getByTestId('create-form-admin-role-btn'));
fireEvent.click(createNewKeyBtn);
Expand Down
30 changes: 15 additions & 15 deletions frontend/src/container/APIKeys/APIKeys.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -512,15 +512,15 @@ function APIKeys(): JSX.Element {
<div className="api-key-container">
<div className="api-key-content">
<header>
<Typography.Title className="title">Access Tokens </Typography.Title>
<Typography.Title className="title">API Keys</Typography.Title>
<Typography.Text className="subtitle">
Create and manage access tokens for the SigNoz API
Create and manage API keys for the SigNoz API
</Typography.Text>
</header>

<div className="api-keys-search-add-new">
<Input
placeholder="Search for token..."
placeholder="Search for keys..."
prefix={<Search size={12} color={Color.BG_VANILLA_400} />}
value={searchValue}
onChange={handleSearch}
Expand All @@ -531,7 +531,7 @@ function APIKeys(): JSX.Element {
type="primary"
onClick={showAddModal}
>
<Plus size={14} /> New Token
<Plus size={14} /> New Key
</Button>
</div>

Expand All @@ -544,15 +544,15 @@ function APIKeys(): JSX.Element {
pageSize: 5,
hideOnSinglePage: true,
showTotal: (total: number, range: number[]): string =>
`${range[0]}-${range[1]} of ${total} tokens`,
`${range[0]}-${range[1]} of ${total} keys`,
}}
/>
</div>

{/* Delete Key Modal */}
<Modal
className="delete-api-key-modal"
title={<span className="title">Delete Token</span>}
title={<span className="title">Delete Key</span>}
open={isDeleteModalOpen}
closable
afterClose={handleModalClose}
Expand All @@ -574,7 +574,7 @@ function APIKeys(): JSX.Element {
onClick={onDeleteHandler}
className="delete-btn"
>
Delete Token
Delete key
</Button>,
]}
>
Expand All @@ -588,7 +588,7 @@ function APIKeys(): JSX.Element {
{/* Edit Key Modal */}
<Modal
className="api-key-modal"
title="Edit token"
title="Edit key"
open={isEditModalOpen}
key="edit-api-key-modal"
afterClose={handleModalClose}
Expand All @@ -612,7 +612,7 @@ function APIKeys(): JSX.Element {
icon={<Check size={14} />}
onClick={onUpdateApiKey}
>
Update Token
Update key
</Button>,
]}
>
Expand All @@ -632,7 +632,7 @@ function APIKeys(): JSX.Element {
label="Name"
rules={[{ required: true }, { type: 'string', min: 6 }]}
>
<Input placeholder="Enter Token Name" autoFocus />
<Input placeholder="Enter Key Name" autoFocus />
</Form.Item>

<Form.Item name="role" label="Role">
Expand Down Expand Up @@ -666,7 +666,7 @@ function APIKeys(): JSX.Element {
{/* Create New Key Modal */}
<Modal
className="api-key-modal"
title="Create new token"
title="Create new key"
open={isAddModalOpen}
key="create-api-key-modal"
closable
Expand All @@ -683,7 +683,7 @@ function APIKeys(): JSX.Element {
onClick={handleCopyClose}
icon={<Check size={12} />}
>
Copy token and close
Copy key and close
</Button>,
]
: [
Expand All @@ -704,7 +704,7 @@ function APIKeys(): JSX.Element {
loading={isLoadingCreateAPIKey}
onClick={onCreateAPIKey}
>
Create new token
Create new key
</Button>,
]
}
Expand All @@ -728,7 +728,7 @@ function APIKeys(): JSX.Element {
rules={[{ required: true }, { type: 'string', min: 6 }]}
validateTrigger="onFinish"
>
<Input placeholder="Enter Token Name" autoFocus />
<Input placeholder="Enter Key Name" autoFocus />
</Form.Item>

<Form.Item name="role" label="Role">
Expand Down Expand Up @@ -769,7 +769,7 @@ function APIKeys(): JSX.Element {
{showNewAPIKeyDetails && (
<div className="api-key-info-container">
<Row>
<Col span={8}>Token</Col>
<Col span={8}>Key</Col>
<Col span={16}>
<span className="copyable-text">
<Typography.Text>
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/mocks-server/__mockdata__/apiKeys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export const getAPIKeysResponse = {
},
token: '1udrUFmRI6gdb8r/hLabS7zRlgfMQlUw/tz9sac82pE=',
role: 'ADMIN',
name: 'No Expiry Token',
name: 'No Expiry Key',
createdAt: 1708008178,
expiresAt: 0,
updatedAt: 1708008190,
Expand Down

0 comments on commit 2f62a9d

Please sign in to comment.