Skip to content

Commit d418783

Browse files
vidartfgithub-actions[bot]krassowski
authored
Change header for unchanged notebook meta (#736)
* Change header for unchanged notebook meta We previously changed to always showing the metadata diff in notebook merges, in case the user needs to make manual edits to it even if there are no changes in the merge itself. That change did not take into account that the display behavior here made some assumptions about only being shown when there was a change. Here we make the title conditional on whether there are changes or not, and make sure not to collapse similar changes in the case where there are none. * Update Playwright Snapshots * Update Playwright Snapshots * Disable animations for metadata drawer expand * Update Playwright Snapshots * Update Playwright Snapshots * fix string for translation Co-authored-by: Michał Krassowski <[email protected]> --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Michał Krassowski <[email protected]>
1 parent 2f856da commit d418783

File tree

29 files changed

+15
-5
lines changed

29 files changed

+15
-5
lines changed

packages/nbdime/src/merge/widget/metadata.ts

+8-3
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import { MergePanel } from '../../common/basepanel';
1717

1818
import type { MetadataMergeModel } from '../model';
1919

20-
const ROOT_METADATA_CLASS = 'jp-Metadata-diff';
20+
const ROOT_METADATA_CLASS = 'jp-Metadata-merge';
2121

2222
/**
2323
* MetadataWidget for changes to Notebook-level metadata
@@ -36,18 +36,23 @@ export class MetadataMergeWidget extends MergePanel<MetadataMergeModel> {
3636

3737
// We know/assume that MetadataMergeModel never has
3838
// null values for local/remote:
39+
const viewOptions = {...this._viewOptions};
40+
const unchanged = model.decisions.length === 0;
41+
if (unchanged) {
42+
viewOptions.collapseIdentical = false;
43+
}
3944
this.view = createNbdimeMergeView({
4045
remote: model.remote,
4146
local: model.local,
4247
merged: model.merged,
4348
factory: this._editorFactory,
4449
translator: this._translator,
45-
...this._viewOptions,
50+
...viewOptions,
4651
});
4752
const trans = this._translator.load('nbdime');
4853
const wrapper = new CollapsiblePanel(
4954
this.view,
50-
trans.__('Notebook metadata changed'),
55+
unchanged ? trans.__('Notebook metadata unchanged') : trans.__('Notebook metadata changed'),
5156
true,
5257
);
5358
this.addWidget(wrapper);

packages/nbdime/src/styles/merge.css

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
.jp-Notebook-merge .jp-Metadata-diff {
1+
.jp-Notebook-merge .jp-Metadata-merge {
22
margin-bottom: 20px;
33
}
44

5-
.jp-Notebook-merge .jp-Metadata-diff .jp-CollapsiblePanel {
5+
.jp-Notebook-merge .jp-Metadata-merge .jp-CollapsiblePanel {
66
border: solid black thin;
77
}
88

ui-tests/tests/nbdime-merge-test1.spec.ts

+5
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,11 @@ test.describe('merge test1', () => {
7070
// Finalize download
7171
expect(await download1.failure()).toBeNull();
7272
});
73+
74+
test('should not collapse source for unchanged metadata', async ({ page }) => {
75+
await page.locator('.jp-Metadata-merge .jp-CollapsiblePanel-header-icon').click();
76+
expect(await page.locator('#main').screenshot({animations: 'disabled'})).toMatchSnapshot();
77+
});
7378
});
7479

7580
test('3 panels view', async ({ page }) => {
Loading
Loading

0 commit comments

Comments
 (0)