Skip to content
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
7 changes: 6 additions & 1 deletion src/sentry/api/endpoints/organization_integrations.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,15 @@ def get(self, request, organization):
if "provider_key" in request.GET:
integrations = integrations.filter(integration__provider=request.GET["provider_key"])

# include the configurations by default if no param
include_config = True
if request.GET.get("includeConfig") == "0":
include_config = False

return self.paginate(
queryset=integrations,
request=request,
order_by="integration__name",
on_results=lambda x: serialize(x, request.user),
on_results=lambda x: serialize(x, request.user, include_config=include_config),
paginator_cls=OffsetPaginator,
)
12 changes: 10 additions & 2 deletions src/sentry/api/serializers/models/integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,12 @@ class IntegrationConfigSerializer(IntegrationSerializer):
def __init__(self, organization_id=None):
self.organization_id = organization_id

def serialize(self, obj, attrs, user):
def serialize(self, obj, attrs, user, include_config=True):
data = super(IntegrationConfigSerializer, self).serialize(obj, attrs, user)

if not include_config:
return data

data.update({"configOrganization": []})

try:
Expand All @@ -54,7 +57,7 @@ def serialize(self, obj, attrs, user):

@register(OrganizationIntegration)
class OrganizationIntegrationSerializer(Serializer):
def serialize(self, obj, attrs, user):
def serialize(self, obj, attrs, user, include_config=True):
# XXX(epurkhiser): This is O(n) for integrations, especially since
# we're using the IntegrationConfigSerializer which pulls in the
# integration installation config object which very well may be making
Expand All @@ -63,7 +66,12 @@ def serialize(self, obj, attrs, user):
objects=obj.integration,
user=user,
serializer=IntegrationConfigSerializer(obj.organization.id),
include_config=include_config,
)

# TODO: skip adding configData if include_config is False
# we need to wait until the Slack migration is complete first
# because we have a dependency on configData in the integration directory
try:
installation = obj.integration.get_installation(obj.organization_id)
except NotImplementedError:
Expand Down
4 changes: 4 additions & 0 deletions src/sentry/db/models/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ def defer(self, *args, **kwargs):
raise NotImplementedError("Use ``values_list`` instead [performance].")

def only(self, *args, **kwargs):
# In rare cases Django can use this if a field is unexpectedly deferred. This
# mostly can happen if a field is added to a model, and then an old pickle is
# passed to a process running the new code. So if you see this error after a
# deploy of a model with a new field, it'll likely fix itself post-deploy.
raise NotImplementedError("Use ``values_list`` instead [performance].")


Expand Down
11 changes: 9 additions & 2 deletions src/sentry/integrations/msteams/card_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -671,7 +671,12 @@ def build_group_card(group, event, rules, integration):
action_cards = build_group_action_cards(group, event, rules, integration)
body.append(action_cards)

return {"type": "AdaptiveCard", "body": body}
return {
"type": "AdaptiveCard",
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
"version": "1.2",
"body": body,
}


def build_linking_card(url):
Expand Down Expand Up @@ -715,6 +720,8 @@ def build_linked_card():
return {
"type": "AdaptiveCard",
"body": [body],
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
"version": "1.2",
}


Expand Down Expand Up @@ -746,7 +753,7 @@ def build_incident_attachment(incident, metric_value=None):
return {
"type": "AdaptiveCard",
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
"version": "1.3",
"version": "1.2",
"body": [
{
"type": "ColumnSet",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,21 @@ import {
} from 'app/actionCreators/indicator';
import {t} from 'app/locale';

const callbackWithArgs = function (callback, ...args) {
if (isFunction(callback)) {
callback = callback.bind(this, ...args);
} else {
callback = null;
}
return callback;
const callbackWithArgs = function (context: any, callback: any, ...args: any) {
return isFunction(callback) ? callback.bind(context, ...args) : undefined;
};

class PluginComponentBase extends React.Component {
constructor(props, context) {
type GenericFieldProps = Parameters<typeof GenericField>[0];

type Props = {};

type State = {state: GenericFieldProps['formState']};

class PluginComponentBase<
P extends Props = Props,
S extends State = State
> extends React.Component<P, S> {
constructor(props: P, context: any) {
super(props, context);

[
Expand All @@ -40,44 +44,46 @@ class PluginComponentBase extends React.Component {
if (this.onSubmit) {
this.onSubmit = this.onSave.bind(this, this.onSubmit.bind(this));
}

this.state = {
state: FormState.READY,
};
}

UNSAFE_componentWillMount() {
this.api = new Client();
} as Readonly<S>;
}

componentWillUnmount() {
this.api.clear();
}

api = new Client();

fetchData() {
// Allow children to implement this
}

onSubmit() {
// Allow children to implement this
}

onLoad(callback, ...args) {
this.setState(
{
state: FormState.LOADING,
},
callbackWithArgs(callback, ...args)
callbackWithArgs(this, callback, ...args)
);
}

onLoadSuccess(callback, ...args) {
this.setState(
{
state: FormState.READY,
},
callbackWithArgs(callback, ...args)
);
onLoadSuccess() {
this.setState({
state: FormState.READY,
});
}

onLoadError(callback, ...args) {
this.setState(
{
state: FormState.ERROR,
},
callbackWithArgs(callback, ...args)
callbackWithArgs(this, callback, ...args)
);
addErrorMessage(t('An error occurred.'));
}
Expand All @@ -86,7 +92,7 @@ class PluginComponentBase extends React.Component {
if (this.state.state === FormState.SAVING) {
return;
}
callback = callbackWithArgs(callback, ...args);
callback = callbackWithArgs(this, callback, ...args);
this.setState(
{
state: FormState.SAVING,
Expand All @@ -99,7 +105,7 @@ class PluginComponentBase extends React.Component {
}

onSaveSuccess(callback, ...args) {
callback = callbackWithArgs(callback, ...args);
callback = callbackWithArgs(this, callback, ...args);
this.setState(
{
state: FormState.READY,
Expand All @@ -112,7 +118,7 @@ class PluginComponentBase extends React.Component {
}

onSaveError(callback, ...args) {
callback = callbackWithArgs(callback, ...args);
callback = callbackWithArgs(this, callback, ...args);
this.setState(
{
state: FormState.ERROR,
Expand All @@ -126,15 +132,17 @@ class PluginComponentBase extends React.Component {

onSaveComplete(callback, ...args) {
clearIndicators();
callback = callbackWithArgs(callback, ...args);
callback = callbackWithArgs(this, callback, ...args);
callback && callback();
}

renderField(props) {
renderField(props: Omit<GenericFieldProps, 'formState'>) {
props = {...props};
props.formState = this.state.state;
props.config = props.config || {};
return <GenericField key={props.config.name} {...props} />;
const newProps = {
...props,
formState: this.state.state,
};
return <GenericField key={newProps.config?.name} {...newProps} />;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,18 @@ import space from 'app/styles/space';

type Props = {
frame: Frame;
registers: {[key: string]: string};
components: Array<SentryAppComponent>;
isExpanded?: boolean;
hasContextSource?: boolean;
hasContextVars?: boolean;
hasContextRegisters?: boolean;
emptySourceNotation?: boolean;
hasAssembly?: boolean;
expandable?: boolean;
registers: {[key: string]: string};
components: Array<SentryAppComponent>;
};

const FrameContext = ({
const Context = ({
hasContextVars = false,
hasContextSource = false,
hasContextRegisters = false,
Expand Down Expand Up @@ -120,7 +120,7 @@ const FrameContext = ({
);
};

export default FrameContext;
export default Context;

const StyledClippedBox = styled(ClippedBox)`
margin-left: 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ import {t} from 'app/locale';
import {getMeta} from 'app/components/events/meta/metaProxy';
import space from 'app/styles/space';

import FrameFunctionName from './frameFunctionName';
import {getPlatform, trimPackage} from './utils';
import FrameDefaultTitleOriginalSourceInfo from './frameDefaultTitleOriginalSourceInfo';
import FunctionName from '../functionName';
import {getPlatform, trimPackage} from '../utils';
import OriginalSourceInfo from './originalSourceInfo';

type Props = {
frame: Frame;
Expand All @@ -23,7 +23,7 @@ type Props = {

type GetPathNameOutput = {key: string; value: string; meta?: Meta};

const FrameDefaultTitle = ({frame, platform}: Props) => {
const DefaultTitle = ({frame, platform}: Props) => {
const title: Array<React.ReactElement> = [];
const framePlatform = getPlatform(frame.platform, platform);

Expand Down Expand Up @@ -113,7 +113,7 @@ const FrameDefaultTitle = ({frame, platform}: Props) => {
}

if (defined(frame.function) || defined(frame.rawFunction)) {
title.push(<FrameFunctionName frame={frame} key="function" className="function" />);
title.push(<FunctionName frame={frame} key="function" className="function" />);
}

// we don't want to render out zero line numbers which are used to
Expand Down Expand Up @@ -149,9 +149,7 @@ const FrameDefaultTitle = ({frame, platform}: Props) => {
title.push(
<Tooltip
key="info-tooltip"
title={
<FrameDefaultTitleOriginalSourceInfo mapUrl={frame.mapUrl} map={frame.map} />
}
title={<OriginalSourceInfo mapUrl={frame.mapUrl} map={frame.map} />}
>
<a className="in-at original-src">
<IconQuestion size="xs" />
Expand All @@ -169,4 +167,4 @@ const StyledExternalLink = styled(ExternalLink)`
margin-left: ${space(0.5)};
`;

export default FrameDefaultTitle;
export default DefaultTitle;
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ type Props = {

// TODO(Priscila): Remove BR tags
// mapUrl not always present; e.g. uploaded source maps
const FrameDefaultTitleOriginalSourceInfo = ({mapUrl, map}: Props) => (
const OriginalSourceInfo = ({mapUrl, map}: Props) => (
<React.Fragment>
<strong>{t('Source Map')}</strong>
<br />
Expand All @@ -18,4 +18,4 @@ const FrameDefaultTitleOriginalSourceInfo = ({mapUrl, map}: Props) => (
</React.Fragment>
);

export default FrameDefaultTitleOriginalSourceInfo;
export default OriginalSourceInfo;
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ type ToggleValueOutput =
meta?: Meta;
};

class FrameFunctionName extends React.Component<Props, State> {
class FunctionName extends React.Component<Props, State> {
static propTypes = {
frame: PropTypes.object,
};
Expand Down Expand Up @@ -91,4 +91,4 @@ class FrameFunctionName extends React.Component<Props, State> {
}
}

export default FrameFunctionName;
export default FunctionName;
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ import overflowEllipsis from 'app/styles/overflowEllipsis';
import {Frame, SentryAppComponent, PlatformType} from 'app/types';
import DebugImage from 'app/components/events/interfaces/debugMeta/debugImage';

import FrameDefaultTitle from './frameDefaultTitle';
import FrameContext from './frameContext';
import FrameFunctionName from './frameFunctionName';
import FrameContext from './context';
import FunctionName from './functionName';
import {getPlatform} from './utils';
import DefaultTitle from './defaultTitle';

type Props = {
data: Frame;
Expand All @@ -47,7 +47,7 @@ type State = {
isExpanded?: boolean;
};

export class FrameLine extends React.Component<Props, State> {
export class Line extends React.Component<Props, State> {
static propTypes: any = {
data: PropTypes.object.isRequired,
nextFrame: PropTypes.object,
Expand Down Expand Up @@ -268,7 +268,7 @@ export class FrameLine extends React.Component<Props, State> {
<VertCenterWrapper>
<div>
{this.renderLeadHint()}
<FrameDefaultTitle frame={this.props.data} platform={this.props.platform} />
<DefaultTitle frame={this.props.data} platform={this.props.platform} />
</div>
{this.renderRepeats()}
</VertCenterWrapper>
Expand Down Expand Up @@ -318,7 +318,7 @@ export class FrameLine extends React.Component<Props, State> {
/>
)}
<Symbol className="symbol">
<FrameFunctionName frame={data} />{' '}
<FunctionName frame={data} />{' '}
{hint !== null ? (
<HintStatus>
<Tooltip title={hint}>{hintIcon}</Tooltip>
Expand Down Expand Up @@ -471,4 +471,4 @@ const LeadHint = styled('div')`
width: 67px;
`;

export default withSentryAppComponents(FrameLine, {componentType: 'stacktrace-link'});
export default withSentryAppComponents(Line, {componentType: 'stacktrace-link'});
Loading