Skip to content

Commit 5cd3825

Browse files
authored
fix(ui) Fix broken redirect on org rename (#72906)
When an organization changes their slug we should redirect to the new slug. This isn't working currently because of changes to OrganizationDetails that elide `features` by default. (#71791) As customer-domains will soon be retried and replaced with a system configuration feature flag, I've chosen to adapt the logic for org details settings to read from `ConfigStore` like it will in the future. Fixes HC-1096
1 parent 0bcc060 commit 5cd3825

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

Diff for: static/app/views/settings/organizationGeneralSettings/index.spec.tsx

+12-1
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,10 @@ import {
1313
within,
1414
} from 'sentry-test/reactTestingLibrary';
1515

16+
import ConfigStore from 'sentry/stores/configStore';
1617
import OrganizationsStore from 'sentry/stores/organizationsStore';
1718
import ProjectsStore from 'sentry/stores/projectsStore';
19+
import type {Config} from 'sentry/types/system';
1820
import {trackAnalytics} from 'sentry/utils/analytics';
1921
import {browserHistory} from 'sentry/utils/browserHistory';
2022
import OrganizationGeneralSettings from 'sentry/views/settings/organizationGeneralSettings';
@@ -24,6 +26,7 @@ jest.mock('sentry/utils/analytics');
2426
describe('OrganizationGeneralSettings', function () {
2527
const ENDPOINT = '/organizations/org-slug/';
2628
const {organization, router} = initializeOrg();
29+
let configState: Config;
2730

2831
const defaultProps = {
2932
organization,
@@ -36,6 +39,7 @@ describe('OrganizationGeneralSettings', function () {
3639
};
3740

3841
beforeEach(function () {
42+
configState = ConfigStore.getState();
3943
OrganizationsStore.addOrReplace(organization);
4044
MockApiClient.addMockResponse({
4145
url: `/organizations/${organization.slug}/auth-provider/`,
@@ -48,6 +52,12 @@ describe('OrganizationGeneralSettings', function () {
4852
});
4953
});
5054

55+
afterEach(function () {
56+
act(function () {
57+
ConfigStore.loadInitialData(configState);
58+
});
59+
});
60+
5161
it('can enable "early adopter"', async function () {
5262
render(<OrganizationGeneralSettings {...defaultProps} />);
5363
const mock = MockApiClient.addMockResponse({
@@ -121,7 +131,8 @@ describe('OrganizationGeneralSettings', function () {
121131
});
122132

123133
it('changes org slug and redirects to new customer-domain', async function () {
124-
const org = OrganizationFixture({features: ['customer-domains']});
134+
ConfigStore.set('features', new Set(['organizations:customer-domains']));
135+
const org = OrganizationFixture();
125136
const updateMock = MockApiClient.addMockResponse({
126137
url: `/organizations/${organization.slug}/`,
127138
method: 'PUT',

Diff for: static/app/views/settings/organizationGeneralSettings/index.tsx

+3-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import Panel from 'sentry/components/panels/panel';
1616
import PanelHeader from 'sentry/components/panels/panelHeader';
1717
import SentryDocumentTitle from 'sentry/components/sentryDocumentTitle';
1818
import {t, tct} from 'sentry/locale';
19+
import ConfigStore from 'sentry/stores/configStore';
1920
import type {Organization} from 'sentry/types/organization';
2021
import {trackAnalytics} from 'sentry/utils/analytics';
2122
import {browserHistory} from 'sentry/utils/browserHistory';
@@ -66,7 +67,8 @@ export default function OrganizationGeneralSettings({}: RouteComponentProps<{},
6667
if (updated.slug && updated.slug !== prevData.slug) {
6768
changeOrganizationSlug(prevData, updated);
6869

69-
if (updated.features.includes('customer-domains')) {
70+
// TODO(mark) Soon to be replaced with multi-region feature flag
71+
if (ConfigStore.get('features').has('organizations:customer-domains')) {
7072
const {organizationUrl} = updated.links;
7173
window.location.replace(`${organizationUrl}/settings/organization/`);
7274
} else {

0 commit comments

Comments
 (0)