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

fix(ui): Update localstorage when project is deleted #29104

Merged
merged 4 commits into from
Oct 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,15 @@ import isEqual from 'lodash/isEqual';
import pick from 'lodash/pick';
import pickBy from 'lodash/pickBy';

import {DATE_TIME_KEYS, URL_PARAM} from 'app/constants/globalSelectionHeader';
import {
DATE_TIME_KEYS,
LOCAL_STORAGE_KEY,
URL_PARAM,
} from 'app/constants/globalSelectionHeader';
import {GlobalSelection} from 'app/types';
import {defined} from 'app/utils';
import {getUtcToLocalDateObject} from 'app/utils/dates';
import localStorage from 'app/utils/localStorage';

import {getParams} from './getParams';

Expand Down Expand Up @@ -117,3 +122,11 @@ export function isSelectionEqual(
}
return true;
}

/**
* Removes globalselection from localstorage
*/
export function removeGlobalSelectionStorage(orgId) {
const localStorageKey = `${LOCAL_STORAGE_KEY}:${orgId}`;
localStorage.removeItem(localStorageKey);
}
4 changes: 4 additions & 0 deletions static/app/views/settings/projectGeneralSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
import ProjectActions from 'app/actions/projectActions';
import Button from 'app/components/button';
import Confirm from 'app/components/confirm';
import {removeGlobalSelectionStorage} from 'app/components/organizations/globalSelectionHeader/utils';
import {Panel, PanelAlert, PanelHeader} from 'app/components/panels';
import {fields} from 'app/data/forms/projectGeneralSettings';
import {t, tct} from 'app/locale';
Expand Down Expand Up @@ -59,6 +60,9 @@ class ProjectGeneralSettings extends AsyncView<Props, State> {
handleRemoveProject = () => {
const {orgId} = this.props.params;
const project = this.state.data;

removeGlobalSelectionStorage(orgId);

if (!project) {
return;
}
Expand Down
4 changes: 4 additions & 0 deletions tests/js/spec/views/settings/projectGeneralSettings.spec.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@ import {mountGlobalModal} from 'sentry-test/modal';
import {selectByValue} from 'sentry-test/select-new';

import {addErrorMessage, addSuccessMessage} from 'app/actionCreators/indicator';
import {removeGlobalSelectionStorage} from 'app/components/organizations/globalSelectionHeader/utils';
import ProjectsStore from 'app/stores/projectsStore';
import ProjectContext from 'app/views/projects/projectContext';
import ProjectGeneralSettings from 'app/views/settings/projectGeneralSettings';

jest.mock('app/actionCreators/indicator');
jest.mock('app/components/organizations/globalSelectionHeader/utils');

describe('projectGeneralSettings', function () {
const org = TestStubs.Organization();
Expand Down Expand Up @@ -136,6 +138,8 @@ describe('projectGeneralSettings', function () {
modal.find('Button[priority="danger"]').simulate('click');

expect(deleteMock).toHaveBeenCalled();

expect(removeGlobalSelectionStorage).toHaveBeenCalledWith('org-slug');
});

it('project admins can transfer project', async function () {
Expand Down