-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Hide show more
btn in file-tree list if no more data
#24983
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
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ | |
<div class="ui list"> | ||
<DiffFileTreeItem v-for="item in fileTree" :key="item.name" :item="item"/> | ||
</div> | ||
<div v-if="isIncomplete" id="diff-too-many-files-stats" class="gt-pt-2"> | ||
<div v-if="hasMore" id="diff-too-many-files-stats" class="gt-pt-2"> | ||
<span class="gt-mr-2">{{ tooManyFilesMessage }}</span><a :class="['ui', 'basic', 'tiny', 'button', isLoadingNewData === true ? 'disabled' : '']" id="diff-show-more-files-stats" @click.stop="loadMoreData">{{ showMoreMessage }}</a> | ||
</div> | ||
</div> | ||
|
@@ -34,6 +34,14 @@ export default { | |
}; | ||
}, | ||
computed: { | ||
hasMore: { | ||
get() { | ||
return this.isIncomplete; | ||
}, | ||
set(newValue) { | ||
this.isIncomplete = newValue; | ||
} | ||
}, | ||
fileTree() { | ||
const result = []; | ||
for (const file of this.files) { | ||
|
@@ -94,6 +102,7 @@ export default { | |
// Merge folders with just a folder as children in order to | ||
// reduce the depth of our tree. | ||
mergeChildIfOnlyOneDir(result); | ||
this.isIncomplete = pageData.diffFileInfo.isIncomplete; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do not change value in a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is it a use case for a store? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
For best practice: https://vuejs.org/guide/essentials/computed.html#best-practices For "store": I think the page data should be passed by a store, this diff page has been broken for many times. |
||
return result; | ||
} | ||
}, | ||
|
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What are you doing here .....
Why a "computed" property should be "set"?
Although Vue documents says writable-computed , but I do not think it is our case .....
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The key point of the problem here, it's not about "updating isIncomplete in computed property by tricks", the root problem is:
When the
pageData.diffFileInfo
changes, it needs to "notify" the Vue component to update its data/properties.The
computed property
doesn't need to update anything, it should just provide the computed (read-only) result (Vue says: "Getters should be side-effect free ")To make the Vue component could be notified by changed
pageData.diffFileInfo
, either:pageData.diffFileInfo
is re-loaded, then Vue component re-read thepageData.diffFileInfo
to its internal reactive data/propertiespageData.diffFileInfo
, then any change onpageData.diffFileInfo
will trigger the Vue's reactive system to sync the values.I think "store" is the best practice here.