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

Pluggable modqueues #849

Merged
merged 3 commits into from Aug 10, 2017

Conversation

Projects
None yet
4 participants
@cvle
Copy link
Member

commented Aug 10, 2017

What does this PR do?

  • Support plugin defined mod queues by adding a field modQueues in the index.js of client side plugins

Example

modQueues: {
  newQueueKey: {
    // name
    name: 'My Queue Name',                    

    // material design icon
    icon: 'star',        

    // Filter by tags
    tags: ['MY_TAG'],                       
    
    // Filter by statuses
    statuses: ['NONE', 'PREMOD', 'ACCEPTED', 'REJECTED'],   

   // Filter by comment containing action_type
    action_type: 'FLAG',                    
  },
},

How To Test

E.g. add this to the featured comments plugin:

modQueues: {
  featured: {
    tags: ['FEATURED'],
    icon: 'star',
    name: 'Featured',
  },
},

@kgardnr kgardnr requested review from okbel and kgardnr Aug 10, 2017

@kgardnr
Copy link
Member

left a comment

💯!!

@kgardnr kgardnr merged commit b60c879 into master Aug 10, 2017

1 check passed

ci/circleci Your tests passed on CircleCI!
Details

@wyattjoh wyattjoh deleted the pluggable-modqueues branch Aug 15, 2017

@leeeandroo

This comment has been minimized.

Copy link
Contributor

commented Jan 17, 2018

Hello @cvle ,

I have a small question about this implementation, could you help me?

How can I use a translation file to use on the queue name?
I've tried to create a translations.yml file, and use it on the queue, but it's not loading. My guess is that the queue config is loaded before the translations.

Thanks,

@wyattjoh

This comment has been minimized.

Copy link
Member

commented Jan 17, 2018

You should be able to do something like this:

import t from 'coral-framework/services/i18n';

// ...
modQueues: {
  featured: {
    tags: ['FEATURED'],
    icon: 'star',
    name: t('modqueue.featured'),
  },
},
// ...

As we've done with our own internal queues. Try using an existing translation first, to see if the translations are loading at all, then experiment to see if you can get your own translation loading.

@leeeandroo

This comment has been minimized.

Copy link
Contributor

commented Jan 18, 2018

Hi @wyattjoh , thanks for your answer.

Thats exactly what I have on my code. But something does not work with my own translation.

On my plugin folder talk-plugin-test, I have a index.js file with this code:

module.exports = { };

And then on the client folder, I have the modQueues.js

import t from 'coral-framework/services/i18n';

const modQueues = {
    test: {
        tags: ['TEST'],
        icon: 'reply',
        name: t('modqueue.test'),
    }
}

export default modQueues

And on my translations.yml:

en:
  modqueue:
    test: "Test"

And load this on index.js:

import translations from './translations.yml';
import modQueues from './modQueues';

export default {
    translations,
    modQueues
};

If I use a language key from the core locales, It works. But If I try to use my key modqueue.test, It's not load and I can see an error on console: en.modqueue.test language key not set
Also, If I try to use some translation from another plugin, It's not work too.

My guess is that maybe the plugins.getTranslations() is called after the plugins.getModQueueConfigs().

Does it make sense for you? Maybe I'm missing something.

Thanks!

@cvle

This comment has been minimized.

Copy link
Member Author

commented Jan 18, 2018

Hi @leeeandroo, you have assessed the situation perfectly. We're going add a feature to lazily evaluate the modqueue config from plugins, so that custom translations can be included. You can track the progress here: https://www.pivotaltracker.com/story/show/154447869.

@kgardnr

This comment has been minimized.

Copy link
Member

commented Jan 18, 2018

Also if this is an urgent need @leeeandroo, feel free to submit a PR for this and we will review it and merge! I think with our current roadmap, we won't get to this for several weeks FYI.

Thanks!

@leeeandroo

This comment has been minimized.

Copy link
Contributor

commented Jan 25, 2018

I would like to try this.
Any tip about this implementation? Are there something similar on the core that I can have a look before start coding? @cvle @wyattjoh @kgardnr

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.