-
Notifications
You must be signed in to change notification settings - Fork 188
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7196ba6
commit a6ae221
Showing
2 changed files
with
85 additions
and
0 deletions.
There are no files selected for viewing
53 changes: 53 additions & 0 deletions
53
packages/compass-global-writes/src/components/shard-zones-description.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,53 @@ | ||
import { | ||
Body, | ||
css, | ||
Link, | ||
spacing, | ||
Subtitle, | ||
} from '@mongodb-js/compass-components'; | ||
import { useConnectionInfo } from '@mongodb-js/compass-connections/provider'; | ||
import React from 'react'; | ||
|
||
const paragraphStyles = css({ | ||
display: 'flex', | ||
flexDirection: 'column', | ||
gap: spacing[100], | ||
}); | ||
|
||
export function ShardZonesDescription() { | ||
const { atlasMetadata } = useConnectionInfo(); | ||
return ( | ||
<> | ||
<Subtitle>Location Codes</Subtitle> | ||
<div className={paragraphStyles}> | ||
<Body> | ||
Each document’s first field should include an ISO 3166-1 Alpha-2 code | ||
for the location it belongs to. | ||
</Body> | ||
<Body> | ||
We also support ISO 3166-2 subdivision codes for countries containing | ||
a cloud provider data center (both ISO 3166-1 and ISO 3166-2 codes may | ||
be used for these countries). All valid country codes and the zones to | ||
which they map are listed in the table below. Additionally, you can | ||
view a list of all location codes{' '} | ||
<Link href="/static/atlas/country_iso_codes.txt">here</Link>. | ||
</Body> | ||
<Body> | ||
{atlasMetadata?.projectId && atlasMetadata?.clusterName && ( | ||
<> | ||
Locations’ zone mapping can be changed by navigating to this | ||
clusters{' '} | ||
<Link | ||
href={`/v2/${atlasMetadata?.projectId}#/clusters/edit/${atlasMetadata?.clusterName}`} | ||
> | ||
Edit Configuration | ||
</Link>{' '} | ||
page and clicking the Configure Location Mappings’ link above the | ||
map. | ||
</> | ||
)} | ||
</Body> | ||
</div> | ||
</> | ||
); | ||
} |
32 changes: 32 additions & 0 deletions
32
packages/compass-global-writes/src/components/shard-zones-descripton.spec.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,32 @@ | ||
import React from 'react'; | ||
import { expect } from 'chai'; | ||
import { screen } from '@mongodb-js/testing-library-compass'; | ||
import type { ConnectionInfo } from '@mongodb-js/compass-connections/provider'; | ||
import { renderWithStore } from '../../tests/create-store'; | ||
import { ShardZonesDescription } from './shard-zones-description'; | ||
|
||
describe('ShardZonesDescription', () => { | ||
it('Provides link to Edit Configuration', async function () { | ||
const connectionInfo = { | ||
id: 'testConnection', | ||
connectionOptions: { | ||
connectionString: 'mongodb://test', | ||
}, | ||
atlasMetadata: { | ||
projectId: 'project1', | ||
clusterName: 'myCluster', | ||
} as ConnectionInfo['atlasMetadata'], | ||
}; | ||
await renderWithStore(<ShardZonesDescription />, { | ||
connectionInfo, | ||
}); | ||
|
||
const link = await screen.findByRole('link', { | ||
name: /Edit Configuration/, | ||
}); | ||
const expectedHref = `/v2/${connectionInfo.atlasMetadata?.projectId}#/clusters/edit/${connectionInfo.atlasMetadata?.clusterName}`; | ||
|
||
expect(link).to.be.visible; | ||
expect(link).to.have.attribute('href', expectedHref); | ||
}); | ||
}); |