Skip to content

Commit 8964a03

Browse files
chore(): Remove default_locale from StoreLocale (medusajs#14300)
## Summary **What** — What changes are introduced in this PR? Remove `default_locale` from Store <> Locale relation **Why** — Why are these changes relevant or necessary? *Please provide answer here* **How** — How have these changes been implemented? *Please provide answer here* **Testing** — How have these changes been tested, or how can the reviewer test the feature? *Please provide answer here* --- ## Examples Provide examples or code snippets that demonstrate how this feature works, or how it can be used in practice. This helps with documentation and ensures maintainers can quickly understand and verify the change. ```ts // Example usage ``` --- ## Checklist Please ensure the following before requesting a review: - [ ] I have added a **changeset** for this PR - Every non-breaking change should be marked as a **patch** - To add a changeset, run `yarn changeset` and follow the prompts - [ ] The changes are covered by relevant **tests** - [ ] I have verified the code works as intended locally - [ ] I have linked the related issue(s) if applicable --- ## Additional Context Add any additional context, related issues, or references that might help the reviewer understand this PR. Co-authored-by: Oli Juhl <[email protected]>
1 parent dd3eb10 commit 8964a03

File tree

23 files changed

+63
-226
lines changed

23 files changed

+63
-226
lines changed

.changeset/plain-bobcats-glow.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
"@medusajs/dashboard": patch
3+
"@medusajs/framework": patch
4+
"@medusajs/store": patch
5+
"@medusajs/types": patch
6+
"@medusajs/medusa": patch
7+
---
8+
9+
chore(): Remove default_locale from StoreLocale

integration-tests/http/__tests__/cart/store/cart-translation.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import { medusaIntegrationTestRunner } from "@medusajs/test-utils"
2+
import { MedusaContainer } from "@medusajs/types"
23
import { Modules, ProductStatus } from "@medusajs/utils"
34
import {
45
createAdminUser,
56
generatePublishableKey,
67
generateStoreHeaders,
78
} from "../../../../helpers/create-admin-user"
8-
import { MedusaContainer } from "@medusajs/types"
99

1010
jest.setTimeout(100000)
1111

@@ -63,7 +63,7 @@ medusaIntegrationTestRunner({
6363
)
6464
await storeModule.updateStores(defaultStore.id, {
6565
supported_locales: [
66-
{ locale_code: "en-US", is_default: true },
66+
{ locale_code: "en-US" },
6767
{ locale_code: "fr-FR" },
6868
{ locale_code: "de-DE" },
6969
],

integration-tests/http/__tests__/draft-order/admin/draft-order-translation.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ medusaIntegrationTestRunner({
4545
)
4646
await storeModule.updateStores(defaultStore.id, {
4747
supported_locales: [
48-
{ locale_code: "en-US", is_default: true },
48+
{ locale_code: "en-US" },
4949
{ locale_code: "fr-FR" },
5050
{ locale_code: "de-DE" },
5151
],

integration-tests/http/__tests__/exchanges/exchange-translation.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ medusaIntegrationTestRunner({
6161
)
6262
await storeModule.updateStores(defaultStore.id, {
6363
supported_locales: [
64-
{ locale_code: "en-US", is_default: true },
64+
{ locale_code: "en-US" },
6565
{ locale_code: "fr-FR" },
6666
{ locale_code: "de-DE" },
6767
],

integration-tests/http/__tests__/order-edits/order-edit-translation.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ medusaIntegrationTestRunner({
6060
)
6161
await storeModule.updateStores(defaultStore.id, {
6262
supported_locales: [
63-
{ locale_code: "en-US", is_default: true },
63+
{ locale_code: "en-US" },
6464
{ locale_code: "fr-FR" },
6565
{ locale_code: "de-DE" },
6666
],

integration-tests/http/__tests__/order/admin/order-translation.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ medusaIntegrationTestRunner({
6262
)
6363
await storeModule.updateStores(defaultStore.id, {
6464
supported_locales: [
65-
{ locale_code: "en-US", is_default: true },
65+
{ locale_code: "en-US" },
6666
{ locale_code: "fr-FR" },
6767
{ locale_code: "de-DE" },
6868
],

integration-tests/http/__tests__/translation/admin/translation.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { medusaIntegrationTestRunner } from "@medusajs/test-utils"
2+
import { MedusaContainer } from "@medusajs/types"
3+
import { Modules } from "@medusajs/utils"
24
import {
35
adminHeaders,
46
createAdminUser,
57
} from "../../../../helpers/create-admin-user"
6-
import { MedusaContainer } from "@medusajs/types"
7-
import { Modules } from "@medusajs/utils"
88

99
jest.setTimeout(100000)
1010

@@ -32,7 +32,7 @@ medusaIntegrationTestRunner({
3232
)
3333
await storeModule.updateStores(defaultStore.id, {
3434
supported_locales: [
35-
{ locale_code: "en-US", is_default: true },
35+
{ locale_code: "en-US" },
3636
{ locale_code: "fr-FR" },
3737
{ locale_code: "de-DE" },
3838
],

packages/admin/dashboard/src/routes/store/store-add-locales/components/add-locales-form/add-locales-form.tsx

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -100,19 +100,10 @@ export const AddLocalesForm = ({ store }: AddLocalesFormProps) => {
100100
new Set([...data.locales, ...preSelectedRows])
101101
) as string[]
102102

103-
let defaultLocale = store.supported_locales?.find(
104-
(l) => l.is_default
105-
)?.locale_code
106-
107-
if (!locales.includes(defaultLocale ?? "")) {
108-
defaultLocale = locales?.[0]
109-
}
110-
111103
await mutateAsync(
112104
{
113105
supported_locales: locales.map((l) => ({
114106
locale_code: l,
115-
is_default: l === defaultLocale,
116107
})),
117108
},
118109
{

packages/admin/dashboard/src/routes/store/store-detail/components/store-general-section/store-general-section.tsx

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,19 @@ import { Link } from "react-router-dom"
77
import { ActionMenu } from "../../../../../components/common/action-menu"
88
import { useSalesChannel, useStockLocation } from "../../../../../hooks/api"
99
import { useRegion } from "../../../../../hooks/api/regions"
10-
import { useFeatureFlag } from "../../../../../providers/feature-flag-provider"
1110

1211
type StoreGeneralSectionProps = {
1312
store: AdminStore
1413
}
1514

1615
export const StoreGeneralSection = ({ store }: StoreGeneralSectionProps) => {
1716
const { t } = useTranslation()
18-
const isTranslationsEnabled = useFeatureFlag("translation")
1917

2018
const { region } = useRegion(store.default_region_id!, undefined, {
2119
enabled: !!store.default_region_id,
2220
})
2321

2422
const defaultCurrency = store.supported_currencies?.find((c) => c.is_default)
25-
const defaultLocale = store.supported_locales?.find((l) => l.is_default)
2623

2724
const { sales_channel } = useSalesChannel(store.default_sales_channel_id!, {
2825
enabled: !!store.default_sales_channel_id,
@@ -88,27 +85,6 @@ export const StoreGeneralSection = ({ store }: StoreGeneralSectionProps) => {
8885
</Text>
8986
)}
9087
</div>
91-
{isTranslationsEnabled && (
92-
<div className="text-ui-fg-subtle grid grid-cols-2 px-6 py-4">
93-
<Text size="small" leading="compact" weight="plus">
94-
{t("store.defaultLocale")}
95-
</Text>
96-
{defaultLocale ? (
97-
<div className="flex items-center gap-x-2">
98-
<Badge size="2xsmall">
99-
{defaultLocale.locale_code?.toUpperCase()}
100-
</Badge>
101-
<Text size="small" leading="compact">
102-
{defaultLocale.locale?.name}
103-
</Text>
104-
</div>
105-
) : (
106-
<Text size="small" leading="compact">
107-
-
108-
</Text>
109-
)}
110-
</div>
111-
)}
11288
<div className="text-ui-fg-subtle grid grid-cols-2 px-6 py-4">
11389
<Text size="small" leading="compact" weight="plus">
11490
{t("store.defaultRegion")}

packages/admin/dashboard/src/routes/store/store-detail/components/store-locale-section/store-locale-section.tsx

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,6 @@ export const StoreLocaleSection = ({ store }: StoreLocaleSectionProps) => {
6060
meta: {
6161
storeId: store.id,
6262
supportedLocales: store.supported_locales,
63-
defaultLocaleCode: store.supported_locales?.find((l) => l.is_default)
64-
?.locale_code,
6563
},
6664
})
6765

@@ -165,12 +163,10 @@ const LocaleActions = ({
165163
storeId,
166164
locale,
167165
supportedLocales,
168-
defaultLocaleCode,
169166
}: {
170167
storeId: string
171168
locale: HttpTypes.AdminLocale
172169
supportedLocales: HttpTypes.AdminStoreLocale[]
173-
defaultLocaleCode: string
174170
}) => {
175171
const { mutateAsync } = useUpdateStore(storeId)
176172
const { t } = useTranslation()
@@ -218,7 +214,6 @@ const LocaleActions = ({
218214
icon: <Trash />,
219215
label: t("actions.remove"),
220216
onClick: handleRemove,
221-
disabled: locale.code === defaultLocaleCode,
222217
},
223218
],
224219
},
@@ -267,9 +262,7 @@ const useColumns = () => {
267262
columnHelper.display({
268263
id: "actions",
269264
cell: ({ row, table }) => {
270-
const { supportedLocales, storeId, defaultLocaleCode } = table.options
271-
.meta as {
272-
defaultLocaleCode: string
265+
const { supportedLocales, storeId } = table.options.meta as {
273266
supportedLocales: HttpTypes.AdminStoreLocale[]
274267
storeId: string
275268
}
@@ -279,7 +272,6 @@ const useColumns = () => {
279272
storeId={storeId}
280273
locale={row.original}
281274
supportedLocales={supportedLocales}
282-
defaultLocaleCode={defaultLocaleCode}
283275
/>
284276
)
285277
},

0 commit comments

Comments
 (0)