Skip to content

Commit

Permalink
use is_promotable and is_submittable (#229)
Browse files Browse the repository at this point in the history
Co-authored-by: Fred Lefévère-Laoide <[email protected]>
  • Loading branch information
FredLL-Avaiga and Fred Lefévère-Laoide authored Jun 23, 2023
1 parent f1c1c79 commit 7b56d98
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 10 deletions.
26 changes: 19 additions & 7 deletions gui/src/ScenarioViewer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ interface PipelinesRowProps {
onFocus: (e: MouseEvent<HTMLElement>) => void;
focusName: string;
setFocusName: (name: string) => void;
submittable: boolean;
}

const MainBoxSx = {
Expand Down Expand Up @@ -144,6 +145,7 @@ const PipelineRow = ({
onFocus,
focusName,
setFocusName,
submittable,
}: PipelinesRowProps) => {
const [pipeline, setPipeline] = useState<string>(label);

Expand Down Expand Up @@ -207,8 +209,12 @@ const PipelineRow = ({
</Grid>
<Grid item xs={2} container alignContent="center" alignItems="center" justifyContent="center">
{submit ? (
<IconButton size="small" onClick={onSubmitPipeline} disabled={!enableScenarioFields || !active}>
<Send color={disableColor("info", !enableScenarioFields)} />
<IconButton
size="small"
onClick={onSubmitPipeline}
disabled={!enableScenarioFields || !active || !submittable}
>
<Send color={disableColor("info", !enableScenarioFields || !active || !submittable)} />
</IconButton>
) : null}
</Grid>
Expand Down Expand Up @@ -251,6 +257,8 @@ const ScenarioViewer = (props: ScenarioViewerProps) => {
scPipelines,
scAuthorizedTags,
scDeletable,
scPromotable,
scSubmittable,
isScenario,
] = useMemo(() => {
let sc: ScenarioFull | undefined = undefined;
Expand All @@ -263,7 +271,7 @@ const ScenarioViewer = (props: ScenarioViewerProps) => {
// DO nothing
}
}
return sc ? [...sc, true] : ["", false, "", "", "", [], [], [], [], false, false];
return sc ? [...sc, true] : ["", false, "", "", "", [], [], [], [], false, false, false, false];
}, [props.scenario, props.defaultScenario]);

const active = useDynamicProperty(props.active, props.defaultActive, true);
Expand Down Expand Up @@ -507,9 +515,12 @@ const ScenarioViewer = (props: ScenarioViewerProps) => {
<IconButton
sx={IconPaddingSx}
onClick={submitScenario}
disabled={!isScenario || !active}
disabled={!isScenario || !active || !scSubmittable}
>
<Send fontSize="medium" color={disableColor("info", !isScenario || !active)} />
<Send
fontSize="medium"
color={disableColor("info", !isScenario || !active || !scSubmittable)}
/>
</IconButton>
) : null}
</Grid>
Expand Down Expand Up @@ -844,7 +855,7 @@ const ScenarioViewer = (props: ScenarioViewerProps) => {

{scPipelines &&
scPipelines.map((item, index) => {
const [key, value] = item;
const [key, value, submittable] = item;
return (
<PipelineRow
active={active}
Expand All @@ -859,6 +870,7 @@ const ScenarioViewer = (props: ScenarioViewerProps) => {
onFocus={onFocus}
focusName={focusName}
setFocusName={setFocusName}
submittable={submittable}
/>
);
})}
Expand All @@ -882,7 +894,7 @@ const ScenarioViewer = (props: ScenarioViewerProps) => {
<Button
variant="outlined"
color="primary"
disabled={!active || !isScenario || scPrimary}
disabled={!active || !isScenario || scPrimary || !scPromotable}
onClick={openPrimaryDialog}
>
PROMOTE TO PRIMARY
Expand Down
6 changes: 5 additions & 1 deletion gui/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@ export type ScenarioFull = [
string,
string[],
Array<[string, string]>,
Array<[string, string]>,
Array<[string, string, boolean]>,
string[],
boolean,
boolean,
boolean
];

Expand All @@ -38,6 +40,8 @@ export enum ScFProps {
pipelines,
authorized_tags,
deletable,
promotable,
submittable,
}
export const ScenarioFullLength = Object.keys(ScFProps).length / 2;

Expand Down
14 changes: 12 additions & 2 deletions src/taipy/gui_core/GuiCoreLib.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,15 @@
from taipy.core import Cycle, DataNode, Pipeline, Scenario, create_scenario
from taipy.core import delete as core_delete
from taipy.core import get as core_get
from taipy.core import get_cycles_scenarios, get_data_nodes, get_scenarios, is_deletable, set_primary
from taipy.core import (
get_cycles_scenarios,
get_data_nodes,
get_scenarios,
is_deletable,
is_promotable,
is_submittable,
set_primary,
)
from taipy.core import submit as core_submit
from taipy.core.notification import CoreEventConsumerBase, EventEntityType
from taipy.core.notification.event import Event
Expand Down Expand Up @@ -68,9 +76,11 @@ def get(self):
scenario.get_simple_label(),
list(scenario.tags),
[(k, v) for k, v in scenario.properties.items() if k not in _GuiCoreScenarioAdapter.__INNER_PROPS],
[(p.id, p.get_simple_label()) for p in scenario.pipelines.values()],
[(p.id, p.get_simple_label(), is_submittable(p)) for p in scenario.pipelines.values()],
list(scenario.properties.get("authorized_tags", set())),
is_deletable(scenario), # deletable
is_promotable(scenario),
is_submittable(scenario),
]
return None

Expand Down

0 comments on commit 7b56d98

Please sign in to comment.