2021-07-13 21:09:19 +03:00
|
|
|
<script>
|
2022-01-29 00:00:11 +03:00
|
|
|
import $ from 'jquery';
|
2021-07-13 21:09:19 +03:00
|
|
|
import {SvgIcon} from '../svg.js';
|
2023-07-09 13:17:22 +03:00
|
|
|
import {useLightTextOnBackground} from '../utils/color.js';
|
|
|
|
import tinycolor from 'tinycolor2';
|
2021-07-13 21:09:19 +03:00
|
|
|
|
2021-12-28 16:28:27 +03:00
|
|
|
const {appSubUrl, i18n} = window.config;
|
2021-07-13 21:09:19 +03:00
|
|
|
|
|
|
|
export default {
|
2022-12-23 19:03:11 +03:00
|
|
|
components: {SvgIcon},
|
2021-07-13 21:09:19 +03:00
|
|
|
data: () => ({
|
|
|
|
loading: false,
|
2021-12-28 16:28:27 +03:00
|
|
|
issue: null,
|
|
|
|
i18nErrorOccurred: i18n.error_occurred,
|
|
|
|
i18nErrorMessage: null,
|
2021-07-13 21:09:19 +03:00
|
|
|
}),
|
|
|
|
computed: {
|
|
|
|
createdAt() {
|
|
|
|
return new Date(this.issue.created_at).toLocaleDateString(undefined, {year: 'numeric', month: 'short', day: 'numeric'});
|
|
|
|
},
|
|
|
|
|
|
|
|
body() {
|
|
|
|
const body = this.issue.body.replace(/\n+/g, ' ');
|
|
|
|
if (body.length > 85) {
|
|
|
|
return `${body.substring(0, 85)}…`;
|
|
|
|
}
|
|
|
|
return body;
|
|
|
|
},
|
|
|
|
|
|
|
|
icon() {
|
|
|
|
if (this.issue.pull_request !== null) {
|
|
|
|
if (this.issue.state === 'open') {
|
2024-02-05 01:37:45 +03:00
|
|
|
if (this.issue.pull_request.draft === true) {
|
|
|
|
return 'octicon-git-pull-request-draft'; // WIP PR
|
|
|
|
}
|
2021-07-13 21:09:19 +03:00
|
|
|
return 'octicon-git-pull-request'; // Open PR
|
|
|
|
} else if (this.issue.pull_request.merged === true) {
|
|
|
|
return 'octicon-git-merge'; // Merged PR
|
|
|
|
}
|
|
|
|
return 'octicon-git-pull-request'; // Closed PR
|
|
|
|
} else if (this.issue.state === 'open') {
|
|
|
|
return 'octicon-issue-opened'; // Open Issue
|
|
|
|
}
|
|
|
|
return 'octicon-issue-closed'; // Closed Issue
|
|
|
|
},
|
|
|
|
|
|
|
|
color() {
|
2024-02-05 01:37:45 +03:00
|
|
|
if (this.issue.pull_request !== null) {
|
|
|
|
if (this.issue.pull_request.draft === true) {
|
|
|
|
return 'grey'; // WIP PR
|
|
|
|
} else if (this.issue.pull_request.merged === true) {
|
|
|
|
return 'purple'; // Merged PR
|
|
|
|
}
|
|
|
|
}
|
2021-07-13 21:09:19 +03:00
|
|
|
if (this.issue.state === 'open') {
|
2024-02-05 01:37:45 +03:00
|
|
|
return 'green'; // Open Issue
|
2021-07-13 21:09:19 +03:00
|
|
|
}
|
2024-02-05 01:37:45 +03:00
|
|
|
return 'red'; // Closed Issue
|
2021-07-13 21:09:19 +03:00
|
|
|
},
|
|
|
|
|
|
|
|
labels() {
|
|
|
|
return this.issue.labels.map((label) => {
|
2021-08-25 20:55:47 +03:00
|
|
|
let textColor;
|
2023-07-09 13:17:22 +03:00
|
|
|
const {r, g, b} = tinycolor(label.color).toRgb();
|
2023-05-10 14:19:03 +03:00
|
|
|
if (useLightTextOnBackground(r, g, b)) {
|
Scoped labels (#22585)
Add a new "exclusive" option per label. This makes it so that when the
label is named `scope/name`, no other label with the same `scope/`
prefix can be set on an issue.
The scope is determined by the last occurence of `/`, so for example
`scope/alpha/name` and `scope/beta/name` are considered to be in
different scopes and can coexist.
Exclusive scopes are not enforced by any database rules, however they
are enforced when editing labels at the models level, automatically
removing any existing labels in the same scope when either attaching a
new label or replacing all labels.
In menus use a circle instead of checkbox to indicate they function as
radio buttons per scope. Issue filtering by label ensures that only a
single scoped label is selected at a time. Clicking with alt key can be
used to remove a scoped label, both when editing individual issues and
batch editing.
Label rendering refactor for consistency and code simplification:
* Labels now consistently have the same shape, emojis and tooltips
everywhere. This includes the label list and label assignment menus.
* In label list, show description below label same as label menus.
* Don't use exactly black/white text colors to look a bit nicer.
* Simplify text color computation. There is no point computing luminance
in linear color space, as this is a perceptual problem and sRGB is
closer to perceptually linear.
* Increase height of label assignment menus to show more labels. Showing
only 3-4 labels at a time leads to a lot of scrolling.
* Render all labels with a new RenderLabel template helper function.
Label creation and editing in multiline modal menu:
* Change label creation to open a modal menu like label editing.
* Change menu layout to place name, description and colors on separate
lines.
* Don't color cancel button red in label editing modal menu.
* Align text to the left in model menu for better readability and
consistent with settings layout elsewhere.
Custom exclusive scoped label rendering:
* Display scoped label prefix and suffix with slightly darker and
lighter background color respectively, and a slanted edge between them
similar to the `/` symbol.
* In menus exclusive labels are grouped with a divider line.
---------
Co-authored-by: Yarden Shoham <hrsi88@gmail.com>
Co-authored-by: Lauris BH <lauris@nix.lv>
2023-02-18 22:17:39 +03:00
|
|
|
textColor = '#eeeeee';
|
2021-08-25 20:55:47 +03:00
|
|
|
} else {
|
Scoped labels (#22585)
Add a new "exclusive" option per label. This makes it so that when the
label is named `scope/name`, no other label with the same `scope/`
prefix can be set on an issue.
The scope is determined by the last occurence of `/`, so for example
`scope/alpha/name` and `scope/beta/name` are considered to be in
different scopes and can coexist.
Exclusive scopes are not enforced by any database rules, however they
are enforced when editing labels at the models level, automatically
removing any existing labels in the same scope when either attaching a
new label or replacing all labels.
In menus use a circle instead of checkbox to indicate they function as
radio buttons per scope. Issue filtering by label ensures that only a
single scoped label is selected at a time. Clicking with alt key can be
used to remove a scoped label, both when editing individual issues and
batch editing.
Label rendering refactor for consistency and code simplification:
* Labels now consistently have the same shape, emojis and tooltips
everywhere. This includes the label list and label assignment menus.
* In label list, show description below label same as label menus.
* Don't use exactly black/white text colors to look a bit nicer.
* Simplify text color computation. There is no point computing luminance
in linear color space, as this is a perceptual problem and sRGB is
closer to perceptually linear.
* Increase height of label assignment menus to show more labels. Showing
only 3-4 labels at a time leads to a lot of scrolling.
* Render all labels with a new RenderLabel template helper function.
Label creation and editing in multiline modal menu:
* Change label creation to open a modal menu like label editing.
* Change menu layout to place name, description and colors on separate
lines.
* Don't color cancel button red in label editing modal menu.
* Align text to the left in model menu for better readability and
consistent with settings layout elsewhere.
Custom exclusive scoped label rendering:
* Display scoped label prefix and suffix with slightly darker and
lighter background color respectively, and a slanted edge between them
similar to the `/` symbol.
* In menus exclusive labels are grouped with a divider line.
---------
Co-authored-by: Yarden Shoham <hrsi88@gmail.com>
Co-authored-by: Lauris BH <lauris@nix.lv>
2023-02-18 22:17:39 +03:00
|
|
|
textColor = '#111111';
|
2021-07-13 21:09:19 +03:00
|
|
|
}
|
2021-08-25 20:55:47 +03:00
|
|
|
return {name: label.name, color: `#${label.color}`, textColor};
|
2021-07-13 21:09:19 +03:00
|
|
|
});
|
|
|
|
}
|
|
|
|
},
|
|
|
|
mounted() {
|
2023-03-05 17:23:42 +03:00
|
|
|
this.$refs.root.addEventListener('ce-load-context-popup', (e) => {
|
2022-10-01 17:26:38 +03:00
|
|
|
const data = e.detail;
|
2021-07-13 21:09:19 +03:00
|
|
|
if (!this.loading && this.issue === null) {
|
2022-10-01 17:26:38 +03:00
|
|
|
this.load(data);
|
2021-07-13 21:09:19 +03:00
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
methods: {
|
2022-10-01 17:26:38 +03:00
|
|
|
load(data) {
|
2021-07-13 21:09:19 +03:00
|
|
|
this.loading = true;
|
2021-12-28 16:28:27 +03:00
|
|
|
this.i18nErrorMessage = null;
|
2022-04-07 21:59:56 +03:00
|
|
|
$.get(`${appSubUrl}/${data.owner}/${data.repo}/issues/${data.index}/info`).done((issue) => {
|
2021-07-13 21:09:19 +03:00
|
|
|
this.issue = issue;
|
2021-12-28 16:28:27 +03:00
|
|
|
}).fail((jqXHR) => {
|
|
|
|
if (jqXHR.responseJSON && jqXHR.responseJSON.message) {
|
|
|
|
this.i18nErrorMessage = jqXHR.responseJSON.message;
|
|
|
|
} else {
|
|
|
|
this.i18nErrorMessage = i18n.network_error;
|
|
|
|
}
|
|
|
|
}).always(() => {
|
2021-07-13 21:09:19 +03:00
|
|
|
this.loading = false;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
</script>
|
2023-09-02 17:59:07 +03:00
|
|
|
<template>
|
|
|
|
<div ref="root">
|
|
|
|
<div v-if="loading" class="ui active centered inline loader"/>
|
|
|
|
<div v-if="!loading && issue !== null">
|
|
|
|
<p><small>{{ issue.repository.full_name }} on {{ createdAt }}</small></p>
|
|
|
|
<p><svg-icon :name="icon" :class="['text', color]"/> <strong>{{ issue.title }}</strong> #{{ issue.number }}</p>
|
|
|
|
<p>{{ body }}</p>
|
|
|
|
<div>
|
|
|
|
<div
|
|
|
|
v-for="label in labels"
|
|
|
|
:key="label.name"
|
|
|
|
class="ui label"
|
|
|
|
:style="{ color: label.textColor, backgroundColor: label.color }"
|
|
|
|
>
|
|
|
|
{{ label.name }}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div v-if="!loading && issue === null">
|
|
|
|
<p><small>{{ i18nErrorOccurred }}</small></p>
|
|
|
|
<p>{{ i18nErrorMessage }}</p>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|