Commit 839d44bf authored by Robert Knight's avatar Robert Knight

Rename `bucketBarContainer` config to `bucketContainerSelector`

We have settled on this for the moment for consistency with
`externalContainerSelector`, although the "Selector" suffix is a bit verbose,
and this could be a problem if we want to support specifying an HTML element
directly via JS config, rather than a selector.
parent aab247bd
...@@ -41,7 +41,7 @@ function configurationKeys(context: Context): string[] { ...@@ -41,7 +41,7 @@ function configurationKeys(context: Context): string[] {
'appType', 'appType',
'annotations', 'annotations',
'branding', 'branding',
'bucketBarContainer', 'bucketContainerSelector',
'enableExperimentalNewNoteButton', 'enableExperimentalNewNoteButton',
'externalContainerSelector', 'externalContainerSelector',
'focus', 'focus',
...@@ -107,7 +107,7 @@ const configDefinitions: ConfigDefinitionMap = { ...@@ -107,7 +107,7 @@ const configDefinitions: ConfigDefinitionMap = {
allowInBrowserExt: false, allowInBrowserExt: false,
getValue: getHostPageSetting, getValue: getHostPageSetting,
}, },
bucketBarContainer: { bucketContainerSelector: {
defaultValue: null, defaultValue: null,
allowInBrowserExt: false, allowInBrowserExt: false,
getValue: getHostPageSetting, getValue: getHostPageSetting,
......
...@@ -77,7 +77,7 @@ describe('annotator/config/index', () => { ...@@ -77,7 +77,7 @@ describe('annotator/config/index', () => {
appType: 'fakeValue', appType: 'fakeValue',
annotations: 'fakeValue', annotations: 'fakeValue',
branding: null, branding: null,
bucketBarContainer: null, bucketContainerSelector: null,
clientUrl: 'fakeValue', clientUrl: 'fakeValue',
contentInfoBanner: null, contentInfoBanner: null,
enableExperimentalNewNoteButton: null, enableExperimentalNewNoteButton: null,
...@@ -111,7 +111,7 @@ describe('annotator/config/index', () => { ...@@ -111,7 +111,7 @@ describe('annotator/config/index', () => {
appType: 'fakeValue', appType: 'fakeValue',
annotations: 'fakeValue', annotations: 'fakeValue',
branding: 'fakeValue', branding: 'fakeValue',
bucketBarContainer: 'fakeValue', bucketContainerSelector: 'fakeValue',
clientUrl: 'fakeValue', clientUrl: 'fakeValue',
contentInfoBanner: 'fakeValue', contentInfoBanner: 'fakeValue',
enableExperimentalNewNoteButton: 'fakeValue', enableExperimentalNewNoteButton: 'fakeValue',
...@@ -169,7 +169,7 @@ describe('annotator/config/index', () => { ...@@ -169,7 +169,7 @@ describe('annotator/config/index', () => {
appType: null, appType: null,
annotations: null, annotations: null,
branding: null, branding: null,
bucketBarContainer: null, bucketContainerSelector: null,
clientUrl: null, clientUrl: null,
contentInfoBanner: null, contentInfoBanner: null,
enableExperimentalNewNoteButton: null, enableExperimentalNewNoteButton: null,
...@@ -235,7 +235,7 @@ describe('annotator/config/index', () => { ...@@ -235,7 +235,7 @@ describe('annotator/config/index', () => {
'appType', 'appType',
'annotations', 'annotations',
'branding', 'branding',
'bucketBarContainer', 'bucketContainerSelector',
'enableExperimentalNewNoteButton', 'enableExperimentalNewNoteButton',
'externalContainerSelector', 'externalContainerSelector',
'focus', 'focus',
......
...@@ -45,7 +45,7 @@ export type SidebarConfig = { sidebarAppUrl: string } & Record<string, unknown>; ...@@ -45,7 +45,7 @@ export type SidebarConfig = { sidebarAppUrl: string } & Record<string, unknown>;
*/ */
export type SidebarContainerConfig = { export type SidebarContainerConfig = {
/** CSS selector for the container of the bucket bar. */ /** CSS selector for the container of the bucket bar. */
bucketBarContainer?: string; bucketContainerSelector?: string;
/** /**
* Details of the annotation service the client should connect to. * Details of the annotation service the client should connect to.
...@@ -173,13 +173,13 @@ export class Sidebar implements Destroyable { ...@@ -173,13 +173,13 @@ export class Sidebar implements Destroyable {
this.iframeContainer.classList.add('theme-clean'); this.iframeContainer.classList.add('theme-clean');
} else { } else {
let bucketBarContainer: HTMLElement | undefined; let bucketBarContainer: HTMLElement | undefined;
if (config.bucketBarContainer) { if (config.bucketContainerSelector) {
bucketBarContainer = document.querySelector( bucketBarContainer = document.querySelector(
config.bucketBarContainer config.bucketContainerSelector
) as HTMLElement | undefined; ) as HTMLElement | undefined;
if (!bucketBarContainer) { if (!bucketBarContainer) {
console.warn( console.warn(
`Custom bucket bar container "${config.bucketBarContainer}" not found` `Custom bucket container "${config.bucketContainerSelector}" not found`
); );
} }
} }
......
...@@ -1073,14 +1073,14 @@ describe('Sidebar', () => { ...@@ -1073,14 +1073,14 @@ describe('Sidebar', () => {
assert.isNull(sidebar.bucketBar); assert.isNull(sidebar.bucketBar);
}); });
it('creates bucket bar in specified container if `bucketBarContainer` config is supplied', () => { it('creates bucket bar in specified container if `bucketContainerSelector` config is supplied', () => {
const bucketBarContainer = document.createElement('div'); const bucketBarContainer = document.createElement('div');
bucketBarContainer.id = 'bucket-bar-container'; bucketBarContainer.id = 'bucket-bar-container';
document.body.append(bucketBarContainer); document.body.append(bucketBarContainer);
try { try {
const sidebar = createSidebar({ const sidebar = createSidebar({
bucketBarContainer: '#bucket-bar-container', bucketContainerSelector: '#bucket-bar-container',
}); });
assert.ok(sidebar.bucketBar); assert.ok(sidebar.bucketBar);
assert.calledWith(FakeBucketBar, bucketBarContainer, sinon.match.any); assert.calledWith(FakeBucketBar, bucketBarContainer, sinon.match.any);
...@@ -1089,15 +1089,15 @@ describe('Sidebar', () => { ...@@ -1089,15 +1089,15 @@ describe('Sidebar', () => {
} }
}); });
it('warns if `bucketBarContainer` config is supplied but invalid', () => { it('warns if `bucketContainerSelector` config is supplied but invalid', () => {
sinon.stub(console, 'warn'); sinon.stub(console, 'warn');
try { try {
createSidebar({ createSidebar({
bucketBarContainer: '#invalid-selector', bucketContainerSelector: '#invalid-selector',
}); });
assert.calledWith( assert.calledWith(
console.warn, console.warn,
`Custom bucket bar container "#invalid-selector" not found` `Custom bucket container "#invalid-selector" not found`
); );
} finally { } finally {
console.warn.restore(); console.warn.restore();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment