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

feature: add key prefix support to useTranslation hook #1371

Merged
merged 1 commit into from
Sep 8, 2021

Conversation

mdjastrzebski
Copy link
Contributor

@mdjastrzebski mdjastrzebski commented Sep 8, 2021

Add keyPrefix option for useTranslation hook (Issue #1359)

i18next.addResource('en', 'translation', 'very.deeply.nested.key', 'here!');
const { t } = useTranslation('translation', { i18n: i18next, keyPrefix: 'very.deeply.nested' });
const text = t('key'); // "here"

Checklist

  • only relevant code is changed (make a diff before you submit the PR)
  • run tests npm run test
  • tests are included

Checklist (for documentation change)

  • only relevant documentation part is changed (make a diff before you submit the PR)
  • motivation/reason is provided

Scope of changes:

  • Added keyPrefix param handling for useTranslation hook
  • Added test for checking the param
  • Added TS typing
  • Updated i18next dep to 2.6.0 (keyPrefix param added to getFixedT)

@coveralls
Copy link

Coverage Status

Coverage remained the same at 96.057% when pulling 80b2579 on mdjastrzebski:feature/key-prefix into ca410ff on i18next:master.

@adrai adrai merged commit 0404f39 into i18next:master Sep 8, 2021
@mdjastrzebski mdjastrzebski deleted the feature/key-prefix branch September 8, 2021 16:22
Jethro-M added a commit to yugabyte/yugabyte-db that referenced this pull request Jun 27, 2023
Summary:
**Context**
Currently in YugabyteDB, pg_stat_statements is used to track latency as aggregates and with columns showing
total_time, min_time, mean_time… for each query type.
The following commit added a query latency histogram column in pg_stat_statment to support tracking
the distribution of query latencies: 2fd44b1
The following commit added the histogram of latencies and calculated percentile latencies to the slow
queries response: 3b50cf9

We would like to expose the histogram of latencies on the YBA UI along with the set of calculated
percentile latencies (P99, P95, P90, etc.).

Prior to this diff, clicking on either a live query or a slow query will bring up the same side info panel
(`QueryInfoSidePanel.js`). This side panel simply iterates over the query object and writes the key values
onto the screen.

**Change**
This diff marks the previous `QueryInfoSidePanel.js` as 'legacy' and uses it as a fallback. This fallback
is used when the user is viewing a live query or a slow query on a universe with YBDB version <
2.19.1.0-b81.
This diff adds `QueryInfoSidePanel.tsx` to handle the new response payload for slow queries on universes
with YBDB version >= 2.19.1.0-b81. The new response payload type interface has been added in
`queries/helpers/types.ts`.

When data is missing the UI will use '-' as a placeholder.
When the histogram data is missing, the UI will just skip rendering it.

This diff also implements a reusable `CodeBlock` component. This component is simply displays the provided
code string and gives the user the option to copy the code string.

**Package Changes**
Upgrade `react-i18next` from `11.8.15` to `11.18.6`
  - This upgrade was motivated by the key prefix feature added in 11.12: i18next/react-i18next#1371

Test Plan:
Verify that the user is able to view the new slow query side panel when selecting slow queries on a
universe with YBDB version >= 2.19.1.0-b81.
Verify that the user is able to copy the code string in the code block.
Verify that the UI does not crash when viewing various queries (slow query, live query, slow query on
universes with YBDB version < 2.19.1.0-b81).

Reviewers: rmadhavan, asharma, kkannan

Reviewed By: kkannan

Subscribers: yugaware

Differential Revision: https://phorge.dev.yugabyte.com/D26236
Jethro-M added a commit to yugabyte/yugabyte-db that referenced this pull request Jul 6, 2023
… info panel for slow queries

Summary:
**Context**
Currently in YugabyteDB, pg_stat_statements is used to track latency as aggregates and with columns showing
total_time, min_time, mean_time… for each query type.
The following commit added a query latency histogram column in pg_stat_statment to support tracking
the distribution of query latencies: 2fd44b1
The following commit added the histogram of latencies and calculated percentile latencies to the slow
queries response: 3b50cf9

We would like to expose the histogram of latencies on the YBA UI along with the set of calculated
percentile latencies (P99, P95, P90, etc.).

Prior to this diff, clicking on either a live query or a slow query will bring up the same side info panel
(`QueryInfoSidePanel.js`). This side panel simply iterates over the query object and writes the key values
onto the screen.

**Change**
This diff marks the previous `QueryInfoSidePanel.js` as 'legacy' and uses it as a fallback. This fallback
is used when the user is viewing a live query or a slow query on a universe with YBDB version <
2.19.1.0-b81.
This diff adds `QueryInfoSidePanel.tsx` to handle the new response payload for slow queries on universes
with YBDB version >= 2.19.1.0-b81. The new response payload type interface has been added in
`queries/helpers/types.ts`.

When data is missing the UI will use '-' as a placeholder.
When the histogram data is missing, the UI will just skip rendering it.

This diff also implements a reusable `CodeBlock` component. This component is simply displays the provided
code string and gives the user the option to copy the code string.

**Package Changes**
Upgrade `react-i18next` from `11.8.15` to `11.18.6`
  - This upgrade was motivated by the key prefix feature added in 11.12: i18next/react-i18next#1371

Original commit: 4220609 / D26236

[PLAT-9456] Fix slow query side panel prop name and add label mapping

**Context**
In febb72f we replaced `rolname` with `userid`.
The `userid` field had no text label mapping so the UI showed an empty string as the label.
We should use 'User Id' as the label instead.

Original commit: 7f335e7 / D25146

Test Plan:
Verify that the user is able to view the new slow query side panel when selecting slow queries on a
universe with YBDB version >= 2.19.1.0-b81.
Verify that the user is able to copy the code string in the code block.
Verify that the UI does not crash when viewing various queries (slow query, live query, slow query on
universes with YBDB version < 2.19.1.0-b81).

- Create a universe with YBDB version <= 2.19.1.0-b80
- Verify that the user can see slow query details.
{F82818}
- Upgrade the universe to a version > 2.19.1.0-b80
- Verify that the user can see slow query details (now in a new component with latency data).
{F82577}

Reviewers: rmadhavan, asharma, kkannan

Reviewed By: kkannan

Subscribers: yugaware

Differential Revision: https://phorge.dev.yugabyte.com/D26692
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants