Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[KED-2997] Create rename run and edit notes UI behavior #665

Merged
merged 44 commits into from
Jan 6, 2022
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
2494eb0
add pencil/edit icon; create run-details modal; open/close of that mo…
tynandebold Dec 2, 2021
0bcf22c
add basic text area in modal
tynandebold Dec 3, 2021
96b0992
Merge branch 'main' of https://github.com/quantumblacklabs/kedro-viz …
tynandebold Dec 6, 2021
fe10f11
local creation of an Input component
tynandebold Dec 6, 2021
2e90f22
create ui folder and add generic textarea and input components
tynandebold Dec 6, 2021
01623a5
use text-decoration for active state
tynandebold Dec 6, 2021
ce09a90
modal gets dynamic data from selected run
tynandebold Dec 6, 2021
15a9690
run details modal tests
tynandebold Dec 7, 2021
e1c08f3
rename textarea to input and use that in modal; remove other input co…
tynandebold Dec 7, 2021
d644efd
test written for input component
tynandebold Dec 7, 2021
7707e34
Merge branch 'main' of https://github.com/quantumblacklabs/kedro-viz …
tynandebold Dec 7, 2021
a9e64b3
updates based on PR review
tynandebold Dec 10, 2021
b175e38
Merge branch 'main' of https://github.com/quantumblacklabs/kedro-viz …
tynandebold Dec 10, 2021
f3a45e0
Rashida's PR reviews; hide edit run button when comparison view is on
tynandebold Dec 14, 2021
1e7f703
Merge branch 'main' of https://github.com/quantumblacklabs/kedro-viz …
tynandebold Dec 14, 2021
810b2a0
Merge branch 'main' of https://github.com/quantumblacklabs/kedro-viz …
tynandebold Dec 17, 2021
9b5fbc9
fix typos; update general edit run modal behavior
tynandebold Dec 17, 2021
1681b4f
Merge branch 'main' of https://github.com/quantumblacklabs/kedro-viz …
tynandebold Dec 17, 2021
29919f9
add runDetails mutation
tynandebold Dec 20, 2021
48c9b8a
remove searchable text; add client to mutation so tests pass
tynandebold Jan 4, 2022
bccfdda
Merge branch 'main' of https://github.com/quantumblacklabs/kedro-viz …
tynandebold Jan 4, 2022
c59b945
don't format schema
tynandebold Jan 4, 2022
40acffd
Update backend schema
rashidakanchwala Jan 4, 2022
b79e682
Fixed mypy error
rashidakanchwala Jan 4, 2022
bb7d883
fixed mypy2
rashidakanchwala Jan 4, 2022
5db44d8
fixed pylint error
rashidakanchwala Jan 4, 2022
2c6f708
update to id from runId in graphql response
rashidakanchwala Jan 4, 2022
f595229
update run_id to id in response -2
rashidakanchwala Jan 4, 2022
63a1320
UpdateRunDetails returns Run
rashidakanchwala Jan 4, 2022
84173ac
correct response from updateRunDetails mutation; reset mutation on er…
tynandebold Jan 5, 2022
c35efe5
fix run-selection anomoly
tynandebold Jan 5, 2022
1abf75a
fix failing RunDetailsModal test
tynandebold Jan 5, 2022
eba39f5
update mutation response
tynandebold Jan 5, 2022
471d03d
Merge branch 'main' of https://github.com/quantumblacklabs/kedro-viz …
tynandebold Jan 5, 2022
327a71b
use the Modal component from the repo, not the QB UI one
tynandebold Jan 5, 2022
dcefcca
fix failing RunDetailsModal test
tynandebold Jan 5, 2022
88f9732
Merge branch 'main' of https://github.com/quantumblacklabs/kedro-viz …
tynandebold Jan 6, 2022
e6fd526
remove working_directory from circleci
tynandebold Jan 6, 2022
f04307e
add working_directory to build_38
tynandebold Jan 6, 2022
3466a2d
use tmp folder instead of repo
tynandebold Jan 6, 2022
ca51744
revert and use arch
tynandebold Jan 6, 2022
27f13cf
revert by removing working_directory from build_38 and test build again
tynandebold Jan 6, 2022
b14fb2f
clear input on trigger; remove arch from circle ci
tynandebold Jan 6, 2022
18db979
Merge branch 'main' of https://github.com/quantumblacklabs/kedro-viz …
tynandebold Jan 6, 2022
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
1 change: 1 addition & 0 deletions src/apollo/queries.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export const GET_RUN_METADATA = gql`
author
gitBranch
gitSha
id
notes
runCommand
timestamp
Expand Down
50 changes: 45 additions & 5 deletions src/components/experiment-tracking/details/index.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,26 @@
import React from 'react';
import React, { useEffect, useState } from 'react';
import { useApolloQuery } from '../../../apollo/utils';
import classnames from 'classnames';
import RunMetadata from '../run-metadata';
import RunDataset from '../run-dataset';
import RunDetailsModal from '../run-details-modal';
import {
GET_RUN_METADATA,
GET_RUN_TRACKING_DATA,
} from '../../../apollo/queries';

import './details.css';

const Details = ({ selectedRuns, sidebarVisible }) => {
const Details = ({
enableComparisonView,
selectedRuns,
setShowRunDetailsModal,
showRunDetailsModal,
sidebarVisible,
theme,
}) => {
const [selectedRunMetadata, setSelectedRunMetadata] = useState(null);
tynandebold marked this conversation as resolved.
Show resolved Hide resolved
const [selectedMetadataRunId, setSelectedMetadataRunId] = useState(null);
tynandebold marked this conversation as resolved.
Show resolved Hide resolved
const { data: { runMetadata } = [], error } = useApolloQuery(
GET_RUN_METADATA,
{
Expand All @@ -25,20 +35,50 @@ const Details = ({ selectedRuns, sidebarVisible }) => {
variables: { runIds: selectedRuns, showDiff: false },
});

useEffect(() => {
if (!runMetadata) {
return;
}

if (!enableComparisonView) {
const metadata = runMetadata.find((run) => run.id === selectedRuns[0]);

setSelectedRunMetadata(metadata);
} else {
const metadata = runMetadata.find(
(run) => run.id === selectedMetadataRunId
);

setSelectedRunMetadata(metadata);
}
}, [enableComparisonView, runMetadata, selectedMetadataRunId, selectedRuns]);
tynandebold marked this conversation as resolved.
Show resolved Hide resolved

const isSingleRun = runMetadata?.length === 1 ? true : false;

if (error || trackingError) {
return null;
}

const isSingleRun = runMetadata && runMetadata.length === 1 ? true : false;

return (
<>
<RunDetailsModal
onClose={setShowRunDetailsModal}
runs={runMetadata}
selectedRunMetadata={selectedRunMetadata}
theme={theme}
visible={showRunDetailsModal}
/>
<div
className={classnames('kedro', 'details-mainframe', {
'details-mainframe--sidebar-visible': sidebarVisible,
})}
>
<RunMetadata isSingleRun={isSingleRun} runs={runMetadata} />
<RunMetadata
isSingleRun={isSingleRun}
runs={runMetadata}
setSelectedMetadataRunId={setSelectedMetadataRunId}
setShowRunDetailsModal={setShowRunDetailsModal}
/>
<RunDataset isSingleRun={isSingleRun} trackingData={runTrackingData} />
</div>
</>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,27 @@
import React from 'react';
import IconButton from '../../icon-button';
import PencilIcon from '../../icons/pencil';

import PrimaryToolbar from '../../primary-toolbar';

export const ExperimentPrimaryToolbar = ({
sidebarVisible,
setSidebarVisible,
showRunDetailsModal,
}) => {
return (
<PrimaryToolbar
visible={{ sidebar: sidebarVisible }}
onToggleSidebar={setSidebarVisible}
/>
>
<IconButton
ariaLive="Edit run details"
className={'pipeline-menu-button--labels'}
icon={PencilIcon}
labelText={`Edit details`}
onClick={() => showRunDetailsModal(true)}
/>
</PrimaryToolbar>
);
};

Expand Down
54 changes: 54 additions & 0 deletions src/components/experiment-tracking/run-details-modal/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import React from 'react';
import Button from '@quantumblack/kedro-ui/lib/components/button';
import Modal from '@quantumblack/kedro-ui/lib/components/modal';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hi, the Kedro-UI modal PR is ready to merge. Just need someone to review the handleKeyevents stuff. Can we use that in this if it gets merged before this PR?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, absolutely we can.

import TextArea from '../../ui/input';

import '../../settings-modal/settings-modal.css';
import './run-details-modal.css';

const RunDetailsModal = ({ onClose, selectedRunMetadata, theme, visible }) => {
return (
<div className="pipeline-settings-modal pipeline-settings-modal--experiment-tracking">
<Modal
onClose={() => onClose(false)}
theme={theme}
title="Edit run details"
visible={visible}
>
<div className="pipeline-settings-modal__content pipeline-settings-modal__content--short">
<div className="pipeline-settings-modal__header">
<div className="pipeline-settings-modal__name">Run name</div>
</div>
<TextArea defaultValue={selectedRunMetadata?.title} size="large" />
</div>
<div className="pipeline-settings-modal__content pipeline-settings-modal__content--short">
<div className="pipeline-settings-modal__header">
<div className="pipeline-settings-modal__name">
Notes (this is searchable)
tynandebold marked this conversation as resolved.
Show resolved Hide resolved
</div>
</div>
<TextArea
characterLimit={500}
defaultValue={selectedRunMetadata?.notes || 'Add here'}
size="small"
/>
</div>
<div className="run-details-modal-button-wrapper">
<Button
mode="secondary"
onClick={() => onClose(false)}
size="small"
theme={theme}
>
Cancel
</Button>
<Button size="small" theme={theme}>
Apply changes
</Button>
</div>
</Modal>
</div>
);
};

export default RunDetailsModal;
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
.pipeline-settings-modal--experiment-tracking .pipeline-settings-modal__name {
margin-top: 0;
}

.run-details-modal-button-wrapper {
align-items: baseline;
display: flex;
justify-content: flex-end;
width: 100%;

.kui-button:first-of-type {
margin-right: 20px;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import React from 'react';
import RunDetailsModal from './index';
import Adapter from 'enzyme-adapter-react-16';
import { configure, mount, shallow } from 'enzyme';

configure({ adapter: new Adapter() });

describe('SettingsModal', () => {
tynandebold marked this conversation as resolved.
Show resolved Hide resolved
it('renders without crashing', () => {
const wrapper = shallow(<RunDetailsModal visible />);

expect(
wrapper.find('.pipeline-settings-modal--experiment-tracking').length
).toBe(1);
});

it('modal closes when X button is clicked', () => {
const setVisible = jest.fn();
const wrapper = mount(<RunDetailsModal onClose={() => setVisible(true)} />);
const onClick = jest.spyOn(React, 'useState');

onClick.mockImplementation((visible) => [visible, setVisible]);
const closeButton = wrapper.find(
'.pipeline-settings-modal--experiment-tracking .kui-icon--close'
);
closeButton.simulate('click');
expect(
wrapper.find(
'.pipeline-settings-modal--experiment-tracking .kui-modal--visible'
).length
).toBe(0);
});
});
30 changes: 25 additions & 5 deletions src/components/experiment-tracking/run-metadata/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@ import './run-metadata.css';
// returned by the graphql endpoint for empty values ( not null or undefined )
const sanitiseEmptyValue = (value) => (value !== '' ? value : '-');

const RunMetadata = ({ isSingleRun, runs = [] }) => {
const RunMetadata = ({
isSingleRun,
runs = [],
setSelectedMetadataRunId,
setShowRunDetailsModal,
}) => {
let initialState = {};
for (let i = 0; i < runs.length; i++) {
initialState[i] = false;
Expand All @@ -20,6 +25,11 @@ const RunMetadata = ({ isSingleRun, runs = [] }) => {
setToggleNotes({ ...toggleNotes, [index]: !toggleNotes[index] });
};

const onTitleOrNoteClick = (id) => {
setSelectedMetadataRunId(id);
setShowRunDetailsModal(true);
};

tynandebold marked this conversation as resolved.
Show resolved Hide resolved
return (
<div
className={classnames('details-metadata', {
Expand All @@ -34,20 +44,27 @@ const RunMetadata = ({ isSingleRun, runs = [] }) => {
className={classnames('details-metadata__run', {
'details-metadata__run--single': isSingleRun,
})}
key={run.title + i} // note: this should revert back to use gitSha once the BE returns the actual value
key={run.title + i} // Note: change to gitSha once BE returns the value
tynandebold marked this conversation as resolved.
Show resolved Hide resolved
>
<table className="details-metadata__table">
<tbody>
{isSingleRun ? (
<tr>
<td className="details-metadata__title" colSpan="2">
<td
className="details-metadata__title"
colSpan="2"
onClick={() => onTitleOrNoteClick(run.id)}
>
{sanitiseEmptyValue(run.title)}
</td>
</tr>
) : (
<tr>
{i === 0 ? <td></td> : null}
<td className="details-metadata__title">
<td
className="details-metadata__title"
onClick={() => onTitleOrNoteClick(run.id)}
>
{sanitiseEmptyValue(run.title)}
</td>
</tr>
Expand Down Expand Up @@ -79,9 +96,12 @@ const RunMetadata = ({ isSingleRun, runs = [] }) => {
<td>
<p
className="details-metadata__notes"
onClick={() => onTitleOrNoteClick(run.id)}
style={toggleNotes[i] ? { display: 'block' } : null}
>
{sanitiseEmptyValue(run.notes)}
{run.notes !== ''
? run.notes
: '- Add notes here (Notes are searchable)'}
tynandebold marked this conversation as resolved.
Show resolved Hide resolved
</p>
{run.notes.length > 100 ? (
<button
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
font-size: 1.4em;
padding-bottom: 16px;
vertical-align: top;
word-wrap: break-word; // For breaking potential long text, such as as git branch, title, etc
word-wrap: break-word; // For breaking potential long text, such as as git branch, title, etc.

&:first-of-type {
width: 230px;
Expand All @@ -56,17 +56,33 @@
}

td.details-metadata__title {
cursor: pointer;
font-weight: 600;
font-size: 2em;
text-decoration-color: transparent;
transition: text-decoration-color 0.2s ease;

&:hover {
text-decoration: underline;
text-decoration-color: var(--color-text);
}
}

.details-metadata__notes {
-webkit-box-orient: vertical;
-webkit-line-clamp: 2;
cursor: pointer;
display: -webkit-box;
margin: 0;
overflow: hidden;
text-overflow: ellipsis;
text-decoration-color: transparent;
transition: text-decoration-color 0.2s ease;

&:hover {
text-decoration: underline;
text-decoration-color: var(--color-text);
}
}

.details-metadata__show-more.kedro {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

&--active {
background: var(--color-run-list-hover);
box-shadow: -1px 0px 0px inset #{$color-accent-blue};
box-shadow: -1px 0px 0px inset $color-accent-blue;
}

&--disabled {
Expand Down Expand Up @@ -48,7 +48,7 @@
}

&--active {
fill: #{$color-accent-blue};
fill: $color-accent-blue;
}
}

Expand Down
Loading