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
5 changes: 5 additions & 0 deletions src/layouts/Base/index.less
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,11 @@
font-size: @size-normal;
margin-right: 20px;
}
.ant-menu-submenu-title .anticon {
// Ant Design adds 10px to an icon immediately followed by a title span.
// Keep submenu titles aligned with ordinary menu items.
margin-right: 10px;
}
& .ant-menu-item-selected {
background-color: @primary-color;
border-radius: @border-radius;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const StepItem = observer((props) => {
}
}, []);

const handleStepClick = () => activeByStep(step, index);
const handleStepClick = () => activeByStep(step, index, true);

const stepItem = (
<div
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ const LogItem = observer((props) => {
<div className={styles.LogItem} ref={inputEl}>
<div className={classNames(styles.LogItem__title)} onClick={toggleExpand}>
{isExpand ? <CaretDownOutlined /> : <CaretRightOutlined />}
{`${nodes.name || nodes.ipv4 || nodes.id}`}
{nodes.ipv4 ? `${nodes.id}(${nodes.ipv4})` : nodes.id}
<span className={styles.logitem_status}>
<span>{runtime || ''}</span>
{stateIcons(false, nodeStatus)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ export default class PipelineLog extends ViewAction {
this.taskTimer = null;
this.refreshing = false;
this.disposer = null;
this.manuallySelectedStepID = null;
}

componentDidMount() {
Expand Down Expand Up @@ -139,6 +140,12 @@ export default class PipelineLog extends ViewAction {
updateOperation = async (operation, tasks) => {
if (!operation) return;

if (
this.rawOperation?.metadata?.uid &&
this.rawOperation.metadata.uid !== operation.metadata?.uid
) {
this.manuallySelectedStepID = null;
}
this.rawOperation = operation;
const operationTasks = tasks || (await this.fetchTasks(operation));
const result = ObjectMapper.operations(operation, operationTasks);
Expand All @@ -148,12 +155,31 @@ export default class PipelineLog extends ViewAction {
this.store.currentOperation = result;
this.store.operationSteps = operationSteps;

const activeIndex = operationSteps.findIndex((step) => !step.isComplete);
const index = activeIndex === -1 ? operationSteps.length - 1 : activeIndex;
this.activeByStep(operationSteps[index], index);
let index = this.manuallySelectedStepID
? operationSteps.findIndex(
(step) => step.stepID === this.manuallySelectedStepID
)
: -1;

if (index === -1) {
const activeIndex = operationSteps.findIndex((step) => !step.isComplete);
index = activeIndex === -1 ? operationSteps.length - 1 : activeIndex;
if (this.manuallySelectedStepID) {
this.manuallySelectedStepID = null;
}
}

if (index >= 0) {
this.activeByStep(operationSteps[index], index);
}
};

activeByStep = async (step, index) => {
activeByStep = async (step, index, manuallySelected = false) => {
if (!step) return;

if (manuallySelected) {
this.manuallySelectedStepID = step.stepID;
}
this.store.currentNodesByStep = step;
this.store.activeStepIndex = index;
};
Expand Down
3 changes: 1 addition & 2 deletions src/utils/object.mapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -272,8 +272,7 @@ const mapOperationStep = (step, tasks) => {
id: target.name,
name: target.name,
uid: target.uid,
// Operation V2 exposes the stable node name, not the node IP.
ipv4: target.name,
ipv4: target.ip || get(task, 'spec.nodeRef.ip', ''),
taskName: get(task, 'metadata.name'),
status: phase,
startAt: get(task, 'status.startedAt'),
Expand Down
30 changes: 29 additions & 1 deletion src/utils/object.mapper.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ describe('operation mapper', () => {
steps: [
{
id: 'step-1',
targets: [{ name: 'node-1', uid: 'node-uid' }],
targets: [{ name: 'node-1', uid: 'node-uid', ip: '10.0.0.1' }],
payload: { step: { name: 'installRuntime' } },
},
],
Expand All @@ -57,6 +57,7 @@ describe('operation mapper', () => {
const result = [operation].map(ObjectMapper.operations)[0];

expect(result.operationSteps[0].nodes[0].status).toBe('Pending');
expect(result.operationSteps[0].nodes[0].ipv4).toBe('10.0.0.1');
expect(result.operationSteps[0].name).toBe('installRuntime');
});

Expand All @@ -75,4 +76,31 @@ describe('operation mapper', () => {
expect(result.operationSteps[0].nodes[0].status).toBe('Succeeded');
expect(result.operationSteps[0].nodes[0].taskName).toBe('task-1');
});

it('uses the task node IP when the operation target omits it', () => {
const operationWithoutTargetIP = {
...operation,
spec: {
...operation.spec,
steps: [
{
...operation.spec.steps[0],
targets: [{ name: 'node-1', uid: 'node-uid' }],
},
],
},
};
const result = ObjectMapper.operations(operationWithoutTargetIP, [
{
metadata: { name: 'task-1' },
spec: {
stepID: 'step-1',
nodeRef: { name: 'node-1', uid: 'node-uid', ip: '10.0.0.2' },
},
status: { phase: 'Running' },
},
]);

expect(result.operationSteps[0].nodes[0].ipv4).toBe('10.0.0.2');
});
});
Loading