From 623eee36feb3e0d5fc2d1cefad14d63e60e3c644 Mon Sep 17 00:00:00 2001 From: joaoGabriel55 Date: Thu, 19 May 2022 16:24:22 -0300 Subject: [PATCH 1/5] rebase --- .../components/story/StoryCopyIdClipboard.js | 16 +++++++++ app/assets/javascripts/templates/story.ejs | 1 + app/assets/javascripts/views/story_view.jsx | 10 ++++++ app/assets/stylesheets/_screen.scss | 20 ++++++++++- .../story/story_copy_id_clipboard_spec.js | 36 +++++++++++++++++++ 5 files changed, 82 insertions(+), 1 deletion(-) create mode 100644 app/assets/javascripts/components/story/StoryCopyIdClipboard.js create mode 100644 spec/javascripts/components/story/story_copy_id_clipboard_spec.js diff --git a/app/assets/javascripts/components/story/StoryCopyIdClipboard.js b/app/assets/javascripts/components/story/StoryCopyIdClipboard.js new file mode 100644 index 000000000..71f67c05d --- /dev/null +++ b/app/assets/javascripts/components/story/StoryCopyIdClipboard.js @@ -0,0 +1,16 @@ +import React from "react"; + +const StoryCopyIdClipboard = ({ id }) => { + return ( + + ); +}; + +export default StoryCopyIdClipboard; diff --git a/app/assets/javascripts/templates/story.ejs b/app/assets/javascripts/templates/story.ejs index 9accddcd7..552d0f34b 100644 --- a/app/assets/javascripts/templates/story.ejs +++ b/app/assets/javascripts/templates/story.ejs @@ -43,6 +43,7 @@
+
<% if (story.get('labels')) { %> <% _.each(story.labels(), function(value) { %> diff --git a/app/assets/javascripts/views/story_view.jsx b/app/assets/javascripts/views/story_view.jsx index 98ea5cfb3..0de1c83b7 100644 --- a/app/assets/javascripts/views/story_view.jsx +++ b/app/assets/javascripts/views/story_view.jsx @@ -19,6 +19,7 @@ import storyTemplate from 'templates/story.ejs'; import alertTemplate from 'templates/alert.ejs'; import storyHoverTemplate from 'templates/story_hover.ejs'; import noteTemplate from 'templates/note.ejs'; +import StoryCopyIdClipboard from '../components/story/StoryCopyIdClipboard'; const LOCAL_STORY_REGEXP = /(?!\s|\b)(#\d+)(?!\w)/g; @@ -568,6 +569,15 @@ const StoryView = FormView.extend({ ); } + const copyStoryIdClipboardLink = this.$('[data-story-id-copy-clipboard]').get(0) + if(copyStoryIdClipboardLink) { + ReactDOM.render( + , + copyStoryIdClipboardLink + ) + new Clipboard('.story-id'); + } + if (isGuest) { this.$el .find('.state-actions') diff --git a/app/assets/stylesheets/_screen.scss b/app/assets/stylesheets/_screen.scss index 9474a044b..4f463b2ac 100644 --- a/app/assets/stylesheets/_screen.scss +++ b/app/assets/stylesheets/_screen.scss @@ -224,10 +224,14 @@ div.story-controls { } div.story-title { - margin-left: 65px; + margin-left: 50px; word-wrap: break-word; } +div.story-title div[data-story-id-copy-clipboard] { + display: inline; +} + .unestimated div.story-title { font-style: italic; } @@ -239,6 +243,20 @@ div.story-title abbr.initials { border: none; } +div.story-title { + .story-id { + cursor: pointer; + color: $blue-4; + font-weight: bold; + margin-right: 8px; + border: none; + + &:hover { + text-decoration: underline; + } + } +} + .input-group-btn .btn-clipboard-id { padding-top: 6px; } diff --git a/spec/javascripts/components/story/story_copy_id_clipboard_spec.js b/spec/javascripts/components/story/story_copy_id_clipboard_spec.js new file mode 100644 index 000000000..b6bc6d7a0 --- /dev/null +++ b/spec/javascripts/components/story/story_copy_id_clipboard_spec.js @@ -0,0 +1,36 @@ +import React from 'react'; +import { mount, shallow } from 'enzyme'; + +import StoryCopyIdClipboard from 'components/story/StoryCopyIdClipboard'; + +describe('', function() { + beforeEach(function() { + sinon.stub(I18n, 't'); + }); + + afterEach(function() { + I18n.t.restore(); + }); + + it("should render story id text", function() { + const wrapper = mount( + + ); + expect(wrapper.find('.story-id').text()).toBe('#70'); + }); + + it("should render story id data-clipboard-text", function() { + const wrapper = mount( + + ); + expect(wrapper.find('[data-clipboard-text]')).toExist(); + }); + + it("should render copy id title", function() { + shallow( + + ); + expect(I18n.t).toHaveBeenCalledWith('story.events.copy_id'); + }); + +}); From 24569435dd756868d5654ce268b7e84a16cb1925 Mon Sep 17 00:00:00 2001 From: joaoGabriel55 Date: Thu, 19 May 2022 16:38:37 -0300 Subject: [PATCH 2/5] New minor fix --- app/assets/javascripts/views/story_view.jsx | 26 ++++++++++++++------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/app/assets/javascripts/views/story_view.jsx b/app/assets/javascripts/views/story_view.jsx index 0de1c83b7..6f2948c7a 100644 --- a/app/assets/javascripts/views/story_view.jsx +++ b/app/assets/javascripts/views/story_view.jsx @@ -542,7 +542,21 @@ const StoryView = FormView.extend({ ); }, - renderCollapsed: function (isGuest) { + appendAttachments: function() { + this.$el.append( + this.makeFormControl(function(div) { + const $storyAttachments = $('
'); + $(div).append($storyAttachments); + + if(process.env.NODE_ENV !== 'test') { + clearTimeout(window.executeAttachinaryTimeout); + window.executeAttachinaryTimeout = setTimeout(ExecuteAttachinary, 1000); + } + }) + ); + }, + + renderCollapsed: function(isGuest) { this.$el.removeClass('editing'); this.$el.html(this.template({ story: this.model, view: this })); this.$el.toggleClass( @@ -561,20 +575,14 @@ const StoryView = FormView.extend({ const estimateButtons = this.$('[data-story-estimate-buttons]').get(0); if (estimateButtons) { ReactDOM.render( - , + , estimateButtons ); } const copyStoryIdClipboardLink = this.$('[data-story-id-copy-clipboard]').get(0) if(copyStoryIdClipboardLink) { - ReactDOM.render( - , - copyStoryIdClipboardLink - ) + ReactDOM.render(, copyStoryIdClipboardLink) new Clipboard('.story-id'); } From 309666e08c4ef51b7251b31f470ebaa39ea36006 Mon Sep 17 00:00:00 2001 From: joaoGabriel55 Date: Mon, 26 Sep 2022 14:15:17 -0300 Subject: [PATCH 3/5] chore: code review --- .../components/story/StoryCopyIdClipboard.js | 11 ++++++----- app/assets/stylesheets/_screen.scss | 1 - .../components/story/story_copy_id_clipboard_spec.js | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/app/assets/javascripts/components/story/StoryCopyIdClipboard.js b/app/assets/javascripts/components/story/StoryCopyIdClipboard.js index 71f67c05d..33425d484 100644 --- a/app/assets/javascripts/components/story/StoryCopyIdClipboard.js +++ b/app/assets/javascripts/components/story/StoryCopyIdClipboard.js @@ -1,15 +1,16 @@ import React from "react"; +import Clipboard from "react-clipboard.js"; const StoryCopyIdClipboard = ({ id }) => { return ( - + ); }; diff --git a/app/assets/stylesheets/_screen.scss b/app/assets/stylesheets/_screen.scss index 4f463b2ac..b678168f6 100644 --- a/app/assets/stylesheets/_screen.scss +++ b/app/assets/stylesheets/_screen.scss @@ -248,7 +248,6 @@ div.story-title { cursor: pointer; color: $blue-4; font-weight: bold; - margin-right: 8px; border: none; &:hover { diff --git a/spec/javascripts/components/story/story_copy_id_clipboard_spec.js b/spec/javascripts/components/story/story_copy_id_clipboard_spec.js index b6bc6d7a0..27bde9a9e 100644 --- a/spec/javascripts/components/story/story_copy_id_clipboard_spec.js +++ b/spec/javascripts/components/story/story_copy_id_clipboard_spec.js @@ -16,7 +16,7 @@ describe('', function() { const wrapper = mount( ); - expect(wrapper.find('.story-id').text()).toBe('#70'); + expect(wrapper.find('.story-id').at(0).text()).toBe('#70'); }); it("should render story id data-clipboard-text", function() { From 9b38b68ffe1ac94fc7eb963c366d587119754d5c Mon Sep 17 00:00:00 2001 From: joaoGabriel55 Date: Thu, 6 Oct 2022 15:30:26 -0300 Subject: [PATCH 4/5] chore: minor fix --- app/assets/javascripts/views/story_view.jsx | 1 - 1 file changed, 1 deletion(-) diff --git a/app/assets/javascripts/views/story_view.jsx b/app/assets/javascripts/views/story_view.jsx index 6f2948c7a..ed4039291 100644 --- a/app/assets/javascripts/views/story_view.jsx +++ b/app/assets/javascripts/views/story_view.jsx @@ -583,7 +583,6 @@ const StoryView = FormView.extend({ const copyStoryIdClipboardLink = this.$('[data-story-id-copy-clipboard]').get(0) if(copyStoryIdClipboardLink) { ReactDOM.render(, copyStoryIdClipboardLink) - new Clipboard('.story-id'); } if (isGuest) { From d9123614b718fb9ad6c976a7141f5847ed16b540 Mon Sep 17 00:00:00 2001 From: Gabriel Date: Wed, 14 Aug 2024 16:46:07 -0300 Subject: [PATCH 5/5] remove explicit return from StoryCopyIdClipboard --- .../components/story/StoryCopyIdClipboard.js | 26 +++++++++---------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/app/assets/javascripts/components/story/StoryCopyIdClipboard.js b/app/assets/javascripts/components/story/StoryCopyIdClipboard.js index 33425d484..7a0178176 100644 --- a/app/assets/javascripts/components/story/StoryCopyIdClipboard.js +++ b/app/assets/javascripts/components/story/StoryCopyIdClipboard.js @@ -1,17 +1,15 @@ -import React from "react"; -import Clipboard from "react-clipboard.js"; +import React from 'react'; +import Clipboard from 'react-clipboard.js'; -const StoryCopyIdClipboard = ({ id }) => { - return ( - - #{id} - - ); -}; +const StoryCopyIdClipboard = ({ id }) => ( + + #{id} + +); export default StoryCopyIdClipboard;