LightPrimary,
Link,
Note,
+ Spinner,
SubHeading,
} from 'design-system';
import { differenceWith, map, uniqBy } from 'lodash';
interface Props {
qualityGate: QualityGate;
+ isFetching?: boolean;
}
const FORBIDDEN_METRIC_TYPES = ['DATA', 'DISTRIB', 'STRING', 'BOOL'];
MetricKey.new_security_hotspots,
];
-export default function Conditions({ qualityGate }: Readonly<Props>) {
+export default function Conditions({ qualityGate, isFetching }: Readonly<Props>) {
const [editing, setEditing] = React.useState<boolean>(
qualityGate.caycStatus === CaycStatus.NonCompliant,
);
<HelperHintIcon />
</DocumentationTooltip>
)}
+ <Spinner loading={isFetching} className="it__spinner sw-ml-4 sw-mt-1" />
</div>
<div>
{(qualityGate.caycStatus === CaycStatus.NonCompliant || editing) && canEdit && (
}
export default function Details({ qualityGateName }: Readonly<Props>) {
- const { data: qualityGate, isLoading } = useQualityGateQuery(qualityGateName);
+ const { data: qualityGate, isLoading, isFetching } = useQualityGateQuery(qualityGateName);
return (
<main className="layout-page-main">
<>
<Helmet defer={false} title={qualityGate.name} />
<DetailsHeader qualityGate={qualityGate} />
- <DetailsContent qualityGate={qualityGate} />
+ <DetailsContent qualityGate={qualityGate} isFetching={isFetching} />
</>
)}
</Spinner>
export interface DetailsContentProps {
qualityGate: QualityGate;
+ isFetching?: boolean;
}
export function DetailsContent(props: DetailsContentProps) {
- const { qualityGate } = props;
- const actions = qualityGate.actions || {};
+ const { qualityGate, isFetching } = props;
+ const actions = qualityGate.actions ?? {};
return (
<div>
</FlagMessage>
)}
- <Conditions qualityGate={qualityGate} />
+ <Conditions qualityGate={qualityGate} isFetching={isFetching} />
<div className="sw-mt-10">
<div className="sw-flex sw-flex-col">
mutationFn: (condition: Omit<Condition, 'id'>) => {
return createCondition({ ...condition, gateName });
},
- onSuccess: () => {
+ onSuccess: (_, condition) => {
queryClient.invalidateQueries([QUALITY_GATES_KEY]);
+ queryClient.setQueryData([QUALITY_GATE_KEY, gateName], (oldData?: QualityGate) => {
+ return oldData?.conditions
+ ? {
+ ...oldData,
+ conditions: [...oldData.conditions, condition],
+ }
+ : undefined;
+ });
queryClient.invalidateQueries([QUALITY_GATE_KEY, gateName]);
addGlobalSuccessMessage(translate('quality_gates.condition_added'));
},