Fix types so the store can return undefined teams (#26386)

* Fix types so the store can return undefined teams

* Fix post test

* fix snapshots

* Address feedback
Этот коммит содержится в:
Daniel Espino García
2024-04-22 12:42:13 +02:00
коммит произвёл GitHub
родитель 7b90b7c2e0
Коммит d0a67cd84a
82 изменённых файлов: 332 добавлений и 206 удалений

Просмотреть файл

@@ -7,9 +7,11 @@ import React from 'react';
import DeleteIntegrationLink from 'components/integrations/delete_integration_link';
import InstalledOAuthApp from 'components/integrations/installed_oauth_app/installed_oauth_app';
import {TestHelper} from 'utils/test_helper';
describe('components/integrations/InstalledOAuthApp', () => {
const FAKE_SECRET = '***************';
const team = {name: 'team_name'};
const team = TestHelper.getTeamMock({name: 'team_name'});
const oauthApp = {
id: 'facxd9wpzpbpfp8pad78xj75pr',
name: 'testApp',

Просмотреть файл

@@ -31,7 +31,7 @@ export type InstalledOAuthAppProps = {
/**
* The team data
*/
team: Partial<Team>;
team?: Team;
/**
* The oauthApp data
@@ -255,7 +255,7 @@ export default class InstalledOAuthApp extends React.PureComponent<InstalledOAut
{' - '}
{regen}
{' - '}
<Link to={`/${this.props.team.name}/integrations/oauth2-apps/edit?id=${oauthApp.id}`}>
<Link to={`/${this.props.team?.name}/integrations/oauth2-apps/edit?id=${oauthApp.id}`}>
<FormattedMessage
id='installed_integrations.edit'
defaultMessage='Edit'

Просмотреть файл

@@ -85,7 +85,21 @@ exports[`components/integrations/InstalledOAuthApps should match snapshot 2`] =
onRegenerateSecret={[MockFunction]}
team={
Object {
"allow_open_invite": false,
"allowed_domains": "",
"company_name": "",
"create_at": 0,
"delete_at": 0,
"description": "",
"display_name": "name",
"email": "",
"group_constrained": false,
"id": "team_id",
"invite_id": "",
"name": "test",
"scheme_id": "id",
"type": "O",
"update_at": 0,
}
}
/>
@@ -122,7 +136,21 @@ exports[`components/integrations/InstalledOAuthApps should match snapshot for Ap
onRegenerateSecret={[MockFunction]}
team={
Object {
"allow_open_invite": false,
"allowed_domains": "",
"company_name": "",
"create_at": 0,
"delete_at": 0,
"description": "",
"display_name": "name",
"email": "",
"group_constrained": false,
"id": "team_id",
"invite_id": "",
"name": "test",
"scheme_id": "id",
"type": "O",
"update_at": 0,
}
}
/>

Просмотреть файл

@@ -7,6 +7,8 @@ import React from 'react';
import BackstageList from 'components/backstage/components/backstage_list';
import InstalledOAuthApps from 'components/integrations/installed_oauth_apps/installed_oauth_apps';
import {TestHelper} from 'utils/test_helper';
describe('components/integrations/InstalledOAuthApps', () => {
const oauthApps = {
facxd9wpzpbpfp8pad78xj75pr: {
@@ -38,9 +40,9 @@ describe('components/integrations/InstalledOAuthApps', () => {
};
const baseProps = {
team: {
team: TestHelper.getTeamMock({
name: 'test',
},
}),
oauthApps,
canManageOauth: true,
actions: {

Просмотреть файл

@@ -5,6 +5,7 @@ import React from 'react';
import {FormattedMessage} from 'react-intl';
import type {OAuthApp} from '@mattermost/types/integrations';
import type {Team} from '@mattermost/types/teams';
import type {ActionResult} from 'mattermost-redux/types/actions';
@@ -23,7 +24,7 @@ type Props = {
/**
* The team data
*/
team: {name: string};
team?: Team;
/**
* The oauthApps data
@@ -123,7 +124,10 @@ export default class InstalledOAuthApps extends React.PureComponent<Props, State
);
});
render(): JSX.Element {
render() {
if (!this.props.team) {
return null;
}
const integrationsEnabled = this.props.enableOAuthServiceProvider && this.props.canManageOauth;
let props;
if (integrationsEnabled) {