Skip to content

Commit

Permalink
feat(scim): Disable form for updating teams on the frontend (#78732)
Browse files Browse the repository at this point in the history
Disables the team settings form when it has the `idp:provisioned` flag
set to true.

<img width="766" alt="image"
src="https://github.com/user-attachments/assets/05103d75-8869-4806-9edf-81cd4a1c6c42">


Requires #78722
  • Loading branch information
leeandher authored Oct 8, 2024
1 parent 02e4ef6 commit f273874
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -103,4 +103,21 @@ describe('TeamSettings', function () {

expect(TeamStore.getAll()).toEqual([]);
});

it('cannot modify idp:provisioned teams regardless of role', function () {
const team = TeamFixture({hasAccess: true, flags: {'idp:provisioned': true}});
const organization = OrganizationFixture({access: []});

render(<TeamSettings {...routerProps} team={team} params={{teamId: team.slug}} />, {
organization,
});

expect(
screen.getByText(
"This team is managed through your organization's identity provider. These settings cannot be modified."
)
).toBeInTheDocument();
expect(screen.getByRole('textbox', {name: 'Team Slug'})).toBeDisabled();
expect(screen.getByTestId('button-remove-team')).toBeDisabled();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import cloneDeep from 'lodash/cloneDeep';
import {addErrorMessage, addSuccessMessage} from 'sentry/actionCreators/indicator';
import {removeTeam, updateTeamSuccess} from 'sentry/actionCreators/teams';
import {hasEveryAccess} from 'sentry/components/acl/access';
import Alert from 'sentry/components/alert';
import {Button} from 'sentry/components/button';
import Confirm from 'sentry/components/confirm';
import FieldGroup from 'sentry/components/forms/fieldGroup';
Expand Down Expand Up @@ -56,6 +57,7 @@ function TeamSettings({team, params}: TeamSettingsProps) {

const hasTeamWrite = hasEveryAccess(['team:write'], {organization, team});
const hasTeamAdmin = hasEveryAccess(['team:admin'], {organization, team});
const isIdpProvisioned = team.flags['idp:provisioned'];

const forms = useMemo(() => {
const formsConfig = cloneDeep(teamSettingsFields);
Expand All @@ -81,6 +83,13 @@ function TeamSettings({team, params}: TeamSettingsProps) {
<SentryDocumentTitle title={t('Team Settings')} orgSlug={organization.slug} />

<PermissionAlert access={['team:write']} team={team} />
{isIdpProvisioned && (
<Alert type="warning" showIcon>
{t(
"This team is managed through your organization's identity provider. These settings cannot be modified."
)}
</Alert>
)}

<Form
apiMethod="PUT"
Expand All @@ -98,21 +107,23 @@ function TeamSettings({team, params}: TeamSettingsProps) {
additionalFieldProps={{
hasTeamWrite,
}}
disabled={isIdpProvisioned}
forms={forms}
/>
</Form>

<Panel>
<PanelHeader>{t('Team Administration')}</PanelHeader>
<FieldGroup
disabled={isIdpProvisioned}
label={t('Remove Team')}
help={t(
"This may affect team members' access to projects and associated alert delivery."
)}
>
<div>
<Confirm
disabled={!hasTeamAdmin}
disabled={isIdpProvisioned || !hasTeamAdmin}
onConfirm={handleRemoveTeam}
priority="danger"
message={tct('Are you sure you want to remove the team [team]?', {
Expand Down

0 comments on commit f273874

Please sign in to comment.