Skip to content
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

Handle invalid issues #18111

Merged
merged 8 commits into from
Dec 28, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions options/locale/locale_en-US.ini
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ occurred = An error has occurred
report_message = If you are sure this is a Gitea bug, please search for issue on <a href="https://github.com/go-gitea/gitea/issues">GitHub</a> and open new issue if necessary.
missing_csrf = Bad Request: no CSRF token present
invalid_csrf = Bad Request: Invalid CSRF token
issue_not_found = The referenced issue couldn't be found.

[startpage]
app_desc = A painless, self-hosted Git service
Expand Down
2 changes: 2 additions & 0 deletions templates/base/head.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@
i18n: {
copy_success: '{{.i18n.Tr "copy_success"}}',
copy_error: '{{.i18n.Tr "copy_error"}}',
error_occurred: '{{.i18n.Tr "error.occurred"}}',
issue_not_found: '{{.i18n.Tr "error.issue_not_found"}}',
wxiaoguang marked this conversation as resolved.
Show resolved Hide resolved
}
};
{{/* in case some pages don't render the pageData, we make sure it is an object to prevent null access */}}
Expand Down
20 changes: 20 additions & 0 deletions web_src/js/components/ContextPopup.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,18 @@
</div>
</div>
</div>
<div v-if="!loading && issue === null">
<p><small>{{ errorTitle }}</small></p>
<p>{{ errorBody }}</p>
</div>
</div>
</template>

<script>
import {SvgIcon} from '../svg.js';

const {appSubUrl} = window.config;
const {issue_not_found, error_occurred} = window.config.i18n;

// NOTE: see models/issue_label.go for similar implementation
const srgbToLinear = (color) => {
Expand Down Expand Up @@ -53,6 +58,14 @@ export default {
}),

computed: {
errorTitle() {
return error_occurred;
},

errorBody() {
return issue_not_found;
},

createdAt() {
return new Date(this.issue.created_at).toLocaleDateString(undefined, {year: 'numeric', month: 'short', day: 'numeric'});
},
Expand Down Expand Up @@ -120,6 +133,13 @@ export default {
callback();
}
});
}).fail(() => {
this.loading = false;
this.$nextTick(() => {
if (callback) {
callback();
}
});
wxiaoguang marked this conversation as resolved.
Show resolved Hide resolved
});
}
}
Expand Down