forked from gocd/gocd
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed issue of duplicate html elements showing up on new dashboard - g…
…ocd#4775 Foundation components were being used for buttonWithTooltip and linkWithTooltip. While these worked in most cases, when such elements are present of pages which get refreshed by some ajax call (as was the case on dashboard), the destruction of these foundation elements (if the element was to be removed from the UI) wasn't clean and lead to issues. The first call to component.onremove would succeed but mithil kept a reference of the old/deleted element and called onremove on it all over again leading to onremove call failing. Since oncreate was being called before onremove, the element wasn't really deleted from the UI. Using a custom html component instead to solve this.
- Loading branch information
1 parent
936e2d9
commit 594227b
Showing
9 changed files
with
223 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
84 changes: 84 additions & 0 deletions
84
server/webapp/WEB-INF/rails.new/spec/webpack/lib/form_helper_spec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
/* | ||
* Copyright 2018 ThoughtWorks, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
describe("Form Helper", () => { | ||
const $ = require("jquery"); | ||
const m = require('mithril'); | ||
const Stream = require('mithril/stream'); | ||
require('jasmine-jquery'); | ||
const f = require('helpers/form_helper'); | ||
|
||
let $root, root; | ||
beforeEach(() => { | ||
[$root, root] = window.createDomElementForTest(); | ||
}); | ||
afterEach(window.destroyDomElementForTest); | ||
const unmount = () => { | ||
m.mount(root, null); | ||
m.redraw(); | ||
}; | ||
|
||
afterEach(() => { | ||
unmount(); | ||
}); | ||
|
||
it("buttonWithTooltip should add a tooltip to the button", () => { | ||
const model = Stream(true); | ||
m.mount(root, { | ||
view() { | ||
return m(f.buttonWithTooltip, { | ||
model, | ||
'tooltipText': "show me on hover", | ||
}, "Fancy button with tooltip"); | ||
} | ||
}); | ||
m.redraw(); | ||
const buttonWithTooltip = $root.find('button'); | ||
expect(buttonWithTooltip).toExist(); | ||
const tooltipId = $(buttonWithTooltip).attr("data-tooltip-id"); | ||
const tooltip = $root.find(`#${tooltipId}`); | ||
expect(tooltip).toExist(); | ||
expect(tooltip).toHaveText("show me on hover"); | ||
expect(tooltip).not.toBeVisible(); | ||
$(buttonWithTooltip).trigger('mouseover'); | ||
expect(tooltip).toBeVisible(); | ||
$(buttonWithTooltip).trigger('mouseout'); | ||
expect(tooltip).not.toBeVisible(); | ||
}); | ||
|
||
it("linkWithTooltip should add a tooltip to the link", () => { | ||
const model = Stream(true); | ||
m.mount(root, { | ||
view() { | ||
return m(f.linkWithTooltip, { | ||
model, | ||
'tooltipText': "show me on hover", | ||
}, "Fancy link with tooltip"); | ||
} | ||
}); | ||
m.redraw(); | ||
const linkWithTooltip = $root.find('a'); | ||
expect(linkWithTooltip).toExist(); | ||
const tooltipId = $(linkWithTooltip).attr("data-tooltip-id"); | ||
const tooltip = $root.find(`#${tooltipId}`); | ||
expect(tooltip).toExist(); | ||
expect(tooltip).toHaveText("show me on hover"); | ||
expect(tooltip).not.toBeVisible(); | ||
$(linkWithTooltip).trigger('mouseover'); | ||
expect(tooltip).toBeVisible(); | ||
$(linkWithTooltip).trigger('mouseout'); | ||
expect(tooltip).not.toBeVisible(); | ||
}); | ||
}); |
22 changes: 22 additions & 0 deletions
22
server/webapp/WEB-INF/rails.new/spec/webpack/lib/uuid_spec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/* | ||
* Copyright 2018 ThoughtWorks, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
const uuid = require("uuid"); | ||
|
||
describe("generate()", () => { | ||
it("should generate a new uuid", () => { | ||
expect(uuid.generate()).not.toEqual(uuid.generate()); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* | ||
* Copyright 2018 ThoughtWorks, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
const uuid = { | ||
generate() { | ||
let d = new Date().getTime(); | ||
const uuid = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) { | ||
const r = (d + Math.random() * 16) % 16 | 0; | ||
d = Math.floor(d / 16); | ||
return (c === 'x' ? r : (r & 0x3 | 0x8)).toString(16); | ||
}); | ||
return uuid; | ||
} | ||
|
||
}; | ||
module.exports = uuid; |