mirror of
https://github.com/grafana/grafana.git
synced 2025-02-13 00:55:47 -06:00
* Add and configure eslint-plugin-import * Fix the lint:ts npm command * Autofix + prettier all the files * Manually fix remaining files * Move jquery code in jest-setup to external file to safely reorder imports * Resolve issue caused by circular dependencies within Prometheus * Update .betterer.results * Fix missing // @ts-ignore * ignore iconBundle.ts * Fix missing // @ts-ignore
61 lines
2.0 KiB
TypeScript
61 lines
2.0 KiB
TypeScript
import React, { FC } from 'react';
|
|
import { connect, ConnectedProps } from 'react-redux';
|
|
|
|
import { Input, Field, Form, Button, FieldSet, VerticalGroup } from '@grafana/ui';
|
|
import { SharedPreferences } from 'app/core/components/SharedPreferences/SharedPreferences';
|
|
import { contextSrv } from 'app/core/core';
|
|
import { AccessControlAction, Team } from 'app/types';
|
|
|
|
import { updateTeam } from './state/actions';
|
|
|
|
const mapDispatchToProps = {
|
|
updateTeam,
|
|
};
|
|
|
|
const connector = connect(null, mapDispatchToProps);
|
|
|
|
interface OwnProps {
|
|
team: Team;
|
|
}
|
|
export type Props = ConnectedProps<typeof connector> & OwnProps;
|
|
|
|
export const TeamSettings: FC<Props> = ({ team, updateTeam }) => {
|
|
const canWriteTeamSettings = contextSrv.hasPermissionInMetadata(AccessControlAction.ActionTeamsWrite, team);
|
|
|
|
return (
|
|
<VerticalGroup>
|
|
<FieldSet label="Team settings">
|
|
<Form
|
|
defaultValues={{ ...team }}
|
|
onSubmit={(formTeam: Team) => {
|
|
updateTeam(formTeam.name, formTeam.email);
|
|
}}
|
|
disabled={!canWriteTeamSettings}
|
|
>
|
|
{({ register }) => (
|
|
<>
|
|
<Field label="Name" disabled={!canWriteTeamSettings}>
|
|
<Input {...register('name', { required: true })} id="name-input" />
|
|
</Field>
|
|
|
|
<Field
|
|
label="Email"
|
|
description="This is optional and is primarily used to set the team profile avatar (via gravatar service)."
|
|
disabled={!canWriteTeamSettings}
|
|
>
|
|
<Input {...register('email')} placeholder="team@email.com" type="email" id="email-input" />
|
|
</Field>
|
|
<Button type="submit" disabled={!canWriteTeamSettings}>
|
|
Update
|
|
</Button>
|
|
</>
|
|
)}
|
|
</Form>
|
|
</FieldSet>
|
|
<SharedPreferences resourceUri={`teams/${team.id}`} disabled={!canWriteTeamSettings} />
|
|
</VerticalGroup>
|
|
);
|
|
};
|
|
|
|
export default connector(TeamSettings);
|