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

♻️ rename tag label to subject #344

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
4 changes: 2 additions & 2 deletions client/src/components/TagPicker/TagPicker.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const TagPicker = ({ label, icon, tags, onChange }) => {
const [opened, setOpened] = useState(false)
const ref = useClickOutside(() => setOpened(false))

const tagCategories = conf ? conf.tagCategories : []
const subjectCategories = conf ? conf.subjectCategories : []

return (
<div className="tagpicker">
Expand Down Expand Up @@ -45,7 +45,7 @@ const TagPicker = ({ label, icon, tags, onChange }) => {
/>
<div ref={ref} className="picker" style={{ display: opened ? 'flex' : 'none' }}>
<div className="picker-body">
{sortBy(tagCategories, ['order']).map(category => (
{sortBy(subjectCategories, ['order']).map(category => (
<div key={category.name} className="category">
{sortBy(category.labels, ['order']).map(label => {
const isSelected = !!tags.find(t => t.id === label.id)
Expand Down
2 changes: 1 addition & 1 deletion client/src/components/UsersList/UsersList.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const UsersList = () => {
const users = usersData ? usersData.users : []
const specialists = usersData ? usersData.users.filter(user => user.specialties.length > 0) : []
const services = servicesData
? servicesData.configuration.tagCategories.find(category => category.name === 'services')
? servicesData.configuration.subjectCategories.find(category => category.name === 'services')
?.labels
: null

Expand Down
2 changes: 1 addition & 1 deletion client/src/components/UsersList/queries.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export const GET_TAG_CATEGORIES = gql`
query {
configuration {
id
tagCategories {
subjectCategories {
id
name
labels {
Expand Down
6 changes: 3 additions & 3 deletions client/src/scenes/Home/components/Searchbar/Searchbar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ const Searchbar = ({ text, tags, loading, onTextChange, onTagsChange }) => {
const intl = getIntl(Searchbar)
const conf = useConfiguration()

const tagLabels = tags
const subjects = tags
.map(tag =>
conf.tagCategories
conf.subjectCategories
.reduce((acc, cat) => acc.concat(cat.labels), [])
.find(label => label.name === tag)
)
Expand Down Expand Up @@ -45,7 +45,7 @@ const Searchbar = ({ text, tags, loading, onTextChange, onTagsChange }) => {
<TagPicker
label={intl('filter.tags')}
icon="local_offer"
tags={tagLabels}
tags={subjects}
onChange={onTagsChange}
/>
</div>
Expand Down
2 changes: 1 addition & 1 deletion client/src/scenes/Settings/Settings.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ const Settings = ({ configuration: conf }) => {
mutate({
variables: {
title: state.title,
tagCategories: serializeTags(state.tagCategories),
subjectCategories: serializeTags(state.subjectCategories),
algoliaSynonyms: listToSynonyms(state.synonyms),
workplaceSharing: state.workplaceSharing,
authorizedDomains: state.authorizedDomains
Expand Down
2 changes: 1 addition & 1 deletion client/src/scenes/Settings/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export const reducer = (state, action) => {
case 'change_slack_commandkey':
return { ...state, slackCommandKey: action.data }
case 'change_tags':
return { ...state, tagCategories: action.data }
return { ...state, subjectCategories: action.data }
default:
return {
...state,
Expand Down
6 changes: 3 additions & 3 deletions client/src/scenes/Settings/queries.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import gql from 'graphql-tag'
const CONFIGURATION_FRAGMENT = `
id
title
tagCategories {
subjectCategories {
id
order
name
Expand Down Expand Up @@ -32,7 +32,7 @@ export const GET_CONFIGURATION = gql`
export const UPDATE_CONFIGURATION = gql`
mutation updateConfiguration(
$title: String!
$tagCategories: Json!
$subjectCategories: Json!
$algoliaSynonyms: Json!
$workplaceSharing: Boolean!
$authorizedDomains: [String!]!
Expand All @@ -41,7 +41,7 @@ export const UPDATE_CONFIGURATION = gql`
) {
updateConfiguration(
title: $title
tagCategories: $tagCategories
subjectCategories: $subjectCategories
algoliaSynonyms: $algoliaSynonyms
workplaceSharing: $workplaceSharing
authorizedDomains: $authorizedDomains
Expand Down
2 changes: 1 addition & 1 deletion client/src/scenes/Settings/scenes/Tags.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const Tags = ({ state, onTagsChange }) => {

return (
<Tab label={intl('tab')}>
<TagsEditor categories={state.tagCategories} onChange={onTagsChange} />
<TagsEditor categories={state.subjectCategories} onChange={onTagsChange} />
</Tab>
)
}
Expand Down
8 changes: 4 additions & 4 deletions e2e/client.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ const upsertConfig = /* GraphQL */ `mutation UpsertConfig{
algoliaApiKey: "${process.env.ALGOLIA_API_KEY_ALL}"
auth0Domain: "${process.env.AUTH0_DOMAIN}"
auth0ClientId: "${process.env.AUTH0_CLIENT_ID}"
tagCategories: {
subjectCategories: {
create: [
{
name: "services",
Expand Down Expand Up @@ -113,7 +113,7 @@ const upsertConfig = /* GraphQL */ `mutation UpsertConfig{
mailgunDomain
mailgunApiKey
slackChannelHook
tagCategories {
subjectCategories {
order
name
labels {
Expand All @@ -139,7 +139,7 @@ const upsertConfigMutation = async apiContext => {

const tagsId = /* GraphQL */ `
query GetAllTags {
tagLabels {
subjects {
id
name
}
Expand All @@ -153,7 +153,7 @@ const tagsQuery = async apiContext => {
}
})
const jsonRes = await res.json()
const results = await jsonRes.data.tagLabels
const results = await jsonRes.data.subjects
const tag = results[0]
const tagEdit = results[1]
return { tag, tagEdit }
Expand Down
16 changes: 8 additions & 8 deletions server/prisma/datamodel.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ type Flag {
type Tag {
id: ID! @unique @id

label: TagLabel @relation(name: "TagsLabel", link: TABLE)
label: Subject @relation(name: "TagSubject", link: TABLE)

node: ZNode! @relation(name: "NodeTags")
user: User! @relation(name: "UserTags", link: TABLE)
Expand All @@ -77,25 +77,25 @@ type Tag {
updatedAt: DateTime! @updatedAt
}

type TagLabel {
type Subject {
id: ID! @unique @id

name: String!
tags: [Tag!]! @relation(name: "TagsLabel", onDelete: CASCADE)
tags: [Tag!]! @relation(name: "TagSubject", onDelete: CASCADE)
specialists: [User!]! @relation(name: "UserSpecialties", link: TABLE)

order: Int!
category: TagCategory! @relation(name: "TagLabelsCategory", link: TABLE)
category: SubjectCategory! @relation(name: "TagLabelsCategory", link: TABLE)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Le nom de la relation doit changer aussi, pour être cohérent


createdAt: DateTime! @createdAt
updatedAt: DateTime! @updatedAt
}

type TagCategory {
type SubjectCategory {
id: ID! @unique @id

name: String!
labels: [TagLabel!]! @relation(name: "TagLabelsCategory", onDelete: CASCADE)
labels: [Subject!]! @relation(name: "SubjectCategory", onDelete: CASCADE)

order: Int!
configuration: Configuration! @relation(name: "ConfigurationTags", link: TABLE)
Expand Down Expand Up @@ -136,7 +136,7 @@ type User {

flags: [Flag!]! @relation(name: "UserFlags")
tags: [Tag!]! @relation(name: "UserTags")
specialties: [TagLabel!]! @relation(name: "UserSpecialties")
specialties: [Subject!]! @relation(name: "UserSpecialties")

history: [HistoryAction!]! @relation(name: "UserHistoryActions")

Expand Down Expand Up @@ -166,7 +166,7 @@ type Configuration {
slackCommandKey: String

tags: Json
tagCategories: [TagCategory!]! @relation(name: "ConfigurationTags", onDelete: CASCADE)
subjectCategories: [SubjectCategory!]! @relation(name: "ConfigurationTags", onDelete: CASCADE)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Le nom de la relation doit changer aussi, pour être cohérent


workplaceSharing: Boolean @default(value: false)

Expand Down
2 changes: 1 addition & 1 deletion server/scripts/prisma_new_service/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ const main = async () => {
algoliaSynonyms: "{\"objectId\": \"testSynonyms\", \"type\": \"synonym\", \"synonyms\": [\"hello\", \"hi\"]}"
mailgunDomain: "${MAILGUN_DOMAIN || ''}"
mailgunApiKey: "${MAILGUN_API_KEY || ''}"
tagCategories: {
subjectCategories: {
create: [
{
name: "services",
Expand Down
10 changes: 5 additions & 5 deletions server/scripts/tmp_tag_resync/part1.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const resync = async (name, stage) => {

const tagsCategories = await Promise.all(
categories.map(([name, tags], order) =>
prisma.mutation.createTagCategory(
prisma.mutation.createSubjectCategory(
{
data: {
name,
Expand Down Expand Up @@ -50,7 +50,7 @@ const resync = async (name, stage) => {
)
)

const tagLabels = tagsCategories.reduce((acc, cat) => acc.concat(cat.labels), [])
const subjects = tagsCategories.reduce((acc, cat) => acc.concat(cat.labels), [])

const tags = await prisma.query.tags(
null,
Expand All @@ -64,16 +64,16 @@ const resync = async (name, stage) => {

return Promise.all(
tags.map(tag => {
const tagLabel = tagLabels.find(label => label.name === tag.label)
if (!tagLabel) {
const subject = subjects.find(label => label.name === tag.label)
if (!subject) {
console.log(`Unknown tag "${tag.label}" on "${tag.id}"`)
return
}
return prisma.mutation.updateTag({
where: { id: tag.id },
data: {
// label: null, // I'll manually remove label. This is a security in case something goes wrong
tagLabel: { connect: { id: tagLabel.id } }
subject: { connect: { id: subject.id } }
}
})
})
Expand Down
4 changes: 2 additions & 2 deletions server/src/endpoints/configuration.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const configurationEndpoint = multiTenant => async (req, res) =>
title,
auth0Domain,
auth0ClientId,
tagCategories,
subjectCategories,
workplaceSharing,
bugReporting
} = multiTenant.current(req)._meta.configuration
Expand All @@ -24,7 +24,7 @@ const configurationEndpoint = multiTenant => async (req, res) =>
title,
auth0Domain,
auth0ClientId,
tagCategories,
subjectCategories,
workplaceSharing,
bugReporting
})
Expand Down
Loading