mirror of
https://github.com/datahub-project/datahub.git
synced 2025-08-18 14:16:48 +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 (
|
return (
|
||||||
<UserContext.Provider
|
<UserContext.Provider
|
||||||
value={{
|
value={{
|
||||||
|
loaded: !!meData,
|
||||||
urn: meData?.me?.corpUser?.urn,
|
urn: meData?.me?.corpUser?.urn,
|
||||||
user: meData?.me?.corpUser as CorpUser,
|
user: meData?.me?.corpUser as CorpUser,
|
||||||
platformPrivileges: meData?.me?.platformPrivileges as PlatformPrivileges,
|
platformPrivileges: meData?.me?.platformPrivileges as PlatformPrivileges,
|
||||||
|
@ -28,6 +28,7 @@ export type State = {
|
|||||||
* Context about the currently-authenticated user.
|
* Context about the currently-authenticated user.
|
||||||
*/
|
*/
|
||||||
export type UserContextType = {
|
export type UserContextType = {
|
||||||
|
loaded: boolean;
|
||||||
urn?: string | null;
|
urn?: string | null;
|
||||||
user?: CorpUser | null;
|
user?: CorpUser | null;
|
||||||
platformPrivileges?: PlatformPrivileges | null;
|
platformPrivileges?: PlatformPrivileges | null;
|
||||||
@ -53,6 +54,7 @@ export const DEFAULT_STATE: State = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const DEFAULT_CONTEXT = {
|
export const DEFAULT_CONTEXT = {
|
||||||
|
loaded: false,
|
||||||
urn: undefined,
|
urn: undefined,
|
||||||
user: undefined,
|
user: undefined,
|
||||||
state: DEFAULT_STATE,
|
state: DEFAULT_STATE,
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { Tabs, Typography } from 'antd';
|
import { Tabs, Typography } from 'antd';
|
||||||
import React, { useState } from 'react';
|
import React, { useEffect, useState } from 'react';
|
||||||
import styled from 'styled-components';
|
import styled from 'styled-components';
|
||||||
import { IngestionSourceList } from './source/IngestionSourceList';
|
import { IngestionSourceList } from './source/IngestionSourceList';
|
||||||
import { useAppConfig } from '../useAppConfig';
|
import { useAppConfig } from '../useAppConfig';
|
||||||
@ -51,12 +51,18 @@ export const ManageIngestionPage = () => {
|
|||||||
* Determines which view should be visible: ingestion sources or secrets.
|
* Determines which view should be visible: ingestion sources or secrets.
|
||||||
*/
|
*/
|
||||||
const me = useUserContext();
|
const me = useUserContext();
|
||||||
const { config } = useAppConfig();
|
const { config, loaded } = useAppConfig();
|
||||||
const isIngestionEnabled = config?.managedIngestionConfig.enabled;
|
const isIngestionEnabled = config?.managedIngestionConfig.enabled;
|
||||||
const showIngestionTab = isIngestionEnabled && me && me.platformPrivileges?.manageIngestion;
|
const showIngestionTab = isIngestionEnabled && me && me.platformPrivileges?.manageIngestion;
|
||||||
const showSecretsTab = isIngestionEnabled && me && me.platformPrivileges?.manageSecrets;
|
const showSecretsTab = isIngestionEnabled && me && me.platformPrivileges?.manageSecrets;
|
||||||
const defaultTab = showIngestionTab ? TabType.Sources : TabType.Secrets;
|
const [selectedTab, setSelectedTab] = useState<TabType>(TabType.Sources);
|
||||||
const [selectedTab, setSelectedTab] = useState<TabType>(defaultTab);
|
|
||||||
|
// 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) => {
|
const onClickTab = (newTab: string) => {
|
||||||
setSelectedTab(TabType[newTab]);
|
setSelectedTab(TabType[newTab]);
|
||||||
|
@ -106,7 +106,13 @@ export function LastExecutionColumn(time: any) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function ScheduleColumn(schedule: any, record: 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 (
|
return (
|
||||||
<Tooltip title={tooltip || 'Not scheduled'}>
|
<Tooltip title={tooltip || 'Not scheduled'}>
|
||||||
<Typography.Text code>{schedule || 'None'}</Typography.Text>
|
<Typography.Text code>{schedule || 'None'}</Typography.Text>
|
||||||
|
@ -11,6 +11,7 @@ describe("managing secrets for ingestion creation", () => {
|
|||||||
// Navigate to the manage ingestion page → secrets
|
// Navigate to the manage ingestion page → secrets
|
||||||
cy.loginWithCredentials();
|
cy.loginWithCredentials();
|
||||||
cy.goToIngestionPage();
|
cy.goToIngestionPage();
|
||||||
|
cy.clickOptionWithText("Secrets");
|
||||||
|
|
||||||
// Create a new secret
|
// Create a new secret
|
||||||
cy.clickOptionWithTestId("create-secret-button");
|
cy.clickOptionWithTestId("create-secret-button");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user