mirror of
https://github.com/datahub-project/datahub.git
synced 2025-08-17 13:45:54 +00:00
fix(ui/ingest): Support invalid cron jobs (#10998)
This commit is contained in:
parent
01b3461d99
commit
0274c70292
@ -127,6 +127,7 @@ const UserContextProvider = ({ children }: { children: React.ReactNode }) => {
|
||||
return (
|
||||
<UserContext.Provider
|
||||
value={{
|
||||
loaded: !!meData,
|
||||
urn: meData?.me?.corpUser?.urn,
|
||||
user: meData?.me?.corpUser as CorpUser,
|
||||
platformPrivileges: meData?.me?.platformPrivileges as PlatformPrivileges,
|
||||
|
@ -28,6 +28,7 @@ export type State = {
|
||||
* Context about the currently-authenticated user.
|
||||
*/
|
||||
export type UserContextType = {
|
||||
loaded: boolean;
|
||||
urn?: string | null;
|
||||
user?: CorpUser | null;
|
||||
platformPrivileges?: PlatformPrivileges | null;
|
||||
@ -53,6 +54,7 @@ export const DEFAULT_STATE: State = {
|
||||
};
|
||||
|
||||
export const DEFAULT_CONTEXT = {
|
||||
loaded: false,
|
||||
urn: undefined,
|
||||
user: undefined,
|
||||
state: DEFAULT_STATE,
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { Tabs, Typography } from 'antd';
|
||||
import React, { useState } from 'react';
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import styled from 'styled-components';
|
||||
import { IngestionSourceList } from './source/IngestionSourceList';
|
||||
import { useAppConfig } from '../useAppConfig';
|
||||
@ -51,12 +51,18 @@ export const ManageIngestionPage = () => {
|
||||
* Determines which view should be visible: ingestion sources or secrets.
|
||||
*/
|
||||
const me = useUserContext();
|
||||
const { config } = useAppConfig();
|
||||
const { config, loaded } = useAppConfig();
|
||||
const isIngestionEnabled = config?.managedIngestionConfig.enabled;
|
||||
const showIngestionTab = isIngestionEnabled && me && me.platformPrivileges?.manageIngestion;
|
||||
const showSecretsTab = isIngestionEnabled && me && me.platformPrivileges?.manageSecrets;
|
||||
const defaultTab = showIngestionTab ? TabType.Sources : TabType.Secrets;
|
||||
const [selectedTab, setSelectedTab] = useState<TabType>(defaultTab);
|
||||
const [selectedTab, setSelectedTab] = useState<TabType>(TabType.Sources);
|
||||
|
||||
// defaultTab might not be calculated correctly on mount, if `config` or `me` haven't been loaded yet
|
||||
useEffect(() => {
|
||||
if (loaded && me.loaded && !showIngestionTab && selectedTab === TabType.Sources) {
|
||||
setSelectedTab(TabType.Secrets);
|
||||
}
|
||||
}, [loaded, me.loaded, showIngestionTab, selectedTab]);
|
||||
|
||||
const onClickTab = (newTab: string) => {
|
||||
setSelectedTab(TabType[newTab]);
|
||||
|
@ -106,7 +106,13 @@ export function LastExecutionColumn(time: any) {
|
||||
}
|
||||
|
||||
export function ScheduleColumn(schedule: any, record: any) {
|
||||
const tooltip = schedule && `Runs ${cronstrue.toString(schedule).toLowerCase()} (${record.timezone})`;
|
||||
let tooltip: string;
|
||||
try {
|
||||
tooltip = schedule && `Runs ${cronstrue.toString(schedule).toLowerCase()} (${record.timezone})`;
|
||||
} catch (e) {
|
||||
tooltip = 'Invalid cron schedule';
|
||||
console.debug('Error parsing cron schedule', e);
|
||||
}
|
||||
return (
|
||||
<Tooltip title={tooltip || 'Not scheduled'}>
|
||||
<Typography.Text code>{schedule || 'None'}</Typography.Text>
|
||||
|
@ -11,6 +11,7 @@ describe("managing secrets for ingestion creation", () => {
|
||||
// Navigate to the manage ingestion page → secrets
|
||||
cy.loginWithCredentials();
|
||||
cy.goToIngestionPage();
|
||||
cy.clickOptionWithText("Secrets");
|
||||
|
||||
// Create a new secret
|
||||
cy.clickOptionWithTestId("create-secret-button");
|
||||
|
Loading…
x
Reference in New Issue
Block a user